diff --git a/include/wx/control.h b/include/wx/control.h index 7d839ac9f5..e6a23540ad 100644 --- a/include/wx/control.h +++ b/include/wx/control.h @@ -41,11 +41,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr); - // set the background image - virtual void SetBackground(const wxBitmap& bitmap, - int alignment = wxALIGN_CENTRE, - wxStretch stretch = wxSTRETCH_NOT); - // simulates the event of given type (i.e. wxButton::Command() is just as // if the button was clicked) virtual void Command(wxCommandEvent &event); @@ -53,10 +48,6 @@ public: // get the control alignment (left/right/centre, top/bottom/centre) int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; } - // get the control border style: uses the current style and falls back to - // the default style for this class otherwise - wxBorder GetBorder() const; - protected: // creates the control (calls wxWindowBase::CreateBase inside) and adds it // to the list of parents children @@ -73,10 +64,6 @@ protected: // initialize the common fields of wxCommandEvent void InitCommandEvent(wxCommandEvent& event) const; - - // override this to change the default (i.e. used when no style is - // specified) border for the control - virtual wxBorder GetDefaultBorder() const; }; // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index cd5fe6607a..c7f2c40929 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: window.h +// Name: wx/gtk/window.h // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -19,33 +19,34 @@ // callback definition for inserting a window (internal) //----------------------------------------------------------------------------- -typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); +class wxWindowGTK; +typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* ); //----------------------------------------------------------------------------- -// wxWindow +// wxWindowGTK //----------------------------------------------------------------------------- -class wxWindow : public wxWindowBase +class wxWindowGTK : public wxWindowBase { - DECLARE_DYNAMIC_CLASS(wxWindow) + DECLARE_DYNAMIC_CLASS(wxWindowGTK) public: // creating the window // ------------------- - wxWindow(); - wxWindow(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); + wxWindowGTK(); + wxWindowGTK(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr); bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr); - virtual ~wxWindow(); + virtual ~wxWindowGTK(); // implement base class (pure) virtual methods // ------------------------------------------- @@ -117,13 +118,13 @@ public: void OnIdle(wxIdleEvent& WXUNUSED(event)) {}; /* used by all window classes in the widget creation process */ - bool PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size ); + bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ); void PostCreation(); /* internal addition of child windows. differs from class to class not by using virtual functions but by using the m_insertCallback */ - void DoAddChild(wxWindow *child); + void DoAddChild(wxWindowGTK *child); /* the methods below are required because many native widgets are composed of several subwidgets and setting a style for @@ -228,7 +229,7 @@ public: void Init(); private: - DECLARE_NO_COPY_CLASS(wxWindow); + DECLARE_NO_COPY_CLASS(wxWindowGTK); }; #endif // __GTKWINDOWH__ diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index cd5fe6607a..c7f2c40929 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: window.h +// Name: wx/gtk/window.h // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -19,33 +19,34 @@ // callback definition for inserting a window (internal) //----------------------------------------------------------------------------- -typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); +class wxWindowGTK; +typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* ); //----------------------------------------------------------------------------- -// wxWindow +// wxWindowGTK //----------------------------------------------------------------------------- -class wxWindow : public wxWindowBase +class wxWindowGTK : public wxWindowBase { - DECLARE_DYNAMIC_CLASS(wxWindow) + DECLARE_DYNAMIC_CLASS(wxWindowGTK) public: // creating the window // ------------------- - wxWindow(); - wxWindow(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); + wxWindowGTK(); + wxWindowGTK(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr); bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr); - virtual ~wxWindow(); + virtual ~wxWindowGTK(); // implement base class (pure) virtual methods // ------------------------------------------- @@ -117,13 +118,13 @@ public: void OnIdle(wxIdleEvent& WXUNUSED(event)) {}; /* used by all window classes in the widget creation process */ - bool PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size ); + bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ); void PostCreation(); /* internal addition of child windows. differs from class to class not by using virtual functions but by using the m_insertCallback */ - void DoAddChild(wxWindow *child); + void DoAddChild(wxWindowGTK *child); /* the methods below are required because many native widgets are composed of several subwidgets and setting a style for @@ -228,7 +229,7 @@ public: void Init(); private: - DECLARE_NO_COPY_CLASS(wxWindow); + DECLARE_NO_COPY_CLASS(wxWindowGTK); }; #endif // __GTKWINDOWH__ diff --git a/include/wx/univ/control.h b/include/wx/univ/control.h index f507adc6b8..ec9478f404 100644 --- a/include/wx/univ/control.h +++ b/include/wx/univ/control.h @@ -16,28 +16,10 @@ #pragma interface "control.h" #endif -#include "wx/bitmap.h" // for m_bitmapBg - class WXDLLEXPORT wxControlRenderer; class WXDLLEXPORT wxInputHandler; class WXDLLEXPORT wxRenderer; -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// control state flags used in wxRenderer and wxColourScheme -enum -{ - wxCONTROL_DISABLED = 0x00000001, // control is disabled - wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus - wxCONTROL_PRESSED = 0x00000004, // (button) is pressed - wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons - wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control - - wxCONTROL_FLAGS_MASK = 0x0000001f -}; - // ---------------------------------------------------------------------------- // wxControlAction: the action is currently just a string which identifies it, // later it might become an atom (i.e. an opaque handler to string). As one @@ -105,26 +87,6 @@ public: virtual void SetLabel(const wxString &label); virtual wxString GetLabel() const; - // set/query the bg image - virtual void SetBackground(const wxBitmap& bitmap, - int alignment = wxALIGN_CENTRE, - wxStretch stretch = wxSTRETCH_NOT); - - const wxBitmap& GetBackgroundBitmap(int *alignment = NULL, - wxStretch *stretch = NULL) const; - - // get the state information - virtual bool IsFocused() const; - virtual bool IsCurrent() const; - virtual bool IsPressed() const; - virtual bool IsDefault() const; - - // return all state flags at once (combination of wxCONTROL_XXX values) - int GetStateFlags() const; - - // operations - virtual void SetCurrent(bool doit = TRUE); - // implementation only from now on // return the index of the accel char in the label or -1 if none @@ -143,30 +105,15 @@ public: const wxEvent& event); protected: - // returns the (low level) renderer to use for drawing the control by - // querying the current theme - wxRenderer *GetRenderer() const; - // create the event translator object for this control: the base class // action creates the default one which doesn't do anything virtual wxInputHandler *CreateInputHandler() const; - // draw the control background, return TRUE if done - virtual bool DoDrawBackground(wxControlRenderer *renderer); - - // draw the controls contents - virtual void DoDraw(wxControlRenderer *renderer); - - // adjust the size of the control to take into account its borders - wxSize AdjustSize(const wxSize& size) const; - // event handlers void OnMouse(wxMouseEvent& event); void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); void OnFocus(wxFocusEvent& event); - void OnPaint(wxPaintEvent& event); - void OnErase(wxEraseEvent& event); private: // common part of all ctors @@ -182,14 +129,6 @@ private: wxString m_label; int m_indexAccel; - // background bitmap info - wxBitmap m_bitmapBg; - int m_alignBgBitmap; - wxStretch m_stretchBgBitmap; - - // state - bool m_isCurrent; - DECLARE_DYNAMIC_CLASS(wxControl) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/univ/renderer.h b/include/wx/univ/renderer.h index 42a8261271..c3729d1d92 100644 --- a/include/wx/univ/renderer.h +++ b/include/wx/univ/renderer.h @@ -28,7 +28,6 @@ #ifndef _WX_UNIV_RENDERER_H_ #define _WX_UNIV_RENDERER_H_ -class WXDLLEXPORT wxControl; class WXDLLEXPORT wxDC; class WXDLLEXPORT wxScrollBar; class WXDLLEXPORT wxWindow; @@ -157,6 +156,12 @@ public: virtual ~wxRenderer(); protected: + // draw a frame around rectFrame rectangle but not touching the rectLabel + // one: this is used by DrawFrame() + void StandardDrawFrame(wxDC& dc, + const wxRect& rectFrame, + const wxRect& rectLabel); + // standard scrollbar hit testing: this assumes that it only has 2 arrows // and a thumb, so the themes which have more complicated scrollbars (e.g. // BeOS) can't use this method @@ -261,7 +266,7 @@ class WXDLLEXPORT wxControlRenderer { public: // create a renderer for this dc with this "fundamental" renderer - wxControlRenderer(wxControl *control, wxDC& dc, wxRenderer *renderer); + wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer); // operations void DrawLabel(const wxBitmap& bitmap = wxNullBitmap, @@ -280,6 +285,7 @@ public: void DrawScrollbar(const wxScrollBar *scrollbar); // accessors + wxWindow *GetWindow() const { return m_window; } wxRenderer *GetRenderer() const { return m_renderer; } wxDC& GetDC() { return m_dc; } @@ -288,7 +294,7 @@ public: wxRect& GetRect() { return m_rect; } private: - wxControl *m_ctrl; + wxWindow *m_window; wxRenderer *m_renderer; wxDC& m_dc; wxRect m_rect; diff --git a/include/wx/univ/window.h b/include/wx/univ/window.h index 095ddd45d0..2a58645d7d 100644 --- a/include/wx/univ/window.h +++ b/include/wx/univ/window.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/univ/window.h -// Purpose: wxUniversalWindow class which is the base class for all +// Purpose: wxWindow class which is the base class for all // wxUniv port controls, it supports the customization of the // window drawing and input processing. // Author: Vadim Zeitlin @@ -18,37 +18,122 @@ #pragma interface "univwindow.h" #endif +#include "wx/bitmap.h" // for m_bitmapBg + +class WXDLLEXPORT wxControlRenderer; class WXDLLEXPORT wxRenderer; +class WXDLLEXPORT wxScrollBar; // ---------------------------------------------------------------------------- -// wxUniversalWindow +// constants // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxUniversalWindow : public wxWindow +// control state flags used in wxRenderer and wxColourScheme +enum +{ + wxCONTROL_DISABLED = 0x00000001, // control is disabled + wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus + wxCONTROL_PRESSED = 0x00000004, // (button) is pressed + wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons + wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control + + wxCONTROL_FLAGS_MASK = 0x0000001f +}; + +// ---------------------------------------------------------------------------- +// wxWindow +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxWindow : public wxWindowNative { public: - // ctor - wxUniversalWindow(wxWindowBase *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxPanelNameStr) - : wxWindow(parent, id, pos, size, style, validator, name) - { } + // ctors and creatie functions + // --------------------------- + + wxWindow() { Init(); } + + wxWindow(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr) + : wxWindowNative(parent, id, pos, size, style, name) + { Init(); } + + // background pixmap support + // ------------------------- + virtual void SetBackground(const wxBitmap& bitmap, + int alignment = wxALIGN_CENTRE, + wxStretch stretch = wxSTRETCH_NOT); + + const wxBitmap& GetBackgroundBitmap(int *alignment = NULL, + wxStretch *stretch = NULL) const; + + // scrollbars: we (re)implement it ourselves using our own scrollbars + // instead of the native ones + // ------------------------------------------------------------------ + + virtual void SetScrollbar( int orient, + int pos, + int thumbVisible, + int range, + bool refresh = TRUE ); + virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); + virtual int GetScrollPos( int orient ) const; + virtual int GetScrollThumb( int orient ) const; + virtual int GetScrollRange( int orient ) const; + + // miscellaneous other methods + // --------------------------- + + // get the state information + virtual bool IsFocused() const; + virtual bool IsCurrent() const; + virtual bool IsPressed() const; + virtual bool IsDefault() const; + + // return all state flags at once (combination of wxCONTROL_XXX values) + int GetStateFlags() const; + + // operations + virtual void SetCurrent(bool doit = TRUE); protected: - // draw the controls contents: the base class version draws the border as - // required (depending on the window style flags and enabled state) and - // adjusts the DC so that subsequent drawing is clipped to the area inside - // the border - virtual void DoDraw(wxDC& dc, wxRenderer *renderer); + // common part of all ctors + void Init(); // event handlers void OnPaint(wxPaintEvent& event); + void OnErase(wxEraseEvent& event); + + // returns the (low level) renderer to use for drawing the control by + // querying the current theme + wxRenderer *GetRenderer() const; + + // draw the control background, return TRUE if done + virtual bool DoDrawBackground(wxControlRenderer *renderer); + + // draw the controls contents + virtual void DoDraw(wxControlRenderer *renderer); + + // adjust the size of the window to take into account its borders + wxSize AdjustSize(const wxSize& size) const; + + // background bitmap info + wxBitmap m_bitmapBg; + int m_alignBgBitmap; + wxStretch m_stretchBgBitmap; + + // is the mouse currently inside the window? + bool m_isCurrent; private: + // the window scrollbars + wxScrollBar *m_scrollbarHorz, + *m_scrollbarVert; + + DECLARE_DYNAMIC_CLASS(wxWindow) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/window.h b/include/wx/window.h index 4ab8d4d35f..860c5fbe1d 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -554,6 +554,10 @@ public: // misc // ---- + // get the window border style: uses the current style and falls back to + // the default style for this class otherwise (see GetDefaultBorder()) + wxBorder GetBorder() const; + void UpdateWindowUI(); #if wxUSE_MENUS @@ -569,10 +573,10 @@ public: // configure the window scrollbars virtual void SetScrollbar( int orient, int pos, - int thumbVisible, + int thumbvisible, int range, - bool refresh = TRUE ) = 0; - virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) = 0; + bool refresh = true ) = 0; + virtual void SetScrollPos( int orient, int pos, bool refresh = true ) = 0; virtual int GetScrollPos( int orient ) const = 0; virtual int GetScrollThumb( int orient ) const = 0; virtual int GetScrollRange( int orient ) const = 0; @@ -762,6 +766,10 @@ protected: // ctor void InitBase(); + // override this to change the default (i.e. used when no style is + // specified) border for the window class + virtual wxBorder GetDefaultBorder() const; + // get the default size for the new window if no explicit size given // FIXME why 20 and not 30, 10 or ...? static int WidthDefault(int w) { return w == -1 ? 20 : w; } @@ -861,12 +869,15 @@ private: // now include the declaration of wxWindow class // ---------------------------------------------------------------------------- +// include the declaration of the platform-specific class #if defined(__WXMSW__) #include "wx/msw/window.h" + #define wxWindowNative wxWindowMSW #elif defined(__WXMOTIF__) #include "wx/motif/window.h" #elif defined(__WXGTK__) #include "wx/gtk/window.h" + #define wxWindowNative wxWindowGTK #elif defined(__WXQT__) #include "wx/qt/window.h" #elif defined(__WXMAC__) @@ -875,6 +886,14 @@ private: #include "wx/os2/window.h" #endif +// for wxUniversal, we now derive the real wxWindow from wxWindow, +// for the native ports we just rename wxWindow into wxWindows +#if defined(__WXUNIVERSAL__) + #include "wx/univ/window.h" +#else + #define wxWindow wxWindowNative +#endif + // ---------------------------------------------------------------------------- // inline functions which couldn't be declared in the class body because of // forward dependencies @@ -889,7 +908,7 @@ inline wxWindow *wxWindowBase::GetGrandParent() const // global function // ---------------------------------------------------------------------------- -WXDLLEXPORT extern wxWindow* wxGetActiveWindow(); +WXDLLEXPORT extern wxWindow *wxGetActiveWindow(); // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() inline WXDLLEXPORT int NewControlId() { return wxWindowBase::NewControlId(); } diff --git a/samples/univ/univ.cpp b/samples/univ/univ.cpp index aef5f0c515..0b6de10279 100644 --- a/samples/univ/univ.cpp +++ b/samples/univ/univ.cpp @@ -131,7 +131,11 @@ END_EVENT_TABLE() bool MyUnivApp::OnInitGui() { +#ifdef __WXMSW__ m_colourBg = *wxLIGHT_GREY; +#else + m_colourBg = wxColour(0xd6d6d6); +#endif if ( argc > 1 ) { @@ -143,6 +147,8 @@ bool MyUnivApp::OnInitGui() // manually use the right colours if ( themeName == _T("gtk") ) m_colourBg = wxColour(0xd6d6d6); + else if ( themeName == _T("win32") ) + m_colourBg = *wxLIGHT_GREY; wxTheme::Set(theme); } diff --git a/src/common/ctrlcmn.cpp b/src/common/ctrlcmn.cpp index 602c5e6dd0..8ff69b938f 100644 --- a/src/common/ctrlcmn.cpp +++ b/src/common/ctrlcmn.cpp @@ -119,32 +119,6 @@ void wxControlBase::InitCommandEvent(wxCommandEvent& event) const } } -// ---------------------------------------------------------------------------- -// other stuff -// ---------------------------------------------------------------------------- - -void wxControlBase::SetBackground(const wxBitmap& bitmap, - int alignment, - wxStretch stretch) -{ -} - -wxBorder wxControlBase::GetBorder() const -{ - wxBorder border = (wxBorder)(m_windowStyle & wxBORDER_MASK); - if ( border == wxBORDER_DEFAULT ) - { - border = GetDefaultBorder(); - } - - return border; -} - -wxBorder wxControlBase::GetDefaultBorder() const -{ - return wxBORDER_NONE; -} - // ---------------------------------------------------------------------------- // wxStaticBitmap // ---------------------------------------------------------------------------- diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 05a5a12d64..23ae0e8d5f 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1473,3 +1473,23 @@ void wxWindowListNode::DeleteData() delete (wxWindow *)GetData(); } +// ---------------------------------------------------------------------------- +// borders +// ---------------------------------------------------------------------------- + +wxBorder wxWindowBase::GetBorder() const +{ + wxBorder border = (wxBorder)(m_windowStyle & wxBORDER_MASK); + if ( border == wxBORDER_DEFAULT ) + { + border = GetDefaultBorder(); + } + + return border; +} + +wxBorder wxWindowBase::GetDefaultBorder() const +{ + return wxBORDER_NONE; +} + diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 684057d25d..5866addee3 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -620,12 +620,12 @@ int wxEntryInitGui() { int retValue = 0; - if ( !wxTheApp->OnInitGui() ) - retValue = -1; - wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_widget_realize( wxRootWindow ); + if ( !wxTheApp->OnInitGui() ) + retValue = -1; + return retValue; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index c9ff4f88d6..9d475f43d9 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -198,15 +198,15 @@ extern wxCursor g_globalCursor; // mouse capture state: the window which has it and if the mouse is currently // inside it -static wxWindow *g_captureWindow = (wxWindow*) NULL; +static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL; static bool g_captureWindowHasMouse = FALSE; -/* extern */ wxWindow *g_focusWindow = (wxWindow*) NULL; +/* extern */ wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL; // the last window which had the focus - this is normally never NULL (except // if we never had focus at all) as even when g_focusWindow is NULL it still // keeps its previous value -static wxWindow *g_focusWindowLast = (wxWindow *)NULL; +static wxWindowGTK *g_focusWindowLast = (wxWindowGTK *)NULL; // if we detect that the app has got/lost the focus, we set this variable to // either TRUE or FALSE and an activate event will be sent during the next @@ -325,11 +325,11 @@ extern bool g_isIdle; //----------------------------------------------------------------------------- // returns the child of win which currently has focus or NULL if not found -static wxWindow *FindFocusedChild(wxWindow *win) +static wxWindowGTK *FindFocusedChild(wxWindowGTK *win) { - wxWindow *winFocus = wxWindow::FindFocus(); + wxWindowGTK *winFocus = wxWindowGTK::FindFocus(); if ( !winFocus ) - return (wxWindow *)NULL; + return (wxWindowGTK *)NULL; if ( winFocus == win ) return win; @@ -338,15 +338,15 @@ static wxWindow *FindFocusedChild(wxWindow *win) node; node = node->GetNext() ) { - wxWindow *child = FindFocusedChild(node->GetData()); + wxWindowGTK *child = FindFocusedChild(node->GetData()); if ( child ) return child; } - return (wxWindow *)NULL; + return (wxWindowGTK *)NULL; } -static void draw_frame( GtkWidget *widget, wxWindow *win ) +static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) { if (!win->m_hasVMT) return; @@ -435,7 +435,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) // "expose_event" of m_widget //----------------------------------------------------------------------------- -gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) +gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindowGTK *win ) { if (gdk_event->count > 0) return FALSE; @@ -448,7 +448,7 @@ gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_even // "draw" of m_widget //----------------------------------------------------------------------------- -static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win ) +static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win ) { draw_frame( widget, win ); } @@ -667,7 +667,9 @@ static long map_to_wx_keysym( KeySym keysym ) // "expose_event" of m_wxwindow //----------------------------------------------------------------------------- -static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) +static int gtk_window_expose_callback( GtkWidget *widget, + GdkEventExpose *gdk_event, + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -746,7 +748,9 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev There, we look for expose events ourselves whereas all other events are handled normally. */ -gint gtk_window_event_event_callback( GtkWidget *widget, GdkEventExpose *event, wxWindow *win ) +gint gtk_window_event_event_callback( GtkWidget *widget, + GdkEventExpose *event, + wxWindow *win ) { if (event->type == GDK_EXPOSE) { @@ -764,7 +768,7 @@ gint gtk_window_event_event_callback( GtkWidget *widget, GdkEventExpose *event, /* This callback is a complete replacement of the gtk_pizza_draw() function, which disabled. */ -static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) +static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -828,7 +832,9 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW // "key_press_event" from any window //----------------------------------------------------------------------------- -static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) +static gint gtk_window_key_press_callback( GtkWidget *widget, + GdkEventKey *gdk_event, + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -873,7 +879,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e #if wxUSE_ACCEL if (!ret) { - wxWindow *ancestor = win; + wxWindowGTK *ancestor = win; while (ancestor) { int command = ancestor->GetAcceleratorTable()->GetCommand( event ); @@ -950,7 +956,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e if ( (!ret) && (gdk_event->keyval == GDK_F10) ) { - wxWindow *ancestor = win; + wxWindowGTK *ancestor = win; while (ancestor) { if (wxIsKindOf(ancestor,wxFrame)) @@ -988,7 +994,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e // "key_release_event" from any window //----------------------------------------------------------------------------- -static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) +static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1078,7 +1084,7 @@ static void AdjustEventButtonState(wxMouseEvent& event) // "button_press_event" //----------------------------------------------------------------------------- -static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) +static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1181,7 +1187,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1252,7 +1258,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton // "button_release_event" //----------------------------------------------------------------------------- -static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) +static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1313,7 +1319,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1395,7 +1401,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, - wxWindow *win ) + wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1461,7 +1467,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1523,7 +1529,9 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, // "focus_in_event" //----------------------------------------------------------------------------- -static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) +static gint gtk_window_focus_in_callback( GtkWidget *widget, + GdkEvent *WXUNUSED(event), + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -1595,7 +1603,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED( // "focus_out_event" //----------------------------------------------------------------------------- -static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) +static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1610,11 +1618,11 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED // g_sendActivateEvent to -1 g_sendActivateEvent = 0; - wxWindow *winFocus = FindFocusedChild(win); + wxWindowGTK *winFocus = FindFocusedChild(win); if ( winFocus ) win = winFocus; - g_focusWindow = (wxWindow *)NULL; + g_focusWindow = (wxWindowGTK *)NULL; /* printf( "OnKillFocus from " ); @@ -1653,7 +1661,7 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED // "enter_notify_event" //----------------------------------------------------------------------------- -static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1692,7 +1700,7 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "leave_notify_event" //----------------------------------------------------------------------------- -static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1740,7 +1748,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- -static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) +static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1776,7 +1784,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) // "value_changed" from m_hAdjust //----------------------------------------------------------------------------- -static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) +static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1813,7 +1821,7 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) static gint gtk_scrollbar_button_press_callback( GtkRange *widget, GdkEventButton *gdk_event, - wxWindow *win) + wxWindowGTK *win) { DEBUG_MAIN_THREAD @@ -1833,7 +1841,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget, static gint gtk_scrollbar_button_release_callback( GtkRange *widget, GdkEventButton *WXUNUSED(gdk_event), - wxWindow *win) + wxWindowGTK *win) { DEBUG_MAIN_THREAD @@ -1879,7 +1887,8 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, wxWindow *wxWindowBase::FindFocus() { - return g_focusWindow; + // the cast is necessary when we compile in wxUniversal mode + return (wxWindow *)g_focusWindow; } //----------------------------------------------------------------------------- @@ -1953,7 +1962,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), static void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), - wxWindow* WXUNUSED_UNLESS_XIM(win) ) + wxWindowGTK* WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1982,7 +1991,7 @@ void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), static gint gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), - wxWindow * WXUNUSED_UNLESS_XIM(win) ) + wxWindowGTK * WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -2068,17 +2077,17 @@ gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), } //----------------------------------------------------------------------------- -// InsertChild for wxWindow. +// InsertChild for wxWindowGTK. //----------------------------------------------------------------------------- -/* Callback for wxWindow. This very strange beast has to be used because +/* Callback for wxWindowGTK. This very strange beast has to be used because * C++ has no virtual methods in a constructor. We have to emulate a * virtual function here as wxNotebook requires a different way to insert * a child in it. I had opted for creating a wxNotebookPage window class * which would have made this superfluous (such in the MDI window system), * but no-one was listening to me... */ -static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) +static void wxInsertChildInWindow( wxWindowGTK* parent, wxWindowGTK* child ) { /* the window might have been scrolled already, do we have to adapt the position */ @@ -2098,18 +2107,19 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) // global functions //----------------------------------------------------------------------------- -wxWindow* wxGetActiveWindow() +wxWindow *wxGetActiveWindow() { - return g_focusWindow; + // the cast is necessary when we compile in wxUniversal mode + return (wxWindow *)g_focusWindow; } //----------------------------------------------------------------------------- -// wxWindow +// wxWindowGTK //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) +IMPLEMENT_DYNAMIC_CLASS(wxWindowGTK, wxWindowBase) -void wxWindow::Init() +void wxWindowGTK::Init() { // common init InitBase(); @@ -2163,28 +2173,34 @@ void wxWindow::Init() #endif } -wxWindow::wxWindow() +wxWindowGTK::wxWindowGTK() { Init(); } -wxWindow::wxWindow( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +wxWindowGTK::wxWindowGTK( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { Init(); Create( parent, id, pos, size, style, name ); } -bool wxWindow::Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +bool wxWindowGTK::Create( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { - wxFAIL_MSG( wxT("wxWindow creation failed") ); + wxFAIL_MSG( wxT("wxWindowGTK creation failed") ); return FALSE; } @@ -2307,7 +2323,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, return TRUE; } -wxWindow::~wxWindow() +wxWindowGTK::~wxWindowGTK() { m_isBeingDeleted = TRUE; m_hasVMT = FALSE; @@ -2350,7 +2366,7 @@ wxWindow::~wxWindow() } } -bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size ) +bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ) { wxCHECK_MSG( !m_needParent || parent, FALSE, wxT("Need complete parent.") ); @@ -2382,7 +2398,7 @@ bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize return TRUE; } -void wxWindow::PostCreation() +void wxWindowGTK::PostCreation() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -2461,7 +2477,7 @@ void wxWindow::PostCreation() m_hasVMT = TRUE; } -void wxWindow::ConnectWidget( GtkWidget *widget ) +void wxWindowGTK::ConnectWidget( GtkWidget *widget ) { gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); @@ -2485,7 +2501,7 @@ void wxWindow::ConnectWidget( GtkWidget *widget ) GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); } -bool wxWindow::Destroy() +bool wxWindowGTK::Destroy() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -2494,15 +2510,15 @@ bool wxWindow::Destroy() return wxWindowBase::Destroy(); } -void wxWindow::DoMoveWindow(int x, int y, int width, int height) +void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) { gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height ); } -void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) +void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - wxASSERT_MSG( (m_parent != NULL), wxT("wxWindow::SetSize requires parent.\n") ); + wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") ); if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; @@ -2593,7 +2609,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } -void wxWindow::OnInternalIdle() +void wxWindowGTK::OnInternalIdle() { if ( g_sendActivateEvent != -1 ) { @@ -2602,7 +2618,7 @@ void wxWindow::OnInternalIdle() // do it only once g_sendActivateEvent = -1; - wxTheApp->SetActive(activate, g_focusWindowLast); + wxTheApp->SetActive(activate, (wxWindow *)g_focusWindowLast); wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId()); event.SetEventObject(this); @@ -2647,7 +2663,7 @@ void wxWindow::OnInternalIdle() UpdateWindowUI(); } -void wxWindow::DoGetSize( int *width, int *height ) const +void wxWindowGTK::DoGetSize( int *width, int *height ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2655,7 +2671,7 @@ void wxWindow::DoGetSize( int *width, int *height ) const if (height) (*height) = m_height; } -void wxWindow::DoSetClientSize( int width, int height ) +void wxWindowGTK::DoSetClientSize( int width, int height ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2718,7 +2734,7 @@ void wxWindow::DoSetClientSize( int width, int height ) } } -void wxWindow::DoGetClientSize( int *width, int *height ) const +void wxWindowGTK::DoGetClientSize( int *width, int *height ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2783,7 +2799,7 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const } } -void wxWindow::DoGetPosition( int *x, int *y ) const +void wxWindowGTK::DoGetPosition( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2800,7 +2816,7 @@ void wxWindow::DoGetPosition( int *x, int *y ) const if (y) (*y) = m_y - dy; } -void wxWindow::DoClientToScreen( int *x, int *y ) const +void wxWindowGTK::DoClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2829,7 +2845,7 @@ void wxWindow::DoClientToScreen( int *x, int *y ) const if (y) *y += org_y; } -void wxWindow::DoScreenToClient( int *x, int *y ) const +void wxWindowGTK::DoScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2858,7 +2874,7 @@ void wxWindow::DoScreenToClient( int *x, int *y ) const if (y) *y -= org_y; } -bool wxWindow::Show( bool show ) +bool wxWindowGTK::Show( bool show ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -2876,7 +2892,7 @@ bool wxWindow::Show( bool show ) return TRUE; } -bool wxWindow::Enable( bool enable ) +bool wxWindowGTK::Enable( bool enable ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -2893,7 +2909,7 @@ bool wxWindow::Enable( bool enable ) return TRUE; } -int wxWindow::GetCharHeight() const +int wxWindowGTK::GetCharHeight() const { wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); @@ -2904,7 +2920,7 @@ int wxWindow::GetCharHeight() const return font->ascent + font->descent; } -int wxWindow::GetCharWidth() const +int wxWindowGTK::GetCharWidth() const { wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); @@ -2915,7 +2931,7 @@ int wxWindow::GetCharWidth() const return gdk_string_width( font, "H" ); } -void wxWindow::GetTextExtent( const wxString& string, +void wxWindowGTK::GetTextExtent( const wxString& string, int *x, int *y, int *descent, @@ -2934,7 +2950,7 @@ void wxWindow::GetTextExtent( const wxString& string, if (externalLeading) (*externalLeading) = 0; // ?? } -void wxWindow::SetFocus() +void wxWindowGTK::SetFocus() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2962,17 +2978,17 @@ void wxWindow::SetFocus() } } -bool wxWindow::AcceptsFocus() const +bool wxWindowGTK::AcceptsFocus() const { return m_acceptsFocus && wxWindowBase::AcceptsFocus(); } -bool wxWindow::Reparent( wxWindowBase *newParentBase ) +bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - wxWindow *oldParent = m_parent, - *newParent = (wxWindow *)newParentBase; + wxWindowGTK *oldParent = m_parent, + *newParent = (wxWindowGTK *)newParentBase; wxASSERT( GTK_IS_WIDGET(m_widget) ); @@ -3003,7 +3019,7 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase ) return TRUE; } -void wxWindow::DoAddChild(wxWindow *child) +void wxWindowGTK::DoAddChild(wxWindowGTK *child) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -3018,7 +3034,7 @@ void wxWindow::DoAddChild(wxWindow *child) (*m_insertCallback)(this, child); } -void wxWindow::Raise() +void wxWindowGTK::Raise() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3027,7 +3043,7 @@ void wxWindow::Raise() gdk_window_raise( m_widget->window ); } -void wxWindow::Lower() +void wxWindowGTK::Lower() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3036,7 +3052,7 @@ void wxWindow::Lower() gdk_window_lower( m_widget->window ); } -bool wxWindow::SetCursor( const wxCursor &cursor ) +bool wxWindowGTK::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -3052,7 +3068,7 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) return wxWindowBase::SetCursor( cursor ); } -void wxWindow::WarpPointer( int x, int y ) +void wxWindowGTK::WarpPointer( int x, int y ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3069,7 +3085,7 @@ void wxWindow::WarpPointer( int x, int y ) gdk_window_warp_pointer( window, x, y ); } -void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) +void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) { if (!m_widget) return; if (!m_widget->window) return; @@ -3111,8 +3127,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_event.area.y = 0; gdk_event.area.width = m_wxwindow->allocation.width; gdk_event.area.height = m_wxwindow->allocation.height; - gtk_window_expose_callback( m_wxwindow, &gdk_event, this ); - + gtk_window_expose_callback( m_wxwindow, &gdk_event, (wxWindow *)this ); } else { @@ -3147,7 +3162,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_event.area.y = rect->y; gdk_event.area.width = rect->width; gdk_event.area.height = rect->height; - gtk_window_expose_callback( m_wxwindow, &gdk_event, this ); + gtk_window_expose_callback( m_wxwindow, &gdk_event, (wxWindow *)this ); } else { @@ -3161,7 +3176,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) } } -void wxWindow::Clear() +void wxWindowGTK::Clear() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3174,7 +3189,7 @@ void wxWindow::Clear() } #if wxUSE_TOOLTIPS -void wxWindow::DoSetToolTip( wxToolTip *tip ) +void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) { wxWindowBase::DoSetToolTip(tip); @@ -3182,13 +3197,13 @@ void wxWindow::DoSetToolTip( wxToolTip *tip ) m_tooltip->Apply( this ); } -void wxWindow::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) +void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) { gtk_tooltips_set_tip( tips, GetConnectWidget(), wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); } #endif // wxUSE_TOOLTIPS -bool wxWindow::SetBackgroundColour( const wxColour &colour ) +bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3229,7 +3244,7 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) return TRUE; } -bool wxWindow::SetForegroundColour( const wxColour &colour ) +bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3259,7 +3274,7 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) return TRUE; } -GtkStyle *wxWindow::GetWidgetStyle() +GtkStyle *wxWindowGTK::GetWidgetStyle() { if (m_widgetStyle) { @@ -3293,7 +3308,7 @@ GtkStyle *wxWindow::GetWidgetStyle() return m_widgetStyle; } -void wxWindow::SetWidgetStyle() +void wxWindowGTK::SetWidgetStyle() { #if DISABLE_STYLE_IF_BROKEN_THEM if (m_widget->style->engine_data) @@ -3382,7 +3397,7 @@ void wxWindow::SetWidgetStyle() } } -void wxWindow::ApplyWidgetStyle() +void wxWindowGTK::ApplyWidgetStyle() { } @@ -3397,7 +3412,7 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting *is_waiting = FALSE; } -static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) +static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win ) { menu->SetInvokingWindow( win ); wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); @@ -3418,14 +3433,14 @@ static gint gs_pop_y = 0; static void pop_pos_callback( GtkMenu * WXUNUSED(menu), gint *x, gint *y, - wxWindow *win ) + wxWindowGTK *win ) { win->ClientToScreen( &gs_pop_x, &gs_pop_y ); *x = gs_pop_x; *y = gs_pop_y; } -bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) +bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3466,7 +3481,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) #if wxUSE_DRAG_AND_DROP -void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) +void wxWindowGTK::SetDropTarget( wxDropTarget *dropTarget ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3482,7 +3497,7 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) #endif // wxUSE_DRAG_AND_DROP -GtkWidget* wxWindow::GetConnectWidget() +GtkWidget* wxWindowGTK::GetConnectWidget() { GtkWidget *connect_widget = m_widget; if (m_wxwindow) connect_widget = m_wxwindow; @@ -3490,7 +3505,7 @@ GtkWidget* wxWindow::GetConnectWidget() return connect_widget; } -bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) +bool wxWindowGTK::IsOwnGtkWindow( GdkWindow *window ) { if (m_wxwindow) return (window == GTK_PIZZA(m_wxwindow)->bin_window); @@ -3498,7 +3513,7 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) return (window == m_widget->window); } -bool wxWindow::SetFont( const wxFont &font ) +bool wxWindowGTK::SetFont( const wxFont &font ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3522,7 +3537,7 @@ bool wxWindow::SetFont( const wxFont &font ) return TRUE; } -void wxWindow::CaptureMouse() +void wxWindowGTK::CaptureMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3553,7 +3568,7 @@ void wxWindow::CaptureMouse() g_captureWindowHasMouse = TRUE; } -void wxWindow::ReleaseMouse() +void wxWindowGTK::ReleaseMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3569,15 +3584,15 @@ void wxWindow::ReleaseMouse() return; gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); - g_captureWindow = (wxWindow*) NULL; + g_captureWindow = (wxWindowGTK*) NULL; } -bool wxWindow::IsRetained() const +bool wxWindowGTK::IsRetained() const { return FALSE; } -void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, +void wxWindowGTK::SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3641,7 +3656,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); } -void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) +void wxWindowGTK::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3693,7 +3708,7 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) } } -int wxWindow::GetScrollThumb( int orient ) const +int wxWindowGTK::GetScrollThumb( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3705,7 +3720,7 @@ int wxWindow::GetScrollThumb( int orient ) const return (int)(m_vAdjust->page_size+0.5); } -int wxWindow::GetScrollPos( int orient ) const +int wxWindowGTK::GetScrollPos( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3717,7 +3732,7 @@ int wxWindow::GetScrollPos( int orient ) const return (int)(m_vAdjust->value+0.5); } -int wxWindow::GetScrollRange( int orient ) const +int wxWindowGTK::GetScrollRange( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3729,7 +3744,7 @@ int wxWindow::GetScrollRange( int orient ) const return (int)(m_vAdjust->upper+0.5); } -void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) +void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 684057d25d..5866addee3 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -620,12 +620,12 @@ int wxEntryInitGui() { int retValue = 0; - if ( !wxTheApp->OnInitGui() ) - retValue = -1; - wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_widget_realize( wxRootWindow ); + if ( !wxTheApp->OnInitGui() ) + retValue = -1; + return retValue; } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index c9ff4f88d6..9d475f43d9 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -198,15 +198,15 @@ extern wxCursor g_globalCursor; // mouse capture state: the window which has it and if the mouse is currently // inside it -static wxWindow *g_captureWindow = (wxWindow*) NULL; +static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL; static bool g_captureWindowHasMouse = FALSE; -/* extern */ wxWindow *g_focusWindow = (wxWindow*) NULL; +/* extern */ wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL; // the last window which had the focus - this is normally never NULL (except // if we never had focus at all) as even when g_focusWindow is NULL it still // keeps its previous value -static wxWindow *g_focusWindowLast = (wxWindow *)NULL; +static wxWindowGTK *g_focusWindowLast = (wxWindowGTK *)NULL; // if we detect that the app has got/lost the focus, we set this variable to // either TRUE or FALSE and an activate event will be sent during the next @@ -325,11 +325,11 @@ extern bool g_isIdle; //----------------------------------------------------------------------------- // returns the child of win which currently has focus or NULL if not found -static wxWindow *FindFocusedChild(wxWindow *win) +static wxWindowGTK *FindFocusedChild(wxWindowGTK *win) { - wxWindow *winFocus = wxWindow::FindFocus(); + wxWindowGTK *winFocus = wxWindowGTK::FindFocus(); if ( !winFocus ) - return (wxWindow *)NULL; + return (wxWindowGTK *)NULL; if ( winFocus == win ) return win; @@ -338,15 +338,15 @@ static wxWindow *FindFocusedChild(wxWindow *win) node; node = node->GetNext() ) { - wxWindow *child = FindFocusedChild(node->GetData()); + wxWindowGTK *child = FindFocusedChild(node->GetData()); if ( child ) return child; } - return (wxWindow *)NULL; + return (wxWindowGTK *)NULL; } -static void draw_frame( GtkWidget *widget, wxWindow *win ) +static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) { if (!win->m_hasVMT) return; @@ -435,7 +435,7 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) // "expose_event" of m_widget //----------------------------------------------------------------------------- -gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) +gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindowGTK *win ) { if (gdk_event->count > 0) return FALSE; @@ -448,7 +448,7 @@ gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_even // "draw" of m_widget //----------------------------------------------------------------------------- -static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win ) +static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win ) { draw_frame( widget, win ); } @@ -667,7 +667,9 @@ static long map_to_wx_keysym( KeySym keysym ) // "expose_event" of m_wxwindow //----------------------------------------------------------------------------- -static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) +static int gtk_window_expose_callback( GtkWidget *widget, + GdkEventExpose *gdk_event, + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -746,7 +748,9 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev There, we look for expose events ourselves whereas all other events are handled normally. */ -gint gtk_window_event_event_callback( GtkWidget *widget, GdkEventExpose *event, wxWindow *win ) +gint gtk_window_event_event_callback( GtkWidget *widget, + GdkEventExpose *event, + wxWindow *win ) { if (event->type == GDK_EXPOSE) { @@ -764,7 +768,7 @@ gint gtk_window_event_event_callback( GtkWidget *widget, GdkEventExpose *event, /* This callback is a complete replacement of the gtk_pizza_draw() function, which disabled. */ -static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) +static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -828,7 +832,9 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW // "key_press_event" from any window //----------------------------------------------------------------------------- -static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) +static gint gtk_window_key_press_callback( GtkWidget *widget, + GdkEventKey *gdk_event, + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -873,7 +879,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e #if wxUSE_ACCEL if (!ret) { - wxWindow *ancestor = win; + wxWindowGTK *ancestor = win; while (ancestor) { int command = ancestor->GetAcceleratorTable()->GetCommand( event ); @@ -950,7 +956,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e if ( (!ret) && (gdk_event->keyval == GDK_F10) ) { - wxWindow *ancestor = win; + wxWindowGTK *ancestor = win; while (ancestor) { if (wxIsKindOf(ancestor,wxFrame)) @@ -988,7 +994,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e // "key_release_event" from any window //----------------------------------------------------------------------------- -static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) +static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1078,7 +1084,7 @@ static void AdjustEventButtonState(wxMouseEvent& event) // "button_press_event" //----------------------------------------------------------------------------- -static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) +static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1181,7 +1187,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1252,7 +1258,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton // "button_release_event" //----------------------------------------------------------------------------- -static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) +static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1313,7 +1319,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1395,7 +1401,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, - wxWindow *win ) + wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1461,7 +1467,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, wxNode *node = win->GetChildren().First(); while (node) { - wxWindow *child = (wxWindow*)node->Data(); + wxWindowGTK *child = (wxWindowGTK*)node->Data(); node = node->Next(); if (!child->IsShown()) @@ -1523,7 +1529,9 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, // "focus_in_event" //----------------------------------------------------------------------------- -static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) +static gint gtk_window_focus_in_callback( GtkWidget *widget, + GdkEvent *WXUNUSED(event), + wxWindow *win ) { DEBUG_MAIN_THREAD @@ -1595,7 +1603,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED( // "focus_out_event" //----------------------------------------------------------------------------- -static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) +static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1610,11 +1618,11 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED // g_sendActivateEvent to -1 g_sendActivateEvent = 0; - wxWindow *winFocus = FindFocusedChild(win); + wxWindowGTK *winFocus = FindFocusedChild(win); if ( winFocus ) win = winFocus; - g_focusWindow = (wxWindow *)NULL; + g_focusWindow = (wxWindowGTK *)NULL; /* printf( "OnKillFocus from " ); @@ -1653,7 +1661,7 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED // "enter_notify_event" //----------------------------------------------------------------------------- -static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1692,7 +1700,7 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "leave_notify_event" //----------------------------------------------------------------------------- -static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) +static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1740,7 +1748,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ // "value_changed" from m_vAdjust //----------------------------------------------------------------------------- -static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) +static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1776,7 +1784,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) // "value_changed" from m_hAdjust //----------------------------------------------------------------------------- -static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) +static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win ) { DEBUG_MAIN_THREAD @@ -1813,7 +1821,7 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) static gint gtk_scrollbar_button_press_callback( GtkRange *widget, GdkEventButton *gdk_event, - wxWindow *win) + wxWindowGTK *win) { DEBUG_MAIN_THREAD @@ -1833,7 +1841,7 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget, static gint gtk_scrollbar_button_release_callback( GtkRange *widget, GdkEventButton *WXUNUSED(gdk_event), - wxWindow *win) + wxWindowGTK *win) { DEBUG_MAIN_THREAD @@ -1879,7 +1887,8 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget, wxWindow *wxWindowBase::FindFocus() { - return g_focusWindow; + // the cast is necessary when we compile in wxUniversal mode + return (wxWindow *)g_focusWindow; } //----------------------------------------------------------------------------- @@ -1953,7 +1962,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), static void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), - wxWindow* WXUNUSED_UNLESS_XIM(win) ) + wxWindowGTK* WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1982,7 +1991,7 @@ void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), static gint gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), - wxWindow * WXUNUSED_UNLESS_XIM(win) ) + wxWindowGTK * WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -2068,17 +2077,17 @@ gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), } //----------------------------------------------------------------------------- -// InsertChild for wxWindow. +// InsertChild for wxWindowGTK. //----------------------------------------------------------------------------- -/* Callback for wxWindow. This very strange beast has to be used because +/* Callback for wxWindowGTK. This very strange beast has to be used because * C++ has no virtual methods in a constructor. We have to emulate a * virtual function here as wxNotebook requires a different way to insert * a child in it. I had opted for creating a wxNotebookPage window class * which would have made this superfluous (such in the MDI window system), * but no-one was listening to me... */ -static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) +static void wxInsertChildInWindow( wxWindowGTK* parent, wxWindowGTK* child ) { /* the window might have been scrolled already, do we have to adapt the position */ @@ -2098,18 +2107,19 @@ static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) // global functions //----------------------------------------------------------------------------- -wxWindow* wxGetActiveWindow() +wxWindow *wxGetActiveWindow() { - return g_focusWindow; + // the cast is necessary when we compile in wxUniversal mode + return (wxWindow *)g_focusWindow; } //----------------------------------------------------------------------------- -// wxWindow +// wxWindowGTK //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) +IMPLEMENT_DYNAMIC_CLASS(wxWindowGTK, wxWindowBase) -void wxWindow::Init() +void wxWindowGTK::Init() { // common init InitBase(); @@ -2163,28 +2173,34 @@ void wxWindow::Init() #endif } -wxWindow::wxWindow() +wxWindowGTK::wxWindowGTK() { Init(); } -wxWindow::wxWindow( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +wxWindowGTK::wxWindowGTK( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { Init(); Create( parent, id, pos, size, style, name ); } -bool wxWindow::Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) +bool wxWindowGTK::Create( wxWindow *parent, + wxWindowID id, + const wxPoint &pos, + const wxSize &size, + long style, + const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { - wxFAIL_MSG( wxT("wxWindow creation failed") ); + wxFAIL_MSG( wxT("wxWindowGTK creation failed") ); return FALSE; } @@ -2307,7 +2323,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, return TRUE; } -wxWindow::~wxWindow() +wxWindowGTK::~wxWindowGTK() { m_isBeingDeleted = TRUE; m_hasVMT = FALSE; @@ -2350,7 +2366,7 @@ wxWindow::~wxWindow() } } -bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size ) +bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ) { wxCHECK_MSG( !m_needParent || parent, FALSE, wxT("Need complete parent.") ); @@ -2382,7 +2398,7 @@ bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize return TRUE; } -void wxWindow::PostCreation() +void wxWindowGTK::PostCreation() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -2461,7 +2477,7 @@ void wxWindow::PostCreation() m_hasVMT = TRUE; } -void wxWindow::ConnectWidget( GtkWidget *widget ) +void wxWindowGTK::ConnectWidget( GtkWidget *widget ) { gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); @@ -2485,7 +2501,7 @@ void wxWindow::ConnectWidget( GtkWidget *widget ) GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); } -bool wxWindow::Destroy() +bool wxWindowGTK::Destroy() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -2494,15 +2510,15 @@ bool wxWindow::Destroy() return wxWindowBase::Destroy(); } -void wxWindow::DoMoveWindow(int x, int y, int width, int height) +void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) { gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height ); } -void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) +void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - wxASSERT_MSG( (m_parent != NULL), wxT("wxWindow::SetSize requires parent.\n") ); + wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") ); if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; @@ -2593,7 +2609,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_resizing = FALSE; } -void wxWindow::OnInternalIdle() +void wxWindowGTK::OnInternalIdle() { if ( g_sendActivateEvent != -1 ) { @@ -2602,7 +2618,7 @@ void wxWindow::OnInternalIdle() // do it only once g_sendActivateEvent = -1; - wxTheApp->SetActive(activate, g_focusWindowLast); + wxTheApp->SetActive(activate, (wxWindow *)g_focusWindowLast); wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId()); event.SetEventObject(this); @@ -2647,7 +2663,7 @@ void wxWindow::OnInternalIdle() UpdateWindowUI(); } -void wxWindow::DoGetSize( int *width, int *height ) const +void wxWindowGTK::DoGetSize( int *width, int *height ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2655,7 +2671,7 @@ void wxWindow::DoGetSize( int *width, int *height ) const if (height) (*height) = m_height; } -void wxWindow::DoSetClientSize( int width, int height ) +void wxWindowGTK::DoSetClientSize( int width, int height ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2718,7 +2734,7 @@ void wxWindow::DoSetClientSize( int width, int height ) } } -void wxWindow::DoGetClientSize( int *width, int *height ) const +void wxWindowGTK::DoGetClientSize( int *width, int *height ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2783,7 +2799,7 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const } } -void wxWindow::DoGetPosition( int *x, int *y ) const +void wxWindowGTK::DoGetPosition( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2800,7 +2816,7 @@ void wxWindow::DoGetPosition( int *x, int *y ) const if (y) (*y) = m_y - dy; } -void wxWindow::DoClientToScreen( int *x, int *y ) const +void wxWindowGTK::DoClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2829,7 +2845,7 @@ void wxWindow::DoClientToScreen( int *x, int *y ) const if (y) *y += org_y; } -void wxWindow::DoScreenToClient( int *x, int *y ) const +void wxWindowGTK::DoScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2858,7 +2874,7 @@ void wxWindow::DoScreenToClient( int *x, int *y ) const if (y) *y -= org_y; } -bool wxWindow::Show( bool show ) +bool wxWindowGTK::Show( bool show ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -2876,7 +2892,7 @@ bool wxWindow::Show( bool show ) return TRUE; } -bool wxWindow::Enable( bool enable ) +bool wxWindowGTK::Enable( bool enable ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -2893,7 +2909,7 @@ bool wxWindow::Enable( bool enable ) return TRUE; } -int wxWindow::GetCharHeight() const +int wxWindowGTK::GetCharHeight() const { wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); @@ -2904,7 +2920,7 @@ int wxWindow::GetCharHeight() const return font->ascent + font->descent; } -int wxWindow::GetCharWidth() const +int wxWindowGTK::GetCharWidth() const { wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); @@ -2915,7 +2931,7 @@ int wxWindow::GetCharWidth() const return gdk_string_width( font, "H" ); } -void wxWindow::GetTextExtent( const wxString& string, +void wxWindowGTK::GetTextExtent( const wxString& string, int *x, int *y, int *descent, @@ -2934,7 +2950,7 @@ void wxWindow::GetTextExtent( const wxString& string, if (externalLeading) (*externalLeading) = 0; // ?? } -void wxWindow::SetFocus() +void wxWindowGTK::SetFocus() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -2962,17 +2978,17 @@ void wxWindow::SetFocus() } } -bool wxWindow::AcceptsFocus() const +bool wxWindowGTK::AcceptsFocus() const { return m_acceptsFocus && wxWindowBase::AcceptsFocus(); } -bool wxWindow::Reparent( wxWindowBase *newParentBase ) +bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - wxWindow *oldParent = m_parent, - *newParent = (wxWindow *)newParentBase; + wxWindowGTK *oldParent = m_parent, + *newParent = (wxWindowGTK *)newParentBase; wxASSERT( GTK_IS_WIDGET(m_widget) ); @@ -3003,7 +3019,7 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase ) return TRUE; } -void wxWindow::DoAddChild(wxWindow *child) +void wxWindowGTK::DoAddChild(wxWindowGTK *child) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -3018,7 +3034,7 @@ void wxWindow::DoAddChild(wxWindow *child) (*m_insertCallback)(this, child); } -void wxWindow::Raise() +void wxWindowGTK::Raise() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3027,7 +3043,7 @@ void wxWindow::Raise() gdk_window_raise( m_widget->window ); } -void wxWindow::Lower() +void wxWindowGTK::Lower() { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3036,7 +3052,7 @@ void wxWindow::Lower() gdk_window_lower( m_widget->window ); } -bool wxWindow::SetCursor( const wxCursor &cursor ) +bool wxWindowGTK::SetCursor( const wxCursor &cursor ) { wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); @@ -3052,7 +3068,7 @@ bool wxWindow::SetCursor( const wxCursor &cursor ) return wxWindowBase::SetCursor( cursor ); } -void wxWindow::WarpPointer( int x, int y ) +void wxWindowGTK::WarpPointer( int x, int y ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); @@ -3069,7 +3085,7 @@ void wxWindow::WarpPointer( int x, int y ) gdk_window_warp_pointer( window, x, y ); } -void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) +void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) { if (!m_widget) return; if (!m_widget->window) return; @@ -3111,8 +3127,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_event.area.y = 0; gdk_event.area.width = m_wxwindow->allocation.width; gdk_event.area.height = m_wxwindow->allocation.height; - gtk_window_expose_callback( m_wxwindow, &gdk_event, this ); - + gtk_window_expose_callback( m_wxwindow, &gdk_event, (wxWindow *)this ); } else { @@ -3147,7 +3162,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_event.area.y = rect->y; gdk_event.area.width = rect->width; gdk_event.area.height = rect->height; - gtk_window_expose_callback( m_wxwindow, &gdk_event, this ); + gtk_window_expose_callback( m_wxwindow, &gdk_event, (wxWindow *)this ); } else { @@ -3161,7 +3176,7 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) } } -void wxWindow::Clear() +void wxWindowGTK::Clear() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3174,7 +3189,7 @@ void wxWindow::Clear() } #if wxUSE_TOOLTIPS -void wxWindow::DoSetToolTip( wxToolTip *tip ) +void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) { wxWindowBase::DoSetToolTip(tip); @@ -3182,13 +3197,13 @@ void wxWindow::DoSetToolTip( wxToolTip *tip ) m_tooltip->Apply( this ); } -void wxWindow::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) +void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) { gtk_tooltips_set_tip( tips, GetConnectWidget(), wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); } #endif // wxUSE_TOOLTIPS -bool wxWindow::SetBackgroundColour( const wxColour &colour ) +bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3229,7 +3244,7 @@ bool wxWindow::SetBackgroundColour( const wxColour &colour ) return TRUE; } -bool wxWindow::SetForegroundColour( const wxColour &colour ) +bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3259,7 +3274,7 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) return TRUE; } -GtkStyle *wxWindow::GetWidgetStyle() +GtkStyle *wxWindowGTK::GetWidgetStyle() { if (m_widgetStyle) { @@ -3293,7 +3308,7 @@ GtkStyle *wxWindow::GetWidgetStyle() return m_widgetStyle; } -void wxWindow::SetWidgetStyle() +void wxWindowGTK::SetWidgetStyle() { #if DISABLE_STYLE_IF_BROKEN_THEM if (m_widget->style->engine_data) @@ -3382,7 +3397,7 @@ void wxWindow::SetWidgetStyle() } } -void wxWindow::ApplyWidgetStyle() +void wxWindowGTK::ApplyWidgetStyle() { } @@ -3397,7 +3412,7 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting *is_waiting = FALSE; } -static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) +static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win ) { menu->SetInvokingWindow( win ); wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); @@ -3418,14 +3433,14 @@ static gint gs_pop_y = 0; static void pop_pos_callback( GtkMenu * WXUNUSED(menu), gint *x, gint *y, - wxWindow *win ) + wxWindowGTK *win ) { win->ClientToScreen( &gs_pop_x, &gs_pop_y ); *x = gs_pop_x; *y = gs_pop_y; } -bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) +bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3466,7 +3481,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) #if wxUSE_DRAG_AND_DROP -void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) +void wxWindowGTK::SetDropTarget( wxDropTarget *dropTarget ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3482,7 +3497,7 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) #endif // wxUSE_DRAG_AND_DROP -GtkWidget* wxWindow::GetConnectWidget() +GtkWidget* wxWindowGTK::GetConnectWidget() { GtkWidget *connect_widget = m_widget; if (m_wxwindow) connect_widget = m_wxwindow; @@ -3490,7 +3505,7 @@ GtkWidget* wxWindow::GetConnectWidget() return connect_widget; } -bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) +bool wxWindowGTK::IsOwnGtkWindow( GdkWindow *window ) { if (m_wxwindow) return (window == GTK_PIZZA(m_wxwindow)->bin_window); @@ -3498,7 +3513,7 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) return (window == m_widget->window); } -bool wxWindow::SetFont( const wxFont &font ) +bool wxWindowGTK::SetFont( const wxFont &font ) { wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); @@ -3522,7 +3537,7 @@ bool wxWindow::SetFont( const wxFont &font ) return TRUE; } -void wxWindow::CaptureMouse() +void wxWindowGTK::CaptureMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3553,7 +3568,7 @@ void wxWindow::CaptureMouse() g_captureWindowHasMouse = TRUE; } -void wxWindow::ReleaseMouse() +void wxWindowGTK::ReleaseMouse() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3569,15 +3584,15 @@ void wxWindow::ReleaseMouse() return; gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); - g_captureWindow = (wxWindow*) NULL; + g_captureWindow = (wxWindowGTK*) NULL; } -bool wxWindow::IsRetained() const +bool wxWindowGTK::IsRetained() const { return FALSE; } -void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, +void wxWindowGTK::SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3641,7 +3656,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); } -void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) +void wxWindowGTK::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -3693,7 +3708,7 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) } } -int wxWindow::GetScrollThumb( int orient ) const +int wxWindowGTK::GetScrollThumb( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3705,7 +3720,7 @@ int wxWindow::GetScrollThumb( int orient ) const return (int)(m_vAdjust->page_size+0.5); } -int wxWindow::GetScrollPos( int orient ) const +int wxWindowGTK::GetScrollPos( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3717,7 +3732,7 @@ int wxWindow::GetScrollPos( int orient ) const return (int)(m_vAdjust->value+0.5); } -int wxWindow::GetScrollRange( int orient ) const +int wxWindowGTK::GetScrollRange( int orient ) const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); @@ -3729,7 +3744,7 @@ int wxWindow::GetScrollRange( int orient ) const return (int)(m_vAdjust->upper+0.5); } -void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) +void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); diff --git a/src/univ/control.cpp b/src/univ/control.cpp index 5419a3fd96..ee360ee1b2 100644 --- a/src/univ/control.cpp +++ b/src/univ/control.cpp @@ -53,9 +53,6 @@ BEGIN_EVENT_TABLE(wxControl, wxControlBase) EVT_SET_FOCUS(wxControl::OnFocus) EVT_KILL_FOCUS(wxControl::OnFocus) - - EVT_PAINT(wxControl::OnPaint) - EVT_ERASE_BACKGROUND(wxControl::OnErase) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -65,7 +62,6 @@ END_EVENT_TABLE() void wxControl::Init() { m_indexAccel = -1; - m_isCurrent = FALSE; } bool wxControl::Create(wxWindow *parent, @@ -86,70 +82,6 @@ bool wxControl::Create(wxWindow *parent, return TRUE; } -// ---------------------------------------------------------------------------- -// state flags -// ---------------------------------------------------------------------------- - -bool wxControl::IsFocused() const -{ - wxControl *self = wxConstCast(this, wxControl); - return self->FindFocus() == self; -} - -bool wxControl::IsPressed() const -{ - return FALSE; -} - -bool wxControl::IsDefault() const -{ - return FALSE; -} - -bool wxControl::IsCurrent() const -{ - return m_isCurrent; -} - -void wxControl::SetCurrent(bool doit) -{ - m_isCurrent = doit; -} - -int wxControl::GetStateFlags() const -{ - int flags = 0; - if ( !IsEnabled() ) - flags |= wxCONTROL_DISABLED; - - // the following states are only possible if our application is active - if - // it is not, even our default/focused controls shouldn't appear as such - if ( wxTheApp->IsActive() ) - { - if ( IsCurrent() ) - flags |= wxCONTROL_CURRENT; - if ( IsFocused() ) - flags |= wxCONTROL_FOCUSED; - if ( IsPressed() ) - flags |= wxCONTROL_PRESSED; - if ( IsDefault() ) - flags |= wxCONTROL_ISDEFAULT; - } - - return flags; -} - -// ---------------------------------------------------------------------------- -// size -// ---------------------------------------------------------------------------- - -wxSize wxControl::AdjustSize(const wxSize& size) const -{ - wxSize sz = size; - wxTheme::Get()->GetRenderer()->AdjustSize(&sz, this); - return sz; -} - // ---------------------------------------------------------------------------- // mnemonics handling // ---------------------------------------------------------------------------- @@ -197,81 +129,6 @@ wxString wxControl::GetLabel() const return m_label; } -// ---------------------------------------------------------------------------- -// background pixmap -// ---------------------------------------------------------------------------- - -void wxControl::SetBackground(const wxBitmap& bitmap, - int alignment, - wxStretch stretch) -{ - m_bitmapBg = bitmap; - m_alignBgBitmap = alignment; - m_stretchBgBitmap = stretch; -} - -const wxBitmap& wxControl::GetBackgroundBitmap(int *alignment, - wxStretch *stretch) const -{ - if ( m_bitmapBg.Ok() ) - { - if ( alignment ) - *alignment = m_alignBgBitmap; - if ( stretch ) - *stretch = m_stretchBgBitmap; - } - - return m_bitmapBg; -} - -// ---------------------------------------------------------------------------- -// painting -// ---------------------------------------------------------------------------- - -wxRenderer *wxControl::GetRenderer() const -{ - return wxTheme::Get()->GetRenderer(); -} - -// the event handler executed when the window background must be painted -void wxControl::OnErase(wxEraseEvent& event) -{ - wxControlRenderer renderer(this, *event.GetDC(), - wxTheme::Get()->GetRenderer()); - - if ( !DoDrawBackground(&renderer) ) - { - // not processed - event.Skip(); - } -} - -// the event handler executed when the window must be repainted -void wxControl::OnPaint(wxPaintEvent& event) -{ - // get the DC to use and create renderer on it - wxPaintDC dc(this); - wxControlRenderer renderer(this, dc, GetRenderer()); - - // do draw the control! - DoDraw(&renderer); -} - -bool wxControl::DoDrawBackground(wxControlRenderer *renderer) -{ - if ( !m_bitmapBg.Ok() ) - return FALSE; - - renderer->DrawBackgroundBitmap(); - - return TRUE; -} - -void wxControl::DoDraw(wxControlRenderer *renderer) -{ - renderer->DrawBorder(); -} - // ---------------------------------------------------------------------------- // focus handling // ---------------------------------------------------------------------------- diff --git a/src/univ/files.lst b/src/univ/files.lst index b7d35978cc..31f44f6c2c 100644 --- a/src/univ/files.lst +++ b/src/univ/files.lst @@ -12,7 +12,8 @@ UNIVOBJS = \ stattext.o \ theme.o \ gtk.o \ - win32.o + win32.o \ + winuniv.o UNIVDEPS = \ bmpbuttn.d \ @@ -28,4 +29,5 @@ UNIVDEPS = \ stattext.d \ theme.d \ gtk.d \ - win32.d + win32.d \ + winuniv.d diff --git a/src/univ/renderer.cpp b/src/univ/renderer.cpp index 81ed774cca..bdc9973298 100644 --- a/src/univ/renderer.cpp +++ b/src/univ/renderer.cpp @@ -43,6 +43,29 @@ // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// wxRenderer: drawing helpers +// ---------------------------------------------------------------------------- + +void wxRenderer::StandardDrawFrame(wxDC& dc, + const wxRect& rectFrame, + const wxRect& rectLabel) +{ + // draw left, bottom and right lines entirely + DrawVerticalLine(dc, rectFrame.GetLeft(), + rectFrame.GetTop(), rectFrame.GetBottom() - 2); + DrawHorizontalLine(dc, rectFrame.GetBottom() - 1, + rectFrame.GetLeft(), rectFrame.GetRight()); + DrawVerticalLine(dc, rectFrame.GetRight() - 1, + rectFrame.GetTop(), rectFrame.GetBottom() - 1); + + // and 2 parts of the top line + DrawHorizontalLine(dc, rectFrame.GetTop(), + rectFrame.GetLeft() + 1, rectLabel.GetLeft()); + DrawHorizontalLine(dc, rectFrame.GetTop(), + rectLabel.GetRight(), rectFrame.GetRight() - 2); +} + // ---------------------------------------------------------------------------- // wxRenderer: scrollbar geometry // ---------------------------------------------------------------------------- @@ -173,15 +196,15 @@ wxRenderer::~wxRenderer() // wxControlRenderer // ---------------------------------------------------------------------------- -wxControlRenderer::wxControlRenderer(wxControl *control, +wxControlRenderer::wxControlRenderer(wxWindow *window, wxDC& dc, wxRenderer *renderer) : m_dc(dc) { - m_ctrl = control; + m_window = window; m_renderer = renderer; - wxSize size = m_ctrl->GetSize(); + wxSize size = m_window->GetSize(); m_rect.x = m_rect.y = 0; m_rect.width = size.x; @@ -190,10 +213,10 @@ wxControlRenderer::wxControlRenderer(wxControl *control, void wxControlRenderer::DrawBorder() { - int flags = m_ctrl->GetStateFlags(); + int flags = m_window->GetStateFlags(); // draw outline - m_renderer->DrawBorder(m_dc, m_ctrl->GetBorder(), + m_renderer->DrawBorder(m_dc, m_window->GetBorder(), m_rect, flags, &m_rect); // fill the inside (TODO: query the theme for bg bitmap) @@ -203,10 +226,10 @@ void wxControlRenderer::DrawBorder() void wxControlRenderer::DrawLabel(const wxBitmap& bitmap, wxCoord marginX, wxCoord marginY) { - m_dc.SetFont(m_ctrl->GetFont()); - m_dc.SetTextForeground(m_ctrl->GetForegroundColour()); + m_dc.SetFont(m_window->GetFont()); + m_dc.SetTextForeground(m_window->GetForegroundColour()); - wxString label = m_ctrl->GetLabel(); + wxString label = m_window->GetLabel(); if ( !label.empty() || bitmap.Ok() ) { wxRect rectLabel = m_rect; @@ -215,33 +238,37 @@ void wxControlRenderer::DrawLabel(const wxBitmap& bitmap, rectLabel.Inflate(-marginX, -marginY); } + wxControl *ctrl = wxStaticCast(m_window, wxControl); + m_renderer->DrawLabel(m_dc, label, bitmap, rectLabel, - m_ctrl->GetStateFlags(), - m_ctrl->GetAlignment(), - m_ctrl->GetAccelIndex()); + m_window->GetStateFlags(), + ctrl->GetAlignment(), + ctrl->GetAccelIndex()); } } void wxControlRenderer::DrawFrame() { - m_dc.SetFont(m_ctrl->GetFont()); - m_dc.SetTextForeground(m_ctrl->GetForegroundColour()); - m_dc.SetTextBackground(m_ctrl->GetBackgroundColour()); + m_dc.SetFont(m_window->GetFont()); + m_dc.SetTextForeground(m_window->GetForegroundColour()); + m_dc.SetTextBackground(m_window->GetBackgroundColour()); + + wxControl *ctrl = wxStaticCast(m_window, wxControl); m_renderer->DrawFrame(m_dc, - m_ctrl->GetLabel(), + m_window->GetLabel(), m_rect, - m_ctrl->GetStateFlags(), - m_ctrl->GetAlignment(), - m_ctrl->GetAccelIndex()); + m_window->GetStateFlags(), + ctrl->GetAlignment(), + ctrl->GetAccelIndex()); } void wxControlRenderer::DrawButtonBorder() { - int flags = m_ctrl->GetStateFlags(); + int flags = m_window->GetStateFlags(); m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect); @@ -250,7 +277,7 @@ void wxControlRenderer::DrawButtonBorder() void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap) { - int style = m_ctrl->GetWindowStyle(); + int style = m_window->GetWindowStyle(); DrawBitmap(bitmap, m_rect, style & wxALIGN_MASK, style & wxBI_EXPAND ? wxEXPAND : wxSTRETCH_NOT); @@ -261,7 +288,7 @@ void wxControlRenderer::DrawBackgroundBitmap() // get the bitmap and the flags int alignment; wxStretch stretch; - wxBitmap bmp = m_ctrl->GetBackgroundBitmap(&alignment, &stretch); + wxBitmap bmp = m_window->GetBackgroundBitmap(&alignment, &stretch); DrawBitmap(bmp, m_rect, alignment, stretch); } @@ -355,7 +382,7 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar) } m_renderer->DrawScrollbar(m_dc, - m_ctrl->GetWindowStyle() & wxVERTICAL + m_window->GetWindowStyle() & wxVERTICAL ? wxVERTICAL : wxHORIZONTAL, thumbStart, thumbEnd, m_rect, diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index 853392d709..7a6ab6735a 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -520,11 +520,11 @@ void wxGTKRenderer::DrawVerticalLine(wxDC& dc, } void wxGTKRenderer::DrawFrame(wxDC& dc, - const wxString& label, - const wxRect& rect, - int flags, - int alignment, - int indexAccel) + const wxString& label, + const wxRect& rect, + int flags, + int alignment, + int indexAccel) { wxCoord height = 0; // of the label wxRect rectFrame = rect; @@ -535,32 +535,33 @@ void wxGTKRenderer::DrawFrame(wxDC& dc, dc.GetTextExtent(label, NULL, &height); rectFrame.y += height / 2; rectFrame.height -= height / 2; - } - // draw the frame - DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight); - DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey); - - // and overwrite it with label (if any) - if ( !label.empty() ) - { - // TODO: the +2 should be customizable + // TODO: the +4 should be customizable wxRect rectText; - rectText.x = rectFrame.x + 2; + rectText.x = rectFrame.x + 4; rectText.y = rect.y; - rectText.width = rectFrame.width - 4; // +2 border width + rectText.width = rectFrame.width - 8; rectText.height = height; - dc.SetBackgroundMode(wxSOLID); - DrawLabel(dc, label, wxNullBitmap, rectText, - flags, alignment, indexAccel); - dc.SetBackgroundMode(wxTRANSPARENT); + wxRect rectLabel; + DrawLabel(dc, label, wxNullBitmap, + rectText, flags, alignment, indexAccel, &rectLabel); + rectLabel.x -= 1; + rectLabel.width += 2; - // GTK+ does this - don't know if this is intentional or not + StandardDrawFrame(dc, rectFrame, rectLabel); + + // GTK+ does it like this dc.SetPen(m_penHighlight); - dc.DrawPoint(rectFrame.GetPosition()); - dc.DrawPoint(rectFrame.x + rectText.width, rectFrame.y); + dc.DrawPoint(rectText.x, rectFrame.y); + dc.DrawPoint(rectText.x + rectLabel.width - 3, rectFrame.y); + } + else + { + // just draw the complete frame + DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight); + DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey); } } diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index 6b849660de..eaa59d73e6 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -803,19 +803,7 @@ void wxWin32Renderer::DrawFrame(wxDC& dc, DrawLabel(dc, label2, wxNullBitmap, rectText, flags, alignment, indexAccel, &rectLabel); - // draw left, bottom and right lines entirely - DrawVerticalLine(dc, rectFrame.GetLeft(), - rectFrame.GetTop(), rectFrame.GetBottom() - 2); - DrawHorizontalLine(dc, rectFrame.GetBottom() - 1, - rectFrame.GetLeft(), rectFrame.GetRight()); - DrawVerticalLine(dc, rectFrame.GetRight() - 1, - rectFrame.GetTop(), rectFrame.GetBottom() - 1); - - // and 2 parts of the top line - DrawHorizontalLine(dc, rectFrame.GetTop(), - rectFrame.GetLeft() + 1, rectLabel.GetLeft()); - DrawHorizontalLine(dc, rectFrame.GetTop(), - rectLabel.GetRight(), rectFrame.GetRight() - 2); + StandardDrawFrame(dc, rectFrame, rectLabel); } else { diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index ed4ab74d3a..545be5e032 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -29,8 +29,8 @@ #endif #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/window.h" - #include "wx/dc.h" #include "wx/dcclient.h" #include "wx/event.h" #endif // WX_PRECOMP @@ -38,44 +38,202 @@ #include "wx/univ/renderer.h" #include "wx/univ/theme.h" -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// we don't have any objects of type wxWindowBase so this cast is always safe -#define self ((wxWindow *)this) - // ============================================================================ // implementation // ============================================================================ // ---------------------------------------------------------------------------- -// drawing +// event tables // ---------------------------------------------------------------------------- -// the event handler executed when the window must be repainted -void wxWindowBase::OnPaint(wxPaintEvent& event) +IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) + +BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) + EVT_PAINT(wxWindow::OnPaint) + EVT_ERASE_BACKGROUND(wxWindow::OnErase) +END_EVENT_TABLE() + +// ---------------------------------------------------------------------------- +// creation +// ---------------------------------------------------------------------------- + +void wxWindow::Init() { - // get the renderer and the DC to use - wxWindowRenderer renderer = wxTheme::Get()->GetRenderer(); - wxPaintDC dc(self); + m_scrollbarVert = + m_scrollbarHorz = (wxScrollBar *)NULL; - // draw the border - DoDrawBorder(dc, renderer); - - // draw the control - DoDraw(dc, renderer); + m_isCurrent = FALSE; } -// draw the border -void wxWindowBase::DoDrawBorder(wxDC& dc, wxRenderer *renderer) +// ---------------------------------------------------------------------------- +// background pixmap +// ---------------------------------------------------------------------------- + +void wxWindow::SetBackground(const wxBitmap& bitmap, + int alignment, + wxStretch stretch) { - if ( !IsTopLevel() && !(m_windowStyle & wxNO_BORDER) ) + m_bitmapBg = bitmap; + m_alignBgBitmap = alignment; + m_stretchBgBitmap = stretch; +} + +const wxBitmap& wxWindow::GetBackgroundBitmap(int *alignment, + wxStretch *stretch) const +{ + if ( m_bitmapBg.Ok() ) { - renderer->DrawBorder(dc, self); + if ( alignment ) + *alignment = m_alignBgBitmap; + if ( stretch ) + *stretch = m_stretchBgBitmap; + } + + return m_bitmapBg; +} + +// ---------------------------------------------------------------------------- +// painting +// ---------------------------------------------------------------------------- + +wxRenderer *wxWindow::GetRenderer() const +{ + return wxTheme::Get()->GetRenderer(); +} + +// the event handler executed when the window background must be painted +void wxWindow::OnErase(wxEraseEvent& event) +{ + wxControlRenderer renderer(this, *event.GetDC(), + wxTheme::Get()->GetRenderer()); + + if ( !DoDrawBackground(&renderer) ) + { + // not processed + event.Skip(); } } -void wxWindowBase::DoDraw(wxDC& dc, wxRenderer *renderer) +// the event handler executed when the window must be repainted +void wxWindow::OnPaint(wxPaintEvent& event) { + // get the DC to use and create renderer on it + wxPaintDC dc(this); + wxControlRenderer renderer(this, dc, GetRenderer()); + + // do draw the control! + DoDraw(&renderer); } + +bool wxWindow::DoDrawBackground(wxControlRenderer *renderer) +{ + if ( !m_bitmapBg.Ok() ) + return FALSE; + + renderer->DrawBackgroundBitmap(); + + return TRUE; +} + +void wxWindow::DoDraw(wxControlRenderer *renderer) +{ + renderer->DrawBorder(); +} + +// ---------------------------------------------------------------------------- +// state flags +// ---------------------------------------------------------------------------- + +bool wxWindow::IsFocused() const +{ + wxWindow *self = wxConstCast(this, wxWindow); + return self->FindFocus() == self; +} + +bool wxWindow::IsPressed() const +{ + return FALSE; +} + +bool wxWindow::IsDefault() const +{ + return FALSE; +} + +bool wxWindow::IsCurrent() const +{ + return m_isCurrent; +} + +void wxWindow::SetCurrent(bool doit) +{ + m_isCurrent = doit; +} + +int wxWindow::GetStateFlags() const +{ + int flags = 0; + if ( !IsEnabled() ) + flags |= wxCONTROL_DISABLED; + + // the following states are only possible if our application is active - if + // it is not, even our default/focused controls shouldn't appear as such + if ( wxTheApp->IsActive() ) + { + if ( IsCurrent() ) + flags |= wxCONTROL_CURRENT; + if ( IsFocused() ) + flags |= wxCONTROL_FOCUSED; + if ( IsPressed() ) + flags |= wxCONTROL_PRESSED; + if ( IsDefault() ) + flags |= wxCONTROL_ISDEFAULT; + } + + return flags; +} + +// ---------------------------------------------------------------------------- +// size +// ---------------------------------------------------------------------------- + +wxSize wxWindow::AdjustSize(const wxSize& size) const +{ + wxSize sz = size; + wxTheme::Get()->GetRenderer()->AdjustSize(&sz, this); + return sz; +} + +// ---------------------------------------------------------------------------- +// scrolling +// ---------------------------------------------------------------------------- + +void wxWindow::SetScrollbar(int orient, + int pos, + int thumb, + int range, + bool refresh) +{ + return wxWindowNative::SetScrollbar(orient, pos, thumb, range, refresh); +} + +void wxWindow::SetScrollPos(int orient, int pos, bool refresh) +{ + return wxWindowNative::SetScrollPos(orient, pos, refresh); +} + +int wxWindow::GetScrollPos(int orient) const +{ + return wxWindowNative::GetScrollPos(orient); +} + +int wxWindow::GetScrollThumb(int orient) const +{ + return wxWindowNative::GetScrollThumb(orient); +} + +int wxWindow::GetScrollRange(int orient) const +{ + return wxWindowNative::GetScrollRange(orient); +} +