From: Mapi B. <ma...@us...> - 2009-10-21 20:56:22
|
Update of /cvsroot/easycalc/PPCport/system - UI In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27710 Modified Files: EasyCalc.cpp EasyCalc.gif EasyCalc.h Log Message: Bug fixes, dynamic language change enabled on UI. Index: EasyCalc.cpp =================================================================== RCS file: /cvsroot/easycalc/PPCport/system - UI/EasyCalc.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EasyCalc.cpp 17 Oct 2009 13:53:14 -0000 1.3 --- EasyCalc.cpp 21 Oct 2009 20:56:12 -0000 1.4 *************** *** 66,74 **** - Global variables. - -------------------------------------------------------------------------------*/ ! HINSTANCE g_hInst; // current instance ! HWND g_hWnd; // current main window handle ! HWND g_hWndMenuBar; // menu bar handle ! StateManager stateMgr; ! LibLang *libLang; --- 66,75 ---- - Global variables. - -------------------------------------------------------------------------------*/ ! HINSTANCE g_hInst = NULL; // current instance ! HWND g_hWnd = NULL; // current main window handle ! HWND g_hWndMenuBar = NULL; // menu bar handle ! int g_systUserLangId = 0; // Detected language of the system user ! StateManager *stateMgr = NULL; ! LibLang *libLang = NULL; *************** *** 81,88 **** static TCHAR *easyCalcStateFileName = _T("\\state.bin"); static TCHAR fileName[FILENAMELEN]; ! static t_state *state; static int ann_state[NB_ANNUN]; static int ckey = KEY_NONE; // Current key static int skey; --- 82,93 ---- static TCHAR *easyCalcStateFileName = _T("\\state.bin"); static TCHAR fileName[FILENAMELEN]; ! static t_state *state; static int ann_state[NB_ANNUN]; + // For handling changes to the main window and application after option changes + static bool screen_redraw = false; + static TCHAR *new_lang = NULL; + static int ckey = KEY_NONE; // Current key static int skey; *************** *** 119,124 **** - Forward declarations. - -------------------------------------------------------------------------------*/ ! ATOM MyRegisterClass (HINSTANCE, LPTSTR); ! BOOL InitInstance (HINSTANCE, int); LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK WndAbout (HWND, UINT, WPARAM, LPARAM); --- 124,130 ---- - Forward declarations. - -------------------------------------------------------------------------------*/ ! static ATOM MyRegisterClass (HINSTANCE, LPTSTR); ! static BOOL InitScreen (void); ! static BOOL InitInstance (HINSTANCE, int); LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK WndAbout (HWND, UINT, WPARAM, LPARAM); *************** *** 225,231 **** --- 231,250 ---- MainShowCmd = nCmdShow; // Make it available to other parts of code + + // Check if the application is running. If it's running then focus on the window. + if (hPrevInstance) { + return(FALSE); + } + // Perform application initialization. // Show the hourglass during that initialization since it will take some time. SetCursor(LoadCursor(NULL, IDC_WAIT)); + + TCHAR language[100]; + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, language, sizeof(language)); + int rc = _stscanf(language, _T("%x"), &g_systUserLangId); + if (rc != 1) // English by default if we can't recognize user language + g_systUserLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); + if (!InitInstance(hInstance, nCmdShow)) { SetCursor(NULL); *************** *** 255,259 **** * Registers the window class. * ********************************************************************************/ ! ATOM MyRegisterClass (HINSTANCE hInstance, LPTSTR szWindowClass) { ATOM a; WNDCLASS wc; --- 274,278 ---- * Registers the window class. * ********************************************************************************/ ! static ATOM MyRegisterClass (HINSTANCE hInstance, LPTSTR szWindowClass) { ATOM a; WNDCLASS wc; *************** *** 284,292 **** /******************************************************************************** * FUNCTION: InitInstance(HINSTANCE, int) * * Saves instance handle, creates main window, initialize overall application * * variables. * ********************************************************************************/ ! BOOL InitInstance (HINSTANCE hInstance, int nCmdShow) { TCHAR szTitle[MAX_LOADSTRING]; // title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // main window class name --- 303,429 ---- /******************************************************************************** + * FUNCTION: InitScreen(HINSTANCE) * + * (Re-)creates main window and menus. * + ********************************************************************************/ + static BOOL InitScreen (void) { + // Initialize menus with proper translated strings + TBBUTTONINFO tbbi; + memset(&tbbi,0,sizeof(tbbi)); + tbbi.cbSize = sizeof(tbbi); + tbbi.dwMask = TBIF_TEXT; + tbbi.pszText = (TCHAR *) libLang->translate(_T("$$FILE")); + int rc = SendMessage(g_hWndMenuBar, TB_SETBUTTONINFO, IDM_FILE, (LPARAM) &tbbi); + tbbi.pszText = (TCHAR *) libLang->translate(_T("$$EDIT")); + rc = SendMessage(g_hWndMenuBar, TB_SETBUTTONINFO, IDM_EDIT, (LPARAM) &tbbi); + tbbi.pszText = (TCHAR *) libLang->translate(_T("$$HELP")); + rc = SendMessage(g_hWndMenuBar, TB_SETBUTTONINFO, IDM_HELP, (LPARAM) &tbbi); + // Doesn't seem to do anything ... + // rc = DrawMenuBar(g_hWndMenuBar); + + HMENU hmmb = (HMENU)SendMessage(g_hWndMenuBar, SHCMBM_GETMENU, (WPARAM) 0, (LPARAM) 0); + MENUITEMINFO mii; + memset(&mii,0,sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_TYPE; + mii.fType = MFT_STRING; + HMENU hmmb_sub = (HMENU) SendMessage(g_hWndMenuBar, SHCMBM_GETSUBMENU, (WPARAM) 0, + (LPARAM) IDM_FILE); + mii.dwTypeData = (TCHAR *) libLang->translate(_T("$$EXIT")); // Force "const" off + rc = SetMenuItemInfo(hmmb_sub, IDM_FILE_EXIT, FALSE, &mii); + hmmb_sub = (HMENU) SendMessage(g_hWndMenuBar, SHCMBM_GETSUBMENU, (WPARAM) 0, (LPARAM) IDM_EDIT); + mii.dwTypeData = (TCHAR *) libLang->translate(_T("$$OPTIONS")); // Force "const" off + rc = SetMenuItemInfo(hmmb_sub, IDM_EDIT_OPTIONS, FALSE, &mii); + hmmb_sub = (HMENU) SendMessage(g_hWndMenuBar, SHCMBM_GETSUBMENU, (WPARAM) 0, (LPARAM) IDM_HELP); + mii.dwTypeData = (TCHAR *) libLang->translate(_T("$$ABOUT...")); // Force "const" off + rc = SetMenuItemInfo(hmmb_sub, IDM_HELP_ABOUT, FALSE, &mii); + // Doesn't seem to do anything ... + // rc = DrawMenuBar(g_hWndMenuBar); + + // Set skin + cur_skin = loaded_skins + state->cur_skin_nb; + // core_init(init_mode, version); + + // Get the screen dimensions and load the skin on it + RECT r; + GetClientRect(hMainWnd, &r); + if ((rc = cur_skin->load(state->skinName[state->cur_skin_nb], + easyCalcDirname, + r.right, + r.bottom))) { + if (rc == -1) { + FrmPopupForm(altNoLayoutFile, g_hWnd); + } else if (rc == -2) { + FrmPopupForm(altErrorGifFile, g_hWnd); + } + return (FALSE); + } + + // Set the annunciators state + for (int i=0 ; i<NB_ANNUN ; i++) ann_state[i] = false; + ann_state[ANN_DEG + calcPrefs.trigo_mode - degree] = true; + switch (dispPrefs.base) { + case disp_decimal: + ann_state[ANN_DEC] = true; + break; + case disp_octal: + ann_state[ANN_OCT] = true; + break; + case disp_binary: + ann_state[ANN_BIN] = true; + break; + case disp_hexa: + ann_state[ANN_HEX] = true; + break; + } + ann_state[ANN_S1 + state->cur_skin_nb] = true; + + // Prepare options panels + #define DEF_NUM_OF_PAGES 3 + propPages = new PROPSHEETPAGE[DEF_NUM_OF_PAGES]; + memset(propPages, 0, sizeof(PROPSHEETPAGE) * DEF_NUM_OF_PAGES); + + propPages[0].dwSize = sizeof(PROPSHEETPAGE); + propPages[0].dwFlags = PSP_DEFAULT | PSP_USETITLE; + propPages[0].pszTemplate = MAKEINTRESOURCE(IDD_OPT_GENERAL); + propPages[0].pfnDlgProc = (DLGPROC)WndOptionsGen; + propPages[0].hInstance = g_hInst; + propPages[0].pszIcon = NULL; + propPages[0].pszTitle = libLang->translate(_T("$$GENERAL")); + propPages[0].lParam = (LPARAM) NULL; + + propPages[1].dwSize = sizeof(PROPSHEETPAGE); + propPages[1].dwFlags = PSP_DEFAULT | PSP_USETITLE; + propPages[1].pszTemplate = MAKEINTRESOURCE(IDD_OPT_SKINS); + propPages[1].pfnDlgProc = (DLGPROC)WndOptionsSkins; + propPages[1].hInstance = g_hInst; + propPages[1].pszIcon = NULL; + propPages[1].pszTitle = libLang->translate(_T("$$SKINS")); + propPages[1].lParam = (LPARAM) NULL; + + propPages[2].dwSize = sizeof(PROPSHEETPAGE); + propPages[2].dwFlags = PSP_DEFAULT | PSP_USETITLE; + propPages[2].pszTemplate = MAKEINTRESOURCE(IDD_OPT_PREFS); + propPages[2].pfnDlgProc = (DLGPROC)WndOptionsCalcPrefs; + propPages[2].hInstance = g_hInst; + propPages[2].pszIcon = NULL; + propPages[2].pszTitle = libLang->translate(_T("$$PREFERENCES TITLE")); + propPages[2].lParam = (LPARAM) NULL; + + // Prepare the painting brush for the input area Edit control + editBgBrush = CreateSolidBrush(cur_skin->getDisplayBgColor()); + cur_skin->create_input_area(hMainWnd, g_hInst); + + // Force redisplay of full zone. + InvalidateRect(hMainWnd, NULL, TRUE); + + return(TRUE); + } + + /******************************************************************************** * FUNCTION: InitInstance(HINSTANCE, int) * * Saves instance handle, creates main window, initialize overall application * * variables. * ********************************************************************************/ ! static BOOL InitInstance (HINSTANCE hInstance, int nCmdShow) { TCHAR szTitle[MAX_LOADSTRING]; // title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // main window class name *************** *** 370,373 **** --- 507,520 ---- libLang = new LibLang (f); + // Create the StateMgr object with proper default language. + stateMgr = new StateManager (); + state = stateMgr->getState(); // This will simplify accessing state part of the object + const TCHAR *defLangName; + if ((defLangName = libLang->getLang(g_systUserLangId)) != NULL) { + // If NULL, then "en" has already been set by default by the constructor. + // Handle other case. + _tcscpy(state->langName, defLangName); + } + // Initialize application level objects Err err=0; *************** *** 384,467 **** } ! cur_skin = loaded_skins + state->cur_skin_nb; ! libLang->setLang(state->langName); // Set the language according to the state. _tcscpy(state->langName, libLang->getLang()); // Copy in state the final selected language. - // core_init(init_mode, version); - - // Get the screen dimensions and load the skin on it - RECT r; - GetClientRect(hMainWnd, &r); - int rc; - if ((rc = cur_skin->load(state->skinName[state->cur_skin_nb], - easyCalcDirname, - r.right, - r.bottom))) { - if (rc == -1) { - FrmPopupForm(altNoLayoutFile, g_hWnd); - } else if (rc == -2) { - FrmPopupForm(altErrorGifFile, g_hWnd); - } - return (FALSE); - } - - // Set the annunciators state - for (int i=0 ; i<NB_ANNUN ; i++) ann_state[i] = false; - ann_state[ANN_DEG + calcPrefs.trigo_mode - degree] = true; - switch (dispPrefs.base) { - case disp_decimal: - ann_state[ANN_DEC] = true; - break; - case disp_octal: - ann_state[ANN_OCT] = true; - break; - case disp_binary: - ann_state[ANN_BIN] = true; - break; - case disp_hexa: - ann_state[ANN_HEX] = true; - break; - } - ann_state[ANN_S1 + stateMgr.state.cur_skin_nb] = true; ! // Prepare the options panels ! #define DEF_NUM_OF_PAGES 3 ! propPages = new PROPSHEETPAGE[DEF_NUM_OF_PAGES]; ! memset(propPages, 0, sizeof(PROPSHEETPAGE) * DEF_NUM_OF_PAGES); ! ! propPages[0].dwSize = sizeof(PROPSHEETPAGE); ! propPages[0].dwFlags = PSP_DEFAULT; ! propPages[0].pszTemplate = MAKEINTRESOURCE(IDD_OPT_GENERAL); ! propPages[0].pfnDlgProc = (DLGPROC)WndOptionsGen; ! propPages[0].hInstance = g_hInst; ! propPages[0].pszIcon = NULL; ! propPages[0].lParam = (LPARAM) NULL; ! ! propPages[1].dwSize = sizeof(PROPSHEETPAGE); ! propPages[1].dwFlags = PSP_DEFAULT; ! propPages[1].pszTemplate = MAKEINTRESOURCE(IDD_OPT_SKINS); ! propPages[1].pfnDlgProc = (DLGPROC)WndOptionsSkins; ! propPages[1].hInstance = g_hInst; ! propPages[1].pszIcon = NULL; ! propPages[1].lParam = (LPARAM) NULL; ! ! propPages[2].dwSize = sizeof(PROPSHEETPAGE); ! propPages[2].dwFlags = PSP_DEFAULT; ! propPages[2].pszTemplate = MAKEINTRESOURCE(IDD_OPT_PREFS); ! propPages[2].pfnDlgProc = (DLGPROC)WndOptionsCalcPrefs; ! propPages[2].hInstance = g_hInst; ! propPages[2].pszIcon = NULL; ! propPages[2].lParam = (LPARAM) NULL; ! // Show window contents (force redisplay of full zone in case an error msg happened ! // and modified the invalidate portion of screen). ! InvalidateRect(hMainWnd, NULL, TRUE); ShowWindow(hMainWnd, nCmdShow); UpdateWindow(hMainWnd); - // Prepare the painting brush for the input area Edit control - editBgBrush = CreateSolidBrush(cur_skin->getDisplayBgColor()); - cur_skin->create_input_area(hMainWnd, g_hInst); - // cur_skin->set_input_text(NULL, _T("Hello 0,1234")); - return (TRUE); } --- 531,547 ---- } ! // From there, proper language has been set, either from initialization ! // or from loading state.bin. ! // Set corresponding current language in libLang. ! libLang->setLang(state->langName); _tcscpy(state->langName, libLang->getLang()); // Copy in state the final selected language. ! // Create main window contents ! InitScreen(); ! // Show window contents ShowWindow(hMainWnd, nCmdShow); UpdateWindow(hMainWnd); return (TRUE); } *************** *** 475,479 **** _tcscpy(fileName, easyCalcDirname); _tcscat(fileName, easyCalcStateFileName); ! state = stateMgr.init(fileName, g_hWnd); } --- 555,559 ---- _tcscpy(fileName, easyCalcDirname); _tcscat(fileName, easyCalcStateFileName); ! stateMgr->init(fileName, g_hWnd); } *************** *** 486,490 **** _tcscpy(fileName, easyCalcDirname); _tcscat(fileName, easyCalcStateFileName); ! stateMgr.save(fileName, g_hWnd); } --- 566,570 ---- _tcscpy(fileName, easyCalcDirname); _tcscat(fileName, easyCalcStateFileName); ! stateMgr->save(fileName, g_hWnd); } *************** *** 502,506 **** cur_skin->repaint_annunciator(hdc, memdc, -(skey+2), 2); else cur_skin->repaint_key(hdc, memdc, skey, 1); ! DeleteObject(memdc); ReleaseDC(hMainWnd, hdc); } --- 582,586 ---- cur_skin->repaint_annunciator(hdc, memdc, -(skey+2), 2); else cur_skin->repaint_key(hdc, memdc, skey, 1); ! DeleteDC(memdc); ReleaseDC(hMainWnd, hdc); } *************** *** 561,565 **** cur_skin->repaint_annunciator(hdc, memdc, -(skey+2), ann_state[-(skey+2)]); else cur_skin->repaint_key(hdc, memdc, skey, 0); ! DeleteObject(memdc); ReleaseDC(hMainWnd, hdc); --- 641,645 ---- cur_skin->repaint_annunciator(hdc, memdc, -(skey+2), ann_state[-(skey+2)]); else cur_skin->repaint_key(hdc, memdc, skey, 0); ! DeleteDC(memdc); ReleaseDC(hMainWnd, hdc); *************** *** 576,580 **** } ! // Process the annunciators, only if the state is up or if it is always selectable if ((skey <= -2) && (skey >= -1-NB_ANNUN) && ((ann_state[-(skey+2)] == 1) || ((skey <= -(ANN_S1+2)) && (skey >= -(ANN_HSTMENU+2))))) { --- 656,660 ---- } ! // Process annunciators, only if the state is up or if it is always selectable if ((skey <= -2) && (skey >= -1-NB_ANNUN) && ((ann_state[-(skey+2)] == 1) || ((skey <= -(ANN_S1+2)) && (skey >= -(ANN_HSTMENU+2))))) { *************** *** 599,602 **** --- 679,688 ---- shell_annunciators(ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_HEX, ANNVAL_UNCH); break; + case ANN_SCRL: + cur_skin->scroll_result_left(g_hWnd); + break; + case ANN_SCRR: + cur_skin->scroll_result_right(g_hWnd); + break; case ANN_HEX: shell_annunciators(ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_DEC, ANNVAL_UNCH); *************** *** 713,717 **** cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = false)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! stateMgr.state.cur_skin_nb = 0; } } else if (skin == ANNVAL_S2) { --- 799,803 ---- cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = false)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! state->cur_skin_nb = 0; } } else if (skin == ANNVAL_S2) { *************** *** 721,725 **** cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = false)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! stateMgr.state.cur_skin_nb = 1; } } else if (skin == ANNVAL_S3) { --- 807,811 ---- cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = false)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! state->cur_skin_nb = 1; } } else if (skin == ANNVAL_S3) { *************** *** 729,733 **** cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = true)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! stateMgr.state.cur_skin_nb = 3; } } else if (skin == ANNVAL_SG) { --- 815,819 ---- cur_skin->repaint_annunciator(hdc, memdc, ANN_S3, (ann_state[ANN_S3] = true)); cur_skin->repaint_annunciator(hdc, memdc, ANN_SG, (ann_state[ANN_SG] = false)); ! state->cur_skin_nb = 3; } } else if (skin == ANNVAL_SG) { *************** *** 813,816 **** --- 899,926 ---- /******************************************************************************** + * FUNCTION: shell_scroll_annunciators() * + * Callback invoked by the skin object to change the state of the result scroll * + * annunciators (none, left, right). * + ********************************************************************************/ + void shell_scroll_annunciators(int scroll) { + HDC hdc = GetDC(hMainWnd); + HDC memdc = CreateCompatibleDC(hdc); + + if (scroll == ANNVAL_SCR_NONE) { + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRL, (ann_state[ANN_SCRL] = false)); + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRR, (ann_state[ANN_SCRR] = false)); + } else if (scroll == ANNVAL_SCR_LEFT) { + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRL, (ann_state[ANN_SCRL] = true)); + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRR, (ann_state[ANN_SCRR] = false)); + } else { + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRL, (ann_state[ANN_SCRL] = false)); + cur_skin->repaint_annunciator(hdc, memdc, ANN_SCRR, (ann_state[ANN_SCRR] = true)); + } + + DeleteDC(memdc); + ReleaseDC(hMainWnd, hdc); + } + + /******************************************************************************** * FUNCTION: shell_powerdown() * * Execute command to end the calculator. * *************** *** 1074,1077 **** --- 1184,1197 ---- psh.ppsp = propPages; PropertySheet(&psh); + // Re-create main window contents if necessary + if (new_lang) { // Set new language and remember it + _tcscpy(state->langName, new_lang); + new_lang = NULL; + libLang->setLang(state->langName); + } + if (screen_redraw) { + screen_redraw = false; + InitScreen(); + } break; #ifdef WIN32_PLATFORM_PSPC *************** *** 1128,1131 **** --- 1248,1257 ---- EndPaint(hWnd, &ps); + // { + // int rc = DrawMenuBar(g_hWnd); + // DWORD wrc = GetLastError(); + // rc = DrawMenuBar(g_hWndMenuBar); + // wrc = GetLastError(); + // } break; *************** *** 1652,1655 **** --- 1778,1782 ---- // SHInitDialog(&shidi); #endif // SHELL_AYGSHELL + SetWindowText(hDlg, libLang->translate(_T("$$ABOUT..."))); return ((INT_PTR) TRUE); *************** *** 1708,1714 **** * Some formatting for the title of option property pages. * ********************************************************************************/ ! BOOL DefDlgCtlColorStaticProc(HWND hDlg, WPARAM wParam, LPARAM lParam) { HDC hDC = (HDC) wParam; ! if (GetDlgCtrlID((HWND)lParam) == IDC_TITLE) { SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHT)); --- 1835,1841 ---- * Some formatting for the title of option property pages. * ********************************************************************************/ ! BOOL DefDlgCtlColorStaticProc(HWND hDlg, WPARAM wParam, LPARAM lParam, int idc_title) { HDC hDC = (HDC) wParam; ! if (GetDlgCtrlID((HWND)lParam) == idc_title) { SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHT)); *************** *** 1732,1736 **** const TCHAR *text = libLang->translate(_T("$$GENERAL")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE); SetWindowText(hWnd, text); hWnd = GetDlgItem(hDlg, IDC_CHECK_MOUSE); --- 1859,1863 ---- const TCHAR *text = libLang->translate(_T("$$GENERAL")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE1); SetWindowText(hWnd, text); hWnd = GetDlgItem(hDlg, IDC_CHECK_MOUSE); *************** *** 1738,1741 **** --- 1865,1882 ---- if (state->mouse_cont) SendMessage(hWnd, BM_SETCHECK, BST_CHECKED, 0); + hWnd = GetDlgItem(hDlg, IDC_LANGUAGE); + SetWindowText(hWnd, libLang->translate(_T("$$LANGUAGE"))); + hWnd = GetDlgItem(hDlg, IDC_LANGUAGE_CB); + int nbLangs = libLang->getNbLang(); + int numSel = 0; + const TCHAR *selLang = libLang->getLang(); + const TCHAR *lang; + for (int i=0 ; i<nbLangs ; i++) { + lang = libLang->getLangByIndex(i); + SendMessage(hWnd, CB_ADDSTRING, (WPARAM) 0, (LPARAM) lang); + if (selLang == lang) + numSel = i; + } + SendMessage(hWnd, CB_SETCURSEL, (WPARAM) numSel, (LPARAM) 0); } return (TRUE); *************** *** 1751,1756 **** } case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam)); default: --- 1892,1928 ---- } + case WM_COMMAND: + { + BOOL res = FALSE; + unsigned int notify_msg = wParam >> 16; + unsigned int notify_src = wParam & 0xFFFF; + HWND hWnd = (HWND) lParam; + switch (notify_src) { + case IDC_LANGUAGE_CB: + switch (notify_msg) { + case CBN_CLOSEUP: + int cur_sel = (int) SendMessage(hWnd, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); + dispPrefs.mode = ((cur_sel == 0) + ? disp_normal + : ((cur_sel == 1) + ? disp_sci + : disp_eng + ) + ); + // Set chosen language, and tell WndProc to modify menus + // and propSheets accordingly. + new_lang = (TCHAR *) libLang->getLangByIndex(cur_sel); // Force "const" off + screen_redraw = true; + + res = TRUE; + break; + } + break; + } + return (res); + } + break; case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam, IDC_TITLE1)); default: *************** *** 1776,1780 **** const TCHAR *text = libLang->translate(_T("$$SKINS")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE); SetWindowText(hWnd, text); text = libLang->translate(_T("$$SKIN")); --- 1948,1952 ---- const TCHAR *text = libLang->translate(_T("$$SKINS")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE2); SetWindowText(hWnd, text); text = libLang->translate(_T("$$SKIN")); *************** *** 1794,1803 **** int numSel = -1; for (int i=0 ; i<3 ; i++) { ! if (stateMgr.state.skinName[i][0] != 0) { TCHAR numText[2]; numText[0] = _T('0'+i); numText[1] = 0; SendMessage(hWnd, CB_ADDSTRING, (WPARAM) 0, (LPARAM) numText); ! if (i == stateMgr.state.cur_skin_nb) numSel = i; } --- 1966,1975 ---- int numSel = -1; for (int i=0 ; i<3 ; i++) { ! if (state->skinName[i][0] != 0) { TCHAR numText[2]; numText[0] = _T('0'+i); numText[1] = 0; SendMessage(hWnd, CB_ADDSTRING, (WPARAM) 0, (LPARAM) numText); ! if (i == state->cur_skin_nb) numSel = i; } *************** *** 1830,1837 **** int numSel = SendMessage(hWnd, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); for (int i=0 ; i<3 ; i++) { ! if (stateMgr.state.skinName[i][0] != 0) { if (numSel-- == 0) { // Done in shell_annunciators ! // stateMgr.state.cur_skin_nb = i; shell_annunciators(ANNVAL_S1+i, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH); break; // Stop loop, we have found it --- 2002,2009 ---- int numSel = SendMessage(hWnd, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); for (int i=0 ; i<3 ; i++) { ! if (state->skinName[i][0] != 0) { if (numSel-- == 0) { // Done in shell_annunciators ! // state->cur_skin_nb = i; shell_annunciators(ANNVAL_S1+i, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH, ANNVAL_UNCH); break; // Stop loop, we have found it *************** *** 1848,1852 **** case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam)); default: --- 2020,2024 ---- case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam, IDC_TITLE2)); default: *************** *** 1871,1877 **** SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); propSheet = (LPPROPSHEETPAGE) lParam; ! const TCHAR *text = libLang->translate(_T("$$CALC PREFERENCES")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE); SetWindowText(hWnd, text); hWnd = GetDlgItem(hDlg, IDC_DEGREE); --- 2043,2049 ---- SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); propSheet = (LPPROPSHEETPAGE) lParam; ! const TCHAR *text = libLang->translate(_T("$$PREFERENCES TITLE")); SetWindowText(hDlg, text); ! HWND hWnd = GetDlgItem(hDlg, IDC_TITLE3); SetWindowText(hWnd, text); hWnd = GetDlgItem(hDlg, IDC_DEGREE); *************** *** 2171,2175 **** case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam)); default: --- 2343,2347 ---- case WM_CTLCOLORSTATIC: ! return (DefDlgCtlColorStaticProc(hDlg, wParam, lParam, IDC_TITLE3)); default: *************** *** 2315,2319 **** { SetWindowText(hDlg, libLang->translate(_T("$$SAVE AS TITLE"))); ! HWND hWnd = GetDlgItem(hDlg, IDC_VARNAME); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDOK); --- 2487,2491 ---- { SetWindowText(hDlg, libLang->translate(_T("$$SAVE AS TITLE"))); ! HWND hWnd = GetDlgItem(hDlg, IDC_VARNAME3); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDOK); *************** *** 2638,2642 **** hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); SetFocus(hWnd); --- 2810,2814 ---- hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME1); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); SetFocus(hWnd); *************** *** 2744,2748 **** hWnd = GetDlgItem(hDlg, IDC_EDIT3); SetWindowText(hWnd, parameter_name); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); SetFocus(hWnd); --- 2916,2920 ---- hWnd = GetDlgItem(hDlg, IDC_EDIT3); SetWindowText(hWnd, parameter_name); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME2); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); SetFocus(hWnd); *************** *** 2855,2859 **** hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDC_EDIT1); --- 3027,3031 ---- hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME1); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDC_EDIT1); *************** *** 2960,2964 **** hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDC_PARAM); --- 3132,3136 ---- hWnd = GetDlgItem(hDlg, IDCANCEL); SetWindowText(hWnd, libLang->translate(_T("$$CANCEL"))); ! hWnd = GetDlgItem(hDlg, IDC_VARNAME2); SetWindowText(hWnd, libLang->translate(_T("$$NAME:"))); hWnd = GetDlgItem(hDlg, IDC_PARAM); Index: EasyCalc.gif =================================================================== RCS file: /cvsroot/easycalc/PPCport/system - UI/EasyCalc.gif,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsslyUA1 and /tmp/cvstZ0Mss differ Index: EasyCalc.h =================================================================== RCS file: /cvsroot/easycalc/PPCport/system - UI/EasyCalc.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EasyCalc.h 17 Oct 2009 13:53:14 -0000 1.3 --- EasyCalc.h 21 Oct 2009 20:56:12 -0000 1.4 *************** *** 144,147 **** --- 144,148 ---- #include "compat/Lang.h" extern LibLang *libLang; + extern int g_systUserLangId; // Detected language of the system user #endif *************** *** 151,156 **** void save_state (void); void shell_beeper(int frequency, int duration); ! void shell_annunciators(int skin, int shf, int angle_mode, int int_mode, int run) SHELL1_SECT; ! void shell_powerdown() SHELL1_SECT; void alertErrorMessage(CError err); void ErrFatalDisplayIf(int cond, TCHAR *msg); --- 152,158 ---- void save_state (void); void shell_beeper(int frequency, int duration); ! void shell_annunciators(int skin, int shf, int angle_mode, int int_mode, int run); ! void shell_scroll_annunciators(int scroll); ! void shell_powerdown(); void alertErrorMessage(CError err); void ErrFatalDisplayIf(int cond, TCHAR *msg); |