/* * AddPinDigit * Description: Add a digit to the pin number sequence * * Arguments: nextstate- expected next state * event - entered digit * Return: nextstate- actual next state * * Input: None. * Output: None * * Operation: Add pin digit and stay within max number of pin digits. * * Error Handling: None. * * Algorithms: None * Data Strutures: None * * Assumptions: None * * Revision History: * Apr. 23, 2013 Nnoduka Eruchalu Initial Revision * Apr. 24, 2013 Nnoduka Eruchalu Modified to use AddDigit() */ state AddPinDigit(state nextstate, eventcode event) { /* add pin digit up to number of allowed digits */ AddDigit(event, NUM_PIN_DIGITS); return nextstate; }
/* * AddParkSpaceDigit * Description: Add a digit to the parking space number sequence * * Arguments: nextstate- expected next state * event - entered digit * Return: nextstate- actual next state * * Input: None. * Output: None * * Operation: Add parking space digit. Stay within max number of digits * * Error Handling: None. * * Algorithms: None * Data Strutures: None * * Assumptions: None * * Revision History: * Apr. 23, 2013 Nnoduka Eruchalu Initial Revision * Apr. 24, 2013 Nnoduka Eruchalu Modified to use AddDigit() */ state AddParkSpaceDigit(state nextstate, eventcode event) { /* add parking space digit up to number of allowed digits */ AddDigit(event, NUM_PARK_SPACE_DIGITS); return nextstate; }
void Score3D::OnNodeSet(Node* node) { if(!node) return; node_->SetRotation(Quaternion(180.0f, Vector3::UP)); SetAlignRight(false); AddDigit(); SetScore(0);//node_->GetName().Contains("High") ? GLOBAL->GetHighscore() : 0 ); }
void Score3D::SetScore(unsigned score) { score_ = score; String scoreString{ score_ }; while (scoreString.Length() != digitNodes_.Size()) { if (digitNodes_.Size() < scoreString.Length()) AddDigit(); else if (digitNodes_.Size() > scoreString.Length()) RemoveDigit(); } //Update score graphics for (Node* n : digitNodes_) { StaticModel* digitModel{ n->GetComponent<StaticModel>() }; digitModel->SetModel(MC->GetModel(String( static_cast<int>(score_ / static_cast<unsigned>(pow(10, digitNodes_.IndexOf(n)))) % 10 ))); digitModel->SetMaterial(MC->GetMaterial("Bubble")); } }
PoeditListCtrl::PoeditListCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, bool dispIDs, const wxValidator& validator, const wxString &name) : wxListView(parent, id, pos, size, style | wxLC_VIRTUAL, validator, name) { m_catalog = NULL; m_displayIDs = dispIDs; m_isRTL = false; m_appIsRTL = (wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft); sortOrder = SortOrder::Default(); CreateColumns(); int i; wxImageList *list = new wxImageList(16, 16); // IMG_NOTHING: list->Add(wxArtProvider::GetBitmap("poedit-status-nothing")); // IMG_AUTOMATIC: list->Add(wxArtProvider::GetBitmap("poedit-status-automatic")); // IMG_COMMENT: list->Add(wxArtProvider::GetBitmap("poedit-status-comment")); // IMG_AUTOMATIC | IMG_COMMENT: list->Add(MergeBitmaps(wxArtProvider::GetBitmap("poedit-status-automatic"), wxArtProvider::GetBitmap("poedit-status-comment"))); // IMG_MODIFIED list->Add(wxArtProvider::GetBitmap("poedit-status-modified")); // IMG_MODIFIED variations: for (i = 1; i < IMG_MODIFIED; i++) { list->Add(MergeBitmaps(BitmapFromList(list, i), wxArtProvider::GetBitmap("poedit-status-modified"))); } // BK_XX variations: for (int bk = 0; bk < 10; bk++) { for(i = 0; i <= (IMG_AUTOMATIC|IMG_COMMENT|IMG_MODIFIED); i++) { wxBitmap bmp = BitmapFromList(list, i); list->Add(AddDigit(bk, 0, 0, bmp)); } } AssignImageList(list, wxIMAGE_LIST_SMALL); // configure items colors & fonts: wxVisualAttributes visual = GetDefaultAttributes(); wxColour shaded = visual.colBg; #ifdef __WXMSW__ // On Windows 7, shaded list items make it impossible to see the selection, // so use different color for it (see bug #336). int verMaj, verMin; wxGetOsVersion(&verMaj, &verMin); if ( verMaj > 6 || (verMaj == 6 && verMin >= 1) ) { shaded.Set(int(0.99 * shaded.Red()), int(0.99 * shaded.Green()), shaded.Blue()); } else #endif // __WXMSW__ #ifdef __WXOSX__ if ( shaded == *wxWHITE ) { // use standard shaded color from finder/databrowser: shaded.Set("#f0f5fd"); } else #endif // __WXOSX__ { shaded.Set(int(DARKEN_FACTOR * shaded.Red()), int(DARKEN_FACTOR * shaded.Green()), int(DARKEN_FACTOR * shaded.Blue())); } m_attrNormal[1].SetBackgroundColour(shaded); m_attrUntranslated[1].SetBackgroundColour(shaded); m_attrFuzzy[1].SetBackgroundColour(shaded); m_attrInvalid[1].SetBackgroundColour(shaded); // FIXME: make this user-configurable if ( IsAlmostWhite(visual.colBg) ) { m_attrUntranslated[0].SetTextColour(gs_UntranslatedForWhite); m_attrUntranslated[1].SetTextColour(gs_UntranslatedForWhite); m_attrFuzzy[0].SetTextColour(gs_FuzzyForWhite); m_attrFuzzy[1].SetTextColour(gs_FuzzyForWhite); } else if ( IsAlmostBlack(visual.colBg) ) { m_attrUntranslated[0].SetTextColour(gs_UntranslatedForBlack); m_attrUntranslated[1].SetTextColour(gs_UntranslatedForBlack); m_attrFuzzy[0].SetTextColour(gs_FuzzyForBlack); m_attrFuzzy[1].SetTextColour(gs_FuzzyForBlack); } // else: we don't know if the default colors would be well-visible on // user's background color, so play it safe and don't highlight // anything // FIXME: todo; use appropriate font for fuzzy/trans/untrans m_attrInvalid[0].SetBackgroundColour(gs_ErrorColor); m_attrInvalid[1].SetBackgroundColour(gs_ErrorColor); // Use gray for IDs if ( IsAlmostBlack(visual.colFg) ) m_attrId.SetTextColour(wxColour("#A1A1A1")); SetCustomFont(wxNullFont); }
MRESULT EXPENTRY Calculator( HWND hwnd, /* window handle */ ULONG msg, /* dispatched message id */ MPARAM mp1, /* first message parameter */ MPARAM mp2 ) /* second message parameter */ { ULONG action; /* Action to process */ switch (msg) { /* switch based on the message*/ /* received */ /* The initialization message has been received. We do some */ /* additional fixup of the dialog to make it look a little */ /* nicer. */ case WM_INITDLG: /* initialize accumulator */ MAKERXSTRING(accumulator, accbuff, 1); strcpy(accbuff, "0"); /* fill in a zero */ digits = 0; /* no digits in number */ hadperiod = NO; /* no period yet */ hadexponent = NO; /* no exponential yet */ oldaction = 0; /* no pending operations */ strcpy(precision, "9"); /* set default precision */ form = SCIENTIFIC; /* set default form */ SetDisplay(&accumulator); /* set initial display value */ /* update the calculator */ /* display */ WinSetWindowText(WinWindowFromID(hwnd, DISPLAY), display.strptr); /* register our external */ /* functions */ RexxRegisterFunctionExe("CalcPrecision", (PFN)CalcPrecision); RexxRegisterFunctionExe("CalcForm", (PFN)CalcForm); return FALSE; /* initialization complete */ /* We are going away, time to post a quit message to the */ /* message loop. */ case WM_CLOSE: /* Deregister our defined */ /* functions */ RexxDeregisterFunction("CalcPrecision"); RexxDeregisterFunction("CalcForm"); /* Standard Close processing */ WinPostMsg(hwnd, WM_QUIT, 0L, 0L); return FALSE; /* Exit now */ /* We've received a WM_CONTROL message. This was */ /* generated by the "Form" check blox. */ case WM_CONTROL: /* change current form */ action = SHORT1FROMMP(mp1); /* Extract message sub-type */ switch (action) { /* process the control */ case BUTTON_FORM: /* form switch button */ if (form == SCIENTIFIC) { /* current scientific? */ form = ENGINEERING; /* make it engineering */ /* update label */ WinSetWindowText(WinWindowFromID(hwnd, BUTTON_FORM), "Engineering"); } else { form = SCIENTIFIC; /* otherwise scientfic */ WinSetWindowText(WinWindowFromID(hwnd, BUTTON_FORM), "Scientific"); } return FALSE; /* all done */ default: /* Unknown, can't handle this */ return FALSE; } /* We've received a WM_COMMAND message. WM_COMMAND messages */ /* are generated by "pressing" buttons on the calculator. The */ /* additional parameters in the received message identify the */ /* button that was pressed */ case WM_COMMAND: action = SHORT1FROMMP(mp1); /* Extract message sub-type */ switch (action) { /* The following buttons will be processed by the actual */ /* calculator routine */ case BUTTON_CLEAR: /* Clear key */ /* initialize accumulator */ MAKERXSTRING(accumulator, accbuff, 1); strcpy(accbuff, "0"); /* fill in a zero */ /* initialize the display */ MAKERXSTRING(display, dispbuff, 1); strcpy(dispbuff, "0"); /* fill in a zero display */ digits = 0; /* no digits yet */ hadperiod = NO; /* turn off number processing */ hadexponent = NO; /* flags. */ oldaction = 0; /* and any pending operations */ /* update the calculator */ /* display */ WinSetWindowText(WinWindowFromID(hwnd, DISPLAY), display.strptr); return FALSE; /* All done */ case BUTTON_DIGITS: /* set new digits */ /* not a whole number? */ if (!CheckWhole(&display)) /* give an error beep */ WinAlarm(HWND_DESKTOP, WA_ERROR); else { /* process the number */ /* copy the number */ strcpy(precision, display.strptr); /* redisplay the accumlator */ SetDisplay(&accumulator); /* display */ WinSetWindowText(WinWindowFromID(hwnd, DISPLAY), display.strptr); } return FALSE; /* All done */ case BUTTON_0: /* Numeric keys */ case BUTTON_1: case BUTTON_2: case BUTTON_3: case BUTTON_4: case BUTTON_5: case BUTTON_6: case BUTTON_7: case BUTTON_8: case BUTTON_9: case BUTTON_PERIOD: /* decimal point */ case BUTTON_EXPONENT: /* exponent value */ case BUTTON_SIGN: /* sign change */ /* Add a digit to display */ AddDigit(action); /* update the accumulator */ /* display */ WinSetWindowText(WinWindowFromID(hwnd, DISPLAY), display.strptr); return FALSE; /* All done */ /* The arithmetic operation keys all have a deferred */ /* execution. When one of these is pressed, the previous*/ /* arithmetic operation is processed using the */ /* accumulator and the current display. The new operator*/ /* is saved for later execution. If no operator exists, */ /* then the current display is moved to the accumulator */ /* and no arithmetic is done */ case BUTTON_MULTIPLY: /* Multiply key */ case BUTTON_DIVIDE: /* Division key */ case BUTTON_PLUS: /* Addition key */ case BUTTON_MINUS: /* Subtraction key */ case BUTTON_IDIV: /* integer division */ case BUTTON_REMAINDER: /* remainder division */ case BUTTON_POWER: /* raise a number to power */ case BUTTON_ENTER: /* "Total" key */ case BUTTON_PROGRAM1: /* programmed Rexx function */ case BUTTON_PROGRAM2: /* programmed Rexx function */ /* Process pending operations */ ProcessArithmetic(action); SetDisplay(&accumulator);/* reset display buffer */ /* update the calculator */ /* display */ WinSetWindowText(WinWindowFromID(hwnd, DISPLAY), accumulator.strptr); return FALSE; /* All done */ default: /* Unknown, can't handle this */ return FALSE; } case WM_ERASEBACKGROUND: /* disable background erase */ return MRFROMLONG(TRUE); /* don't allow this */ /* Message not handled by us. PM gives us first chance at all */ /* messages. Those we don't want to process we pass on to the */ /* default dialog procedure. */ default: return WinDefWindowProc(hwnd, msg, mp1, mp2); } return FALSE; /* Should never reach here */ }