void CDocSelector::OnSize(UINT nType, int cx, int cy) { CControlBar::OnSize(nType, cx, cy); // Yogesh Jagota CRect rc; GetWindowRect(&rc); m_cxAvailable = rc.Width(); ScreenToClient(&rc); rc.top += 3; rc.bottom -= 1; rc.right -= 2; rc.left = ( rc.right - DS_MENU_BUTTON_WIDTH ) - 1; m_btnMenuButton.MoveWindow( &rc ); // End Yogesh Jagota if (m_Buttons.GetSize() == 0) return; CRect rect; GetClientRect(&rect); // Yogesh Jagota // int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) // / (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN; // // if (newsize <= DS_WIDTH && m_iButtonWidth != newsize) // ResizeButtons(newsize); // End Yogesh Jagota // Yogesh Jagota int nSize = m_Buttons.GetSize(); int newsize = ( ( rect.Width() - ( DS_MENU_BUTTON_WIDTH + DS_LEFT_MARGIN ) ) - ( nSize * DS_SEPERATER_MARGIN ) ) / nSize; if ( newsize < MINWIDTH ) ResizeButtons( MINWIDTH ); else if ( newsize > DS_WIDTH ) ResizeButtons( DS_WIDTH ); else if ( newsize != m_iButtonWidth ) ResizeButtons( newsize ); // End Yogesh Jagota }
void KeyboardWidget::OnResize(const PixelRect &rc) { PrepareSize(rc); ResizeButtons(); MoveButtons(rc); }
void KeyboardControl::OnResize(PixelSize new_size) { button_width = new_size.cx / 10; button_height = new_size.cy / 5; ResizeButtons(); MoveButtons(); }
void KeyboardWidget::OnResize(const PixelRect &rc) { const PixelSize new_size = rc.GetSize(); button_width = new_size.cx / 10; button_height = new_size.cy / 5; ResizeButtons(); MoveButtons(rc); }
LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case WM_SIZE: SendMessage(_htoolbar, WM_SIZE, 0, 0); ResizeButtons(); break; case WM_TIMER: Refresh(); return 0; case WM_CONTEXTMENU: { Point pt(lparam); ScreenToClient(_htoolbar, &pt); if ((HWND)wparam==_htoolbar && SendMessage(_htoolbar, TB_HITTEST, 0, (LPARAM)&pt)>=0) break; // avoid displaying context menu for application button _and_ desktop bar at the same time goto def;} case PM_GET_LAST_ACTIVE: return (LRESULT)(HWND)_last_foreground_wnd; default: def: if (nmsg == WM_SHELLHOOK) { switch(wparam) { case HSHELL_WINDOWCREATED: case HSHELL_WINDOWDESTROYED: case HSHELL_WINDOWACTIVATED: case HSHELL_REDRAW: #ifdef HSHELL_FLASH case HSHELL_FLASH: #endif #ifdef HSHELL_RUDEAPPACTIVATED case HSHELL_RUDEAPPACTIVATED: #endif Refresh(); break; } } else { return super::WndProc(nmsg, wparam, lparam); } } return 0; }
void CategoryList::AddCategory(wxJigsawPalette *palette) { long newButtonID = wxNewId(), h; CategoryButton * newButton = new CategoryButton(this, newButtonID, palette->GetPaletteName()); newButton->SetShapes(&palette->GetShapes()); newButton->SetColor(palette->GetColours().GetColour()); Connect(newButtonID, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CategoryList::OnCategoryButtonPressed)); h = ResizeButtons(); SetSize(GetSize().GetWidth(), h); ReCreateScrollBars(); if(GetCategoryCount() == 1) { wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, newButtonID); ProcessEvent(e); } }
INT_PTR PluginHangUIChild::HangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, LPARAM aLParam) { mDlgHandle = aDlgHandle; switch (aMsgCode) { case WM_INITDIALOG: { // Register a wait on the Firefox process so that we will be informed // if it dies while the dialog is showing RegisterWaitForSingleObject(&mRegWaitProcess, mParentProcess, &SOnParentProcessExit, this, INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE); SetWindowText(aDlgHandle, mWindowTitle); SetDlgItemText(aDlgHandle, IDC_MSG, mMessageText); SetDlgItemText(aDlgHandle, IDC_NOFUTURE, mNoFutureText); SetDlgItemText(aDlgHandle, IDC_CONTINUE, mWaitBtnText); SetDlgItemText(aDlgHandle, IDC_STOP, mKillBtnText); ResizeButtons(); HANDLE icon = LoadImage(NULL, IDI_QUESTION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); if (icon) { SendDlgItemMessage(aDlgHandle, IDC_DLGICON, STM_SETICON, (WPARAM)icon, 0); } EnableWindow(mParentWindow, FALSE); return TRUE; } case WM_CLOSE: { mResponseBits |= HANGUI_USER_RESPONSE_CANCEL; EndDialog(aDlgHandle, 0); SetWindowLongPtr(aDlgHandle, DWLP_MSGRESULT, 0); return TRUE; } case WM_COMMAND: { switch (LOWORD(aWParam)) { case IDC_CONTINUE: if (HIWORD(aWParam) == BN_CLICKED) { mResponseBits |= HANGUI_USER_RESPONSE_CONTINUE; EndDialog(aDlgHandle, 1); SetWindowLongPtr(aDlgHandle, DWLP_MSGRESULT, 0); return TRUE; } break; case IDC_STOP: if (HIWORD(aWParam) == BN_CLICKED) { mResponseBits |= HANGUI_USER_RESPONSE_STOP; EndDialog(aDlgHandle, 1); SetWindowLongPtr(aDlgHandle, DWLP_MSGRESULT, 0); return TRUE; } break; case IDC_NOFUTURE: if (HIWORD(aWParam) == BN_CLICKED) { if (Button_GetCheck(GetDlgItem(aDlgHandle, IDC_NOFUTURE)) == BST_CHECKED) { mResponseBits |= HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN; } else { mResponseBits &= ~static_cast<DWORD>(HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN); } SetWindowLongPtr(aDlgHandle, DWLP_MSGRESULT, 0); return TRUE; } break; default: break; } break; } case WM_DESTROY: { EnableWindow(mParentWindow, TRUE); break; } default: break; } return FALSE; }
BOOL CDocSelector::RemoveButton(CWnd* wnd) { // Yogesh Jagota int index = -1; for ( int i = 0; i < m_Buttons.GetSize(); i++ ) { if ( GetButtonFromID( i )->m_AttachedView == wnd ) { index = i; break; } } if ( index == -1 ) return FALSE; // End Yogesh Jagota if (index >= m_Buttons.GetSize() || index < 0) { ASSERT(0); // out of range return FALSE; } if (m_iSelectedButton == index) m_iSelectedButton = -1; if (m_iSelectedButton > index) m_iSelectedButton -= 1; delete GetButtonFromID(index); m_Buttons.RemoveAt(index); for (register int x = index; x < m_Buttons.GetSize(); x++) GetButtonFromID(x)->m_iID -= 1; m_iNextButtonStart -= m_iButtonWidth + 1; if (m_iButtonWidth != DS_WIDTH) { // do that funky animation thing CRect rect; GetClientRect(&rect); int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) / (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN; if (newsize > DS_WIDTH) newsize = DS_WIDTH; // Yogesh Jagota. Removed animation because did'nt liked it. // Remove if you want animated addition or removal of buttons. // // this loop is shortened to make the following loop.... // if (newsize > m_iButtonWidth) // { // register int y; // for (y = m_iButtonWidth; y <= newsize; y+=3) // { // ResizeButtons(y); // Sleep(15); // } // if (y != newsize) // ResizeButtons(newsize); // } // End Yogesh Jagota if (newsize > m_iButtonWidth) ResizeButtons(newsize); } ResizeButtons(m_iButtonWidth); return TRUE; }
///////////////////////////////////////////////////////////////////////////// // CDocSelector message handlers BOOL CDocSelector::AddButton( CWnd* wnd, WORD wIcon ,HICON hIcon ) { CRect rect; GetClientRect(&rect); // Yogesh Jagota CDocument* pDoc = ((CView *) wnd)->GetDocument(); CString sPath = pDoc->GetPathName(); CString sFileName; if ( sPath.IsEmpty() ) sPath = pDoc->GetTitle(); // Can be only the filename, like Noname01 if ( sPath.Find( _T('\\') ) != -1 ) sFileName = sPath.Mid( sPath.ReverseFind( _T('\\') ) + 1 ); else sFileName = sPath; // If there is no space left to display extra buttons... int nNewSize = ( ( rect.Width() - DS_MENU_BUTTON_WIDTH ) / ( m_Buttons.GetSize() + 1 ) ) - DS_SEPERATER_MARGIN; bool bShowButton = true; if ( nNewSize <= MINWIDTH ) { // Check if the menu button is displayed, if not, display it... m_btnMenuButton.ShowWindow( SW_SHOW ); // Don't show the button... bShowButton = false; } else m_nDisplayedButtons++; // End Yogesh Jagota CSwitcherButton* newbutton = new CSwitcherButton(); // Yogesh Jagota newbutton->m_AttachedView = wnd; // I am saving the frame to make life easier in case // of activation in selection process... CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetMainWnd(); CWnd * pWnd = pFrame->GetWindow( GW_CHILD ); ASSERT (pWnd); pWnd = pWnd->GetWindow( GW_CHILD ); while (pWnd) { if ( ((CFrameWnd *)pWnd)->GetActiveView() == (CView*)wnd ) newbutton->m_FrameWnd = (CFrameWnd *)pWnd; pWnd = pWnd->GetWindow( GW_HWNDNEXT ); } // Load the icon.... if ( hIcon) { newbutton->m_iIcon=hIcon; newbutton->m_iIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); } else if ( wIcon != -1 ) newbutton->m_iIcon = ::LoadIcon( AfxGetInstanceHandle(), MAKEINTRESOURCE( wIcon ) ); // End Yogesh Jagota newbutton->m_iID = m_Buttons.GetSize(); if (!newbutton->DoCreate(this, m_iNextButtonStart, rect.top + 3, m_iButtonWidth, DS_HEIGHT - 2, sFileName, sPath )) // Yogesh Jagota { return FALSE; } if ( !bShowButton ) newbutton->ShowWindow( SW_HIDE ); m_Buttons.Add((void*)newbutton); m_iNextButtonStart += m_iButtonWidth + DS_SEPERATER_MARGIN; if (m_iNextButtonStart - DS_SEPERATER_MARGIN > rect.Width()) { // this loop makes a neat little animation int newsize = ((rect.Width() - DS_MENU_BUTTON_WIDTH ) / (m_Buttons.GetSize())) - DS_SEPERATER_MARGIN; // Yogesh Jagota. Removed animation because did'nt liked it. // Remove if you want animated addition or removal of buttons. // // register int y; // for (y = m_iButtonWidth; y >= newsize; y-=3) // { // ResizeButtons(y); // Sleep(15); // } // // if (y != newsize) // /* ResizeButtons(newsize); */ <- this is the next line... // End Yogesh Jagota ResizeButtons(newsize); if (m_iButtonWidth < MINWIDTH) { // the smallest allowable button size has been reached... // in this version, we can't handle this ASSERT(0); return FALSE; } } else m_btnMenuButton.ShowWindow( SW_HIDE ); // Yogesh Jagota if ( m_iSelectedButton != -1 ) ((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Unselect(); m_iSelectedButton = newbutton->m_iID; ((CSwitcherButton *) m_Buttons.GetAt( m_iSelectedButton ))->Select(); // End Yogesh Jagota return TRUE; }
void TaskBar::Refresh() { for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) it->second._used = 0; EnumWindows(EnumWndProc, (LPARAM)this); //EnumDesktopWindows(GetThreadDesktop(GetCurrentThreadId()), EnumWndProc, (LPARAM)_htoolbar); set<int> btn_idx_to_delete; set<HBITMAP> hbmp_to_delete; for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) { TaskBarEntry& entry = it->second; if (!entry._used && entry._id) { // store button indexes to remove btn_idx_to_delete.insert(entry._btn_idx); hbmp_to_delete.insert(entry._hbmp); entry._id = 0; } } if (!btn_idx_to_delete.empty()) { // remove buttons from right to left for(set<int>::reverse_iterator it=btn_idx_to_delete.rbegin(); it!=btn_idx_to_delete.rend(); ++it) { int idx = *it; SendMessage(_htoolbar, TB_DELETEBUTTON, idx, 0); for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) { TaskBarEntry& entry = it->second; // adjust button indexes if (entry._btn_idx > idx) { --entry._btn_idx; --entry._bmp_idx; TBBUTTONINFO info; info.cbSize = sizeof(TBBUTTONINFO); info.dwMask = TBIF_IMAGE; info.iImage = entry._bmp_idx; SendMessage(_htoolbar, TB_SETBUTTONINFO, entry._id, (LPARAM)&info); } } } for(set<HBITMAP>::iterator it=hbmp_to_delete.begin(); it!=hbmp_to_delete.end(); ++it) { HBITMAP hbmp = *it; TBREPLACEBITMAP tbrepl = {0, (UINT_PTR)hbmp, 0, 0}; SendMessage(_htoolbar, TB_REPLACEBITMAP, 0, (LPARAM)&tbrepl); DeleteObject(hbmp); for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) if (it->second._hbmp == hbmp) { _map.erase(it); break; } } ResizeButtons(); } }
void CategoryList::OnSize( wxSizeEvent& event ) { ResizeButtons(); ReCreateScrollBars(); }