X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..3d7e30a4186cc3379c3b21040712181a3c6d0b3b:/src/msw/radiobox.cpp diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 81467bcfb3..f49f7a857d 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -98,8 +98,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, SetValidator(val); parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; @@ -116,7 +116,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, m_noRowsOrCols = majorDim; if (majorDim==0) m_majorDim = n ; - m_majorDim = majorDim ; + else // Seemed to make sense to put this 'else' here... (RD) + m_majorDim = majorDim ; long msStyle = GROUP_FLAGS; @@ -124,41 +125,39 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, WXDWORD exStyle = Determine3DEffects(0, &want3D) ; // Even with extended styles, need to combine with WS_BORDER // for them to look right. - if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || - (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))) +/* + if ( want3D || wxStyleHasBorder(m_windowStyle) ) msStyle |= WS_BORDER; +*/ - m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title), - msStyle, - 0,0,0,0, - (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ; - HWND the_handle = (HWND) parent->GetHWND() ; + m_hWnd = (WXHWND)::CreateWindowEx + ( + (DWORD)exStyle, + GROUP_CLASS, + title, + msStyle, + 0, 0, 0, 0, + the_handle, + (HMENU)m_windowId, + wxGetInstance(), + NULL + ); + #if CTL3D if (want3D) { - Ctl3dSubclassCtl((HWND) m_hWnd); - m_useCtl3D = TRUE; + Ctl3dSubclassCtl((HWND)m_hWnd); + m_useCtl3D = TRUE; } #endif - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); - // Subclass again for purposes of dialog editing mode SubclassWin((WXHWND)m_hWnd); -/* Label will be the same as button font now. - if (labelFont) - { - labelFont->RealizeResource(); - if (labelFont->GetResourceHandle()) - SendMessage(ms_handle,WM_SETFONT, - (WPARAM)labelFont->GetResourceHandle(),0L); - } -*/ - // Some radio boxes test consecutive id. (void)NewControlId() ; m_radioButtons = new WXHWND[n]; @@ -181,13 +180,13 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, if (want3D) { Ctl3dSubclassCtl((HWND) m_hWnd); - m_useCtl3D = TRUE; + m_useCtl3D = TRUE; } #endif - if (GetFont()) + if (GetFont().Ok()) { SendMessage((HWND)m_radioButtons[i],WM_SETFONT, - (WPARAM)GetFont()->GetResourceHandle(),0L); + (WPARAM)GetFont().GetResourceHandle(),0L); } m_subControls.Append((wxObject *)newId); } @@ -217,8 +216,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, SetValidator(val); parent->AddChild(this); - m_backgroundColour = parent->GetDefaultBackgroundColour() ; - m_foregroundColour = parent->GetDefaultForegroundColour() ; + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; m_windowStyle = (long&)style; @@ -245,8 +244,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, WXDWORD exStyle = Determine3DEffects(0, &want3D) ; // Even with extended styles, need to combine with WS_BORDER // for them to look right. - if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || - (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))) + if ( want3D || wxStyleHasBorder(m_windowStyle) ) msStyle |= WS_BORDER; m_hWnd = (WXHWND) CreateWindowEx((DWORD) exStyle, GROUP_CLASS, (title == "" ? NULL : (const char *)title), @@ -254,26 +252,17 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, 0,0,0,0, (HWND) parent->GetHWND(), (HMENU) m_windowId, wxGetInstance(), NULL) ; -/* - if (labelFont) - { - labelFont->RealizeResource(); - if (labelFont->GetResourceHandle()) - SendMessage(ms_handle,WM_SETFONT, - (WPARAM)labelFont->GetResourceHandle(),0L); - } -*/ the_handle = (HWND) parent->GetHWND(); #if CTL3D if (want3D) { Ctl3dSubclassCtl((HWND) m_hWnd); - m_useCtl3D = TRUE; + m_useCtl3D = TRUE; } #endif - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); // Subclass again for purposes of dialog editing mode SubclassWin((WXHWND)m_hWnd); @@ -302,7 +291,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, if (want3D) { Ctl3dSubclassCtl((HWND) m_hWnd); - m_useCtl3D = TRUE; + m_useCtl3D = TRUE; } #endif m_subControls.Append((wxObject *)newId); @@ -321,7 +310,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, wxRadioBox::~wxRadioBox(void) { m_isBeingDeleted = TRUE; - + if (m_radioButtons) { int i; @@ -409,6 +398,8 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) yy = currentY; + AdjustForParentClientOrigin(xx, yy, sizeFlags); + char buf[400]; int y_offset = yy; @@ -416,7 +407,7 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) int current_width, cyf; int cx1,cy1 ; - wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont()); + wxGetCharSize(m_hWnd, &cx1, &cy1, & GetFont()); // Attempt to have a look coherent with other platforms: // We compute the biggest toggle dim, then we align all // items according this value. @@ -432,7 +423,7 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) { // It's a labelled toggle GetWindowText((HWND) m_radioButtons[i], buf, 300); - GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, GetFont()); + GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, & GetFont()); eachWidth = (int)(current_width + RADIO_SIZE); eachHeight = (int)((3*cyf)/2); } @@ -512,7 +503,7 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) { // It's a labeled item GetWindowText((HWND) m_radioButtons[i], buf, 300); - GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL,GetFont()); + GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, & GetFont()); // How do we find out radio button bitmap size!! // By adjusting them carefully, manually :-) @@ -575,6 +566,15 @@ void wxRadioBox::GetPosition(int *x, int *y) const { ::ScreenToClient((HWND) parent->GetHWND(), &point); } + // We may be faking the client origin. + // So a window that's really at (0, 30) may appear + // (to wxWin apps) to be at (0, 0). + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + point.x -= pt.x; + point.y -= pt.y; + } *x = point.x; *y = point.y; @@ -598,11 +598,6 @@ void wxRadioBox::SetLabel(const wxString& label) void wxRadioBox::SetFocus(void) { -/* - if (m_noItems > 0) - ::SetFocus((HWND) m_radioButtons[0]); -*/ -/* Begin Alberts Patch 26. 5. 1997*/ if (m_noItems > 0) { if (m_selectedButton == -1) @@ -610,7 +605,6 @@ void wxRadioBox::SetFocus(void) else ::SetFocus((HWND) m_radioButtons[m_selectedButton]); } -/* Ende Alberts Patch*/ } @@ -642,7 +636,7 @@ void wxRadioBox::Enable(int item, bool enable) void wxRadioBox::Enable(bool enable) { wxControl::Enable(enable); - + int i; for (i = 0; i < m_noItems; i++) ::EnableWindow((HWND) m_radioButtons[i], enable); @@ -665,7 +659,7 @@ void wxRadioBox::Show(int item, bool show) } WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, - WXUINT message, WXWPARAM wParam, WXLPARAM lParam) + WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { #if CTL3D if ( m_useCtl3D ) @@ -713,43 +707,13 @@ bool wxRadioBox::SetStringSelection (const wxString& s) return FALSE; } -/* -void wxRadioBox::SetLabelFont(wxFont *font) -{ - // Decrement the usage count of the old label font - // (we may be able to free it up) - if (labelFont) - labelFont->ReleaseResource(); - - labelFont = font; - - // Increment usage count - if (font) - font->UseResource(); - - HWND hWnd = GetHWND(); - if (hWnd != 0) - { - if (font) - { - font->RealizeResource(); - - if (font->GetResourceHandle()) - SendMessage(hWnd, WM_SETFONT, - (WPARAM)font->GetResourceHandle(),TRUE); - } - } -} - -*/ - bool wxRadioBox::ContainsHWND(WXHWND hWnd) const { - int i; + int i; for (i = 0; i < Number(); i++) if (GetRadioButtons()[i] == hWnd) return TRUE; - return FALSE; + return FALSE; } void wxRadioBox::Command (wxCommandEvent & event) @@ -758,4 +722,21 @@ void wxRadioBox::Command (wxCommandEvent & event) ProcessCommand (event); } +long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +{ + if (nMsg == WM_NCHITTEST) + { + int xPos = LOWORD(lParam); // horizontal position of cursor + int yPos = HIWORD(lParam); // vertical position of cursor + + ScreenToClient(&xPos, &yPos); + + // Make sure you can drag by the top of the groupbox, but let + // other (enclosed) controls get mouse events also + if (yPos < 10) + return (long)HTCLIENT; + } + + return wxControl::MSWWindowProc(nMsg, wParam, lParam); +}