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

@@ -486,38 +486,7 @@ void wxView::OnChangeFilename(void)
wxString name;
GetDocument()->GetPrintableName(name);
// If the frame is an MDI child, just set the title to the 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
GetFrame()->SetTitle(name);
}
}

View File

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

View File

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

View File

@@ -14,6 +14,7 @@
#include "wx/mdi.h"
#include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
@@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve
// wxMDIChildFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel)
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
EVT_SIZE(wxMDIChildFrame::OnSize)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
END_EVENT_TABLE()
@@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name )
{
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())
{
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;
wxWindow::GetClientSize( width, height );
}
void wxMDIChildFrame::AddChild( wxWindow *child )
{
wxWindow::AddChild( child );
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
@@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
}
};
wxMenuBar *wxMDIChildFrame::GetMenuBar()
{
return m_menuBar;
};
void wxMDIChildFrame::Activate(void)
{
};

View File

@@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data )
event.SetEventObject( menu );
event.SetInt(id );
wxWindow *win = menu->GetInvokingWindow();
if (win) win->ProcessEvent( event );
if (win) win->GetEventHandler()->ProcessEvent( event );
};
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 )
{
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
event.SetExtraLong( (long) toggleDown);
/*
wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex );
event.SetEventObject(this);
event.SetInt( toolIndex );
event.SetExtraLong((long) toggleDown);
*/
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) )
{
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex );
wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
@@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
void wxToolBar::OnMouseEnter( int toolIndex )
{
wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex);
wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
event.SetEventObject(this);
event.SetInt( toolIndex );
@@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void)
void wxToolBar::ClearTools(void)
{
wxFAIL_MSG("wxToolBar::ClearTools not implemented");
};
void wxToolBar::Realize(void)
@@ -204,37 +198,70 @@ void wxToolBar::Realize(void)
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::SetToggle(int toolIndex, bool toggle)
void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
{
wxFAIL_MSG("wxToolBar::ToggleTool not implemented");
};
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
{
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
{
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/control.h"
#include "wx/app.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28;
@@ -74,12 +77,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
wxFrame::wxFrame()
{
m_doingOnSize = FALSE;
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_frameToolBar = NULL;
m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
wxTopLevelWindows.Insert( this );
};
@@ -87,12 +91,13 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
m_doingOnSize = FALSE;
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_frameToolBar = NULL;
m_sizeSet = FALSE;
m_addPrivateChild = FALSE;
m_wxwindow = NULL;
m_mainWindow = NULL;
Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this );
};
@@ -102,13 +107,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
long style, const wxString &name )
{
m_needParent = FALSE;
m_mainWindow = NULL;
m_wxwindow = NULL;
PreCreation( parent, id, pos, size, style, name );
m_doingOnSize = FALSE;
m_title = title;
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );

View File

@@ -14,6 +14,7 @@
#include "wx/mdi.h"
#include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
@@ -171,11 +172,9 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve
// wxMDIChildFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel)
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
EVT_SIZE(wxMDIChildFrame::OnSize)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
END_EVENT_TABLE()
@@ -215,55 +214,19 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
long style, const wxString& name )
{
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())
{
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;
wxWindow::GetClientSize( width, height );
}
void wxMDIChildFrame::AddChild( wxWindow *child )
{
wxWindow::AddChild( child );
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
@@ -304,6 +267,11 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
}
};
wxMenuBar *wxMDIChildFrame::GetMenuBar()
{
return m_menuBar;
};
void wxMDIChildFrame::Activate(void)
{
};

View File

@@ -154,7 +154,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data )
event.SetEventObject( menu );
event.SetInt(id );
wxWindow *win = menu->GetInvokingWindow();
if (win) win->ProcessEvent( event );
if (win) win->GetEventHandler()->ProcessEvent( event );
};
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 )
{
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
event.SetExtraLong( (long) toggleDown);
/*
wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, toolIndex );
event.SetEventObject(this);
event.SetInt( toolIndex );
event.SetExtraLong((long) toggleDown);
*/
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) )
{
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex );
wxCommandEvent event( wxEVT_COMMAND_TOOL_RCLICKED, toolIndex );
event.SetEventObject( this );
event.SetInt( toolIndex );
@@ -134,7 +127,7 @@ void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y
void wxToolBar::OnMouseEnter( int toolIndex )
{
wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex);
wxCommandEvent event( wxEVT_COMMAND_TOOL_ENTER, toolIndex );
event.SetEventObject(this);
event.SetInt( toolIndex );
@@ -177,6 +170,7 @@ void wxToolBar::AddSeparator(void)
void wxToolBar::ClearTools(void)
{
wxFAIL_MSG("wxToolBar::ClearTools not implemented");
};
void wxToolBar::Realize(void)
@@ -204,37 +198,70 @@ void wxToolBar::Realize(void)
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::SetToggle(int toolIndex, bool toggle)
void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
{
wxFAIL_MSG("wxToolBar::ToggleTool not implemented");
};
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
{
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
{
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 );
};