void CMuleToolbarCtrl::OnSize(UINT nType, int cx, int cy) { CToolBarCtrl::OnSize(nType, cx, cy); SetAllButtonsWidth(); AutoSize(); }
void CMuleToolbarCtrl::OnTbnReset(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/) { // First get rid of old buttons // while saving their states for (int i = GetButtonCount()-1; i >= 0; i--) { TBBUTTON Button; GetButton(i, &Button); for (int j = 0; j < m_buttoncount ; j++) { if (TBButtons[j].idCommand == Button.idCommand) { TBButtons[j].fsState = Button.fsState; TBButtons[j].fsStyle = Button.fsStyle; TBButtons[j].iString = Button.iString; } } DeleteButton(i); } TBBUTTON sepButton; sepButton.idCommand = 0; sepButton.fsStyle = TBSTYLE_SEP; sepButton.fsState = TBSTATE_ENABLED; sepButton.iString = -1; sepButton.iBitmap = -1; // set default configuration CString config = strDefaultToolbar; // MORPH START show less controls if (thePrefs.IsLessControls()) config=strDefaultLessControlsToolbar; // MORPH END show less controls for (int i = 0; i <config.GetLength(); i += 2) { int index = _tstoi(config.Mid(i, 2)); if (index == 99) { AddButtons(1, &sepButton); continue; } AddButtons(1, &TBButtons[index]); } // save new (default) configuration thePrefs.SetToolbarSettings(config); Localize(); // we have to localize the button-text theApp.emuledlg->ShowConnectionState(); ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true); SetAllButtonsWidth(); // then calc and set the button width AutoSize(); }
void CMuleToolbarCtrl::Localize(void) { if (m_hWnd) { SetAllButtonsStrings(); SetAllButtonsWidth(); AutoSize(); UpdateIdealSize(); } }
void CMuleToolbarCtrl::OnTbnToolbarChange(NMHDR* /*pNMHDR*/, LRESULT* pResult) { CString config; for (int i = 0; i < GetButtonCount();i++) { TBBUTTON buttoninfo; if (GetButton(i, &buttoninfo)) config.AppendFormat(_T("%02i"), (buttoninfo.idCommand != 0) ? buttoninfo.idCommand - IDC_TOOLBARBUTTON : 99); } thePrefs.SetToolbarSettings(config); Localize(); theApp.emuledlg->ShowConnectionState(); SetAllButtonsWidth(); AutoSize(); *pResult = 0; }
void CMuleToolbarCtrl::Refresh() { SetAllButtonsWidth(); AutoSize(); // Causes a toolbar to be resized. if (theApp.emuledlg->m_ctlMainTopReBar.m_hWnd) { theApp.emuledlg->RemoveAnchor(theApp.emuledlg->m_ctlMainTopReBar.m_hWnd); REBARBANDINFO rbbi = {0}; CSize sizeBar; GetMaxSize(&sizeBar); ASSERT( sizeBar.cx != 0 && sizeBar.cy != 0 ); rbbi.cbSize = sizeof(rbbi); rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; rbbi.cxMinChild = sizeBar.cy; rbbi.cyMinChild = sizeBar.cy; rbbi.cxIdeal = sizeBar.cx; VERIFY( theApp.emuledlg->m_ctlMainTopReBar.SetBandInfo(MULE_TOOLBAR_BAND_NR, &rbbi) ); theApp.emuledlg->AddAnchor(theApp.emuledlg->m_ctlMainTopReBar.m_hWnd, TOP_LEFT, TOP_RIGHT); } CRect rToolbarRect; GetWindowRect(&rToolbarRect); if (m_iPreviousHeight == rToolbarRect.Height()) { Invalidate(); RedrawWindow(); } else { m_iPreviousHeight = rToolbarRect.Height(); CRect rClientRect; theApp.emuledlg->GetClientRect(&rClientRect); CRect rStatusbarRect; theApp.emuledlg->statusbar->GetWindowRect(&rStatusbarRect); rClientRect.top += rToolbarRect.Height(); rClientRect.bottom -= rStatusbarRect.Height(); CWnd* wnds[] = { theApp.emuledlg->serverwnd, theApp.emuledlg->kademliawnd, theApp.emuledlg->transferwnd, theApp.emuledlg->sharedfileswnd, theApp.emuledlg->searchwnd, theApp.emuledlg->chatwnd, #ifdef IRC theApp.emuledlg->ircwnd, #endif theApp.emuledlg->statisticswnd }; for (int i = 0; i < _countof(wnds); i++) { wnds[i]->SetWindowPos(NULL, rClientRect.left, rClientRect.top, rClientRect.Width(), rClientRect.Height(), SWP_NOZORDER); theApp.emuledlg->RemoveAnchor(wnds[i]->m_hWnd); theApp.emuledlg->AddAnchor(wnds[i]->m_hWnd, TOP_LEFT, BOTTOM_RIGHT); } theApp.emuledlg->Invalidate(); theApp.emuledlg->RedrawWindow(); } }
void CMuleToolbarCtrl::Init(void) { m_astrToolbarPaths.RemoveAll(); // Win98: Explicitly set to Unicode to receive Unicode notifications. SendMessage(CCM_SETUNICODEFORMAT, TRUE); ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_ALTDRAG | CCS_ADJUSTABLE | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | CCS_NODIVIDER); if (thePrefs.GetUseReBarToolbar()) { ModifyStyle(0, CCS_NORESIZE); SetExtendedStyle(GetExtendedStyle() | TBSTYLE_EX_HIDECLIPPEDBUTTONS); } ChangeToolbarBitmap(thePrefs.GetToolbarBitmapSettings(), false); // add button-text: TCHAR cButtonStrings[2000]; int lLen, lLen2; m_buttoncount = 0; _tcscpy(cButtonStrings, GetResString(IDS_MAIN_BTN_CONNECT)); lLen = _tcslen(GetResString(IDS_MAIN_BTN_CONNECT)) + 1; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_KADEMLIA)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_KADEMLIA), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_SERVER)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SERVER), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_TRANS)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_TRANS), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_SEARCH)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SEARCH), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_FILES)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_FILES), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_MESSAGES)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_MESSAGES), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; #ifdef IRC lLen2 = _tcslen(GetResString(IDS_IRC)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_IRC), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; #endif lLen2 = _tcslen(GetResString(IDS_EM_STATISTIC)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_STATISTIC), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_PREFS)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_PREFS), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_TOOLS)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_TOOLS), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; lLen2 = _tcslen(GetResString(IDS_EM_HELP)) + 1; memcpy(cButtonStrings+lLen, GetResString(IDS_EM_HELP), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; #ifdef MOD_SUNYAN lLen2 = _tcslen(GetResString(IDS_DMIBOX)) + 1; memcpy(cButtonStrings+lLen,GetResString(IDS_DMIBOX), lLen2*sizeof(TCHAR)); lLen += lLen2; ++m_buttoncount; #endif // terminate memcpy(cButtonStrings+lLen, _T("\0"), sizeof(TCHAR)); AddStrings(cButtonStrings); // initialize buttons: for(int i = 0; i < m_buttoncount; i++) { TBButtons[i].fsState = TBSTATE_ENABLED; TBButtons[i].fsStyle = TBSTYLE_CHECKGROUP; TBButtons[i].idCommand = IDC_TOOLBARBUTTON + i; TBButtons[i].iString = i; switch (TBButtons[i].idCommand) { case TBBTN_CONNECT: case TBBTN_OPTIONS: case TBBTN_TOOLS: case TBBTN_HELP: TBButtons[i].fsStyle = TBSTYLE_BUTTON; break; } } // set button image indices int iBitmap = 0; for (int i = 0; i < m_buttoncount; i++) { TBButtons[i].iBitmap = iBitmap; if (TBButtons[i].idCommand == TBBTN_CONNECT) // 'Connect' button has 3 states iBitmap += 3; else iBitmap += 1; } TBBUTTON sepButton = {0}; sepButton.idCommand = 0; sepButton.fsStyle = TBSTYLE_SEP; sepButton.fsState = TBSTATE_ENABLED; sepButton.iString = -1; sepButton.iBitmap = -1; CString config = thePrefs.GetToolbarSettings(); for (int i = 0; i < config.GetLength(); i += 2) { int index = _tstoi(config.Mid(i, 2)); if (index == 99) { AddButtons(1, &sepButton); continue; } AddButtons(1, &TBButtons[index]); } // recalc toolbar-size SetAllButtonsStrings(); ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true); SetAllButtonsWidth(); // then calc and set the button width AutoSize(); // and finally call the original (but maybe obsolete) function SaveCurHeight(); }