]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobox.cpp
Added WS_VISIBLE style
[wxWidgets.git] / src / msw / radiobox.cpp
index 7d41132ef3ec11b1d722216501796c594710af29..521caa3e09dc30d8753e47dd1792122ba589a6d7 100644 (file)
@@ -5,8 +5,8 @@
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:     wxWindows license
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ===========================================================================
@@ -413,15 +413,21 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
 
     int extraHeight = cy1;
 
+    /* We'll assume the adjustments below are OK for Win 3.1 too
 #if defined(CTL3D) && !CTL3D
     // Requires a bigger group box in plain Windows
     extraHeight *= 3;
     extraHeight /= 2;
 #endif
-
+    */
+    
     int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight;
     int width  = GetNumHor() * (sizeBtn.x + cx1) + cx1;
 
+    // Add extra space under the label, if it exists.
+    if (!wxControl::GetLabel().IsEmpty())
+        height += cy1/2;
+
     // and also wide enough for its label
     int widthLabel;
     GetTextExtent(GetTitle(), &widthLabel, NULL);
@@ -507,10 +513,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     x_offset += cx1;
     y_offset += cy1;
 
-#if defined(CTL3D) && (!CTL3D)
-    y_offset += (int)(cy1/2); // Fudge factor since buttons overlapped label
-    // JACS 2/12/93. CTL3D draws group label quite high.
-#endif
+    // Add extra space under the label, if it exists.
+    if (!wxControl::GetLabel().IsEmpty())
+        y_offset += cy1/2;
 
     int startX = x_offset;
     int startY = y_offset;
@@ -786,6 +791,10 @@ long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
             }
 #endif // Win32
 
+        // VZ: this code breaks radiobox redrawing under Windows XP, don't use
+        //     it. If you need to get messages from the static controls,
+        //     create them as a child of another (non static) window
+#if 0
         // This is required for the radiobox to be sensitive to mouse input,
         // e.g. for Dialog Editor.
         case WM_NCHITTEST:
@@ -801,6 +810,7 @@ long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
                     return (long)HTCLIENT;
             }
             break;
+#endif // 0
     }
 
     return wxControl::MSWWindowProc(nMsg, wParam, lParam);
@@ -835,7 +845,7 @@ WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSE
     wxColour colBack = GetBackgroundColour();
 
     if (!IsEnabled())
-        colBack = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+        colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
 
     ::SetBkColor(hdc, wxColourToRGB(colBack));
     ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
@@ -874,7 +884,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
         case WM_NOTIFY:
             {
                 NMHDR* hdr = (NMHDR *)lParam;
-                if ( (int)hdr->code == TTN_NEEDTEXT )
+                if ( hdr->code == TTN_NEEDTEXT )
                 {
                     wxRadioBox *radiobox = (wxRadioBox *)
                         ::GetWindowLong(hwnd, GWL_USERDATA);
@@ -905,14 +915,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
 
                 bool processed = TRUE;
 
-                bool horz = (radiobox->GetWindowStyle() & wxRA_SPECIFY_COLS) != 0;
-                int num = radiobox->Number(),
-                    rows = radiobox->GetNumVer(),
-                    cols = radiobox->GetNumHor();
-
-                int selOld = radiobox->GetSelection();
-                int selNew = selOld;
-
+                wxDirection dir;
                 switch ( wParam )
                 {
                     case VK_UP:
@@ -948,17 +951,6 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                                   radiobox->GetWindowStyle()
                                  );
 
-                        int dim = horz ? cols : rows;
-                        if ( selNew % dim == 0 )
-                        {
-                            selNew -= dim - 1;
-                        }
-                        else
-                        {
-                            selNew++;
-                        }
-                    }
-
                     if ( selNew != selOld )
                     {
                         radiobox->SetSelection(selNew);
@@ -974,45 +966,45 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
 
 #ifdef __WIN32__
         case WM_HELP:
-        {
-            wxRadioBox *radiobox = (wxRadioBox *)
-                    ::GetWindowLong(hwnd, GWL_USERDATA);
+            {
+                wxRadioBox *radiobox = (wxRadioBox *)
+                        ::GetWindowLong(hwnd, GWL_USERDATA);
 
-            wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+                wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
 
-            bool processed = TRUE;
+                bool processed = TRUE;
 
-            HELPINFO* info = (HELPINFO*) lParam;
-            // Don't yet process menu help events, just windows
-            if (info->iContextType == HELPINFO_WINDOW)
-            {
-                wxWindow* subjectOfHelp = radiobox;
-                bool eventProcessed = FALSE;
-                while (subjectOfHelp && !eventProcessed)
+                HELPINFO* info = (HELPINFO*) lParam;
+                // Don't yet process menu help events, just windows
+                if (info->iContextType == HELPINFO_WINDOW)
                 {
-                    wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId);
-                    helpEvent.SetEventObject(radiobox);
-                    eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
+                    wxWindow* subjectOfHelp = radiobox;
+                    bool eventProcessed = FALSE;
+                    while (subjectOfHelp && !eventProcessed)
+                    {
+                        wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId);
+                        helpEvent.SetEventObject(radiobox);
+                        eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
 
-                    // Go up the window hierarchy until the event is handled (or not)
-                    subjectOfHelp = subjectOfHelp->GetParent();
+                        // Go up the window hierarchy until the event is handled (or not)
+                        subjectOfHelp = subjectOfHelp->GetParent();
+                    }
+                    processed = eventProcessed;
                 }
-                processed = eventProcessed;
-            }
-            else if (info->iContextType == HELPINFO_MENUITEM)
-            {
-                wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
-                helpEvent.SetEventObject(radiobox);
-                processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
-            }
-            else processed = FALSE;
+                else if (info->iContextType == HELPINFO_MENUITEM)
+                {
+                    wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
+                    helpEvent.SetEventObject(radiobox);
+                    processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
+                }
+                else processed = FALSE;
 
-            if (processed)
-                return 0;
+                if (processed)
+                    return 0;
 
-            break;
-        }
-#endif
+                break;
+            }
+#endif // __WIN32__
     }
 
     return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam);