Fix for TextCtrl problem as reported by Vegh

Move definition of wxMenuItem to /gtk/menuitem.h
  Radical change of how to insert a child into a
    paren window. As C++ doesn't have any VMT in
    a class's consructor, I have to use a callback.
  Fixed culumn resizing bug in wxListCtrl
  Fixed menu height bug in MDI code


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1998-11-03 11:19:58 +00:00
parent c55bc98ef7
commit 6ca41e57f4
62 changed files with 800 additions and 842 deletions

View File

@ -21,6 +21,7 @@
#include "glib.h" #include "glib.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
#endif #endif

View File

@ -59,7 +59,6 @@ public:
bool Destroy(); bool Destroy();
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual void Enable( bool enable );
virtual void Centre( int direction = wxHORIZONTAL ); virtual void Centre( int direction = wxHORIZONTAL );
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
@ -98,28 +97,17 @@ public:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
void AddChild( wxWindow *child );
// implementation // implementation
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
virtual void ImplementSetPosition();
private: virtual wxPoint GetClientAreaOrigin() const;
friend wxWindow;
friend wxMDIChildFrame;
friend wxMDIClientWindow;
// update frame's menus (called from OnIdle)
void DoMenuUpdates(); void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu); void DoMenuUpdates(wxMenu* menu);
virtual void ImplementSetPosition();
GtkWidget *m_mainWindow;
wxMenuBar *m_frameMenuBar; wxMenuBar *m_frameMenuBar;
wxStatusBar *m_frameStatusBar; wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar; wxToolBar *m_frameToolBar;
int m_toolBarHeight;
bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;

View File

@ -178,7 +178,6 @@ class wxMDIClientWindow: public wxWindow
wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 ); wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 );
~wxMDIClientWindow(void); ~wxMDIClientWindow(void);
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL ); virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
void AddChild( wxWindow *child );
}; };
#endif // __MDIH__ #endif // __MDIH__

View File

@ -19,6 +19,7 @@
#include "wx/object.h" #include "wx/object.h"
#include "wx/list.h" #include "wx/list.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/menuitem.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@ -67,56 +68,6 @@ public:
// wxMenu // wxMenu
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMenuItem: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
wxMenuItem();
// accessors
// id
void SetId(int id) { m_id = id; }
int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
// the item's text
void SetText(const wxString& str);
const wxString& GetText() const { return m_text; }
// what kind of menu item we are
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
bool IsCheckable() const { return m_isCheckMenu; }
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
wxMenu *GetSubMenu() const { return m_subMenu; }
bool IsSubMenu() const { return m_subMenu != NULL; }
// state
void Enable( bool enable = TRUE );
bool IsEnabled() const { return m_isEnabled; }
void Check( bool check = TRUE );
bool IsChecked() const;
// help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_helpStr = str; }
const wxString& GetHelp() const { return m_helpStr; }
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
private:
int m_id;
wxString m_text;
bool m_isCheckMenu;
bool m_isChecked;
bool m_isEnabled;
wxMenu *m_subMenu;
wxString m_helpStr;
GtkWidget *m_menuItem; // GtkMenuItem
};
class wxMenu: public wxEvtHandler class wxMenu: public wxEvtHandler
{ {
DECLARE_DYNAMIC_CLASS(wxMenu) DECLARE_DYNAMIC_CLASS(wxMenu)

View File

@ -1,95 +1,90 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.h // Name: menuitem.h
// Purpose: wxMenuItem class // Purpose: wxMenuItem class
// Author: Vadim Zeitlin // Author: Robert Roebling
// Modified by:
// Created: 11.11.97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows license // Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _MENUITEM_H #ifndef __GTKMENUITEMH__
#define _MENUITEM_H #define __GTKMENUITEMH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "menuitem.h" #pragma interface
#endif #endif
// ---------------------------------------------------------------------------- #include "wx/defs.h"
// headers #include "wx/string.h"
// ----------------------------------------------------------------------------
#include "wx/setup.h"
// an exception to the general rule that a normal header doesn't include other
// headers - only because ownerdrw.h is not always included and I don't want
// to write #ifdef's everywhere...
#if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// id for a separator line in the menu (invalid for normal item)
#define ID_SEPARATOR (-1) #define ID_SEPARATOR (-1)
// ---------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour // classes
// ---------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuItem: public wxObject
#if wxUSE_OWNER_DRAWN class wxMenuItem;
, public wxOwnerDrawn
#endif class wxMenu;
//-----------------------------------------------------------------------------
// wxMenuItem
//-----------------------------------------------------------------------------
class wxMenuItem: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public: public:
// ctor & dtor wxMenuItem();
wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR,
const wxString& strName = "", const wxString& wxHelp = "",
bool bCheckable = FALSE, wxMenu *pSubMenu = NULL);
virtual ~wxMenuItem();
// accessors (some more are inherited from wxOwnerDrawn or are below) // accessors
bool IsSeparator() const { return m_idItem == ID_SEPARATOR; } // id
bool IsEnabled() const { return m_bEnabled; } void SetId(int id) { m_id = id; }
bool IsChecked() const { return m_bChecked; } int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
int GetId() const { return m_idItem; } // the item's text
const wxString& GetHelp() const { return m_strHelp; } void SetText(const wxString& str);
wxMenu *GetSubMenu() const { return m_pSubMenu; } const wxString& GetText() const { return m_text; }
// operations // what kind of menu item we are
void SetName(const wxString& strName) { m_strName = strName; } void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; } bool IsCheckable() const { return m_isCheckMenu; }
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
wxMenu *GetSubMenu() const { return m_subMenu; }
bool IsSubMenu() const { return m_subMenu != NULL; }
void Enable(bool bDoEnable = TRUE); // state
void Check(bool bDoCheck = TRUE); void Enable( bool enable = TRUE );
bool IsEnabled() const { return m_isEnabled; }
void Check( bool check = TRUE );
bool IsChecked() const;
void DeleteSubMenu(); // help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_helpStr = str; }
const wxString& GetHelp() const { return m_helpStr; }
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
private: private:
int m_idItem; // numeric id of the item int m_id;
wxString m_strHelp; // associated help string wxString m_text;
wxMenu *m_pSubMenu, // may be NULL bool m_isCheckMenu;
*m_pParentMenu; // menu this item is contained in bool m_isChecked;
bool m_bEnabled, // enabled or greyed? bool m_isEnabled;
m_bChecked; // checked? (only if checkable) wxMenu *m_subMenu;
wxString m_helpStr;
#if wxUSE_OWNER_DRAWN GtkWidget *m_menuItem; // GtkMenuItem
// wxOwnerDrawn base class already has these variables - nothing to do
#else //!owner drawn
bool m_bCheckable; // can be checked?
wxString m_strName; // name or label of the item
public:
const wxString& GetName() const { return m_strName; }
bool IsCheckable() const { return m_bCheckable; }
#endif //owner drawn
}; };
#endif //_MENUITEM_H
#endif
//__GTKMENUITEMH__

View File

@ -8,11 +8,11 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __NOTEBOOKH__ #ifndef __GTKNOTEBOOKH__
#define __NOTEBOOKH__ #define __GTKNOTEBOOKH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "notebook.h" #pragma interface
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@ -137,15 +137,13 @@ public:
// get the panel which represents the given page // get the panel which represents the given page
wxWindow *GetPage(int nPage) const; wxWindow *GetPage(int nPage) const;
// implementation // implementation
void AddChild(wxWindow *child);
void SetConstraintSizes(bool recurse); void SetConstraintSizes(bool recurse);
bool DoPhase(int phase); bool DoPhase(int phase);
void ApplyWidgetStyle(); void ApplyWidgetStyle();
private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
@ -183,4 +181,4 @@ typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
}, },
#endif #endif
// __NOTEBOOKH__ // __GTKNOTEBOOKH__

View File

@ -46,6 +46,12 @@ class wxItemResource;
class wxWindow; class wxWindow;
class wxCanvas; class wxCanvas;
//-----------------------------------------------------------------------------
// callback definition for inserting a window
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -64,14 +70,11 @@ class wxWindow: public wxEvtHandler
public: public:
wxWindow(); wxWindow();
inline wxWindow(wxWindow *parent, wxWindowID id, wxWindow(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
const wxString& name = wxPanelNameStr) const wxString& name = wxPanelNameStr);
{
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@ -240,12 +243,18 @@ public:
const wxSize &size, long style, const wxString &name ); const wxSize &size, long style, const wxString &name );
void PostCreation(); void PostCreation();
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
virtual void ImplementSetPosition(); virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
GtkStyle *GetWidgetStyle(); GtkStyle *GetWidgetStyle();
void SetWidgetStyle(); void SetWidgetStyle();
virtual void ApplyWidgetStyle(); virtual void ApplyWidgetStyle();
wxWindow *m_parent; wxWindow *m_parent;
wxList m_children; wxList m_children;
int m_x,m_y; int m_x,m_y;
@ -282,6 +291,8 @@ public:
GdkGC *m_scrollGC; GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle; GtkStyle *m_widgetStyle;
wxInsertChildFunction m_insertCallback;
public: public:
wxLayoutConstraints *m_constraints; wxLayoutConstraints *m_constraints;

View File

@ -59,7 +59,6 @@ public:
bool Destroy(); bool Destroy();
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual void Enable( bool enable );
virtual void Centre( int direction = wxHORIZONTAL ); virtual void Centre( int direction = wxHORIZONTAL );
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
@ -98,28 +97,17 @@ public:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
void AddChild( wxWindow *child );
// implementation // implementation
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
virtual void ImplementSetPosition();
private: virtual wxPoint GetClientAreaOrigin() const;
friend wxWindow;
friend wxMDIChildFrame;
friend wxMDIClientWindow;
// update frame's menus (called from OnIdle)
void DoMenuUpdates(); void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu); void DoMenuUpdates(wxMenu* menu);
virtual void ImplementSetPosition();
GtkWidget *m_mainWindow;
wxMenuBar *m_frameMenuBar; wxMenuBar *m_frameMenuBar;
wxStatusBar *m_frameStatusBar; wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar; wxToolBar *m_frameToolBar;
int m_toolBarHeight;
bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;

View File

@ -178,7 +178,6 @@ class wxMDIClientWindow: public wxWindow
wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 ); wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 );
~wxMDIClientWindow(void); ~wxMDIClientWindow(void);
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL ); virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
void AddChild( wxWindow *child );
}; };
#endif // __MDIH__ #endif // __MDIH__

View File

@ -19,6 +19,7 @@
#include "wx/object.h" #include "wx/object.h"
#include "wx/list.h" #include "wx/list.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/menuitem.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@ -67,56 +68,6 @@ public:
// wxMenu // wxMenu
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMenuItem: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
wxMenuItem();
// accessors
// id
void SetId(int id) { m_id = id; }
int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
// the item's text
void SetText(const wxString& str);
const wxString& GetText() const { return m_text; }
// what kind of menu item we are
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
bool IsCheckable() const { return m_isCheckMenu; }
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
wxMenu *GetSubMenu() const { return m_subMenu; }
bool IsSubMenu() const { return m_subMenu != NULL; }
// state
void Enable( bool enable = TRUE );
bool IsEnabled() const { return m_isEnabled; }
void Check( bool check = TRUE );
bool IsChecked() const;
// help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_helpStr = str; }
const wxString& GetHelp() const { return m_helpStr; }
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
private:
int m_id;
wxString m_text;
bool m_isCheckMenu;
bool m_isChecked;
bool m_isEnabled;
wxMenu *m_subMenu;
wxString m_helpStr;
GtkWidget *m_menuItem; // GtkMenuItem
};
class wxMenu: public wxEvtHandler class wxMenu: public wxEvtHandler
{ {
DECLARE_DYNAMIC_CLASS(wxMenu) DECLARE_DYNAMIC_CLASS(wxMenu)

View File

@ -1,95 +1,90 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.h // Name: menuitem.h
// Purpose: wxMenuItem class // Purpose: wxMenuItem class
// Author: Vadim Zeitlin // Author: Robert Roebling
// Modified by:
// Created: 11.11.97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows license // Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _MENUITEM_H #ifndef __GTKMENUITEMH__
#define _MENUITEM_H #define __GTKMENUITEMH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "menuitem.h" #pragma interface
#endif #endif
// ---------------------------------------------------------------------------- #include "wx/defs.h"
// headers #include "wx/string.h"
// ----------------------------------------------------------------------------
#include "wx/setup.h"
// an exception to the general rule that a normal header doesn't include other
// headers - only because ownerdrw.h is not always included and I don't want
// to write #ifdef's everywhere...
#if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// id for a separator line in the menu (invalid for normal item)
#define ID_SEPARATOR (-1) #define ID_SEPARATOR (-1)
// ---------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour // classes
// ---------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuItem: public wxObject
#if wxUSE_OWNER_DRAWN class wxMenuItem;
, public wxOwnerDrawn
#endif class wxMenu;
//-----------------------------------------------------------------------------
// wxMenuItem
//-----------------------------------------------------------------------------
class wxMenuItem: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public: public:
// ctor & dtor wxMenuItem();
wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR,
const wxString& strName = "", const wxString& wxHelp = "",
bool bCheckable = FALSE, wxMenu *pSubMenu = NULL);
virtual ~wxMenuItem();
// accessors (some more are inherited from wxOwnerDrawn or are below) // accessors
bool IsSeparator() const { return m_idItem == ID_SEPARATOR; } // id
bool IsEnabled() const { return m_bEnabled; } void SetId(int id) { m_id = id; }
bool IsChecked() const { return m_bChecked; } int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
int GetId() const { return m_idItem; } // the item's text
const wxString& GetHelp() const { return m_strHelp; } void SetText(const wxString& str);
wxMenu *GetSubMenu() const { return m_pSubMenu; } const wxString& GetText() const { return m_text; }
// operations // what kind of menu item we are
void SetName(const wxString& strName) { m_strName = strName; } void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; } bool IsCheckable() const { return m_isCheckMenu; }
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
wxMenu *GetSubMenu() const { return m_subMenu; }
bool IsSubMenu() const { return m_subMenu != NULL; }
void Enable(bool bDoEnable = TRUE); // state
void Check(bool bDoCheck = TRUE); void Enable( bool enable = TRUE );
bool IsEnabled() const { return m_isEnabled; }
void Check( bool check = TRUE );
bool IsChecked() const;
void DeleteSubMenu(); // help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_helpStr = str; }
const wxString& GetHelp() const { return m_helpStr; }
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }
private: private:
int m_idItem; // numeric id of the item int m_id;
wxString m_strHelp; // associated help string wxString m_text;
wxMenu *m_pSubMenu, // may be NULL bool m_isCheckMenu;
*m_pParentMenu; // menu this item is contained in bool m_isChecked;
bool m_bEnabled, // enabled or greyed? bool m_isEnabled;
m_bChecked; // checked? (only if checkable) wxMenu *m_subMenu;
wxString m_helpStr;
#if wxUSE_OWNER_DRAWN GtkWidget *m_menuItem; // GtkMenuItem
// wxOwnerDrawn base class already has these variables - nothing to do
#else //!owner drawn
bool m_bCheckable; // can be checked?
wxString m_strName; // name or label of the item
public:
const wxString& GetName() const { return m_strName; }
bool IsCheckable() const { return m_bCheckable; }
#endif //owner drawn
}; };
#endif //_MENUITEM_H
#endif
//__GTKMENUITEMH__

View File

@ -8,11 +8,11 @@
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __NOTEBOOKH__ #ifndef __GTKNOTEBOOKH__
#define __NOTEBOOKH__ #define __GTKNOTEBOOKH__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "notebook.h" #pragma interface
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@ -137,15 +137,13 @@ public:
// get the panel which represents the given page // get the panel which represents the given page
wxWindow *GetPage(int nPage) const; wxWindow *GetPage(int nPage) const;
// implementation // implementation
void AddChild(wxWindow *child);
void SetConstraintSizes(bool recurse); void SetConstraintSizes(bool recurse);
bool DoPhase(int phase); bool DoPhase(int phase);
void ApplyWidgetStyle(); void ApplyWidgetStyle();
private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
@ -183,4 +181,4 @@ typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
}, },
#endif #endif
// __NOTEBOOKH__ // __GTKNOTEBOOKH__

View File

@ -46,6 +46,12 @@ class wxItemResource;
class wxWindow; class wxWindow;
class wxCanvas; class wxCanvas;
//-----------------------------------------------------------------------------
// callback definition for inserting a window
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -64,14 +70,11 @@ class wxWindow: public wxEvtHandler
public: public:
wxWindow(); wxWindow();
inline wxWindow(wxWindow *parent, wxWindowID id, wxWindow(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
const wxString& name = wxPanelNameStr) const wxString& name = wxPanelNameStr);
{
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@ -240,12 +243,18 @@ public:
const wxSize &size, long style, const wxString &name ); const wxSize &size, long style, const wxString &name );
void PostCreation(); void PostCreation();
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
virtual void ImplementSetPosition(); virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
GtkStyle *GetWidgetStyle(); GtkStyle *GetWidgetStyle();
void SetWidgetStyle(); void SetWidgetStyle();
virtual void ApplyWidgetStyle(); virtual void ApplyWidgetStyle();
wxWindow *m_parent; wxWindow *m_parent;
wxList m_children; wxList m_children;
int m_x,m_y; int m_x,m_y;
@ -282,6 +291,8 @@ public:
GdkGC *m_scrollGC; GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle; GtkStyle *m_widgetStyle;
wxInsertChildFunction m_insertCallback;
public: public:
wxLayoutConstraints *m_constraints; wxLayoutConstraints *m_constraints;

View File

@ -324,8 +324,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
panel->SetBackgroundColour("cadet blue"); panel->SetBackgroundColour("cadet blue");
panel->SetForegroundColour("blue"); panel->SetForegroundColour("blue");
wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28)); wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
(*tc) << " More text.";
tc->SetBackgroundColour("wheat"); tc->SetBackgroundColour("wheat");
tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE ); tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
(*tc) << " More text.";
tc->SetBackgroundColour("wheat"); tc->SetBackgroundColour("wheat");
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text); m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);

View File

@ -54,7 +54,7 @@ bool MyApp::OnInit(void)
{ {
// Create the main frame window // Create the main frame window
frame = new MyFrame((wxFrame *) NULL, -1, (char *) "MDI Demo", wxPoint(0, 0), wxSize(500, 400), frame = new MyFrame((wxFrame *) NULL, -1, (char *) "MDI Demo", wxPoint(-1, -1), wxSize(500, 400),
wxDEFAULT_FRAME | wxHSCROLL | wxVSCROLL); wxDEFAULT_FRAME | wxHSCROLL | wxVSCROLL);
// Give it an icon (this is ignored in MDI mode: uses resources) // Give it an icon (this is ignored in MDI mode: uses resources)
@ -331,7 +331,7 @@ void MyFrame::InitToolBar(wxToolBar* toolBar)
#endif #endif
int currentX = 5; int currentX = 5;
toolBar->AddTool(0, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file");
currentX += width + 5; currentX += width + 5;
toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file");
currentX += width + 5; currentX += width + 5;

View File

@ -674,6 +674,7 @@ wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMain
// m_currentCursor = wxSTANDARD_CURSOR; // m_currentCursor = wxSTANDARD_CURSOR;
m_currentCursor = (wxCursor *) NULL; m_currentCursor = (wxCursor *) NULL;
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE ); m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
m_isDraging = FALSE;
} }
void wxListHeaderWindow::DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h ) void wxListHeaderWindow::DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h )

View File

@ -83,6 +83,10 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -71,6 +71,10 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -65,6 +65,10 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child ); gtk_widget_realize( GTK_BUTTON( m_widget )->child );

View File

@ -82,6 +82,10 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
} }
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -93,6 +93,10 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
ConnectWidget( GTK_COMBO(m_widget)->button ); ConnectWidget( GTK_COMBO(m_widget)->button );

View File

@ -98,6 +98,9 @@ bool wxDialog::Create( wxWindow *parent,
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;

View File

@ -18,7 +18,6 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/mdi.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@ -104,9 +103,6 @@ wxFrame::wxFrame()
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = (GtkWidget *) NULL;
m_mainWindow = (GtkWidget *) NULL;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
@ -118,9 +114,6 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = (GtkWidget *) NULL;
m_mainWindow = (GtkWidget *) NULL;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
@ -152,18 +145,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
m_mainWindow = gtk_myfixed_new();
gtk_widget_show( m_mainWindow );
GTK_WIDGET_UNSET_FLAGS( m_mainWindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWindow );
gtk_widget_set_uposition( m_mainWindow, 0, 0 );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_mainWindow), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
@ -171,9 +157,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
PostCreation(); if (m_parent) m_parent->AddChild( this );
gtk_widget_realize( m_mainWindow ); PostCreation();
return TRUE; return TRUE;
} }
@ -184,8 +170,6 @@ wxFrame::~wxFrame()
if (m_frameStatusBar) delete m_frameStatusBar; if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar; if (m_frameToolBar) delete m_frameToolBar;
// if (m_mainWindow) gtk_widget_destroy( m_mainWindow );
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
@ -203,16 +187,6 @@ bool wxFrame::Show( bool show )
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
void wxFrame::Enable( bool enable )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!m_mainWindow) return;
wxWindow::Enable( enable );
gtk_widget_set_sensitive( m_mainWindow, enable );
}
void wxFrame::OnCloseWindow( wxCloseEvent &event ) void wxFrame::OnCloseWindow( wxCloseEvent &event )
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
@ -228,6 +202,24 @@ bool wxFrame::Destroy()
return TRUE; return TRUE;
} }
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
if (m_frameMenuBar)
{
int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2;
}
if (m_frameToolBar)
{
int h = 0;
m_frameToolBar->GetSize( (int*)NULL, &h );
pt.y += h;
}
return pt;
}
void wxFrame::ImplementSetPosition(void) void wxFrame::ImplementSetPosition(void)
{ {
if ((m_x != -1) || (m_y != -1)) if ((m_x != -1) || (m_y != -1))
@ -240,6 +232,7 @@ void wxFrame::Centre( int direction )
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); ImplementSetPosition();
} }
@ -285,7 +278,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if ((m_height == height) && (m_width == width) && if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return; (m_sizeSet)) return;
if (!m_mainWindow) return;
if (!m_wxwindow) return; if (!m_wxwindow) return;
m_width = width; m_width = width;
@ -295,57 +287,41 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
gtk_widget_set_usize( m_widget, width, height ); gtk_widget_set_usize( m_widget, m_width, m_height );
int main_x = 0; // This emulates the new wxMSW behaviour
int main_y = 0;
int main_height = height;
int main_width = width;
// This emulates Windows behaviour:
// The menu bar is part of the main window, but the status bar
// is on the implementation side in the client area. The
// function GetClientSize returns the size of the client area
// minus the status bar height. Under wxGTK, the main window
// is represented by m_mainWindow. The menubar is inserted
// into m_mainWindow whereas the statusbar is insertes into
// m_wxwindow just like any other window.
// not really needed
// gtk_widget_set_usize( m_mainWindow, width, height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
main_y = wxMENU_HEIGHT; m_frameMenuBar->m_x = 1;
main_height -= wxMENU_HEIGHT; m_frameMenuBar->m_y = 1;
} m_frameMenuBar->m_width = m_width-2;
m_frameMenuBar->m_height = wxMENU_HEIGHT-2;
int toolbar_height = 0; gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 );
if (m_frameToolBar) m_frameToolBar->GetSize( (int *) NULL, &toolbar_height ); gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
main_y += toolbar_height;
main_height -= toolbar_height;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y );
gtk_widget_set_usize( m_wxwindow, main_width, main_height );
if (m_frameMenuBar)
{
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 );
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
int y = 0; int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT; if (m_frameMenuBar) y = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y ); int h = m_frameToolBar->m_height;
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
m_frameToolBar->m_x = 2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, 2, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, m_width-3, h );
} }
if (m_frameStatusBar) if (m_frameStatusBar)
{ {
m_frameStatusBar->SetSize( 0, main_height-wxSTATUS_HEIGHT, width, wxSTATUS_HEIGHT ); // OK, this hurts in the eye, but I don't want to call SetSize()
// because I don't want to call any non-native functions here.
m_frameStatusBar->m_x = 0;
m_frameStatusBar->m_y = m_height-wxSTATUS_HEIGHT;
m_frameStatusBar->m_width = m_width;
m_frameStatusBar->m_height = wxSTATUS_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT );
gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT );
} }
m_sizeSet = TRUE; m_sizeSet = TRUE;
@ -372,7 +348,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{ {
wxWindow *win = (wxWindow *)node->Data(); wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog) if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
#if 0 // not in m_children anyway #if 0 // not in m_children anyway ?
&& (win != m_frameMenuBar) && && (win != m_frameMenuBar) &&
(win != m_frameToolBar) && (win != m_frameToolBar) &&
(win != m_frameStatusBar) (win != m_frameStatusBar)
@ -393,45 +369,6 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
} }
} }
void wxFrame::AddChild( wxWindow *child )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// wxFrame and wxDialog as children aren't placed into the parents
if (IS_KIND_OF(child,wxMDIChildFrame)) wxFAIL_MSG( "wxFrame::AddChild error.\n" );
if ( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog))
{
m_children.Append( child );
if ((child->m_x != -1) && (child->m_y != -1))
gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
return;
}
if (m_addPrivateChild)
{
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
else
{
m_children.Append( child );
if (m_wxwindow)
gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{ {
menu->SetInvokingWindow( win ); menu->SetInvokingWindow( win );
@ -449,7 +386,6 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" ); wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
m_frameMenuBar = menuBar; m_frameMenuBar = menuBar;
@ -466,7 +402,7 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
if (m_frameMenuBar->m_parent != this) if (m_frameMenuBar->m_parent != this)
{ {
m_frameMenuBar->m_parent = this; m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), gtk_myfixed_put( GTK_MYFIXED(m_wxwindow),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y ); m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
} }
} }
@ -483,9 +419,9 @@ wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& nam
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" ); wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
m_addPrivateChild = TRUE;
m_frameToolBar = OnCreateToolBar( style, id, name ); m_frameToolBar = OnCreateToolBar( style, id, name );
m_addPrivateChild = FALSE;
GetChildren()->DeleteObject( m_frameToolBar );
return m_frameToolBar; return m_frameToolBar;
} }

View File

@ -35,6 +35,10 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
m_widget = gtk_progress_bar_new(); m_widget = gtk_progress_bar_new();
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -121,6 +121,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
gtk_widget_realize( GTK_WIDGET(m_list) ); gtk_widget_realize( GTK_WIDGET(m_list) );

View File

@ -17,12 +17,20 @@
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <wx/intl.h> #include <wx/intl.h>
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30;
//-----------------------------------------------------------------------------
// globals
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMDIParentFrame // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
@ -38,7 +46,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//-----------------------------------------------------------------------------
// page change callback // page change callback
//-----------------------------------------------------------------------------
static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget), static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page, GtkNotebookPage *page,
gint WXUNUSED(nPage), gint WXUNUSED(nPage),
@ -59,6 +70,8 @@ static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
} }
} }
//-----------------------------------------------------------------------------
// wxMDIParentFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
@ -109,7 +122,7 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
int x = 0; int x = 0;
int y = 0; int y = 0;
GetClientSize( &x, &y ); GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 ); m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
} }
} }
@ -122,7 +135,7 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
int x = 0; int x = 0;
int y = 0; int y = 0;
GetClientSize( &x, &y ); GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 ); m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }
@ -214,6 +227,7 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_title = title; m_title = title;
return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
} }
@ -262,7 +276,7 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
} }
mdi_frame->SetMDIMenuBar( m_menuBar ); mdi_frame->SetMDIMenuBar( m_menuBar );
gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWindow), gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_wxwindow),
m_menuBar->m_widget, m_menuBar->m_x, m_menuBar->m_y ); m_menuBar->m_widget, m_menuBar->m_x, m_menuBar->m_y );
} }
} }
@ -280,6 +294,32 @@ void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) )
{ {
} }
//-----------------------------------------------------------------------------
// InsertChild callback for wxMDIClientWindow
//-----------------------------------------------------------------------------
static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child )
{
wxString s = child->m_title;
if (s.IsNull()) s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
gtk_notebook_append_page( notebook, child->m_widget, label_widget );
child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
gtk_notebook_set_page( notebook, parent->m_children.Number()-1 );
gtk_page_change_callback( (GtkNotebook *) NULL, child->m_page, 0, parent );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMDIClientWindow // wxMDIClientWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -303,6 +343,8 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" ); PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
@ -312,6 +354,8 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -319,35 +363,5 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
return TRUE; return TRUE;
} }
void wxMDIClientWindow::AddChild( wxWindow *child )
{
if (!child->IsKindOf(CLASSINFO(wxMDIChildFrame)))
{
wxFAIL_MSG("wxNotebook::AddChild: Child has to be wxMDIChildFrame");
return;
}
m_children.Append( child );
wxString s;
wxMDIChildFrame* mdi_child = (wxMDIChildFrame*) child;
s = mdi_child->m_title;
if (s.IsNull()) s = _("MDI child");
GtkWidget *label_widget;
label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), child->m_widget, label_widget );
mdi_child->m_page = (GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), m_children.Number()-1 );
gtk_page_change_callback( (GtkNotebook *) NULL, mdi_child->m_page, 0, this );
}

View File

@ -7,9 +7,9 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "menu.h" #pragma implementation "menu.h"
#pragma implementation "menuitem.h"
#endif #endif
#include "wx/menu.h" #include "wx/menu.h"

View File

@ -36,7 +36,6 @@ public:
m_box = (GtkWidget *) NULL; m_box = (GtkWidget *) NULL;
} }
//private:
int m_id; int m_id;
wxString m_text; wxString m_text;
int m_image; int m_image;
@ -87,6 +86,40 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//-----------------------------------------------------------------------------
// InsertChild callback for wxNotebook
//-----------------------------------------------------------------------------
static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
{
wxNotebookPage *page = new wxNotebookPage();
page->m_id = parent->GetPageCount();
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
page->m_client = child;
gtk_notebook_append_page( notebook, child->m_widget, page->m_box );
page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
page->m_parent = notebook;
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
return;
}
parent->m_pages.Append( page );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebook // wxNotebook
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -127,6 +160,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@ -141,6 +175,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
(gpointer)this (gpointer)this
); );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -411,39 +449,6 @@ wxWindow *wxNotebook::GetPage( int page ) const
return nb_page->m_client; return nb_page->m_client;
} }
void wxNotebook::AddChild( wxWindow *win )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
page->m_id = GetPageCount();
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
page->m_client = win;
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, page->m_box );
page->m_page =
(GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
page->m_parent = GTK_NOTEBOOK(m_widget);
gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
return;
}
m_pages.Append( page );
}
// override these 2 functions to do nothing: everything is done in OnSize // override these 2 functions to do nothing: everything is done in OnSize
void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{ {

View File

@ -159,6 +159,9 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
if (newSize.y == -1) newSize.y = height; if (newSize.y == -1) newSize.y = height;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height );
PostCreation(); PostCreation();
SetLabel( title ); SetLabel( title );

View File

@ -60,6 +60,9 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -126,6 +126,10 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event", gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -99,10 +99,13 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
SetRange( minValue, maxValue ); SetRange( minValue, maxValue );
SetValue( value ); SetValue( value );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE ); Show( TRUE );

View File

@ -57,6 +57,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
m_widget = gtk_label_new( "Bitmap" ); m_widget = gtk_label_new( "Bitmap" );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -40,6 +40,10 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
m_widget = gtk_frame_new(m_label); m_widget = gtk_frame_new(m_label);
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetLabel(label); SetLabel(label);

View File

@ -92,6 +92,10 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -118,6 +118,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -119,6 +119,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
if (bMultiLine) if (bMultiLine)
@ -136,6 +140,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
{ {
gint tmp = 0; gint tmp = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp ); gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
SetInsertionPointEnd();
} }
if (style & wxTE_READONLY) if (style & wxTE_READONLY)

View File

@ -132,6 +132,10 @@ printf("5\n");
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
printf("Robert's new insertion code :-)\n");
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
printf("postcreate\n"); printf("postcreate\n");
PostCreation(); PostCreation();

View File

@ -23,12 +23,9 @@
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/mdi.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
@ -862,6 +859,29 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailab
*/ */
} }
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
// Callback for wxWindow. 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 superflouus (such in the MDI window system),
// but no-one is listening to me...
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
child->m_y );
gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
child->m_width,
child->m_height );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -917,6 +937,15 @@ wxWindow::wxWindow()
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_insertCallback = wxInsertChildInWindow;
Create( parent, id, pos, size, style, name );
} }
bool wxWindow::Create( wxWindow *parent, wxWindowID id, bool wxWindow::Create( wxWindow *parent, wxWindowID id,
@ -927,8 +956,6 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
m_cursor = (wxCursor *) NULL;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
@ -1017,6 +1044,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
if (m_parent) m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -1086,12 +1117,29 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
m_x = (int)pos.x;
m_y = (int)pos.y;
m_width = size.x; m_width = size.x;
if (m_width == -1) m_width = 20; if (m_width == -1) m_width = 20;
m_height = size.y; m_height = size.y;
if (m_height == -1) m_height = 20; if (m_height == -1) m_height = 20;
m_x = (int)pos.x;
m_y = (int)pos.y;
if (!m_needParent) // some reasonable defaults
{
if (m_x == -1)
{
m_x = (gdk_screen_width () - m_width) / 2;
if (m_x < 10) m_x = 10;
}
if (m_y == -1)
{
m_y = (gdk_screen_height () - m_height) / 2;
if (m_y < 10) m_y = 10;
}
}
m_minWidth = -1; m_minWidth = -1;
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
@ -1123,8 +1171,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
void wxWindow::PostCreation() void wxWindow::PostCreation()
{ {
if (m_parent) m_parent->AddChild( this );
if (m_wxwindow) if (m_wxwindow)
{ {
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
@ -1220,6 +1266,21 @@ void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
// are we to set fonts here ? // are we to set fonts here ?
} }
wxPoint wxWindow::GetClientAreaOrigin() const
{
return wxPoint(0,0);
}
void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
{
if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
x += pt.x;
y += pt.y;
}
}
void wxWindow::ImplementSetSize() void wxWindow::ImplementSetSize()
{ {
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
@ -1231,13 +1292,6 @@ void wxWindow::ImplementSetSize()
void wxWindow::ImplementSetPosition() void wxWindow::ImplementSetPosition()
{ {
if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
{
if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y );
return;
}
if (!m_parent) if (!m_parent)
{ {
wxFAIL_MSG( "wxWindow::SetSize error.\n" ); wxFAIL_MSG( "wxWindow::SetSize error.\n" );
@ -1280,12 +1334,15 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
if (newH == -1) newH = 26; if (newH == -1) newH = 26;
} }
AdjustForParentClientOrigin( newX, newY, sizeFlags );
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet)) if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
{ {
m_x = newX; m_x = newX;
m_y = newY; m_y = newY;
ImplementSetPosition(); ImplementSetPosition();
} }
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet)) if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{ {
m_width = newW; m_width = newW;
@ -1445,8 +1502,18 @@ void wxWindow::GetPosition( int *x, int *y ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (x) (*x) = m_x; int xx = m_x;
if (y) (*y) = m_y; int yy = m_y;
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
if (x) (*x) = xx;
if (y) (*y) = yy;
} }
void wxWindow::ClientToScreen( int *x, int *y ) void wxWindow::ClientToScreen( int *x, int *y )
@ -1472,6 +1539,10 @@ void wxWindow::ClientToScreen( int *x, int *y )
} }
} }
wxPoint pt(GetClientAreaOrigin());
org_x += pt.x;
org_y += pt.y;
if (x) *x += org_x; if (x) *x += org_x;
if (y) *y += org_y; if (y) *y += org_y;
} }
@ -1499,6 +1570,10 @@ void wxWindow::ScreenToClient( int *x, int *y )
} }
} }
wxPoint pt(GetClientAreaOrigin());
org_x -= pt.x;
org_y -= pt.y;
if (x) *x -= org_x; if (x) *x -= org_x;
if (y) *y -= org_y; if (y) *y -= org_y;
} }
@ -1676,72 +1751,9 @@ bool wxWindow::OnClose()
void wxWindow::AddChild( wxWindow *child ) void wxWindow::AddChild( wxWindow *child )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window need client area" );
wxASSERT_MSG( (child != NULL), "invalid child" ); wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// Addchild is (often) called before the program
// has left the parents constructor so that no
// virtual tables work yet. The approach below
// practically imitates virtual tables, i.e. it
// implements a different AddChild() behaviour
// for wxFrame, wxDialog, wxWindow and
// wxMDIParentFrame.
// wxFrame and wxDialog as children aren't placed into the parents
if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) /*&&
(!IS_KIND_OF(child,wxMDIChildFrame))*/)
{
m_children.Append( child );
if ((child->m_x != -1) && (child->m_y != -1))
gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
return;
}
// In the case of an wxMDIChildFrame descendant, we use the
// client windows's AddChild()
if (IS_KIND_OF(this,wxMDIParentFrame))
{
if (IS_KIND_OF(child,wxMDIChildFrame))
{
wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow();
if (client)
{
client->AddChild( child );
return;
}
}
}
// wxNotebook is very special, so it has a private AddChild()
if (IS_KIND_OF(this,wxNotebook))
{
wxNotebook *tab = (wxNotebook*)this;
tab->AddChild( child );
return;
}
// wxFrame has a private AddChild
if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame))
{
wxFrame *frame = (wxFrame*)this;
frame->AddChild( child );
return;
}
// All the rest
m_children.Append( child ); m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget,
child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
} }
wxList *wxWindow::GetChildren() wxList *wxWindow::GetChildren()
@ -1751,8 +1763,7 @@ wxList *wxWindow::GetChildren()
void wxWindow::RemoveChild( wxWindow *child ) void wxWindow::RemoveChild( wxWindow *child )
{ {
if (GetChildren()) if (GetChildren()) GetChildren()->DeleteObject( child );
GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL; child->m_parent = (wxWindow *) NULL;
} }

View File

@ -83,6 +83,10 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &b
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -71,6 +71,10 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -65,6 +65,10 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child ); gtk_widget_realize( GTK_BUTTON( m_widget )->child );

View File

@ -82,6 +82,10 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
} }
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -93,6 +93,10 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
ConnectWidget( GTK_COMBO(m_widget)->button ); ConnectWidget( GTK_COMBO(m_widget)->button );

View File

@ -98,6 +98,9 @@ bool wxDialog::Create( wxWindow *parent,
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;

View File

@ -18,7 +18,6 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/mdi.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@ -104,9 +103,6 @@ wxFrame::wxFrame()
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = (GtkWidget *) NULL;
m_mainWindow = (GtkWidget *) NULL;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
@ -118,9 +114,6 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = (GtkWidget *) NULL;
m_mainWindow = (GtkWidget *) NULL;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
@ -152,18 +145,11 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
m_mainWindow = gtk_myfixed_new();
gtk_widget_show( m_mainWindow );
GTK_WIDGET_UNSET_FLAGS( m_mainWindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWindow );
gtk_widget_set_uposition( m_mainWindow, 0, 0 );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_mainWindow), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
@ -171,9 +157,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
PostCreation(); if (m_parent) m_parent->AddChild( this );
gtk_widget_realize( m_mainWindow ); PostCreation();
return TRUE; return TRUE;
} }
@ -184,8 +170,6 @@ wxFrame::~wxFrame()
if (m_frameStatusBar) delete m_frameStatusBar; if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar; if (m_frameToolBar) delete m_frameToolBar;
// if (m_mainWindow) gtk_widget_destroy( m_mainWindow );
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
@ -203,16 +187,6 @@ bool wxFrame::Show( bool show )
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
void wxFrame::Enable( bool enable )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!m_mainWindow) return;
wxWindow::Enable( enable );
gtk_widget_set_sensitive( m_mainWindow, enable );
}
void wxFrame::OnCloseWindow( wxCloseEvent &event ) void wxFrame::OnCloseWindow( wxCloseEvent &event )
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
@ -228,6 +202,24 @@ bool wxFrame::Destroy()
return TRUE; return TRUE;
} }
wxPoint wxFrame::GetClientAreaOrigin() const
{
wxPoint pt(0, 0);
if (m_frameMenuBar)
{
int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2;
}
if (m_frameToolBar)
{
int h = 0;
m_frameToolBar->GetSize( (int*)NULL, &h );
pt.y += h;
}
return pt;
}
void wxFrame::ImplementSetPosition(void) void wxFrame::ImplementSetPosition(void)
{ {
if ((m_x != -1) || (m_y != -1)) if ((m_x != -1) || (m_y != -1))
@ -240,6 +232,7 @@ void wxFrame::Centre( int direction )
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); ImplementSetPosition();
} }
@ -285,7 +278,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if ((m_height == height) && (m_width == width) && if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return; (m_sizeSet)) return;
if (!m_mainWindow) return;
if (!m_wxwindow) return; if (!m_wxwindow) return;
m_width = width; m_width = width;
@ -295,57 +287,41 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
gtk_widget_set_usize( m_widget, width, height ); gtk_widget_set_usize( m_widget, m_width, m_height );
int main_x = 0; // This emulates the new wxMSW behaviour
int main_y = 0;
int main_height = height;
int main_width = width;
// This emulates Windows behaviour:
// The menu bar is part of the main window, but the status bar
// is on the implementation side in the client area. The
// function GetClientSize returns the size of the client area
// minus the status bar height. Under wxGTK, the main window
// is represented by m_mainWindow. The menubar is inserted
// into m_mainWindow whereas the statusbar is insertes into
// m_wxwindow just like any other window.
// not really needed
// gtk_widget_set_usize( m_mainWindow, width, height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
main_y = wxMENU_HEIGHT; m_frameMenuBar->m_x = 1;
main_height -= wxMENU_HEIGHT; m_frameMenuBar->m_y = 1;
} m_frameMenuBar->m_width = m_width-2;
m_frameMenuBar->m_height = wxMENU_HEIGHT-2;
int toolbar_height = 0; gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 );
if (m_frameToolBar) m_frameToolBar->GetSize( (int *) NULL, &toolbar_height ); gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
main_y += toolbar_height;
main_height -= toolbar_height;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y );
gtk_widget_set_usize( m_wxwindow, main_width, main_height );
if (m_frameMenuBar)
{
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 );
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
int y = 0; int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT; if (m_frameMenuBar) y = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y ); int h = m_frameToolBar->m_height;
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
m_frameToolBar->m_x = 2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, 2, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, m_width-3, h );
} }
if (m_frameStatusBar) if (m_frameStatusBar)
{ {
m_frameStatusBar->SetSize( 0, main_height-wxSTATUS_HEIGHT, width, wxSTATUS_HEIGHT ); // OK, this hurts in the eye, but I don't want to call SetSize()
// because I don't want to call any non-native functions here.
m_frameStatusBar->m_x = 0;
m_frameStatusBar->m_y = m_height-wxSTATUS_HEIGHT;
m_frameStatusBar->m_width = m_width;
m_frameStatusBar->m_height = wxSTATUS_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT );
gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT );
} }
m_sizeSet = TRUE; m_sizeSet = TRUE;
@ -372,7 +348,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{ {
wxWindow *win = (wxWindow *)node->Data(); wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog) if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
#if 0 // not in m_children anyway #if 0 // not in m_children anyway ?
&& (win != m_frameMenuBar) && && (win != m_frameMenuBar) &&
(win != m_frameToolBar) && (win != m_frameToolBar) &&
(win != m_frameStatusBar) (win != m_frameStatusBar)
@ -393,45 +369,6 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
} }
} }
void wxFrame::AddChild( wxWindow *child )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// wxFrame and wxDialog as children aren't placed into the parents
if (IS_KIND_OF(child,wxMDIChildFrame)) wxFAIL_MSG( "wxFrame::AddChild error.\n" );
if ( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog))
{
m_children.Append( child );
if ((child->m_x != -1) && (child->m_y != -1))
gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
return;
}
if (m_addPrivateChild)
{
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
else
{
m_children.Append( child );
if (m_wxwindow)
gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{ {
menu->SetInvokingWindow( win ); menu->SetInvokingWindow( win );
@ -449,7 +386,6 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" ); wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
m_frameMenuBar = menuBar; m_frameMenuBar = menuBar;
@ -466,7 +402,7 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
if (m_frameMenuBar->m_parent != this) if (m_frameMenuBar->m_parent != this)
{ {
m_frameMenuBar->m_parent = this; m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), gtk_myfixed_put( GTK_MYFIXED(m_wxwindow),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y ); m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
} }
} }
@ -483,9 +419,9 @@ wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& nam
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" ); wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
m_addPrivateChild = TRUE;
m_frameToolBar = OnCreateToolBar( style, id, name ); m_frameToolBar = OnCreateToolBar( style, id, name );
m_addPrivateChild = FALSE;
GetChildren()->DeleteObject( m_frameToolBar );
return m_frameToolBar; return m_frameToolBar;
} }

View File

@ -35,6 +35,10 @@ bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
m_widget = gtk_progress_bar_new(); m_widget = gtk_progress_bar_new();
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -121,6 +121,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
gtk_widget_realize( GTK_WIDGET(m_list) ); gtk_widget_realize( GTK_WIDGET(m_list) );

View File

@ -17,12 +17,20 @@
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <wx/intl.h> #include <wx/intl.h>
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 30;
//-----------------------------------------------------------------------------
// globals
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMDIParentFrame // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
@ -38,7 +46,10 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//-----------------------------------------------------------------------------
// page change callback // page change callback
//-----------------------------------------------------------------------------
static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget), static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page, GtkNotebookPage *page,
gint WXUNUSED(nPage), gint WXUNUSED(nPage),
@ -59,6 +70,8 @@ static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
} }
} }
//-----------------------------------------------------------------------------
// wxMDIParentFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
@ -109,7 +122,7 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
int x = 0; int x = 0;
int y = 0; int y = 0;
GetClientSize( &x, &y ); GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 ); m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
} }
} }
@ -122,7 +135,7 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
int x = 0; int x = 0;
int y = 0; int y = 0;
GetClientSize( &x, &y ); GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 ); m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }
@ -214,6 +227,7 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_title = title; m_title = title;
return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
} }
@ -262,7 +276,7 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
} }
mdi_frame->SetMDIMenuBar( m_menuBar ); mdi_frame->SetMDIMenuBar( m_menuBar );
gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWindow), gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_wxwindow),
m_menuBar->m_widget, m_menuBar->m_x, m_menuBar->m_y ); m_menuBar->m_widget, m_menuBar->m_x, m_menuBar->m_y );
} }
} }
@ -280,6 +294,32 @@ void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) )
{ {
} }
//-----------------------------------------------------------------------------
// InsertChild callback for wxMDIClientWindow
//-----------------------------------------------------------------------------
static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child )
{
wxString s = child->m_title;
if (s.IsNull()) s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
gtk_notebook_append_page( notebook, child->m_widget, label_widget );
child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
gtk_notebook_set_page( notebook, parent->m_children.Number()-1 );
gtk_page_change_callback( (GtkNotebook *) NULL, child->m_page, 0, parent );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMDIClientWindow // wxMDIClientWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -303,6 +343,8 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" ); PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
@ -312,6 +354,8 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -319,35 +363,5 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
return TRUE; return TRUE;
} }
void wxMDIClientWindow::AddChild( wxWindow *child )
{
if (!child->IsKindOf(CLASSINFO(wxMDIChildFrame)))
{
wxFAIL_MSG("wxNotebook::AddChild: Child has to be wxMDIChildFrame");
return;
}
m_children.Append( child );
wxString s;
wxMDIChildFrame* mdi_child = (wxMDIChildFrame*) child;
s = mdi_child->m_title;
if (s.IsNull()) s = _("MDI child");
GtkWidget *label_widget;
label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), child->m_widget, label_widget );
mdi_child->m_page = (GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), m_children.Number()-1 );
gtk_page_change_callback( (GtkNotebook *) NULL, mdi_child->m_page, 0, this );
}

View File

@ -7,9 +7,9 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "menu.h" #pragma implementation "menu.h"
#pragma implementation "menuitem.h"
#endif #endif
#include "wx/menu.h" #include "wx/menu.h"

View File

@ -36,7 +36,6 @@ public:
m_box = (GtkWidget *) NULL; m_box = (GtkWidget *) NULL;
} }
//private:
int m_id; int m_id;
wxString m_text; wxString m_text;
int m_image; int m_image;
@ -87,6 +86,40 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//-----------------------------------------------------------------------------
// InsertChild callback for wxNotebook
//-----------------------------------------------------------------------------
static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
{
wxNotebookPage *page = new wxNotebookPage();
page->m_id = parent->GetPageCount();
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget);
page->m_client = child;
gtk_notebook_append_page( notebook, child->m_widget, page->m_box );
page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
page->m_parent = notebook;
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
return;
}
parent->m_pages.Append( page );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebook // wxNotebook
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -127,6 +160,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@ -141,6 +175,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
(gpointer)this (gpointer)this
); );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -411,39 +449,6 @@ wxWindow *wxNotebook::GetPage( int page ) const
return nb_page->m_client; return nb_page->m_client;
} }
void wxNotebook::AddChild( wxWindow *win )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
page->m_id = GetPageCount();
page->m_box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(page->m_box), 2);
page->m_client = win;
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, page->m_box );
page->m_page =
(GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
page->m_parent = GTK_NOTEBOOK(m_widget);
gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
return;
}
m_pages.Append( page );
}
// override these 2 functions to do nothing: everything is done in OnSize // override these 2 functions to do nothing: everything is done in OnSize
void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{ {

View File

@ -159,6 +159,9 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
if (newSize.y == -1) newSize.y = height; if (newSize.y == -1) newSize.y = height;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height );
PostCreation(); PostCreation();
SetLabel( title ); SetLabel( title );

View File

@ -60,6 +60,9 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -126,6 +126,10 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event", gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -99,10 +99,13 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
SetRange( minValue, maxValue ); SetRange( minValue, maxValue );
SetValue( value ); SetValue( value );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE ); Show( TRUE );

View File

@ -57,6 +57,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
m_widget = gtk_label_new( "Bitmap" ); m_widget = gtk_label_new( "Bitmap" );
} }
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -40,6 +40,10 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
m_widget = gtk_frame_new(m_label); m_widget = gtk_frame_new(m_label);
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetLabel(label); SetLabel(label);

View File

@ -92,6 +92,10 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() ); SetBackgroundColour( parent->GetBackgroundColour() );

View File

@ -118,6 +118,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );

View File

@ -119,6 +119,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
if (bMultiLine) if (bMultiLine)
@ -136,6 +140,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
{ {
gint tmp = 0; gint tmp = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp ); gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
SetInsertionPointEnd();
} }
if (style & wxTE_READONLY) if (style & wxTE_READONLY)

View File

@ -132,6 +132,10 @@ printf("5\n");
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
printf("Robert's new insertion code :-)\n");
m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
printf("postcreate\n"); printf("postcreate\n");
PostCreation(); PostCreation();

View File

@ -23,12 +23,9 @@
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/mdi.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
@ -862,6 +859,29 @@ static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailab
*/ */
} }
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
// Callback for wxWindow. 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 superflouus (such in the MDI window system),
// but no-one is listening to me...
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
child->m_y );
gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
child->m_width,
child->m_height );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -917,6 +937,15 @@ wxWindow::wxWindow()
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = wxInsertChildInWindow;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_insertCallback = wxInsertChildInWindow;
Create( parent, id, pos, size, style, name );
} }
bool wxWindow::Create( wxWindow *parent, wxWindowID id, bool wxWindow::Create( wxWindow *parent, wxWindowID id,
@ -927,8 +956,6 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
m_cursor = (wxCursor *) NULL;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
@ -1017,6 +1044,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
if (m_parent) m_parent->AddChild( this );
(m_parent->m_insertCallback)( m_parent, this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@ -1086,12 +1117,29 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
m_x = (int)pos.x;
m_y = (int)pos.y;
m_width = size.x; m_width = size.x;
if (m_width == -1) m_width = 20; if (m_width == -1) m_width = 20;
m_height = size.y; m_height = size.y;
if (m_height == -1) m_height = 20; if (m_height == -1) m_height = 20;
m_x = (int)pos.x;
m_y = (int)pos.y;
if (!m_needParent) // some reasonable defaults
{
if (m_x == -1)
{
m_x = (gdk_screen_width () - m_width) / 2;
if (m_x < 10) m_x = 10;
}
if (m_y == -1)
{
m_y = (gdk_screen_height () - m_height) / 2;
if (m_y < 10) m_y = 10;
}
}
m_minWidth = -1; m_minWidth = -1;
m_minHeight = -1; m_minHeight = -1;
m_maxWidth = -1; m_maxWidth = -1;
@ -1123,8 +1171,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
void wxWindow::PostCreation() void wxWindow::PostCreation()
{ {
if (m_parent) m_parent->AddChild( this );
if (m_wxwindow) if (m_wxwindow)
{ {
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
@ -1220,6 +1266,21 @@ void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
// are we to set fonts here ? // are we to set fonts here ?
} }
wxPoint wxWindow::GetClientAreaOrigin() const
{
return wxPoint(0,0);
}
void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
{
if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
x += pt.x;
y += pt.y;
}
}
void wxWindow::ImplementSetSize() void wxWindow::ImplementSetSize()
{ {
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
@ -1231,13 +1292,6 @@ void wxWindow::ImplementSetSize()
void wxWindow::ImplementSetPosition() void wxWindow::ImplementSetPosition()
{ {
if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
{
if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y );
return;
}
if (!m_parent) if (!m_parent)
{ {
wxFAIL_MSG( "wxWindow::SetSize error.\n" ); wxFAIL_MSG( "wxWindow::SetSize error.\n" );
@ -1280,12 +1334,15 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
if (newH == -1) newH = 26; if (newH == -1) newH = 26;
} }
AdjustForParentClientOrigin( newX, newY, sizeFlags );
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet)) if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
{ {
m_x = newX; m_x = newX;
m_y = newY; m_y = newY;
ImplementSetPosition(); ImplementSetPosition();
} }
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet)) if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{ {
m_width = newW; m_width = newW;
@ -1445,8 +1502,18 @@ void wxWindow::GetPosition( int *x, int *y ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (x) (*x) = m_x; int xx = m_x;
if (y) (*y) = m_y; int yy = m_y;
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
if (x) (*x) = xx;
if (y) (*y) = yy;
} }
void wxWindow::ClientToScreen( int *x, int *y ) void wxWindow::ClientToScreen( int *x, int *y )
@ -1472,6 +1539,10 @@ void wxWindow::ClientToScreen( int *x, int *y )
} }
} }
wxPoint pt(GetClientAreaOrigin());
org_x += pt.x;
org_y += pt.y;
if (x) *x += org_x; if (x) *x += org_x;
if (y) *y += org_y; if (y) *y += org_y;
} }
@ -1499,6 +1570,10 @@ void wxWindow::ScreenToClient( int *x, int *y )
} }
} }
wxPoint pt(GetClientAreaOrigin());
org_x -= pt.x;
org_y -= pt.y;
if (x) *x -= org_x; if (x) *x -= org_x;
if (y) *y -= org_y; if (y) *y -= org_y;
} }
@ -1676,72 +1751,9 @@ bool wxWindow::OnClose()
void wxWindow::AddChild( wxWindow *child ) void wxWindow::AddChild( wxWindow *child )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window need client area" );
wxASSERT_MSG( (child != NULL), "invalid child" ); wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// Addchild is (often) called before the program
// has left the parents constructor so that no
// virtual tables work yet. The approach below
// practically imitates virtual tables, i.e. it
// implements a different AddChild() behaviour
// for wxFrame, wxDialog, wxWindow and
// wxMDIParentFrame.
// wxFrame and wxDialog as children aren't placed into the parents
if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) /*&&
(!IS_KIND_OF(child,wxMDIChildFrame))*/)
{
m_children.Append( child );
if ((child->m_x != -1) && (child->m_y != -1))
gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
return;
}
// In the case of an wxMDIChildFrame descendant, we use the
// client windows's AddChild()
if (IS_KIND_OF(this,wxMDIParentFrame))
{
if (IS_KIND_OF(child,wxMDIChildFrame))
{
wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow();
if (client)
{
client->AddChild( child );
return;
}
}
}
// wxNotebook is very special, so it has a private AddChild()
if (IS_KIND_OF(this,wxNotebook))
{
wxNotebook *tab = (wxNotebook*)this;
tab->AddChild( child );
return;
}
// wxFrame has a private AddChild
if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame))
{
wxFrame *frame = (wxFrame*)this;
frame->AddChild( child );
return;
}
// All the rest
m_children.Append( child ); m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget,
child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
} }
wxList *wxWindow::GetChildren() wxList *wxWindow::GetChildren()
@ -1751,8 +1763,7 @@ wxList *wxWindow::GetChildren()
void wxWindow::RemoveChild( wxWindow *child ) void wxWindow::RemoveChild( wxWindow *child )
{ {
if (GetChildren()) if (GetChildren()) GetChildren()->DeleteObject( child );
GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL; child->m_parent = (wxWindow *) NULL;
} }