mdi private menus

Chris's check menu additions
frame fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-07-22 22:13:31 +00:00
parent 47fa796902
commit 716b736420
29 changed files with 752 additions and 230 deletions

View File

@@ -65,8 +65,8 @@ bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(
//-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_SIZE(wxFrame::OnSize)
EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_IDLE(wxFrame::OnIdle)
END_EVENT_TABLE()
@@ -172,9 +172,12 @@ void wxFrame::Enable( bool enable )
gtk_widget_set_sensitive( m_mainWindow, enable );
};
void wxFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
void wxFrame::OnCloseWindow( wxCloseEvent &event )
{
this->Destroy();
if ( GetEventHandler()->OnClose() || event.GetForce())
{
this->Destroy();
}
};
bool wxFrame::Destroy(void)
@@ -290,7 +293,7 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
}
};
void SetInvokingWindow( wxMenu *menu, wxWindow *win )
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
wxNode *node = menu->m_items.First();
@@ -305,18 +308,24 @@ void SetInvokingWindow( wxMenu *menu, wxWindow *win )
void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{
m_frameMenuBar = menuBar;
wxNode *node = m_frameMenuBar->m_menus.First();
while (node)
if (m_frameMenuBar)
{
wxMenu *menu = (wxMenu*)node->Data();
SetInvokingWindow( menu, this );
node = node->Next();
};
m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
if (m_frameMenuBar->m_parent != this)
{
wxNode *node = m_frameMenuBar->m_menus.First();
while (node)
{
wxMenu *menu = (wxMenu*)node->Data();
SetInvokingWindow( menu, this );
node = node->Next();
};
m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow),
m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
}
}
};
bool wxFrame::CreateStatusBar( int number )

View File

@@ -13,6 +13,11 @@
#endif
#include "wx/mdi.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
// wxMDIParentFrame
@@ -31,15 +36,40 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
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),
wxMDIClientWindow *client_win )
{
wxNode *node = client_win->m_children.First();
while (node)
{
wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data();
if (child_frame->m_page == page)
{
wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)client_win->m_parent;
mdi_frame->m_currentChild = child_frame;
mdi_frame->SetMDIMenuBar( child_frame->m_menuBar );
return;
};
node = node->Next();
}
}
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
END_EVENT_TABLE()
wxMDIParentFrame::wxMDIParentFrame(void)
{
m_clientWindow = NULL;
m_currentChild = NULL;
m_parentFrameActive = TRUE;
m_toolBar = NULL;
};
wxMDIParentFrame::wxMDIParentFrame( wxWindow *parent,
@@ -50,6 +80,7 @@ wxMDIParentFrame::wxMDIParentFrame( wxWindow *parent,
m_clientWindow = NULL;
m_currentChild = NULL;
m_parentFrameActive = TRUE;
m_toolBar = NULL;
Create( parent, id, title, pos, size, style, name );
};
@@ -69,18 +100,31 @@ bool wxMDIParentFrame::Create( wxWindow *parent,
return TRUE;
};
void wxMDIParentFrame::OnSize( wxSizeEvent& event )
void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
{
wxFrame::OnSize( event );
wxFrame::GtkOnSize( x, y, width, height );
if (m_mdiMenuBar)
{
int x = 0;
int y = 0;
GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 );
}
};
void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
{
};
void wxMDIParentFrame::SetMenuBar( wxMenuBar *menu_bar )
{
wxFrame::SetMenuBar( menu_bar );
if (m_mdiMenuBar) m_mdiMenuBar->Show( FALSE );
m_mdiMenuBar = menu_bar;
if (m_mdiMenuBar)
{
int x = 0;
int y = 0;
GetClientSize( &x, &y );
m_mdiMenuBar->SetSize( 1, 1, x-2, 26 );
m_mdiMenuBar->Show( TRUE );
}
};
void wxMDIParentFrame::GetClientSize(int *width, int *height ) const
@@ -88,6 +132,16 @@ void wxMDIParentFrame::GetClientSize(int *width, int *height ) const
wxFrame::GetClientSize( width, height );
};
void wxMDIParentFrame::SetToolBar( wxToolBar *toolbar )
{
m_toolBar = toolbar;
};
wxWindow *wxMDIParentFrame::GetToolBar(void) const
{
return m_toolBar;
};
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild(void) const
{
return m_currentChild;
@@ -106,9 +160,17 @@ wxMDIClientWindow *wxMDIParentFrame::OnCreateClient(void)
void wxMDIParentFrame::ActivateNext(void)
{
if (m_clientWindow)
gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
};
void wxMDIParentFrame::ActivatePrevious(void)
{
if (m_clientWindow)
gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
};
void wxMDIParentFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
{
};
@@ -122,8 +184,14 @@ void wxMDIParentFrame::OnSysColourChanged( wxSysColourChangedEvent& WXUNUSED(eve
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxPanel)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
END_EVENT_TABLE()
wxMDIChildFrame::wxMDIChildFrame(void)
{
m_menuBar = NULL;
m_page = NULL;
};
wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame *parent,
@@ -131,11 +199,23 @@ wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame *parent,
const wxPoint& WXUNUSED(pos), const wxSize& size,
long style, const wxString& name )
{
m_menuBar = NULL;
m_page = NULL;
Create( parent, id, title, wxDefaultPosition, size, style, name );
};
wxMDIChildFrame::~wxMDIChildFrame(void)
{
if (m_menuBar)
{
wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->m_parent;
if (mdi_frame->m_currentChild == this)
{
mdi_frame->SetMDIMenuBar( NULL );
mdi_frame->m_currentChild = NULL;
};
delete m_menuBar;
}
};
bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
@@ -147,8 +227,59 @@ bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
};
void wxMDIChildFrame::SetMenuBar( wxMenuBar *WXUNUSED(menu_bar) )
void wxMDIChildFrame::OnCloseWindow( wxCloseEvent &event )
{
if ( GetEventHandler()->OnClose() || event.GetForce())
{
this->Destroy();
}
};
bool wxMDIChildFrame::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
wxNode *node = menu->m_items.First();
while (node)
{
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
if (menuitem->m_isSubMenu) SetInvokingWindow( menuitem->m_subMenu, win );
node = node->Next();
};
};
void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
{
m_menuBar = menu_bar;
if (m_menuBar)
{
wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->m_parent;
if (m_menuBar->m_parent != this)
{
wxNode *node = m_menuBar->m_menus.First();
while (node)
{
wxMenu *menu = (wxMenu*)node->Data();
SetInvokingWindow( menu, this );
node = node->Next();
};
m_menuBar->m_parent = mdi_frame;
}
mdi_frame->SetMDIMenuBar( m_menuBar );
gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWindow),
m_menuBar->m_widget, m_menuBar->m_x, m_menuBar->m_y );
}
};
void wxMDIChildFrame::Activate(void)
@@ -182,6 +313,11 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
m_widget = gtk_notebook_new();
gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
GTK_SIGNAL_FUNC(gtk_page_change_callback), (gpointer)this );
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
PostCreation();
Show( TRUE );
@@ -191,16 +327,17 @@ bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style )
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;
if (child->IsKindOf(CLASSINFO(wxMDIChildFrame)))
{
wxMDIChildFrame* mdi_child = (wxMDIChildFrame*) child;
s = mdi_child->m_title;
};
wxMDIChildFrame* mdi_child = (wxMDIChildFrame*) child;
s = mdi_child->m_title;
if (s.IsNull()) s = "MDI child";
GtkWidget *label_widget;
@@ -211,6 +348,10 @@ void wxMDIClientWindow::AddChild( wxWindow *child )
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 );
};

View File

@@ -61,7 +61,7 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title )
gtk_menu_bar_append( GTK_MENU_BAR(m_menubar), root_menu );
};
int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString )
static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString )
{
if (menu->m_title == menuString)
{
@@ -91,7 +91,48 @@ int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemStr
return -1;
};
// Find a wxMenuItem using its id. Recurses down into sub-menus
static wxMenuItem* FindMenuItemByIdRecursive( const wxMenu* menu, int id )
{
wxMenuItem* result = menu->FindItemForId( id );
wxNode *node = menu->m_items.First();
while (node && result == 0)
{
wxMenuItem *item = (wxMenuItem*)node->Data();
if (item->m_subMenu) result = FindMenuItemByIdRecursive( item->m_subMenu, id );
node = node->Next();
};
return result;
};
wxMenuItem* wxMenuBar::FindMenuItemById( int id ) const
{
wxMenuItem* result = 0;
wxNode *node = m_menus.First();
while (node && result == 0)
{
wxMenu *menu = (wxMenu*)node->Data();
result = FindMenuItemByIdRecursive( menu, id );
node = node->Next();
}
return result;
}
bool wxMenuBar::IsChecked( int id ) const
{
wxMenuItem* item = FindMenuItemById( id );
if (item) return item->IsChecked();
return FALSE;
}
bool wxMenuBar::IsEnabled( int id ) const
{
wxMenuItem* item = FindMenuItemById( id );
if (item) return item->IsEnabled();
return FALSE;
}
//-----------------------------------------------------------------------------
// wxMenu
//-----------------------------------------------------------------------------
@@ -124,6 +165,29 @@ wxMenuItem::wxMenuItem(void)
m_menuItem = NULL;
};
void wxMenuItem::Check( bool check )
{
if ( IsCheckable() )
{
m_checked = check;
gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check );
}
}
bool wxMenuItem::IsChecked() const
{
if ( IsCheckable() )
{
return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
}
return FALSE;
}
void wxMenuItem::Enable( bool enable )
{
m_isEnabled = enable;
}
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
wxMenu::wxMenu( const wxString &title )
@@ -219,9 +283,22 @@ int wxMenu::FindItem( const wxString itemString ) const
return -1;
};
void wxMenu::Check( int WXUNUSED(id), bool WXUNUSED(Flag) )
wxMenuItem* wxMenu::FindItemForId( int id ) const
{
// I'm just too lazy
wxNode *node = m_items.First();
while (node)
{
wxMenuItem *item = (wxMenuItem*)node->Data();
if (item->m_id == id) return item;
node = node->Next();
}
return NULL;
}
void wxMenu::Check( int id, bool Flag )
{
wxMenuItem* item = FindItemForId( id );
if (item) item->Check(Flag);
};
void wxMenu::Enable( int id, bool enable )

View File

@@ -153,6 +153,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_notebook_new();
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect
(
GTK_OBJECT(m_widget), "switch_page",

View File

@@ -21,7 +21,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool,wxObject)
wxToolBarTool::wxToolBarTool( wxToolBarGTK *owner, int theIndex,
wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex,
const wxBitmap& bitmap1, const wxBitmap& bitmap2,
bool toggle, wxObject *clientData,
const wxString& shortHelpString, const wxString& longHelpString )
@@ -45,7 +45,7 @@ wxToolBarTool::~wxToolBarTool(void)
};
//-----------------------------------------------------------------------------
// wxToolBarGTK
// wxToolBar
//-----------------------------------------------------------------------------
static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
@@ -59,27 +59,27 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxToolBarGTK,wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl)
BEGIN_EVENT_TABLE(wxToolBarGTK, wxControl)
BEGIN_EVENT_TABLE(wxToolBar, wxControl)
END_EVENT_TABLE()
wxToolBarGTK::wxToolBarGTK(void)
wxToolBar::wxToolBar(void)
{
};
wxToolBarGTK::wxToolBarGTK( wxWindow *parent, wxWindowID id,
wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, pos, size, style, name );
};
wxToolBarGTK::~wxToolBarGTK(void)
wxToolBar::~wxToolBar(void)
{
};
bool wxToolBarGTK::Create( wxWindow *parent, wxWindowID id,
bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
@@ -104,7 +104,7 @@ bool wxToolBarGTK::Create( wxWindow *parent, wxWindowID id,
return TRUE;
};
bool wxToolBarGTK::OnLeftClick( int toolIndex, bool toggleDown )
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{
wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
event.SetEventObject(this);
@@ -115,7 +115,7 @@ bool wxToolBarGTK::OnLeftClick( int toolIndex, bool toggleDown )
return TRUE;
};
void wxToolBarGTK::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{
wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, toolIndex);
event.SetEventObject(this);
@@ -123,7 +123,7 @@ void wxToolBarGTK::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSE
GetEventHandler()->ProcessEvent(event);
};
void wxToolBarGTK::OnMouseEnter( int toolIndex )
void wxToolBar::OnMouseEnter( int toolIndex )
{
wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex);
event.SetEventObject(this);
@@ -131,7 +131,7 @@ void wxToolBarGTK::OnMouseEnter( int toolIndex )
GetEventHandler()->ProcessEvent(event);
};
wxToolBarTool *wxToolBarGTK::AddTool( int toolIndex, const wxBitmap& bitmap,
wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap, bool toggle,
float WXUNUSED(xPos), float WXUNUSED(yPos), wxObject *clientData,
const wxString& helpString1, const wxString& helpString2 )
@@ -160,48 +160,48 @@ wxToolBarTool *wxToolBarGTK::AddTool( int toolIndex, const wxBitmap& bitmap,
return tool;
};
void wxToolBarGTK::AddSeparator(void)
void wxToolBar::AddSeparator(void)
{
gtk_toolbar_append_space( m_toolbar );
};
void wxToolBarGTK::ClearTools(void)
void wxToolBar::ClearTools(void)
{
};
void wxToolBarGTK::EnableTool(int toolIndex, bool enable)
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
};
void wxToolBarGTK::ToggleTool(int toolIndex, bool toggle)
void wxToolBar::ToggleTool(int toolIndex, bool toggle)
{
};
void wxToolBarGTK::SetToggle(int toolIndex, bool toggle)
void wxToolBar::SetToggle(int toolIndex, bool toggle)
{
};
wxObject *wxToolBarGTK::GetToolClientData(int index) const
wxObject *wxToolBar::GetToolClientData(int index) const
{
};
bool wxToolBarGTK::GetToolState(int toolIndex) const
bool wxToolBar::GetToolState(int toolIndex) const
{
};
bool wxToolBarGTK::GetToolEnabled(int toolIndex) const
bool wxToolBar::GetToolEnabled(int toolIndex) const
{
};
void wxToolBarGTK::SetMargins(int x, int y)
void wxToolBar::SetMargins(int x, int y)
{
};
void wxToolBarGTK::SetToolPacking(int packing)
void wxToolBar::SetToolPacking(int packing)
{
};
void wxToolBarGTK::SetToolSeparation(int separation)
void wxToolBar::SetToolSeparation(int separation)
{
};