wxMDIChildFrame inherits from wxFrame

toolbar work
  mini menubar change
  compile fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-07-29 13:21:22 +00:00
parent da468d387d
commit cf4219e77a
17 changed files with 228 additions and 223 deletions

View File

@@ -157,9 +157,6 @@ class WXDLLEXPORT wxView: public wxEvtHandler
inline wxFrame *GetFrame(void) const { return m_viewFrame ; } inline wxFrame *GetFrame(void) const { return m_viewFrame ; }
inline void SetFrame(wxFrame *frame) { m_viewFrame = frame; } inline void SetFrame(wxFrame *frame) { m_viewFrame = frame; }
#ifdef __WXGTK__
inline void SetFrame(wxMDIChildFrame *frame) { m_viewFrame = (wxFrame*)frame; }
#endif
virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView); virtual void OnActivateView(bool activate, wxView *activeView, wxView *deactiveView);
virtual void OnDraw(wxDC *dc) = 0; virtual void OnDraw(wxDC *dc) = 0;

View File

@@ -19,15 +19,17 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/toolbar.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMDIChildFrame; class wxMDIChildFrame;
class wxMDIClientWindow;
class wxMenu;
class wxMenuBar;
class wxToolBar;
class wxStatusBar;
class wxFrame; class wxFrame;
@@ -36,6 +38,7 @@ class wxFrame;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern const char *wxFrameNameStr; extern const char *wxFrameNameStr;
extern const char *wxToolBarNameStr;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxFrame // wxFrame
@@ -77,10 +80,10 @@ public:
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual void SetMenuBar( wxMenuBar *menuBar );
virtual wxMenuBar *GetMenuBar(); virtual wxMenuBar *GetMenuBar();
void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
wxString GetTitle() const { return m_title; } virtual wxString GetTitle() const { return m_title; }
void SetIcon( const wxIcon &icon ); virtual void SetIcon( const wxIcon &icon );
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
@@ -93,6 +96,7 @@ public:
private: private:
friend wxWindow; friend wxWindow;
friend wxMDIChildFrame; friend wxMDIChildFrame;
friend wxMDIClientWindow;
// update frame's menus (called from OnIdle) // update frame's menus (called from OnIdle)
void DoMenuUpdates(); void DoMenuUpdates();
@@ -103,7 +107,6 @@ private:
wxStatusBar *m_frameStatusBar; wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar; wxToolBar *m_frameToolBar;
int m_toolBarHeight; int m_toolBarHeight;
bool m_doingOnSize;
bool m_addPrivateChild; // for toolbar (and maybe menubar) bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;

View File

@@ -100,7 +100,7 @@ class wxMDIParentFrame: public wxFrame
// wxMDIChildFrame // wxMDIChildFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMDIChildFrame: public wxPanel class wxMDIChildFrame: public wxFrame
{ {
DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
@@ -116,25 +116,46 @@ class wxMDIChildFrame: public wxPanel
wxWindowID id, const wxString& title, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr ); long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr );
void SetMenuBar( wxMenuBar *menu_bar );
virtual void SetMenuBar( wxMenuBar *menu_bar );
virtual wxMenuBar *GetMenuBar();
// no status bars in wxGTK virtual void GetClientSize( int *width, int *height ) const;
virtual bool CreateStatusBar( int WXUNUSED(number) = 1 ) { return FALSE; }; virtual void AddChild( wxWindow *child );
virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {};
virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {};
virtual void Maximize(void) {}; virtual void Activate(void);
virtual void Restore(void) {};
virtual void Activate(void); // no status bars
virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number), long WXUNUSED(style),
wxWindowID WXUNUSED(id), const wxString& WXUNUSED(name) ) {return (wxStatusBar*)NULL; }
virtual wxStatusBar *GetStatusBar() { return (wxStatusBar*)NULL; }
virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {}
virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {}
// no size hints
virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW),
int WXUNUSED(maxH), int WXUNUSED(incW) ) {}
// no toolbar bars
virtual wxToolBar* CreateToolBar( long WXUNUSED(style), wxWindowID WXUNUSED(id),
const wxString& WXUNUSED(name) ) { return (wxToolBar*)NULL; }
virtual wxToolBar *GetToolBar() { return (wxToolBar*)NULL; }
// no icon
void SetIcon( const wxIcon &icon ) { m_icon = icon; }
// no title
void SetTitle( const wxString &title ) { m_title = title; }
wxString GetTitle() const { return m_title; }
// no maximize etc
virtual void Maximize(void) {}
virtual void Restore(void) {}
bool Destroy(void);
void OnCloseWindow( wxCloseEvent& event );
void OnSize( wxSizeEvent &event );
void OnActivate( wxActivateEvent &event ); void OnActivate( wxActivateEvent &event );
public: public:
wxString m_title;
wxMenuBar *m_menuBar; wxMenuBar *m_menuBar;
// private: // private:

View File

@@ -117,7 +117,6 @@ class wxToolBar: public wxControl
virtual void EnableTool(int toolIndex, bool enable); virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
virtual void SetToggle(int toolIndex, bool toggle); // Set this to be togglable (or not)
virtual wxObject *GetToolClientData(int index) const; virtual wxObject *GetToolClientData(int index) const;
virtual bool GetToolState(int toolIndex) const; virtual bool GetToolState(int toolIndex) const;

View File

@@ -19,15 +19,17 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/toolbar.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMDIChildFrame; class wxMDIChildFrame;
class wxMDIClientWindow;
class wxMenu;
class wxMenuBar;
class wxToolBar;
class wxStatusBar;
class wxFrame; class wxFrame;
@@ -36,6 +38,7 @@ class wxFrame;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern const char *wxFrameNameStr; extern const char *wxFrameNameStr;
extern const char *wxToolBarNameStr;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxFrame // wxFrame
@@ -77,10 +80,10 @@ public:
virtual void SetMenuBar( wxMenuBar *menuBar ); virtual void SetMenuBar( wxMenuBar *menuBar );
virtual wxMenuBar *GetMenuBar(); virtual wxMenuBar *GetMenuBar();
void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
wxString GetTitle() const { return m_title; } virtual wxString GetTitle() const { return m_title; }
void SetIcon( const wxIcon &icon ); virtual void SetIcon( const wxIcon &icon );
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
@@ -93,6 +96,7 @@ public:
private: private:
friend wxWindow; friend wxWindow;
friend wxMDIChildFrame; friend wxMDIChildFrame;
friend wxMDIClientWindow;
// update frame's menus (called from OnIdle) // update frame's menus (called from OnIdle)
void DoMenuUpdates(); void DoMenuUpdates();
@@ -103,7 +107,6 @@ private:
wxStatusBar *m_frameStatusBar; wxStatusBar *m_frameStatusBar;
wxToolBar *m_frameToolBar; wxToolBar *m_frameToolBar;
int m_toolBarHeight; int m_toolBarHeight;
bool m_doingOnSize;
bool m_addPrivateChild; // for toolbar (and maybe menubar) bool m_addPrivateChild; // for toolbar (and maybe menubar)
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;

View File

@@ -100,7 +100,7 @@ class wxMDIParentFrame: public wxFrame
// wxMDIChildFrame // wxMDIChildFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxMDIChildFrame: public wxPanel class wxMDIChildFrame: public wxFrame
{ {
DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
@@ -116,25 +116,46 @@ class wxMDIChildFrame: public wxPanel
wxWindowID id, const wxString& title, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr ); long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr );
void SetMenuBar( wxMenuBar *menu_bar );
virtual void SetMenuBar( wxMenuBar *menu_bar );
virtual wxMenuBar *GetMenuBar();
// no status bars in wxGTK virtual void GetClientSize( int *width, int *height ) const;
virtual bool CreateStatusBar( int WXUNUSED(number) = 1 ) { return FALSE; }; virtual void AddChild( wxWindow *child );
virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {};
virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {};
virtual void Maximize(void) {}; virtual void Activate(void);
virtual void Restore(void) {};
virtual void Activate(void); // no status bars
virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number), long WXUNUSED(style),
wxWindowID WXUNUSED(id), const wxString& WXUNUSED(name) ) {return (wxStatusBar*)NULL; }
virtual wxStatusBar *GetStatusBar() { return (wxStatusBar*)NULL; }
virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number) ) {}
virtual void SetStatusWidths( int WXUNUSED(n), int *WXUNUSED(width) ) {}
// no size hints
virtual void SetSizeHints( int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW),
int WXUNUSED(maxH), int WXUNUSED(incW) ) {}
// no toolbar bars
virtual wxToolBar* CreateToolBar( long WXUNUSED(style), wxWindowID WXUNUSED(id),
const wxString& WXUNUSED(name) ) { return (wxToolBar*)NULL; }
virtual wxToolBar *GetToolBar() { return (wxToolBar*)NULL; }
// no icon
void SetIcon( const wxIcon &icon ) { m_icon = icon; }
// no title
void SetTitle( const wxString &title ) { m_title = title; }
wxString GetTitle() const { return m_title; }
// no maximize etc
virtual void Maximize(void) {}
virtual void Restore(void) {}
bool Destroy(void);
void OnCloseWindow( wxCloseEvent& event );
void OnSize( wxSizeEvent &event );
void OnActivate( wxActivateEvent &event ); void OnActivate( wxActivateEvent &event );
public: public:
wxString m_title;
wxMenuBar *m_menuBar; wxMenuBar *m_menuBar;
// private: // private:

View File

@@ -117,7 +117,6 @@ class wxToolBar: public wxControl
virtual void EnableTool(int toolIndex, bool enable); virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
virtual void SetToggle(int toolIndex, bool toggle); // Set this to be togglable (or not)
virtual wxObject *GetToolClientData(int index) const; virtual wxObject *GetToolClientData(int index) const;
virtual bool GetToolState(int toolIndex) const; virtual bool GetToolState(int toolIndex) const;

View File

@@ -486,38 +486,7 @@ void wxView::OnChangeFilename(void)
wxString name; wxString name;
GetDocument()->GetPrintableName(name); GetDocument()->GetPrintableName(name);
// If the frame is an MDI child, just set the title to the name. GetFrame()->SetTitle(name);
// Otherwise, append the document name to the name of the application
// I have to do an illegal cast because in wxGTK, wxMDIChildFrame
// doesn't inherited from wxFrame, Robert Roebling
wxFrame *frame = NULL;
wxMDIChildFrame *mdi_frame = NULL;
#ifdef __WXGTK__
if (GetFrame()->IsKindOf(CLASSINFO(wxMDIChildFrame)))
mdi_frame = (wxMDIChildFrame*)GetFrame();
else
#endif
frame = GetFrame();
if (frame)
{
frame->SetTitle(name);
return;
}
#ifdef __WXGTK__
if (mdi_frame)
{
if (wxTheApp->GetAppName() != "")
{
char buf[400];
sprintf(buf, "%s - %s", (const char *)wxTheApp->GetAppName(), (const char *)name);
mdi_frame->SetTitle(buf);
}
else
mdi_frame->SetTitle(name);
}
#endif
} }
} }

View File

@@ -32,6 +32,7 @@
#include <wx/app.h> #include <wx/app.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/menu.h>
#include <wx/generic/msgdlgg.h> #include <wx/generic/msgdlgg.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>

View File

@@ -16,6 +16,9 @@
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/control.h" #include "wx/control.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28; const wxMENU_HEIGHT = 28;
@@ -74,12 +77,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
wxFrame::wxFrame() wxFrame::wxFrame()
{ {
m_doingOnSize = FALSE;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_frameToolBar = NULL; m_frameToolBar = NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE; m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
}; };
@@ -87,12 +91,13 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_doingOnSize = FALSE;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_frameToolBar = NULL; m_frameToolBar = NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE; m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
}; };
@@ -102,13 +107,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
m_mainWindow = NULL;
m_wxwindow = NULL;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_doingOnSize = FALSE;
m_title = title; m_title = title;
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );

View File

@@ -14,6 +14,7 @@
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve
// wxMDIChildFrame // wxMDIChildFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
EVT_SIZE(wxMDIChildFrame::OnSize)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate) EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_title = title; m_title = title;
return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
}; };
void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) void wxMDIChildFrame::GetClientSize( int *width, int *height ) const
{ {
if ( GetEventHandler()->OnClose() || event.GetForce()) wxWindow::GetClientSize( width, height );
{
this->Destroy();
}
};
void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
if ( GetAutoLayout() )
Layout();
else {
// no child: go out !
if (!GetChildren()->First())
return;
// do we have exactly one child?
wxWindow *child = NULL;
for(wxNode *node = GetChildren()->First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
{
if ( child ) // it's the second one: do nothing
return;
child = win;
};
};
// yes: set it's size to fill all the frame
int client_x, client_y;
GetClientSize(&client_x, &client_y);
child->SetSize( 1, 1, client_x-2, client_y);
}
};
bool wxMDIChildFrame::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
} }
void wxMDIChildFrame::AddChild( wxWindow *child )
{
wxWindow::AddChild( child );
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{ {
menu->SetInvokingWindow( win ); menu->SetInvokingWindow( win );
@@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
} }
}; };
wxMenuBar *wxMDIChildFrame::GetMenuBar()
{
return m_menuBar;
};
void wxMDIChildFrame::Activate(void) void wxMDIChildFrame::Activate(void)
{ {
}; };

View File

@@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data )
event.SetEventObject( menu ); event.SetEventObject( menu );
event.SetInt(id ); event.SetInt(id );
wxWindow *win = menu->GetInvokingWindow(); wxWindow *win = menu->GetInvokingWindow();
if (win) win->ProcessEvent( event ); if (win) win->GetEventHandler()->ProcessEvent( event );
}; };
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)

View File

@@ -106,17 +106,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{ {
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
event.SetExtraLong( (long) toggleDown);
/*
wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
event.SetEventObject(this); event.SetEventObject(this);
event.SetInt( toolIndex ); event.SetInt( toolIndex );
event.SetExtraLong((long) toggleDown); event.SetExtraLong((long) toggleDown);
*/
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
@@ -125,7 +118,7 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) ) void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{ {
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex );
event.SetEventObject( this ); event.SetEventObject( this );
event.SetInt( toolIndex ); event.SetInt( toolIndex );
@@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
void wxToolBar::OnMouseEnter( int toolIndex ) void wxToolBar::OnMouseEnter( int toolIndex )
{ {
wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
event.SetEventObject(this); event.SetEventObject(this);
event.SetInt( toolIndex ); event.SetInt( toolIndex );
@@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void)
void wxToolBar::ClearTools(void) void wxToolBar::ClearTools(void)
{ {
wxFAIL_MSG("wxToolBar::ClearTools not implemented");
}; };
void wxToolBar::Realize(void) void wxToolBar::Realize(void)
@@ -204,37 +198,70 @@ void wxToolBar::Realize(void)
void wxToolBar::EnableTool(int toolIndex, bool enable) void wxToolBar::EnableTool(int toolIndex, bool enable)
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex)
{
tool->m_enabled = enable;
return;
}
node = node->Next();
};
}; };
void wxToolBar::ToggleTool(int toolIndex, bool toggle) void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
{
};
void wxToolBar::SetToggle(int toolIndex, bool toggle)
{ {
wxFAIL_MSG("wxToolBar::ToggleTool not implemented");
}; };
wxObject *wxToolBar::GetToolClientData(int index) const wxObject *wxToolBar::GetToolClientData(int index) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
};
return (wxObject*)NULL;
}; };
bool wxToolBar::GetToolState(int toolIndex) const bool wxToolBar::GetToolState(int toolIndex) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
};
return FALSE;
}; };
bool wxToolBar::GetToolEnabled(int toolIndex) const bool wxToolBar::GetToolEnabled(int toolIndex) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
};
return FALSE;
}; };
void wxToolBar::SetMargins(int x, int y) void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{ {
}; };
void wxToolBar::SetToolPacking(int packing) void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{ {
}; };
void wxToolBar::SetToolSeparation(int separation) void wxToolBar::SetToolSeparation( int separation )
{ {
gtk_toolbar_set_space_size( m_toolbar, separation );
}; };

View File

@@ -16,6 +16,9 @@
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/control.h" #include "wx/control.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28; const wxMENU_HEIGHT = 28;
@@ -74,12 +77,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
wxFrame::wxFrame() wxFrame::wxFrame()
{ {
m_doingOnSize = FALSE;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_frameToolBar = NULL; m_frameToolBar = NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE; m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
}; };
@@ -87,12 +91,13 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_doingOnSize = FALSE;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_frameToolBar = NULL; m_frameToolBar = NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
m_addPrivateChild = FALSE; m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
}; };
@@ -102,13 +107,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
m_mainWindow = NULL;
m_wxwindow = NULL;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_doingOnSize = FALSE;
m_title = title; m_title = title;
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );

View File

@@ -14,6 +14,7 @@
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve
// wxMDIChildFrame // wxMDIChildFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
EVT_SIZE(wxMDIChildFrame::OnSize)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate) EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_title = title; m_title = title;
return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
}; };
void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event ) void wxMDIChildFrame::GetClientSize( int *width, int *height ) const
{ {
if ( GetEventHandler()->OnClose() || event.GetForce()) wxWindow::GetClientSize( width, height );
{
this->Destroy();
}
};
void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
if ( GetAutoLayout() )
Layout();
else {
// no child: go out !
if (!GetChildren()->First())
return;
// do we have exactly one child?
wxWindow *child = NULL;
for(wxNode *node = GetChildren()->First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
{
if ( child ) // it's the second one: do nothing
return;
child = win;
};
};
// yes: set it's size to fill all the frame
int client_x, client_y;
GetClientSize(&client_x, &client_y);
child->SetSize( 1, 1, client_x-2, client_y);
}
};
bool wxMDIChildFrame::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
} }
void wxMDIChildFrame::AddChild( wxWindow *child )
{
wxWindow::AddChild( child );
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{ {
menu->SetInvokingWindow( win ); menu->SetInvokingWindow( win );
@@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
} }
}; };
wxMenuBar *wxMDIChildFrame::GetMenuBar()
{
return m_menuBar;
};
void wxMDIChildFrame::Activate(void) void wxMDIChildFrame::Activate(void)
{ {
}; };

View File

@@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data )
event.SetEventObject( menu ); event.SetEventObject( menu );
event.SetInt(id ); event.SetInt(id );
wxWindow *win = menu->GetInvokingWindow(); wxWindow *win = menu->GetInvokingWindow();
if (win) win->ProcessEvent( event ); if (win) win->GetEventHandler()->ProcessEvent( event );
}; };
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)

View File

@@ -106,17 +106,10 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{ {
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
event.SetExtraLong( (long) toggleDown);
/*
wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
event.SetEventObject(this); event.SetEventObject(this);
event.SetInt( toolIndex ); event.SetInt( toolIndex );
event.SetExtraLong((long) toggleDown); event.SetExtraLong((long) toggleDown);
*/
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
@@ -125,7 +118,7 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) ) void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{ {
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex );
event.SetEventObject( this ); event.SetEventObject( this );
event.SetInt( toolIndex ); event.SetInt( toolIndex );
@@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
void wxToolBar::OnMouseEnter( int toolIndex ) void wxToolBar::OnMouseEnter( int toolIndex )
{ {
wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
event.SetEventObject(this); event.SetEventObject(this);
event.SetInt( toolIndex ); event.SetInt( toolIndex );
@@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void)
void wxToolBar::ClearTools(void) void wxToolBar::ClearTools(void)
{ {
wxFAIL_MSG("wxToolBar::ClearTools not implemented");
}; };
void wxToolBar::Realize(void) void wxToolBar::Realize(void)
@@ -204,37 +198,70 @@ void wxToolBar::Realize(void)
void wxToolBar::EnableTool(int toolIndex, bool enable) void wxToolBar::EnableTool(int toolIndex, bool enable)
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex)
{
tool->m_enabled = enable;
return;
}
node = node->Next();
};
}; };
void wxToolBar::ToggleTool(int toolIndex, bool toggle) void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
{
};
void wxToolBar::SetToggle(int toolIndex, bool toggle)
{ {
wxFAIL_MSG("wxToolBar::ToggleTool not implemented");
}; };
wxObject *wxToolBar::GetToolClientData(int index) const wxObject *wxToolBar::GetToolClientData(int index) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
};
return (wxObject*)NULL;
}; };
bool wxToolBar::GetToolState(int toolIndex) const bool wxToolBar::GetToolState(int toolIndex) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
};
return FALSE;
}; };
bool wxToolBar::GetToolEnabled(int toolIndex) const bool wxToolBar::GetToolEnabled(int toolIndex) const
{ {
wxNode *node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
};
return FALSE;
}; };
void wxToolBar::SetMargins(int x, int y) void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{ {
}; };
void wxToolBar::SetToolPacking(int packing) void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{ {
}; };
void wxToolBar::SetToolSeparation(int separation) void wxToolBar::SetToolSeparation( int separation )
{ {
gtk_toolbar_set_space_size( m_toolbar, separation );
}; };