int CGUIDialogContextMenu::Show(const CContextButtons& choices) { auto dialog = g_windowManager.GetWindow<CGUIDialogContextMenu>(WINDOW_DIALOG_CONTEXT_MENU); if (!dialog) return -1; dialog->m_buttons = choices; dialog->Initialize(); dialog->SetInitialVisibility(); dialog->SetupButtons(); dialog->PositionAtCurrentFocus(); dialog->Open(); return dialog->m_clickedButton; }
void InitVariables(void) { FvwmContext = XUniqueContext(); MenuContext = XUniqueContext(); /* initialize some lists */ Scr.AllBindings = NULL; Scr.AllMenus = NULL; Scr.TheList = NULL; Scr.DefaultIcon = NULL; Scr.d_depth = DefaultDepth(dpy, Scr.screen); Scr.FvwmRoot.w = Scr.Root; Scr.FvwmRoot.next = 0; /* RBW - 05/15/1998 - 2 new fields to init - stacking order chain. */ Scr.FvwmRoot.stack_next = &Scr.FvwmRoot; Scr.FvwmRoot.stack_prev = &Scr.FvwmRoot; XGetWindowAttributes(dpy, Scr.Root, &(Scr.FvwmRoot.attr)); Scr.root_pushes = 0; Scr.pushed_window = &Scr.FvwmRoot; Scr.FvwmRoot.number_cmap_windows = 0; /* create graphics contexts */ CreateGCs(); SetupButtons(); /* setup win-95 title bar buttons */ Scr.MyDisplayWidth = DisplayWidth(dpy, Scr.screen); Scr.MyDisplayHeight = DisplayHeight(dpy, Scr.screen); Scr.NoBoundaryWidth = 1; Scr.BoundaryWidth = BOUNDARY_WIDTH; Scr.CornerWidth = CORNER_WIDTH; Scr.Hilite = NULL; Scr.Focus = NULL; Scr.Ungrabbed = NULL; Scr.StdFont.font = NULL; #ifndef NON_VIRTUAL Scr.VxMax = 2 * Scr.MyDisplayWidth; Scr.VyMax = 2 * Scr.MyDisplayHeight; #else Scr.VxMax = 0; Scr.VyMax = 0; #endif Scr.Vx = Scr.Vy = 0; Scr.SizeWindow = None; /* Sets the current desktop number to zero */ /* Multiple desks are available even in non-virtual * compilations */ { Atom atype; int aformat; unsigned long nitems, bytes_remain; unsigned char *prop; Scr.CurrentDesk = 0; if ((XGetWindowProperty(dpy, Scr.Root, _XA_WM_DESKTOP, 0L, 1L, True, _XA_WM_DESKTOP, &atype, &aformat, &nitems, &bytes_remain, &prop)) == Success) { if (prop != NULL) { Restarting = True; Scr.CurrentDesk = *(unsigned long *) prop; } } } Scr.EdgeScrollX = Scr.EdgeScrollY = 100; Scr.ScrollResistance = Scr.MoveResistance = 0; Scr.OpaqueSize = 5; Scr.ClickTime = 150; Scr.ColormapFocus = COLORMAP_FOLLOWS_MOUSE; /* set major operating modes */ Scr.NumBoxes = 0; Scr.randomx = Scr.randomy = 0; Scr.buttons2grab = 7; return; }
BOOL CInformErrorDialog::OnInitDialog() { CDialog::OnInitDialog(); String_64 BoxTitle; BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR); // "Serious error" String_256 VerySeriousError; VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR); // "A very serious error has occured - please consult your technical support." // Andy Hills, 22-11-00 // Store the help context. // We need to do this here, because the global help context variable // nNextMessageHelpContext may change before the user clicks the 'Help' // button. This fixes bug 6359. m_nHelpContext = Error::GetErrorNumber(); if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext(); // Find out how many buttons there are. for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--) { if (m_ButtonStr[NumButtons - 1] != 0) break; } // Adjust the OK and Cancel fields if necessary if (m_OK > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("OK out of range, OK=%u, NumButtons=%d\n"), m_OK, NumButtons); } // Default to first button m_OK = 1; } if (m_Cancel > (UINT32) NumButtons) { if (IsUserName("Tim")) { TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d\n"), m_Cancel, NumButtons); } // Default to be the same as OK (this means a box with a single OK box will // respond to Enter and Esc without the user having to specify a Cancel ID). m_Cancel = m_OK; } if (m_Help > (UINT32) NumButtons) { TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)\n"), (INT32) m_Help, (INT32) NumButtons); // The only really safe thing we can do is drop the help button. m_Help = 0; } // Make sure we have correct dialog information GetDialogInfo(); if (!ValidInfo) { // Serious error - fall back to to MessageBox(). goto SevereError; } // Get icon position IconPos = DefIconPos; // Get a DC for this dialog, so we can find out the size of text strings. // We'll also need to select in our font or else it'll base the width upon the // System font rather than the font we're using (MS Sans Serif at last check) CDC *pDC; CFont *OldFont; pDC = GetDC(); ENSURE(pDC != NULL, "Can't get DC for error box dialog"); // Check the DC if (pDC == NULL) goto SevereError; OldFont = pDC->SelectObject(GetFont()); // Set buttons text and move/resize buttons according to the number of them, // and their contents. BOOL Success; Success = SetupButtons(pDC->m_hDC, NumButtons); // Size the error message control, and put the message in it. Success = Success && SetupMessage(pDC->m_hDC); if (OldFont != NULL) pDC->SelectObject(OldFont); // We've finished with this DC now. ReleaseDC(pDC); // Check for failure in button/message setup. if (!Success) goto SevereError; // Play the appropriate sound and set the appropriate title bar text ID. UINT32 TitleID; TitleID = m_TitleStr; switch (m_ErrorBoxType) { case ERRORTYPE_NORMAL: // No sound for this one - it's just a message; nothing to shout about. if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_QUESTION: MessageBeep(MB_ICONQUESTION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_NORMAL); break; case ERRORTYPE_ERROR: MessageBeep(MB_ICONEXCLAMATION); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ERROR); break; case ERRORTYPE_WARNING: MessageBeep(MB_ICONASTERISK); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_WARNING); break; case ERRORTYPE_SERIOUS: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_SERIOUS); break; case ERRORTYPE_ENSURE: MessageBeep(MB_ICONHAND); if (TitleID == 0) TitleID = _R(IDS_ERRORBOX_ENSURE); break; default: ENSURE(FALSE, "Bad errortype in CInformErrorDialog::OnInitDialog()"); goto SevereError; break; } // Set the title bar text if necessary. if (TitleID != 0) { String_64 Title(TitleID); SetWindowText((TCHAR*) Title); } // Centre the dialog on the screen (Code stolen from splash.cpp) // Get the size of the screen INT32 ScreenWidth, ScreenHeight; ScreenWidth = GetSystemMetrics(SM_CXSCREEN); ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Get the size of the dialog box RECT DialogRect; GetWindowRect(&DialogRect); INT32 DialogWidth, DialogHeight; DialogWidth = DialogRect.right - DialogRect.left; DialogHeight = DialogRect.bottom - DialogRect.top; // Chicago M7 gives us crap values at this point if we are minimized so try and make them sane if (DialogWidth<=0) DialogWidth = ScreenWidth / 2; else if (DialogWidth > ScreenWidth) DialogWidth = ScreenWidth; if (DialogHeight<=0) DialogHeight = ScreenHeight / 2; else if (DialogHeight > ScreenHeight) DialogHeight = ScreenHeight; // Centre the dialog box and give it the 'top' style. INT32 Left, Top; Left = (ScreenWidth - DialogWidth) / 2; Top = (ScreenHeight - DialogHeight) / 2; SetWindowPos(&wndTop, Left, Top, DialogWidth, DialogHeight, SWP_SHOWWINDOW); // If we got this far, then we changed the keyboard focus, so return FALSE. return FALSE; SevereError: // Ooer - deeply catastrophic error...report to user and exit. String_256 Message; // First - check that this isn't just because of an empty error message. if (m_StaticTextStr == 0) { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if ((pMsg == NULL) || (pMsg[0] == 0)) { // // There is no error message! // // In debug builds, give developer a chance to go into debugger to see who is not // setting an error message. #ifdef _DEBUG if (::MessageBox(ParentHwnd, "Somebody reported an error without an error message being set.\r" "Click OK to continue, or Cancel to go into debugger", "DEBUG Warning from Camelot", MB_OKCANCEL| MB_SYSTEMMODAL | MB_ICONHAND) == IDCANCEL) { // User wants to go into debugger DebugBreak(); } #endif // Tell the user a spurious error has occured, if (!Message.Load(_R(IDS_ERRORBOX_SPURIOUS))) // Can't load error message - panic. goto VerySevereError; // Try to get the string that says "Warning from Camelot" String_64 Title; if (!Title.Load(_R(IDS_ERRORBOX_WARNING))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *) Title, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. } } // Inform the user that we've got a bit of a bad karma situation, and that the error // box might be not be completely accurate. if (!Message.Load(_R(IDS_ERRORBOX_SEVERE))) goto VerySevereError; if (::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, /*"Serious Error", */ MB_OK | MB_SYSTEMMODAL | MB_ICONHAND) == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; // Ok - try to report the error as best we can... // Work out what buttons to put on the dialog... // We use SYSTEMMODAL with ICONHAND because the SDK docs recommend this for low // memory/severe error situations. UINT32 MBFlags; MBFlags = MB_SYSTEMMODAL | MB_ICONHAND; // Do we need a cancel icon? if (m_Cancel != m_OK) MBFlags |= MB_OKCANCEL; else MBFlags |= MB_OK; if (m_StaticTextStr != 0) { if (Message.Load(m_StaticTextStr, m_OwnerModule)) { // Error message loaded ok - display it INT32 Result = ::MessageBox(ParentHwnd, (TCHAR *) Message, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } else { // Can't load error message - bail out goto VerySevereError; } } else { // Get the error message TCHAR *pMsg = Error::GetErrorString(); if (pMsg == NULL) // No error message! goto VerySevereError; // Found error message ok - display it INT32 Result = ::MessageBox(ParentHwnd, pMsg, (TCHAR *)BoxTitle, MBFlags); if (Result == 0) // Could not create the message box - try our fallback one (probably won't // work but what the hell). goto VerySevereError; if (Result == IDCANCEL) { // Simulate user hitting cancel button. EndDialog((INT32) m_Cancel); } else { // Simulate user hitting default button. EndDialog((INT32) m_OK); } return TRUE; // We haven't set the keyboard focus. } VerySevereError: // Very bad - we can't even report the error - just let the user that something deeply // sad has happened, and pretend that the OK button was pressed. ::MessageBox(ParentHwnd, (TCHAR *)VerySeriousError, (TCHAR *)BoxTitle, MB_OK | MB_SYSTEMMODAL | MB_ICONHAND); // Simulate user hitting default button. EndDialog((INT32) m_OK); return TRUE; // We haven't set the keyboard focus. }
int main(void) { ind = 0; // Setup functions for operation CP0Init(); INTInitialize(); ADCSetup(); SetupButtons(); SetupIO(); SetupT1CountINT(); SetupTimer2_3PWM(); //SetupUART(115200); NU32_EnableUART2Interrupt(); // Wait until LCD screen comes up wait(1000); wait(1000); wait(1000); wait(1000); LCDConfig(); LCDSetup(); ClearLCDScreen(); char msg[32]; sprintf(msg,"UART demo. Press A to start"); WriteLCD(1,msg); int button = 1; while(button == 1) { button = BUTTON_A; } wait(1000); while(button == 0) { button = BUTTON_A; } wait(1000); // send dollar signs to enter command mode char send1[] = "$$$"; SerialTransmit(send1); wait(1000);wait(1000);wait(1000); // print message and wait for press /* ClearLCDScreen(); wait(1000);wait(1000);wait(1000); sprintf(msg,"command mode. press A"); WriteLCD(1,msg); wait(1000);wait(1000);wait(1000); button = 1; while(button == 1) { button = BUTTON_A; } wait(1000); while(button == 0) { button = BUTTON_A; } wait(1000); wait(1000); */ while(next == 0); next = 0; char send2[] = "GB\n"; SerialTransmit(send2); while(1) { ClearLCDScreen(); WriteLCD(0,string); wait(10000); wait(10000); wait(10000); } // receive response from chip char temp[4]; SerialReceive(temp, 4, CHAR_MODE); // // print response to lcd // ClearLCDScreen(); // WriteLCD(1,temp); char temp2[32]; SerialReceive(temp2, 32, HEX_MODE); ClearLCDScreen(); WriteLCD(1,temp2); /* * Software State machine * POR: * Try to connect * * */ return 0; }
int main(void) { int delay; d2 = 0; d1 = 0; state = 0; reset = 1; adc1 = 0; adc2 = 0; led = 0; pwm = 0; double volt1 = 0.0; double volt2 = 0.0; // Setup functions for operation CP0Init(); INTInitialize(); ADCSetup(); SetupButtons(); SetupIO(); SetupT1CountINT(); SetupTimer2_3PWM(); // Wait until LCD screen comes up wait(1000); wait(1000); wait(1000); wait(1000); LCDConfig(); LCDSetup(); // Start the timer T1CONbits.ON = 1; while(1) { if(reset == 1) { ClearLCDScreen(); sprintf(string,"A = Cmd button"); WriteLCD(1,string); reset = 0; state = 0; } else { switch(state) { case 0: if(state_init[0] != 0) state_init[0] = 0; wait(100); break; case 1: if(state_init[0] != 1) { state_init[0] = 1; if(state_init[1] == 0) state_init[1] = 1; else state_init[1] = 0; } wait(100); break; case 2: if(state_init[0] != 2) { state_init[0] = 2; if(state_init[2] == 0) state_init[2] = 1; else state_init[2] = 0; } wait(100); break; case 3: if(state_init[0] != 3) { state_init[0] = 3; if(state_init[3] == 0) state_init[3] = 1; else state_init[3] = 0; } wait(100); break; case 4: if(state_init[0] != 4) { state_init[0] = 4; if(state_init[4] == 0) state_init[4] = 1; else state_init[4] = 0; } wait(100); break; default: wait(100); break; } if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 0) sprintf(string,"LB=0;RB=0;WPER=0"); else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 0) sprintf(string,"LB=1;RB=0;WPER=0"); else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 0) sprintf(string,"LB=0;RB=1;WPER=0"); else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 0) sprintf(string,"LB=1;RB=1;WPER=0"); else if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 1) sprintf(string,"LB=0;RB=0;WPER=1"); else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 1) sprintf(string,"LB=1;RB=0;WPER=1"); else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 1) sprintf(string,"LB=0;RB=1;WPER=1"); else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 1) sprintf(string,"LB=1;RB=1;WPER=1"); if(state != -1)// && state != 0) { wait(100); WriteLCD(2,string); } } } return 0; }