wxMDIChildFrame::SetTitle() works
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,6 +80,7 @@ END_EVENT_TABLE()
|
|||||||
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
|
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
|
||||||
EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
|
EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
|
||||||
EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
|
EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
|
||||||
|
EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
|
||||||
|
|
||||||
EVT_CLOSE(MyChild::OnClose)
|
EVT_CLOSE(MyChild::OnClose)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -233,8 +234,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
|
|||||||
|
|
||||||
wxMenu *option_menu = new wxMenu;
|
wxMenu *option_menu = new wxMenu;
|
||||||
|
|
||||||
// Dummy option
|
|
||||||
option_menu->Append(MDI_REFRESH, "&Refresh picture");
|
option_menu->Append(MDI_REFRESH, "&Refresh picture");
|
||||||
|
option_menu->Append(MDI_CHANGE_TITLE, "Change &title...");
|
||||||
|
|
||||||
wxMenu *help_menu = new wxMenu;
|
wxMenu *help_menu = new wxMenu;
|
||||||
help_menu->Append(MDI_ABOUT, "&About");
|
help_menu->Append(MDI_ABOUT, "&About");
|
||||||
@@ -415,12 +416,27 @@ void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|||||||
Close(TRUE);
|
Close(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyChild::OnRefresh(wxCommandEvent& event)
|
void MyChild::OnRefresh(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if ( canvas )
|
if ( canvas )
|
||||||
canvas->Refresh();
|
canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyChild::OnChangeTitle(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
static wxString s_title = _T("Canvas Frame");
|
||||||
|
|
||||||
|
wxString title = wxGetTextFromUser(_T("Enter the new title for MDI child"),
|
||||||
|
_T("MDI sample question"),
|
||||||
|
s_title,
|
||||||
|
this);
|
||||||
|
if ( !title )
|
||||||
|
return;
|
||||||
|
|
||||||
|
s_title = title;
|
||||||
|
SetTitle(s_title);
|
||||||
|
}
|
||||||
|
|
||||||
void MyChild::OnActivate(wxActivateEvent& event)
|
void MyChild::OnActivate(wxActivateEvent& event)
|
||||||
{
|
{
|
||||||
if ( event.GetActive() && canvas )
|
if ( event.GetActive() && canvas )
|
||||||
|
@@ -406,6 +406,18 @@ void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event )
|
|||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMDIChildFrame::SetTitle( const wxString &title )
|
||||||
|
{
|
||||||
|
if ( title == m_title )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_title = title;
|
||||||
|
|
||||||
|
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
|
||||||
|
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
|
||||||
|
gtk_notebook_set_tab_label_text(notebook, m_page->child, title.mbc_str());
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "size_allocate"
|
// "size_allocate"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -406,6 +406,18 @@ void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event )
|
|||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMDIChildFrame::SetTitle( const wxString &title )
|
||||||
|
{
|
||||||
|
if ( title == m_title )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_title = title;
|
||||||
|
|
||||||
|
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
|
||||||
|
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
|
||||||
|
gtk_notebook_set_tab_label_text(notebook, m_page->child, title.mbc_str());
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "size_allocate"
|
// "size_allocate"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user