]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobox.cpp
Some of these are not in BASE, cahnge back to WXDLLEXPORT
[wxWidgets.git] / src / msw / radiobox.cpp
index bbb4333cf92b7333ad0d8cd7e004247967481cd4..524027ecf9e7d15dd2b688b2b6a383b461fc38bb 100644 (file)
@@ -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: wxCONSTRUCTOR
+#if 0 // wxUSE_EXTENDED_RTTI
+WX_DEFINE_FLAGS( wxRadioBoxStyle )
+
+wxBEGIN_FLAGS( wxRadioBoxStyle )
+    // new style border flags, we put them first to
+    // use them for streaming out
+    wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+    wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+    wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+    wxFLAGS_MEMBER(wxBORDER_RAISED)
+    wxFLAGS_MEMBER(wxBORDER_STATIC)
+    wxFLAGS_MEMBER(wxBORDER_NONE)
+    
+    // old style border flags
+    wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+    wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+    wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+    wxFLAGS_MEMBER(wxRAISED_BORDER)
+    wxFLAGS_MEMBER(wxSTATIC_BORDER)
+    wxFLAGS_MEMBER(wxBORDER)
+
+    // standard window styles
+    wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+    wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+    wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    wxFLAGS_MEMBER(wxWANTS_CHARS)
+    wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    wxFLAGS_MEMBER(wxVSCROLL)
+    wxFLAGS_MEMBER(wxHSCROLL)
+
+    wxFLAGS_MEMBER(wxRA_SPECIFY_COLS)
+    wxFLAGS_MEMBER(wxRA_HORIZONTAL)
+    wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS)
+    wxFLAGS_MEMBER(wxRA_VERTICAL)
+
+wxEND_FLAGS( wxRadioBoxStyle )
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox, wxControl,"wx/radiobox.h")
+
+wxBEGIN_PROPERTIES_TABLE(wxRadioBox)
+    wxEVENT_PROPERTY( Select , wxEVT_COMMAND_RADIOBOX_SELECTED , wxCommandEvent )
+    wxPROPERTY_FLAGS( WindowStyle , wxRadioBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+wxEND_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
@@ -238,7 +294,7 @@ bool wxRadioBox::Create(wxWindow *parent,
     m_radioHeight = new int[n];
 
     WXHFONT hfont = 0;
-    wxFont& font = GetFont();
+    wxFont font = GetFont();
     if ( font.Ok() )
     {
         hfont = font.GetResourceHandle();
@@ -289,13 +345,36 @@ bool wxRadioBox::Create(wxWindow *parent,
                          0, 0, 0, 0, hwndParent,
                          (HMENU)NewControlId(), wxGetInstance(), NULL);
 
-    SetSelection(0);
+#ifdef __WXWINCE__
+    // Set the z-order correctly
+    SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+#endif
 
+    SetSelection(0);
     SetSize(pos.x, pos.y, size.x, size.y);
 
+    // Now that we have items determine what is the best size and set it.
+    SetBestSize(size);
+    
     return TRUE;
 }
 
+bool wxRadioBox::Create(wxWindow *parent,
+                        wxWindowID id,
+                        const wxString& title,
+                        const wxPoint& pos,
+                        const wxSize& size,
+                        const wxArrayString& choices,
+                        int majorDim,
+                        long style,
+                        const wxValidator& val,
+                        const wxString& name)
+{
+    wxCArrayString chs(choices);
+    return Create(parent, id, title, pos, size, chs.GetCount(),
+                  chs.GetStrings(), majorDim, style, val, name);
+}
+
 wxRadioBox::~wxRadioBox()
 {
     m_isBeingDeleted = TRUE;
@@ -392,7 +471,7 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
 {
     // the radiobox should be big enough for its buttons
     int cx1, cy1;
-    wxGetCharSize(m_hWnd, &cx1, &cy1, &GetFont());
+    wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont());
 
     int extraHeight = cy1;
 
@@ -451,7 +530,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 #endif
 
     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.
@@ -710,10 +789,10 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
     HWND hwndBtn = (HWND)hWndBtn;
 
     if ( !s_wndprocRadioBtn )
-        s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC);
+        s_wndprocRadioBtn = (WXFARPROC)wxGetWindowProc(hwndBtn);
 
-    ::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
-    ::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
+    wxSetWindowProc(hwndBtn, wxRadioBtnWndProc);
+    wxSetWindowUserData(hwndBtn, this);
 }
 
 void wxRadioBox::SendNotificationEvent()
@@ -751,7 +830,7 @@ bool wxRadioBox::SetFont(const wxFont& font)
 // our window proc
 // ----------------------------------------------------------------------------
 
-long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
     switch ( nMsg )
     {
@@ -767,7 +846,7 @@ long wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 
                 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
 
-                return (WXHBRUSH)brush->GetResourceHandle();
+                return (WXLRESULT)brush->GetResourceHandle();
             }
 #endif // Win32
 
@@ -819,9 +898,6 @@ WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSE
     HDC hdc = (HDC)pDC;
     wxColour colBack = GetBackgroundColour();
 
-    if (!IsEnabled())
-        colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
-
     ::SetBkColor(hdc, wxColourToRGB(colBack));
     ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
 
@@ -861,8 +937,8 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                 NMHDR* hdr = (NMHDR *)lParam;
                 if ( hdr->code == TTN_NEEDTEXT )
                 {
-                    wxRadioBox *radiobox = (wxRadioBox *)
-                        ::GetWindowLong(hwnd, GWL_USERDATA);
+                    wxRadioBox *
+                        radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
 
                     wxCHECK_MSG( radiobox, 0,
                                  wxT("radio button without radio box?") );
@@ -883,8 +959,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
 
         case WM_KEYDOWN:
             {
-                wxRadioBox *radiobox = (wxRadioBox *)
-                    ::GetWindowLong(hwnd, GWL_USERDATA);
+                wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
 
                 wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
 
@@ -940,15 +1015,32 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
             }
             break;
 
+        case WM_SETFOCUS:
+        case WM_KILLFOCUS:
+            {
+                wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+                wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+                // if we don't do this, no focus events are generated for the
+                // radiobox and, besides, we need to notify the parent about
+                // the focus change, otherwise the focus handling logic in
+                // wxControlContainer doesn't work
+                if ( message == WM_SETFOCUS )
+                    radiobox->HandleSetFocus((WXHWND)wParam);
+                else
+                    radiobox->HandleKillFocus((WXHWND)wParam);
+            }
+            break;
+
 #ifdef __WIN32__
         case WM_HELP:
             {
-                wxRadioBox *radiobox = (wxRadioBox *)
-                        ::GetWindowLong(hwnd, GWL_USERDATA);
+                wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
 
                 wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
 
-                bool processed = TRUE;
+                bool processed wxDUMMY_INITIALIZE(true);
 
                 // HELPINFO doesn't seem to be supported on WinCE.
 #ifndef __WXWINCE__
@@ -984,7 +1076,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
                     processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
                 }
                 else
-                    processed = FALSE;
+                    processed = false;
 #endif
                 if (processed)
                     return 0;