]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobox.cpp
macro naming changes, delegate api calls getting property info, object info exposed...
[wxWidgets.git] / src / msw / radiobox.cpp
index f5bc5e6c6f88ef49d95a89ccb855dc6d47f737e0..7c7d92283962bfc2b14e3b02c2533f24afc302c7 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
 /////////////////////////////////////////////////////////////////////////////
 
 // ===========================================================================
@@ -17,7 +17,7 @@
 // headers
 // ---------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "radiobox.h"
 #endif
 
     #include "wx/tooltip.h"
 #endif // wxUSE_TOOLTIPS
 
+// TODO: WX_CONSTRUCTOR
+#if 0 // wxUSE_EXTENDED_RTTI
+WX_DEFINE_FLAGS( wxRadioBoxStyle )
+
+WX_BEGIN_FLAGS( wxRadioBoxStyle )
+    // new style border flags, we put them first to
+    // use them for streaming out
+    WX_FLAGS_MEMBER(wxBORDER_SIMPLE)
+    WX_FLAGS_MEMBER(wxBORDER_SUNKEN)
+    WX_FLAGS_MEMBER(wxBORDER_DOUBLE)
+    WX_FLAGS_MEMBER(wxBORDER_RAISED)
+    WX_FLAGS_MEMBER(wxBORDER_STATIC)
+    WX_FLAGS_MEMBER(wxBORDER_NONE)
+    
+    // old style border flags
+    WX_FLAGS_MEMBER(wxSIMPLE_BORDER)
+    WX_FLAGS_MEMBER(wxSUNKEN_BORDER)
+    WX_FLAGS_MEMBER(wxDOUBLE_BORDER)
+    WX_FLAGS_MEMBER(wxRAISED_BORDER)
+    WX_FLAGS_MEMBER(wxSTATIC_BORDER)
+    WX_FLAGS_MEMBER(wxNO_BORDER)
+
+    // standard window styles
+    WX_FLAGS_MEMBER(wxTAB_TRAVERSAL)
+    WX_FLAGS_MEMBER(wxCLIP_CHILDREN)
+    WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    WX_FLAGS_MEMBER(wxWANTS_CHARS)
+    WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
+    WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    WX_FLAGS_MEMBER(wxVSCROLL)
+    WX_FLAGS_MEMBER(wxHSCROLL)
+
+    WX_FLAGS_MEMBER(wxRA_SPECIFY_COLS)
+    WX_FLAGS_MEMBER(wxRA_HORIZONTAL)
+    WX_FLAGS_MEMBER(wxRA_SPECIFY_ROWS)
+    WX_FLAGS_MEMBER(wxRA_VERTICAL)
+
+WX_END_FLAGS( wxRadioBoxStyle )
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox, wxControl,"wx/radiobox.h")
+
+WX_BEGIN_PROPERTIES_TABLE(wxRadioBox)
+    WX_EVENT_PROPERTY( Select , wxEVT_COMMAND_RADIOBOX_SELECTED , wxCommandEvent )
+    WX_PROPERTY_FLAGS( WindowStyle , wxRadioBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+WX_END_PROPERTIES_TABLE()
+
+#else
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
+#endif
+
+/*
+       selection
+       content
+               label
+               dimension
+               item
+*/
 
 // there are two possible ways to create the radio buttons: either as children
 // of the radiobox or as siblings of it - allow playing with both variants for
@@ -183,22 +239,6 @@ bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id)
         return FALSE;
 }
 
-#if WXWIN_COMPATIBILITY
-wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
-        int x, int y, int width, int height,
-        int n, char **choices,
-        int majorDim, long style, const char *name)
-{
-    wxString *choices2 = new wxString[n];
-    for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
-    Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
-            wxDefaultValidator, name);
-    Callback(func);
-    delete choices2;
-}
-
-#endif // WXWIN_COMPATIBILITY
-
 // Radio box item
 wxRadioBox::wxRadioBox()
 {
@@ -300,7 +340,7 @@ bool wxRadioBox::Create(wxWindow *parent,
 
     // Create a dummy radio control to end the group.
     (void)::CreateWindow(_T("BUTTON"),
-                         _T(""),
+                         wxEmptyString,
                          WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
                          0, 0, 0, 0, hwndParent,
                          (HMENU)NewControlId(), wxGetInstance(), NULL);
@@ -348,7 +388,6 @@ void wxRadioBox::SetSelection(int N)
         ::SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
 
     ::SendMessage((HWND)m_radioButtons[N], BM_SETCHECK, 1, 0L);
-    ::SetFocus((HWND)m_radioButtons[N]);
 
     m_selectedButton = N;
 }
@@ -650,10 +689,9 @@ void wxRadioBox::SetFocus()
 {
     if (m_noItems > 0)
     {
-        if (m_selectedButton == -1)
-            ::SetFocus((HWND) m_radioButtons[0]);
-        else
-            ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
+        ::SetFocus((HWND)m_radioButtons[m_selectedButton == -1
+                                            ? 0
+                                            : m_selectedButton]);
     }
 
 }
@@ -717,6 +755,7 @@ bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
 void wxRadioBox::Command(wxCommandEvent & event)
 {
     SetSelection (event.m_commandInt);
+    SetFocus();
     ProcessCommand (event);
 }
 
@@ -724,8 +763,6 @@ void wxRadioBox::Command(wxCommandEvent & event)
 //     radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
 void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
 {
-    // No GWL_USERDATA in Win16, so omit this subclassing.
-#ifdef __WIN32__
     HWND hwndBtn = (HWND)hWndBtn;
 
     if ( !s_wndprocRadioBtn )
@@ -733,7 +770,6 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
 
     ::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
     ::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
-#endif // __WIN32__
 }
 
 void wxRadioBox::SendNotificationEvent()
@@ -837,11 +873,6 @@ WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSE
 #endif // wxUSE_CTL3D
 
     HDC hdc = (HDC)pDC;
-    if (GetParent()->GetTransparentBackground())
-        SetBkMode(hdc, TRANSPARENT);
-    else
-        SetBkMode(hdc, OPAQUE);
-
     wxColour colBack = GetBackgroundColour();
 
     if (!IsEnabled())
@@ -954,6 +985,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                     if ( selNew != selOld )
                     {
                         radiobox->SetSelection(selNew);
+                        radiobox->SetFocus();
 
                         // emulate the button click
                         radiobox->SendNotificationEvent();
@@ -974,15 +1006,24 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
 
                 bool processed = TRUE;
 
+                // HELPINFO doesn't seem to be supported on WinCE.
+#ifndef __WXWINCE__
                 HELPINFO* info = (HELPINFO*) lParam;
                 // Don't yet process menu help events, just windows
                 if (info->iContextType == HELPINFO_WINDOW)
+#endif
                 {
                     wxWindow* subjectOfHelp = radiobox;
                     bool eventProcessed = FALSE;
                     while (subjectOfHelp && !eventProcessed)
                     {
-                        wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId);
+                        wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(),
+#ifdef __WXWINCE__
+                                              wxPoint(0, 0)
+#else
+                                              wxPoint(info->MousePos.x, info->MousePos.y)
+#endif
+                            ) ; // info->iCtrlId);
                         helpEvent.SetEventObject(radiobox);
                         eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
 
@@ -991,14 +1032,16 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                     }
                     processed = eventProcessed;
                 }
+#ifndef __WXWINCE__
                 else if (info->iContextType == HELPINFO_MENUITEM)
                 {
                     wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
                     helpEvent.SetEventObject(radiobox);
                     processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
                 }
-                else processed = FALSE;
-
+                else
+                    processed = FALSE;
+#endif
                 if (processed)
                     return 0;