]> git.saurik.com Git - wxWidgets.git/commitdiff
1. always create the buttons with WS_CLIPSIBLINGS style, this prevetns them
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Feb 2002 00:02:51 +0000 (00:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Feb 2002 00:02:51 +0000 (00:02 +0000)
   from overwriting each other when the main window is resized
2. more tweaks to MSWGetStyle() and related code, added a new, easier to use,
   version of MSWCreateControl()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/button.h
include/wx/msw/control.h
src/msw/button.cpp
src/msw/control.cpp
src/msw/textctrl.cpp
src/msw/window.cpp

index 967568a938742c595bb7091f3f034ec70c95d8f2..36a00a6cc10084c46f0e4ef1cba2121a3bdd75fa 100644 (file)
@@ -110,6 +110,7 @@ All (GUI):
 wxMSW:
 
 - small appearance fixes for native look under Windows XP
+- refresh the buttons properly when the window is resized (Hans Van Leemputten)
 - huge (40*) speed up in wxMask::Create()
 - changing wxWindows styles also changes the underlying Windows window style
 - fixed flicker in wxTreeCtrl::SetItemXXX()
index 52a68b5ab32590078ce0591d2b6ad241ce983fda..70f51f6fa5fede77054924b07612e1cfceaec609 100644 (file)
@@ -69,7 +69,9 @@ protected:
     // send a notification event, return TRUE if processed
     bool SendClickEvent();
 
+    // usually overridden base class virtuals
     virtual wxSize DoGetBestSize() const;
+    virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
 
 private:
     DECLARE_DYNAMIC_CLASS(wxButton)
index dc66995be7e478f7e89a791b602cd30a38df1d14..e5e7f5c918ca0f6a7509761136c24775f12ca816 100644 (file)
@@ -92,6 +92,17 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    // create the control of the given Window class
+    bool MSWCreateControl(const wxChar *classname,
+                          const wxString& label,
+                          const wxPoint& pos,
+                          const wxSize& size,
+                          long style);
+
+    // NB: the method below is deprecated now, with MSWGetStyle() the method
+    //     above should be used instead! Once all the controls are updated to
+    //     implement MSWGetStyle() this version will disappear.
+    //
     // create the control of the given class with the given style (combination
     // of WS_XXX flags, i.e. Windows style, not wxWindows one), returns
     // FALSE if creation failed
@@ -108,9 +119,8 @@ protected:
                           const wxString& label = wxEmptyString,
                           WXDWORD exstyle = (WXDWORD)-1);
 
-    // determine the extended styles combination for this window (may slightly
-    // modify style parameter, this is why it's non const)
-    WXDWORD GetExStyle(WXDWORD& style, bool *want3D) const;
+    // default style for the control include WS_TABSTOP if it AcceptsFocus()
+    virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
 
 private:
     DECLARE_EVENT_TABLE()
index 62da82af8e9ebd9f9aadc4278061fcc6d878af5f..29464dda75a52ba3ac0ee20345a9ccf530018001 100644 (file)
@@ -68,66 +68,47 @@ bool wxButton::Create(wxWindow *parent,
                       const wxValidator& validator,
                       const wxString& name)
 {
-    if ( !CreateBase(parent, id, pos, size, style, validator, name) )
+    if ( !CreateControl(parent, id, pos, size, style, validator, name) )
         return FALSE;
 
-    parent->AddChild((wxButton *)this);
+    return MSWCreateControl(_T("BUTTON"), label, pos, size, style);
+}
 
-    m_backgroundColour = parent->GetBackgroundColour();
-    m_foregroundColour = parent->GetForegroundColour();
+wxButton::~wxButton()
+{
+}
 
-    long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ;
+// ----------------------------------------------------------------------------
+// flags
+// ----------------------------------------------------------------------------
 
-    if ( m_windowStyle & wxCLIP_SIBLINGS )
-        msStyle |= WS_CLIPSIBLINGS;
+WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const
+{
+    // buttons never have an external border, they draw their own one
+    WXDWORD msStyle = wxControl::MSWGetStyle
+                      (
+                        (style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle
+                      );
+
+    // we must use WS_CLIPSIBLINGS with the buttons or they would draw over
+    // each other in any resizeable dialog which has more than one button in
+    // the bottom
+    msStyle |= WS_CLIPSIBLINGS;
 
 #ifdef __WIN32__
-    if(m_windowStyle & wxBU_LEFT)
+    // don't use "else if" here: weird as it is, but you may combine wxBU_LEFT
+    // and wxBU_RIGHT to get BS_CENTER!
+    if ( style & wxBU_LEFT )
         msStyle |= BS_LEFT;
-    if(m_windowStyle & wxBU_RIGHT)
+    if ( style & wxBU_RIGHT )
         msStyle |= BS_RIGHT;
-    if(m_windowStyle & wxBU_TOP)
+    if ( style & wxBU_TOP )
         msStyle |= BS_TOP;
-    if(m_windowStyle & wxBU_BOTTOM)
+    if ( style & wxBU_BOTTOM )
         msStyle |= BS_BOTTOM;
-#endif
-
-    m_hWnd = (WXHWND)CreateWindowEx
-                     (
-                      MakeExtendedStyle(m_windowStyle),
-                      wxT("BUTTON"),
-                      label,
-                      msStyle,
-                      0, 0, 0, 0,
-                      GetWinHwnd(parent),
-                      (HMENU)m_windowId,
-                      wxGetInstance(),
-                      NULL
-                     );
-
-    if (m_hWnd == 0)
-    {
-        wxString msg;
-#ifdef __WIN16__
-        msg.Printf(wxT("CreateWindowEx failed"));
-#else
-        msg.Printf(wxT("CreateWindowEx failed with error number %ld"), (long) GetLastError());
-#endif
-        wxFAIL_MSG(msg);
-    }
-
-    // Subclass again for purposes of dialog editing mode
-    SubclassWin(m_hWnd);
-
-    SetFont(parent->GetFont());
-
-    SetSize(pos.x, pos.y, size.x, size.y);
-
-    return TRUE;
-}
+#endif // __WIN32__
 
-wxButton::~wxButton()
-{
+    return msStyle;
 }
 
 // ----------------------------------------------------------------------------
@@ -284,6 +265,12 @@ long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 
         // and conitnue with processing the message normally as well
     }
+#if 0
+    else if ( nMsg == WM_MOVE )
+    {
+        Refresh();
+    }
+#endif
 
     // let the base class do all real processing
     return wxControl::MSWWindowProc(nMsg, wParam, lParam);
index 5454e029f9e633219be6bbfe51221104fdbb93c5..930d7542ce8ff106fbfb3ad4a5afffed908ee7f7 100644 (file)
@@ -57,19 +57,34 @@ wxControl::~wxControl()
 }
 
 
-bool wxControl::Create(wxWindow *parent, wxWindowID id,
+bool wxControl::Create(wxWindow *parent,
+                       wxWindowID id,
                        const wxPoint& pos,
-                       const wxSize& size, long style,
+                       const wxSize& size,
+                       long style,
                        const wxValidator& validator,
                        const wxString& name)
 {
-    bool rval = wxWindow::Create(parent, id, pos, size, style, name);
-    if (rval) {
+    if ( !wxWindow::Create(parent, id, pos, size, style, name) )
+        return FALSE;
+
 #if wxUSE_VALIDATORS
-        SetValidator(validator);
+    SetValidator(validator);
 #endif
-    }
-    return rval;
+
+    return TRUE;
+}
+
+bool wxControl::MSWCreateControl(const wxChar *classname,
+                                 const wxString& label,
+                                 const wxPoint& pos,
+                                 const wxSize& size,
+                                 long style)
+{
+    WXDWORD exstyle;
+    WXDWORD msStyle = MSWGetStyle(style, &exstyle);
+
+    return MSWCreateControl(classname, msStyle, pos, size, label, exstyle);
 }
 
 bool wxControl::MSWCreateControl(const wxChar *classname,
@@ -88,11 +103,11 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
     // if no extended style given, determine it ourselves
     if ( exstyle == (WXDWORD)-1 )
     {
-        exstyle = GetExStyle(style, &want3D);
+        exstyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
     }
 
-    // all controls have these styles (wxWindows creates all controls visible
-    // by default)
+    // all controls should have these styles (wxWindows creates all controls
+    // visible by default)
     style |= WS_CHILD | WS_VISIBLE;
 
     int x = pos.x == -1 ? 0 : pos.x,
@@ -269,16 +284,16 @@ WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED
     return (WXHBRUSH)brush->GetResourceHandle();
 }
 
-WXDWORD wxControl::GetExStyle(WXDWORD& style, bool *want3D) const
+WXDWORD wxControl::MSWGetStyle(long style, WXDWORD *exstyle) const
 {
-    WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, want3D);
+    long msStyle = wxWindow::MSWGetStyle(style, exstyle);
 
-    // Even with extended styles, need to combine with WS_BORDER for them to
-    // look right.
-    if ( *want3D || wxStyleHasBorder(m_windowStyle) )
-        style |= WS_BORDER;
+    if ( AcceptsFocus() )
+    {
+        msStyle |= WS_TABSTOP;
+    }
 
-    return exStyle;
+    return msStyle;
 }
 
 // ---------------------------------------------------------------------------
index b5a07c42390cc586a7a3a1d0e308988d997a3ba7..4ecf1d2019c7a751cd6305b6648fe72908457a4f 100644 (file)
@@ -360,7 +360,7 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
     long msStyle = wxControl::MSWGetStyle(style, exstyle);
 
     // default styles
-    msStyle |= ES_LEFT | WS_TABSTOP;
+    msStyle |= ES_LEFT;
 
     if ( style & wxTE_MULTILINE )
     {
index 1f157a7511272108c42afec3137fa72295503154..a189e89dccbd407f523ab1d297be7413060de97d 100644 (file)
@@ -1027,7 +1027,11 @@ void wxWindowMSW::SetWindowStyleFlag(long flags)
     // update the internal variable
     wxWindowBase::SetWindowStyleFlag(flags);
 
-    // now update the Windows style as well if needed
+    // now update the Windows style as well if needed - and if the window had
+    // been already created
+    if ( !GetHwnd() )
+        return;
+
     WXDWORD exstyle, exstyleOld;
     long style = MSWGetStyle(flags, &exstyle),
          styleOld = MSWGetStyle(flagsOld, &exstyleOld);