]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
ODBC library is built when wxUSE_GUI=0, too
[wxWidgets.git] / src / msw / window.cpp
index 6099e4e34d0cce6a44571335ac7fa73018c33870..1e9be60f14ea80e59f74cc8a8efdd01d3f6579e1 100644 (file)
@@ -17,7 +17,7 @@
 // headers
 // ---------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "window.h"
 #endif
 
@@ -49,7 +49,7 @@
     #include "wx/statbox.h"
 #endif
 
-#if wxUSE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
     #include "wx/ownerdrw.h"
 #endif
 
@@ -233,12 +233,38 @@ static inline void wxBringWindowToTop(HWND hwnd)
 IMPLEMENT_DYNAMIC_CLASS_XTI(wxWindow, wxWindowBase,"wx/window.h")
 
 WX_BEGIN_PROPERTIES_TABLE(wxWindow)
-       WX_READONLY_PROPERTY( Parent,wxWindow*, GetParent,  )
+    // Always constructor Properties first
+
+    WX_READONLY_PROPERTY( Parent,wxWindow*, GetParent,  )
        WX_PROPERTY( Id,wxWindowID, SetId, GetId, -1 )
+       WX_PROPERTY_SET_BY_REF( Position,wxPoint, SetPosition , GetPosition, wxPoint(-1,-1) ) // pos
+       WX_PROPERTY_SET_BY_REF( Size,wxSize, SetSize, GetSize, wxSize(-1,-1) ) // size
+    WX_PROPERTY( WindowStyle , long , SetWindowStyle , GetWindowStyle , ) // style 
+
+    // Then all relations of the object graph
+
+    WX_READONLY_PROPERTY_COLLECTION( Children , wxWindowList , wxWindowBase* , GetChildren )
+
+   // and finally all other properties
+
+       WX_PROPERTY( ExtraStyle , long , SetExtraStyle , GetExtraStyle , ) // extstyle
+       WX_PROPERTY_SET_BY_REF_RET_BOOL( BackgroundColour , wxColour , SetBackgroundColour , GetBackgroundColour , ) // bg
+       WX_PROPERTY_SET_BY_REF_RET_BOOL( ForegroundColour , wxColour , SetForegroundColour , GetForegroundColour , ) // fg
+       WX_PROPERTY_SET_RET_BOOL( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) )
+       WX_PROPERTY_SET_RET_BOOL( Shown , bool , Show , IsShown , wxxVariant((bool)true) )
+#if 0
+    // possible property candidates (not in xrc) or not valid in all subclasses
        WX_PROPERTY_SET_BY_REF( Title,wxString, SetTitle, GetTitle, wxT("") )
+       WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( Font , wxFont , SetFont , GetFont  , )
        WX_PROPERTY_SET_BY_REF( Label,wxString, SetLabel, GetLabel, wxT("") )
-       WX_PROPERTY_SET_BY_REF( Position,wxPoint, SetPosition , GetPosition, wxDefaultPosition )
-       WX_PROPERTY_SET_BY_REF( Size,wxSize, SetSize, GetSize, wxDefaultSize )
+       // MaxHeight, Width , MinHeight , Width
+       // TODO switch label to control and title to toplevels
+       WX_PROPERTY( ThemeEnabled , bool , SetThemeEnabled , GetThemeEnabled , )
+       //WX_PROPERTY_SET_BY_REF( Cursor , wxCursor , SetCursor , GetCursor , )
+       // WX_PROPERTY( ToolTip , wxString , SetToolTip , GetToolTipText , )
+       WX_PROPERTY( AutoLayout , bool , SetAutoLayout , GetAutoLayout , )
+#endif
 WX_END_PROPERTIES_TABLE()
 
 WX_BEGIN_HANDLERS_TABLE(wxWindow)
@@ -1283,14 +1309,6 @@ bool wxWindowMSW::Reparent(wxWindowBase *parent)
     return TRUE;
 }
 
-void wxWindowMSW::Clear()
-{
-    wxClientDC dc((wxWindow *)this);
-    wxBrush brush(GetBackgroundColour(), wxSOLID);
-    dc.SetBackground(brush);
-    dc.Clear();
-}
-
 static inline void SendSetRedraw(HWND hwnd, bool on)
 {
 #ifndef __WXMICROWIN__
@@ -2348,13 +2366,15 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 
         case WM_PAINT:
             {
-                wxPaintDCEx *pdc = 0;
-                if (wParam) {
-                    pdc = new wxPaintDCEx(this, (WXHDC) wParam);
+                if ( wParam )
+                {
+                    // cast to wxWindow is needed for wxUniv
+                    wxPaintDCEx dc((wxWindow *)this, (WXHDC)wParam);
+                    processed = HandlePaint();
                 }
-                processed = HandlePaint();
-                if (pdc) {
-                    delete pdc;
+                else
+                {
+                    processed = HandlePaint();
                 }
                 break;
             }
@@ -3518,7 +3538,16 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd),
 // owner drawn stuff
 // ---------------------------------------------------------------------------
 
-bool wxWindowMSW::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
+#if (wxUSE_OWNER_DRAWN && wxUSE_MENUS_NATIVE) || \
+        (wxUSE_CONTROLS && !defined(__WXUNIVERSAL__))
+    #define WXUNUSED_UNLESS_ODRAWN(param) param
+#else
+    #define WXUNUSED_UNLESS_ODRAWN(param)
+#endif
+
+bool
+wxWindowMSW::MSWOnDrawItem(int WXUNUSED_UNLESS_ODRAWN(id),
+                           WXDRAWITEMSTRUCT * WXUNUSED_UNLESS_ODRAWN(itemStruct))
 {
 #if wxUSE_OWNER_DRAWN
 
@@ -3550,28 +3579,32 @@ bool wxWindowMSW::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
 
 #endif // USE_OWNER_DRAWN
 
-#if wxUSE_CONTROLS
+#if wxUSE_CONTROLS && !defined(__WXUNIVERSAL__) 
 
 #if wxUSE_OWNER_DRAWN
-    wxWindow *item = FindItem(id);
-    if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
-        return ((wxControl *)item)->MSWOnDraw(itemStruct);
-#elif !defined(__WXUNIVERSAL__)
+    wxControl *item = wxDynamicCast(FindItem(id), wxControl);
+#else // !wxUSE_OWNER_DRAWN
     // we may still have owner-drawn buttons internally because we have to make
     // them owner-drawn to support colour change
-    wxWindow *item = FindItem(id);
-    if ( item && item->IsKindOf(CLASSINFO(wxButton)) )
-        return ((wxButton *)item)->MSWOnDraw(itemStruct);
+    wxControl *item = wxDynamicCast(FindItem(id), wxButton);
 #endif // USE_OWNER_DRAWN
 
+    if ( item )
+    {
+        return item->MSWOnDraw(itemStruct);
+    }
+
 #endif // wxUSE_CONTROLS
 
     return FALSE;
 }
 
-bool wxWindowMSW::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
+bool
+wxWindowMSW::MSWOnMeasureItem(int WXUNUSED_UNLESS_ODRAWN(id),
+                              WXMEASUREITEMSTRUCT *
+                                  WXUNUSED_UNLESS_ODRAWN(itemStruct))
 {
-#if wxUSE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN && wxUSE_MENUS_NATIVE
     // is it a menu item?
     MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
     if ( id == 0 && pMeasureStruct->CtlType == ODT_MENU )
@@ -3584,12 +3617,13 @@ bool wxWindowMSW::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
                                         &pMeasureStruct->itemHeight);
     }
 
-    wxWindow *item = FindItem(id);
-    if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
+    wxControl *item = wxDynamicCast(FindItem(id), wxControl);
+    if ( item )
     {
-        return ((wxControl *)item)->MSWOnMeasure(itemStruct);
+        return item->MSWOnMeasure(itemStruct);
     }
-#endif  // owner-drawn menus
+#endif // wxUSE_OWNER_DRAWN
+
     return FALSE;
 }
 
@@ -4405,8 +4439,6 @@ wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType,
 // WM_KEYDOWN one
 bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII)
 {
-    bool ctrlDown = FALSE;
-
     int id;
     if ( isASCII )
     {
@@ -4431,7 +4463,7 @@ bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII)
                     break;
 
                 default:
-                    ctrlDown = TRUE;
+                    //ctrlDown = TRUE;
                     break;
             }
         }