bool wxRadioBox::OS2Command( WXUINT uCmd, WXWORD wId) { int nSelectedButton = -1; if (uCmd == BN_CLICKED) { if (wId == GetId()) return true; for (unsigned int i = 0; i < m_nNoItems; i++) { if (wId == wxGetWindowId(m_ahRadioButtons[i])) { nSelectedButton = i; break; } } if (nSelectedButton == -1) { // // Just ignore it // return false; } if (nSelectedButton != m_nSelectedButton) { m_nSelectedButton = nSelectedButton; SendNotificationEvent(); } return true; } else return false; } // end of wxRadioBox::OS2Command
bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id_) { const int id = (signed short)id_; if ( cmd == BN_CLICKED ) { if (id == GetId()) return true; int selectedButton = wxNOT_FOUND; const unsigned int count = GetCount(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( unsigned int i = 0; i < count; i++ ) { const HWND hwndBtn = (*m_radioButtons)[i]; if ( id == wxGetWindowId(hwndBtn) ) { // we can get BN_CLICKED for a button which just became focused // but it may not be checked, in which case we shouldn't // generate a radiobox selection changed event for it if ( ::SendMessage(hwndBtn, BM_GETCHECK, 0, 0) == BST_CHECKED ) selectedButton = i; break; } } if ( selectedButton == wxNOT_FOUND ) { // just ignore it - due to a hack with WM_NCHITTEST handling in our // wnd proc, we can receive dummy click messages when we click near // the radiobox edge (this is ugly but Julian wouldn't let me get // rid of this...) return false; } if ( selectedButton != m_selectedButton ) { m_selectedButton = selectedButton; SendNotificationEvent(); } //else: don't generate events when the selection doesn't change return true; } else return false; }
// Make sure the window style (etc.) reflects the HWND style (roughly) void wxWindow::AdoptAttributesFromHWND() { SetId(wxGetWindowId(m_hWnd)); long style = GetWindowLong(GetHwnd(), GWL_STYLE); if (style & WS_VSCROLL) m_windowStyle |= wxVSCROLL; if (style & WS_HSCROLL) m_windowStyle |= wxHSCROLL; }
bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id) { if ( cmd == BN_CLICKED ) { if (id == GetId()) return true; int selectedButton = wxNOT_FOUND; int count = GetCount(); for ( int i = 0; i < count; i++ ) { if ( id == wxGetWindowId((*m_radioButtons)[i]) ) { selectedButton = i; break; } } if ( selectedButton == wxNOT_FOUND ) { // just ignore it - due to a hack with WM_NCHITTEST handling in our // wnd proc, we can receive dummy click messages when we click near // the radiobox edge (this is ugly but Julian wouldn't let me get // rid of this...) return false; } if ( selectedButton != m_selectedButton ) { m_selectedButton = selectedButton; SendNotificationEvent(); } //else: don't generate events when the selection doesn't change return true; } else return false; }
void wxMDIParentFrame::OnMDIChild(wxCommandEvent& event) { wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); if ( child->GetHWND() ) { int childId = wxGetWindowId(child->GetHWND()); if ( childId == event.GetId() ) { wxStaticCast(child, wxMDIChildFrame)->Activate(); return; } } node = node->GetNext(); } wxFAIL_MSG( "unknown MDI child selected?" ); }
void wxMDIParentFrame::OnMDIChild(wxCommandEvent& event) { wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); if ( child->GetHWND() ) { int childId = wxGetWindowId(child->GetHWND()); if ( childId == event.GetId() ) { ::SendMessage( GetWinHwnd(GetClientWindow()), WM_MDIACTIVATE, (WPARAM)child->GetHWND(), 0); return; } } node = node->GetNext(); } wxFAIL_MSG( "unknown MDI child selected?" ); }
bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) { // In case it's e.g. a toolbar. if ( hwnd ) { wxWindow *win = wxFindWinFromHandle(hwnd); if ( win ) return win->MSWCommand(cmd, id); } // is it one of standard MDI commands? WXWPARAM wParam = 0; WXLPARAM lParam = 0; int msg; switch ( id ) { case IDM_WINDOWCASCADE: msg = WM_MDICASCADE; wParam = MDITILE_SKIPDISABLED; break; case IDM_WINDOWTILEHOR: wParam |= MDITILE_HORIZONTAL; // fall through case IDM_WINDOWTILEVERT: if ( !wParam ) wParam = MDITILE_VERTICAL; msg = WM_MDITILE; wParam |= MDITILE_SKIPDISABLED; break; case IDM_WINDOWICONS: msg = WM_MDIICONARRANGE; break; case IDM_WINDOWNEXT: msg = WM_MDINEXT; lParam = 0; // next child break; case IDM_WINDOWPREV: msg = WM_MDINEXT; lParam = 1; // previous child break; default: msg = 0; } if ( msg ) { ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, lParam); return true; } // FIXME VZ: what does this test do?? if (id >= 0xF000) { return false; // Get WndProc to call default proc } if ( IsMdiCommandId(id) ) { wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); if ( child->GetHWND() ) { long childId = wxGetWindowId(child->GetHWND()); if (childId == (long)id) { ::SendMessage( GetWinHwnd(GetClientWindow()), WM_MDIACTIVATE, (WPARAM)child->GetHWND(), 0); return true; } } node = node->GetNext(); } } else if ( m_parentFrameActive ) { return ProcessCommand(id); } else if ( m_currentChild ) { return m_currentChild->HandleCommand(id, cmd, hwnd); } else { // this shouldn't happen because it means that our messages are being // lost (they're not sent to the parent frame nor to the children) wxFAIL_MSG(wxT("MDI parent frame is not active, yet there is no active MDI child?")); } return false; }
wxWindow* wxWindow::CreateWindowFromHWND ( wxWindow* pParent , WXHWND hWnd ) { wxString sStr(wxGetWindowClass(hWnd)); long lId = wxGetWindowId(hWnd); long lStyle = ::WinQueryWindowULong((HWND)hWnd ,QWL_STYLE ); wxWindow* pWin = NULL; sStr.UpperCase(); if (sStr == wxT("BUTTON")) { if (lStyle == BS_AUTOCHECKBOX) { pWin = new wxCheckBox; } else if (lStyle == BS_AUTORADIOBUTTON) { pWin = new wxRadioButton; } else if (lStyle & BS_BITMAP || lStyle == BS_USERBUTTON) { pWin = new wxBitmapButton; } else if (lStyle == BS_PUSHBUTTON) { pWin = new wxButton; } else if (lStyle == SS_GROUPBOX) { pWin = new wxStaticBox; } else { wxLogError(wxT("Don't know what kind of button this is: id = %ld"), lId); } } else if (sStr == wxT("COMBOBOX")) { pWin = new wxComboBox; } else if (sStr == wxT("EDIT")) { pWin = new wxTextCtrl; } else if (sStr == wxT("LISTBOX")) { pWin = new wxListBox; } else if (sStr == wxT("SCROLLBAR")) { pWin = new wxScrollBar; } else if (sStr == wxT("MSCTLS_UPDOWN32")) { pWin = new wxSpinButton; } else if (sStr == wxT("MSCTLS_TRACKBAR32")) { pWin = new wxSlider; } else if (sStr == wxT("STATIC")) { if (lStyle == SS_TEXT) pWin = new wxStaticText; else if (lStyle == SS_ICON) { pWin = new wxStaticBitmap; } } else { wxString sMsg(wxT("Don't know how to convert from Windows class ")); sMsg += sStr; wxLogError(sMsg); } if (pWin) { pParent->AddChild(pWin); pWin->SetEventHandler(pWin); pWin->SetHWND(hWnd); pWin->SetId(lId); pWin->SubclassWin(hWnd); pWin->AdoptAttributesFromHWND(); pWin->SetupColours(); return pWin; } else return NULL; } // end of wxWindow::CreateWindowFromHWND
wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) { wxCHECK_MSG( parent, NULL, _T("must have valid parent for a control") ); wxString str(wxGetWindowClass(hWnd)); str.UpperCase(); long id = wxGetWindowId(hWnd); long style = GetWindowLong((HWND) hWnd, GWL_STYLE); wxWindow* win = NULL; if (str == wxT("BUTTON")) { int style1 = (style & 0xFF); #if wxUSE_CHECKBOX if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) || (style1 == BS_CHECKBOX)) { win = new wxCheckBox; } else #endif #if wxUSE_RADIOBTN if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON)) { win = new wxRadioButton; } else #endif #if wxUSE_BMPBUTTON #if defined(__WIN32__) && defined(BS_BITMAP) if (style & BS_BITMAP) { // TODO: how to find the bitmap? win = new wxBitmapButton; wxLogError(wxT("Have not yet implemented bitmap button as BS_BITMAP button.")); } else #endif if (style1 == BS_OWNERDRAW) { // TODO: how to find the bitmap? // TODO: can't distinguish between bitmap button and bitmap static. // Change implementation of wxStaticBitmap to SS_BITMAP. // PROBLEM: this assumes that we're using resource-based bitmaps. // So maybe need 2 implementations of bitmap buttons/static controls, // with a switch in the drawing code. Call default proc if BS_BITMAP. win = new wxBitmapButton; } else #endif #if wxUSE_BUTTON if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON)) { win = new wxButton; } else #endif #if wxUSE_STATBOX if (style1 == BS_GROUPBOX) { win = new wxStaticBox; } else #endif { wxLogError(wxT("Don't know what kind of button this is: id = %ld"), id); } } #if wxUSE_COMBOBOX else if (str == wxT("COMBOBOX")) { win = new wxComboBox; } #endif #if wxUSE_TEXTCTRL // TODO: Problem if the user creates a multiline - but not rich text - text control, // since wxWin assumes RichEdit control for this. Should have m_isRichText in // wxTextCtrl. Also, convert as much of the window style as is necessary // for correct functioning. // Could have wxWindow::AdoptAttributesFromHWND(WXHWND) // to be overridden by each control class. else if (str == wxT("EDIT")) { win = new wxTextCtrl; } #endif #if wxUSE_LISTBOX else if (str == wxT("LISTBOX")) { win = new wxListBox; } #endif #if wxUSE_SCROLLBAR else if (str == wxT("SCROLLBAR")) { win = new wxScrollBar; } #endif #if wxUSE_SPINBTN else if (str == wxT("MSCTLS_UPDOWN32")) { win = new wxSpinButton; } #endif #if wxUSE_SLIDER else if (str == wxT("MSCTLS_TRACKBAR32")) { // Need to ascertain if it's horiz or vert win = new wxSlider; } #endif // wxUSE_SLIDER #if wxUSE_STATTEXT else if (str == wxT("STATIC")) { int style1 = (style & 0xFF); if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) #ifndef __WXWINCE__ || (style1 == SS_SIMPLE) #endif ) win = new wxStaticText; #if wxUSE_STATBMP #if defined(__WIN32__) && defined(BS_BITMAP) else if (style1 == SS_BITMAP) { win = new wxStaticBitmap; // Help! this doesn't correspond with the wxWin implementation. wxLogError(wxT("Please make SS_BITMAP statics into owner-draw buttons.")); } #endif #endif /* wxUSE_STATBMP */ } #endif else { wxString msg(wxT("Don't know how to convert from Windows class ")); msg += str; wxLogError(msg); } if (win) { parent->AddChild(win); win->SubclassWin(hWnd); win->AdoptAttributesFromHWND(); win->SetupColours(); } return win; }