#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+#include "wx/gtk/win_gtk.h"
#endif
bool Destroy();
virtual bool Show( bool show );
- virtual void Enable( bool enable );
virtual void Centre( int direction = wxHORIZONTAL );
virtual void GetClientSize( int *width, int *height ) const;
void OnCloseWindow( wxCloseEvent& event );
void OnIdle(wxIdleEvent& event);
- void AddChild( wxWindow *child );
-
// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
-
-private:
- friend wxWindow;
- friend wxMDIChildFrame;
- friend wxMDIClientWindow;
-
- // update frame's menus (called from OnIdle)
+ virtual void ImplementSetPosition();
+ virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu);
- virtual void ImplementSetPosition();
- GtkWidget *m_mainWindow;
wxMenuBar *m_frameMenuBar;
wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar;
- int m_toolBarHeight;
- bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title;
wxIcon m_icon;
wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 );
~wxMDIClientWindow(void);
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
- void AddChild( wxWindow *child );
};
#endif // __MDIH__
#include "wx/object.h"
#include "wx/list.h"
#include "wx/window.h"
+#include "wx/menuitem.h"
//-----------------------------------------------------------------------------
// classes
// 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
{
DECLARE_DYNAMIC_CLASS(wxMenu)
///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.h
// Purpose: wxMenuItem class
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 11.11.97
+// Author: Robert Roebling
// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
-#ifndef _MENUITEM_H
-#define _MENUITEM_H
+#ifndef __GTKMENUITEMH__
+#define __GTKMENUITEMH__
#ifdef __GNUG__
-#pragma interface "menuitem.h"
+#pragma interface
#endif
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#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
+#include "wx/defs.h"
+#include "wx/string.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
-// id for a separator line in the menu (invalid for normal item)
#define ID_SEPARATOR (-1)
-// ----------------------------------------------------------------------------
-// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
-// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxMenuItem: public wxObject
-#if wxUSE_OWNER_DRAWN
- , public wxOwnerDrawn
-#endif
-{
-DECLARE_DYNAMIC_CLASS(wxMenuItem)
-
-public:
- // ctor & dtor
- wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR,
- const wxString& strName = "", const wxString& wxHelp = "",
- bool bCheckable = FALSE, wxMenu *pSubMenu = NULL);
- virtual ~wxMenuItem();
+//-----------------------------------------------------------------------------
+// classes
+//-----------------------------------------------------------------------------
- // accessors (some more are inherited from wxOwnerDrawn or are below)
- bool IsSeparator() const { return m_idItem == ID_SEPARATOR; }
- bool IsEnabled() const { return m_bEnabled; }
- bool IsChecked() const { return m_bChecked; }
+class wxMenuItem;
- int GetId() const { return m_idItem; }
- const wxString& GetHelp() const { return m_strHelp; }
- wxMenu *GetSubMenu() const { return m_pSubMenu; }
+class wxMenu;
- // operations
- void SetName(const wxString& strName) { m_strName = strName; }
- void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; }
+//-----------------------------------------------------------------------------
+// wxMenuItem
+//-----------------------------------------------------------------------------
- void Enable(bool bDoEnable = TRUE);
- void Check(bool bDoCheck = TRUE);
+class wxMenuItem: public wxObject
+{
+DECLARE_DYNAMIC_CLASS(wxMenuItem)
- void DeleteSubMenu();
+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_idItem; // numeric id of the item
- wxString m_strHelp; // associated help string
- wxMenu *m_pSubMenu, // may be NULL
- *m_pParentMenu; // menu this item is contained in
- bool m_bEnabled, // enabled or greyed?
- m_bChecked; // checked? (only if checkable)
-
-#if wxUSE_OWNER_DRAWN
- // 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
+ 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
};
-#endif //_MENUITEM_H
+
+#endif
+ //__GTKMENUITEMH__
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#ifndef __NOTEBOOKH__
-#define __NOTEBOOKH__
+#ifndef __GTKNOTEBOOKH__
+#define __GTKNOTEBOOKH__
#ifdef __GNUG__
-#pragma interface "notebook.h"
+#pragma interface
#endif
#include "wx/defs.h"
// get the panel which represents the given page
wxWindow *GetPage(int nPage) const;
+
// implementation
- void AddChild(wxWindow *child);
void SetConstraintSizes(bool recurse);
bool DoPhase(int phase);
void ApplyWidgetStyle();
-
-private:
// common part of all ctors
void Init();
},
#endif
- // __NOTEBOOKH__
+ // __GTKNOTEBOOKH__
class wxWindow;
class wxCanvas;
+//-----------------------------------------------------------------------------
+// callback definition for inserting a window
+//-----------------------------------------------------------------------------
+
+typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
+
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
public:
wxWindow();
- inline wxWindow(wxWindow *parent, wxWindowID id,
+ wxWindow(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
- const wxString& name = wxPanelNameStr)
- {
- Create(parent, id, pos, size, style, name);
- }
+ const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
// implementation
- virtual GtkWidget* GetConnectWidget(void);
- virtual bool IsOwnGtkWindow( GdkWindow *window );
- void ConnectWidget( GtkWidget *widget );
- void ConnectDnDWidget( GtkWidget *widget );
- void DisconnectDnDWidget( GtkWidget *widget );
+ virtual GtkWidget *GetConnectWidget(void);
+ virtual bool IsOwnGtkWindow( GdkWindow *window );
+ void ConnectWidget( GtkWidget *widget );
+ void ConnectDnDWidget( GtkWidget *widget );
+ void DisconnectDnDWidget( GtkWidget *widget );
+
+ void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
+ const wxSize &size, long style, const wxString &name );
+ void PostCreation();
+ bool HasVMT();
+
+ virtual void ImplementSetSize();
+ virtual void ImplementSetPosition();
+
+ virtual wxPoint GetClientAreaOrigin() const;
+ virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
+
+ GtkStyle *GetWidgetStyle();
+ void SetWidgetStyle();
+ virtual void ApplyWidgetStyle();
- void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
- const wxSize &size, long style, const wxString &name );
- void PostCreation();
- bool HasVMT();
- virtual void ImplementSetSize();
- virtual void ImplementSetPosition();
- GtkStyle *GetWidgetStyle();
- void SetWidgetStyle();
- virtual void ApplyWidgetStyle();
wxWindow *m_parent;
wxList m_children;
bool m_resizing;
GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle;
+
+ wxInsertChildFunction m_insertCallback;
public:
bool Destroy();
virtual bool Show( bool show );
- virtual void Enable( bool enable );
virtual void Centre( int direction = wxHORIZONTAL );
virtual void GetClientSize( int *width, int *height ) const;
void OnCloseWindow( wxCloseEvent& event );
void OnIdle(wxIdleEvent& event);
- void AddChild( wxWindow *child );
-
// implementation
virtual void GtkOnSize( int x, int y, int width, int height );
-
-private:
- friend wxWindow;
- friend wxMDIChildFrame;
- friend wxMDIClientWindow;
-
- // update frame's menus (called from OnIdle)
+ virtual void ImplementSetPosition();
+ virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu);
- virtual void ImplementSetPosition();
- GtkWidget *m_mainWindow;
wxMenuBar *m_frameMenuBar;
wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar;
- int m_toolBarHeight;
- bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title;
wxIcon m_icon;
wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 );
~wxMDIClientWindow(void);
virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL );
- void AddChild( wxWindow *child );
};
#endif // __MDIH__
#include "wx/object.h"
#include "wx/list.h"
#include "wx/window.h"
+#include "wx/menuitem.h"
//-----------------------------------------------------------------------------
// classes
// 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
{
DECLARE_DYNAMIC_CLASS(wxMenu)
///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.h
// Purpose: wxMenuItem class
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 11.11.97
+// Author: Robert Roebling
// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
-#ifndef _MENUITEM_H
-#define _MENUITEM_H
+#ifndef __GTKMENUITEMH__
+#define __GTKMENUITEMH__
#ifdef __GNUG__
-#pragma interface "menuitem.h"
+#pragma interface
#endif
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#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
+#include "wx/defs.h"
+#include "wx/string.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
-// id for a separator line in the menu (invalid for normal item)
#define ID_SEPARATOR (-1)
-// ----------------------------------------------------------------------------
-// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
-// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxMenuItem: public wxObject
-#if wxUSE_OWNER_DRAWN
- , public wxOwnerDrawn
-#endif
-{
-DECLARE_DYNAMIC_CLASS(wxMenuItem)
-
-public:
- // ctor & dtor
- wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR,
- const wxString& strName = "", const wxString& wxHelp = "",
- bool bCheckable = FALSE, wxMenu *pSubMenu = NULL);
- virtual ~wxMenuItem();
+//-----------------------------------------------------------------------------
+// classes
+//-----------------------------------------------------------------------------
- // accessors (some more are inherited from wxOwnerDrawn or are below)
- bool IsSeparator() const { return m_idItem == ID_SEPARATOR; }
- bool IsEnabled() const { return m_bEnabled; }
- bool IsChecked() const { return m_bChecked; }
+class wxMenuItem;
- int GetId() const { return m_idItem; }
- const wxString& GetHelp() const { return m_strHelp; }
- wxMenu *GetSubMenu() const { return m_pSubMenu; }
+class wxMenu;
- // operations
- void SetName(const wxString& strName) { m_strName = strName; }
- void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; }
+//-----------------------------------------------------------------------------
+// wxMenuItem
+//-----------------------------------------------------------------------------
- void Enable(bool bDoEnable = TRUE);
- void Check(bool bDoCheck = TRUE);
+class wxMenuItem: public wxObject
+{
+DECLARE_DYNAMIC_CLASS(wxMenuItem)
- void DeleteSubMenu();
+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_idItem; // numeric id of the item
- wxString m_strHelp; // associated help string
- wxMenu *m_pSubMenu, // may be NULL
- *m_pParentMenu; // menu this item is contained in
- bool m_bEnabled, // enabled or greyed?
- m_bChecked; // checked? (only if checkable)
-
-#if wxUSE_OWNER_DRAWN
- // 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
+ 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
};
-#endif //_MENUITEM_H
+
+#endif
+ //__GTKMENUITEMH__
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#ifndef __NOTEBOOKH__
-#define __NOTEBOOKH__
+#ifndef __GTKNOTEBOOKH__
+#define __GTKNOTEBOOKH__
#ifdef __GNUG__
-#pragma interface "notebook.h"
+#pragma interface
#endif
#include "wx/defs.h"
// get the panel which represents the given page
wxWindow *GetPage(int nPage) const;
+
// implementation
- void AddChild(wxWindow *child);
void SetConstraintSizes(bool recurse);
bool DoPhase(int phase);
void ApplyWidgetStyle();
-
-private:
// common part of all ctors
void Init();
},
#endif
- // __NOTEBOOKH__
+ // __GTKNOTEBOOKH__
class wxWindow;
class wxCanvas;
+//-----------------------------------------------------------------------------
+// callback definition for inserting a window
+//-----------------------------------------------------------------------------
+
+typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
+
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
public:
wxWindow();
- inline wxWindow(wxWindow *parent, wxWindowID id,
+ wxWindow(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
- const wxString& name = wxPanelNameStr)
- {
- Create(parent, id, pos, size, style, name);
- }
+ const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
// implementation
- virtual GtkWidget* GetConnectWidget(void);
- virtual bool IsOwnGtkWindow( GdkWindow *window );
- void ConnectWidget( GtkWidget *widget );
- void ConnectDnDWidget( GtkWidget *widget );
- void DisconnectDnDWidget( GtkWidget *widget );
+ virtual GtkWidget *GetConnectWidget(void);
+ virtual bool IsOwnGtkWindow( GdkWindow *window );
+ void ConnectWidget( GtkWidget *widget );
+ void ConnectDnDWidget( GtkWidget *widget );
+ void DisconnectDnDWidget( GtkWidget *widget );
+
+ void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
+ const wxSize &size, long style, const wxString &name );
+ void PostCreation();
+ bool HasVMT();
+
+ virtual void ImplementSetSize();
+ virtual void ImplementSetPosition();
+
+ virtual wxPoint GetClientAreaOrigin() const;
+ virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
+
+ GtkStyle *GetWidgetStyle();
+ void SetWidgetStyle();
+ virtual void ApplyWidgetStyle();
- void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
- const wxSize &size, long style, const wxString &name );
- void PostCreation();
- bool HasVMT();
- virtual void ImplementSetSize();
- virtual void ImplementSetPosition();
- GtkStyle *GetWidgetStyle();
- void SetWidgetStyle();
- virtual void ApplyWidgetStyle();
wxWindow *m_parent;
wxList m_children;
bool m_resizing;
GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle;
+
+ wxInsertChildFunction m_insertCallback;
public:
panel->SetBackgroundColour("cadet blue");
panel->SetForegroundColour("blue");
wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
+ (*tc) << " More text.";
tc->SetBackgroundColour("wheat");
tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
+ (*tc) << " More text.";
tc->SetBackgroundColour("wheat");
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
{
// 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);
// Give it an icon (this is ignored in MDI mode: uses resources)
#endif
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;
toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file");
currentX += width + 5;
// m_currentCursor = wxSTANDARD_CURSOR;
m_currentCursor = (wxCursor *) NULL;
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
+ m_isDraging = FALSE;
}
void wxListHeaderWindow::DoDrawRect( wxPaintDC *dc, int x, int y, int w, int h )
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child );
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
ConnectWidget( GTK_COMBO(m_widget)->button );
gtk_widget_set_usize( m_widget, m_width, m_height );
+ if (m_parent) m_parent->AddChild( this );
+
+
PostCreation();
return TRUE;
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
-#include "wx/mdi.h"
#include "wx/dcclient.h"
#include "wx/gtk/win_gtk.h"
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
- m_addPrivateChild = FALSE;
- m_wxwindow = (GtkWidget *) NULL;
- m_mainWindow = (GtkWidget *) NULL;
wxTopLevelWindows.Insert( this );
}
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
- m_addPrivateChild = FALSE;
- m_wxwindow = (GtkWidget *) NULL;
- m_mainWindow = (GtkWidget *) NULL;
Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this );
}
gtk_window_set_title( GTK_WINDOW(m_widget), title );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
- gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL);
+ gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
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();
gtk_widget_show( m_wxwindow );
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_FUNC(gtk_frame_size_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
+ if (m_parent) m_parent->AddChild( this );
+
PostCreation();
- gtk_widget_realize( m_mainWindow );
-
return TRUE;
}
if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar;
-// if (m_mainWindow) gtk_widget_destroy( m_mainWindow );
-
wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
}
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 )
{
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
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)
{
if ((m_x != -1) || (m_y != -1))
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
+
ImplementSetPosition();
}
if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return;
- if (!m_mainWindow) return;
if (!m_wxwindow) return;
m_width = width;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
- gtk_widget_set_usize( m_widget, width, height );
-
- int main_x = 0;
- 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.
+ gtk_widget_set_usize( m_widget, m_width, m_height );
-// not really needed
-// gtk_widget_set_usize( m_mainWindow, width, height );
+ // This emulates the new wxMSW behaviour
if (m_frameMenuBar)
{
- main_y = wxMENU_HEIGHT;
- main_height -= wxMENU_HEIGHT;
- }
-
- int toolbar_height = 0;
- if (m_frameToolBar) m_frameToolBar->GetSize( (int *) NULL, &toolbar_height );
-
- 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 );
+ m_frameMenuBar->m_x = 1;
+ m_frameMenuBar->m_y = 1;
+ m_frameMenuBar->m_width = m_width-2;
+ m_frameMenuBar->m_height = wxMENU_HEIGHT-2;
+ gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 );
+ gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
}
if (m_frameToolBar)
{
int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
- gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
+ int h = m_frameToolBar->m_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)
{
- 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;
{
wxWindow *win = (wxWindow *)node->Data();
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_frameToolBar) &&
(win != m_frameStatusBar)
}
}
-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 )
{
menu->SetInvokingWindow( win );
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
- wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
m_frameMenuBar = menuBar;
if (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 );
}
}
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
- m_addPrivateChild = TRUE;
m_frameToolBar = OnCreateToolBar( style, id, name );
- m_addPrivateChild = FALSE;
+
+ GetChildren()->DeleteObject( m_frameToolBar );
return m_frameToolBar;
}
m_widget = gtk_progress_bar_new();
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
gtk_widget_show( list_item );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
gtk_widget_realize( GTK_WIDGET(m_list) );
#include "wx/gtk/win_gtk.h"
#include <wx/intl.h>
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const int wxMENU_HEIGHT = 30;
+
+//-----------------------------------------------------------------------------
+// globals
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
-// wxMDIParentFrame
+// "size_allocate"
//-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
}
+//-----------------------------------------------------------------------------
// page change callback
+//-----------------------------------------------------------------------------
+
static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page,
gint WXUNUSED(nPage),
}
}
+//-----------------------------------------------------------------------------
+// wxMDIParentFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
int x = 0;
int y = 0;
GetClientSize( &x, &y );
- m_mdiMenuBar->SetSize( 1, 1, x-2, 26 );
+ m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
}
}
int x = 0;
int y = 0;
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 );
}
}
long style, const wxString& name )
{
m_title = title;
+
return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
}
}
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 );
}
}
{
}
+//-----------------------------------------------------------------------------
+// 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
//-----------------------------------------------------------------------------
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{
m_needParent = TRUE;
+
+ m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
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();
Show( 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 );
-}
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
#ifdef __GNUG__
#pragma implementation "menu.h"
+#pragma implementation "menuitem.h"
#endif
#include "wx/menu.h"
m_box = (GtkWidget *) NULL;
}
-//private:
int m_id;
wxString m_text;
int m_image;
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
//-----------------------------------------------------------------------------
long style, const wxString& name )
{
m_needParent = TRUE;
+ m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name );
(gpointer)this
);
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
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
void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{
if (newSize.y == -1) newSize.y = height;
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();
SetLabel( title );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
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();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
SetRange( minValue, maxValue );
SetValue( value );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
- SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE );
m_widget = gtk_label_new( "Bitmap" );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
m_widget = gtk_frame_new(m_label);
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetLabel(label);
SetSize( newSize.x, newSize.y );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
if (bMultiLine)
{
gint tmp = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
+ SetInsertionPointEnd();
}
if (style & wxTE_READONLY)
SetName(name);
SetValidator(validator);
+printf("Robert's new insertion code :-)\n");
+ m_parent->AddChild( this );
+ (m_parent->m_insertCallback)( m_parent, this );
+
printf("postcreate\n");
PostCreation();
#include "wx/msgdlg.h"
#include "wx/dcclient.h"
#include "wx/dnd.h"
-#include "wx/mdi.h"
#include "wx/menu.h"
-#include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
-#include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
*/
}
+//-----------------------------------------------------------------------------
+// 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
//-----------------------------------------------------------------------------
m_resizing = FALSE;
m_scrollGC = (GdkGC*) 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,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
m_isEnabled = TRUE;
m_needParent = TRUE;
- m_cursor = (wxCursor *) NULL;
-
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
gtk_widget_show( m_wxwindow );
+
+ if (m_parent) m_parent->AddChild( this );
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
{
if (m_needParent && (parent == NULL))
wxFatalError( "Need complete parent.", name );
-
+
m_widget = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
- m_x = (int)pos.x;
- m_y = (int)pos.y;
+
m_width = size.x;
if (m_width == -1) m_width = 20;
m_height = size.y;
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_minHeight = -1;
m_maxWidth = -1;
void wxWindow::PostCreation()
{
- if (m_parent) m_parent->AddChild( this );
-
if (m_wxwindow)
{
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
// 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()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
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)
{
wxFAIL_MSG( "wxWindow::SetSize error.\n" );
if (newH == -1) newH = 26;
}
+ AdjustForParentClientOrigin( newX, newY, sizeFlags );
+
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
{
m_x = newX;
m_y = newY;
ImplementSetPosition();
}
+
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{
m_width = newW;
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (x) (*x) = m_x;
- if (y) (*y) = m_y;
+ int xx = m_x;
+ 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 )
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x += pt.x;
+ org_y += pt.y;
+
if (x) *x += org_x;
if (y) *y += org_y;
}
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x -= pt.x;
+ org_y -= pt.y;
+
if (x) *x -= org_x;
if (y) *y -= org_y;
}
void wxWindow::AddChild( wxWindow *child )
{
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->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 );
- 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()
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren())
- GetChildren()->DeleteObject( child );
+ if (GetChildren()) GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), (gpointer*)this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
gtk_widget_realize( GTK_BUTTON( m_widget )->child );
}
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
ConnectWidget( GTK_COMBO(m_widget)->button );
gtk_widget_set_usize( m_widget, m_width, m_height );
+ if (m_parent) m_parent->AddChild( this );
+
+
PostCreation();
return TRUE;
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
-#include "wx/mdi.h"
#include "wx/dcclient.h"
#include "wx/gtk/win_gtk.h"
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
- m_addPrivateChild = FALSE;
- m_wxwindow = (GtkWidget *) NULL;
- m_mainWindow = (GtkWidget *) NULL;
wxTopLevelWindows.Insert( this );
}
m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE;
- m_addPrivateChild = FALSE;
- m_wxwindow = (GtkWidget *) NULL;
- m_mainWindow = (GtkWidget *) NULL;
Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this );
}
gtk_window_set_title( GTK_WINDOW(m_widget), title );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
- gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL);
+ gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
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();
gtk_widget_show( m_wxwindow );
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_FUNC(gtk_frame_size_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
+ if (m_parent) m_parent->AddChild( this );
+
PostCreation();
- gtk_widget_realize( m_mainWindow );
-
return TRUE;
}
if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar;
-// if (m_mainWindow) gtk_widget_destroy( m_mainWindow );
-
wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
}
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 )
{
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
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)
{
if ((m_x != -1) || (m_y != -1))
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
+
ImplementSetPosition();
}
if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return;
- if (!m_mainWindow) return;
if (!m_wxwindow) return;
m_width = width;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
- gtk_widget_set_usize( m_widget, width, height );
-
- int main_x = 0;
- 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.
+ gtk_widget_set_usize( m_widget, m_width, m_height );
-// not really needed
-// gtk_widget_set_usize( m_mainWindow, width, height );
+ // This emulates the new wxMSW behaviour
if (m_frameMenuBar)
{
- main_y = wxMENU_HEIGHT;
- main_height -= wxMENU_HEIGHT;
- }
-
- int toolbar_height = 0;
- if (m_frameToolBar) m_frameToolBar->GetSize( (int *) NULL, &toolbar_height );
-
- 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 );
+ m_frameMenuBar->m_x = 1;
+ m_frameMenuBar->m_y = 1;
+ m_frameMenuBar->m_width = m_width-2;
+ m_frameMenuBar->m_height = wxMENU_HEIGHT-2;
+ gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 );
+ gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
}
if (m_frameToolBar)
{
int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
- gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
+ int h = m_frameToolBar->m_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)
{
- 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;
{
wxWindow *win = (wxWindow *)node->Data();
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_frameToolBar) &&
(win != m_frameStatusBar)
}
}
-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 )
{
menu->SetInvokingWindow( win );
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
- wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
m_frameMenuBar = menuBar;
if (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 );
}
}
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
- m_addPrivateChild = TRUE;
m_frameToolBar = OnCreateToolBar( style, id, name );
- m_addPrivateChild = FALSE;
+
+ GetChildren()->DeleteObject( m_frameToolBar );
return m_frameToolBar;
}
m_widget = gtk_progress_bar_new();
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
gtk_widget_show( list_item );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
gtk_widget_realize( GTK_WIDGET(m_list) );
#include "wx/gtk/win_gtk.h"
#include <wx/intl.h>
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const int wxMENU_HEIGHT = 30;
+
+//-----------------------------------------------------------------------------
+// globals
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
-// wxMDIParentFrame
+// "size_allocate"
//-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
}
+//-----------------------------------------------------------------------------
// page change callback
+//-----------------------------------------------------------------------------
+
static void gtk_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page,
gint WXUNUSED(nPage),
}
}
+//-----------------------------------------------------------------------------
+// wxMDIParentFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
int x = 0;
int y = 0;
GetClientSize( &x, &y );
- m_mdiMenuBar->SetSize( 1, 1, x-2, 26 );
+ m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
}
}
int x = 0;
int y = 0;
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 );
}
}
long style, const wxString& name )
{
m_title = title;
+
return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
}
}
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 );
}
}
{
}
+//-----------------------------------------------------------------------------
+// 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
//-----------------------------------------------------------------------------
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
{
m_needParent = TRUE;
+
+ m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI;
PreCreation( parent, -1, wxPoint(10,10), wxSize(100,100), style, "wxMDIClientWindow" );
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();
Show( 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 );
-}
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
#ifdef __GNUG__
#pragma implementation "menu.h"
+#pragma implementation "menuitem.h"
#endif
#include "wx/menu.h"
m_box = (GtkWidget *) NULL;
}
-//private:
int m_id;
wxString m_text;
int m_image;
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
//-----------------------------------------------------------------------------
long style, const wxString& name )
{
m_needParent = TRUE;
+ m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name );
(gpointer)this
);
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
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
void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{
if (newSize.y == -1) newSize.y = height;
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();
SetLabel( title );
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
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();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_signal_connect( GTK_OBJECT(m_widget), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
SetRange( minValue, maxValue );
SetValue( value );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
- SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE );
m_widget = gtk_label_new( "Bitmap" );
}
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
m_widget = gtk_frame_new(m_label);
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetLabel(label);
SetSize( newSize.x, newSize.y );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
SetBackgroundColour( parent->GetBackgroundColour() );
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y );
+ m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
if (bMultiLine)
{
gint tmp = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
+ SetInsertionPointEnd();
}
if (style & wxTE_READONLY)
SetName(name);
SetValidator(validator);
+printf("Robert's new insertion code :-)\n");
+ m_parent->AddChild( this );
+ (m_parent->m_insertCallback)( m_parent, this );
+
printf("postcreate\n");
PostCreation();
#include "wx/msgdlg.h"
#include "wx/dcclient.h"
#include "wx/dnd.h"
-#include "wx/mdi.h"
#include "wx/menu.h"
-#include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
-#include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
*/
}
+//-----------------------------------------------------------------------------
+// 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
//-----------------------------------------------------------------------------
m_resizing = FALSE;
m_scrollGC = (GdkGC*) 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,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
m_isEnabled = TRUE;
m_needParent = TRUE;
- m_cursor = (wxCursor *) NULL;
-
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
gtk_widget_show( m_wxwindow );
+
+ if (m_parent) m_parent->AddChild( this );
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
{
if (m_needParent && (parent == NULL))
wxFatalError( "Need complete parent.", name );
-
+
m_widget = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
- m_x = (int)pos.x;
- m_y = (int)pos.y;
+
m_width = size.x;
if (m_width == -1) m_width = 20;
m_height = size.y;
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_minHeight = -1;
m_maxWidth = -1;
void wxWindow::PostCreation()
{
- if (m_parent) m_parent->AddChild( this );
-
if (m_wxwindow)
{
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
// 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()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
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)
{
wxFAIL_MSG( "wxWindow::SetSize error.\n" );
if (newH == -1) newH = 26;
}
+ AdjustForParentClientOrigin( newX, newY, sizeFlags );
+
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
{
m_x = newX;
m_y = newY;
ImplementSetPosition();
}
+
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{
m_width = newW;
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (x) (*x) = m_x;
- if (y) (*y) = m_y;
+ int xx = m_x;
+ 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 )
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x += pt.x;
+ org_y += pt.y;
+
if (x) *x += org_x;
if (y) *y += org_y;
}
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x -= pt.x;
+ org_y -= pt.y;
+
if (x) *x -= org_x;
if (y) *y -= org_y;
}
void wxWindow::AddChild( wxWindow *child )
{
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->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 );
- 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()
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren())
- GetChildren()->DeleteObject( child );
+ if (GetChildren()) GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}