allow the user to set the contents of the status fields
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4475b41041
commit
9df6b3b041
@ -155,6 +155,7 @@ class MyFrame : public wxMDIParentFrame
|
|||||||
|
|
||||||
void OnResetFieldsWidth(wxCommandEvent& event);
|
void OnResetFieldsWidth(wxCommandEvent& event);
|
||||||
void OnSetStatusFields(wxCommandEvent& event);
|
void OnSetStatusFields(wxCommandEvent& event);
|
||||||
|
void OnSetStatusTexts(wxCommandEvent& event);
|
||||||
void OnRecreateStatusBar(wxCommandEvent& event);
|
void OnRecreateStatusBar(wxCommandEvent& event);
|
||||||
void OnSetStyleNormal(wxCommandEvent& event);
|
void OnSetStyleNormal(wxCommandEvent& event);
|
||||||
void OnSetStyleFlat(wxCommandEvent& event);
|
void OnSetStyleFlat(wxCommandEvent& event);
|
||||||
@ -168,6 +169,8 @@ private:
|
|||||||
StatBar_Max
|
StatBar_Max
|
||||||
} m_statbarKind;
|
} m_statbarKind;
|
||||||
|
|
||||||
|
|
||||||
|
void OnUpdateSetStatusTexts(wxUpdateUIEvent& event);
|
||||||
void OnUpdateResetFieldsWidth(wxUpdateUIEvent& event);
|
void OnUpdateResetFieldsWidth(wxUpdateUIEvent& event);
|
||||||
void OnUpdateSetStatusFields(wxUpdateUIEvent& event);
|
void OnUpdateSetStatusFields(wxUpdateUIEvent& event);
|
||||||
void OnUpdateStatusBarToggle(wxUpdateUIEvent& event);
|
void OnUpdateStatusBarToggle(wxUpdateUIEvent& event);
|
||||||
@ -204,6 +207,7 @@ enum
|
|||||||
// menu items
|
// menu items
|
||||||
StatusBar_Quit = 1,
|
StatusBar_Quit = 1,
|
||||||
StatusBar_SetFields,
|
StatusBar_SetFields,
|
||||||
|
StatusBar_SetTexts,
|
||||||
StatusBar_ResetFieldsWidth,
|
StatusBar_ResetFieldsWidth,
|
||||||
StatusBar_Recreate,
|
StatusBar_Recreate,
|
||||||
StatusBar_About,
|
StatusBar_About,
|
||||||
@ -232,6 +236,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
#endif
|
#endif
|
||||||
EVT_MENU(StatusBar_Quit, MyFrame::OnQuit)
|
EVT_MENU(StatusBar_Quit, MyFrame::OnQuit)
|
||||||
EVT_MENU(StatusBar_SetFields, MyFrame::OnSetStatusFields)
|
EVT_MENU(StatusBar_SetFields, MyFrame::OnSetStatusFields)
|
||||||
|
EVT_MENU(StatusBar_SetTexts, MyFrame::OnSetStatusTexts)
|
||||||
EVT_MENU(StatusBar_ResetFieldsWidth, MyFrame::OnResetFieldsWidth)
|
EVT_MENU(StatusBar_ResetFieldsWidth, MyFrame::OnResetFieldsWidth)
|
||||||
EVT_MENU(StatusBar_Recreate, MyFrame::OnRecreateStatusBar)
|
EVT_MENU(StatusBar_Recreate, MyFrame::OnRecreateStatusBar)
|
||||||
EVT_MENU(StatusBar_About, MyFrame::OnAbout)
|
EVT_MENU(StatusBar_About, MyFrame::OnAbout)
|
||||||
@ -242,6 +247,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
|
|
||||||
EVT_UPDATE_UI(StatusBar_ResetFieldsWidth, MyFrame::OnUpdateResetFieldsWidth)
|
EVT_UPDATE_UI(StatusBar_ResetFieldsWidth, MyFrame::OnUpdateResetFieldsWidth)
|
||||||
EVT_UPDATE_UI(StatusBar_Toggle, MyFrame::OnUpdateStatusBarToggle)
|
EVT_UPDATE_UI(StatusBar_Toggle, MyFrame::OnUpdateStatusBarToggle)
|
||||||
|
EVT_UPDATE_UI(StatusBar_SetTexts, MyFrame::OnUpdateSetStatusTexts)
|
||||||
EVT_UPDATE_UI(StatusBar_SetFields, MyFrame::OnUpdateSetStatusFields)
|
EVT_UPDATE_UI(StatusBar_SetFields, MyFrame::OnUpdateSetStatusFields)
|
||||||
EVT_UPDATE_UI(StatusBar_SetStyleNormal, MyFrame::OnUpdateSetStyleNormal)
|
EVT_UPDATE_UI(StatusBar_SetStyleNormal, MyFrame::OnUpdateSetStyleNormal)
|
||||||
EVT_UPDATE_UI(StatusBar_SetStyleFlat, MyFrame::OnUpdateSetStyleFlat)
|
EVT_UPDATE_UI(StatusBar_SetStyleFlat, MyFrame::OnUpdateSetStyleFlat)
|
||||||
@ -324,11 +330,14 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
wxMenu *statbarMenu = new wxMenu;
|
wxMenu *statbarMenu = new wxMenu;
|
||||||
statbarMenu->Append(StatusBar_SetFields, _T("&Set field count\tCtrl-C"),
|
statbarMenu->Append(StatusBar_SetFields, _T("&Set field count\tCtrl-C"),
|
||||||
_T("Set the number of status bar fields"));
|
_T("Set the number of status bar fields"));
|
||||||
|
statbarMenu->Append(StatusBar_SetTexts, _T("&Set field text\tCtrl-T"),
|
||||||
|
_T("Set the text to display for each status bar field"));
|
||||||
|
|
||||||
wxMenu *statbarStyleMenu = new wxMenu;
|
wxMenu *statbarStyleMenu = new wxMenu;
|
||||||
statbarStyleMenu->Append(StatusBar_SetStyleNormal, _T("&Normal"), _T("Sets the style of the first field to normal (sunken) look"), true);
|
statbarStyleMenu->Append(StatusBar_SetStyleNormal, _T("&Normal"), _T("Sets the style of the first field to normal (sunken) look"), true);
|
||||||
statbarStyleMenu->Append(StatusBar_SetStyleFlat, _T("&Flat"), _T("Sets the style of the first field to flat look"), true);
|
statbarStyleMenu->Append(StatusBar_SetStyleFlat, _T("&Flat"), _T("Sets the style of the first field to flat look"), true);
|
||||||
statbarStyleMenu->Append(StatusBar_SetStyleRaised, _T("&Raised"), _T("Sets the style of the first field to raised look"), true);
|
statbarStyleMenu->Append(StatusBar_SetStyleRaised, _T("&Raised"), _T("Sets the style of the first field to raised look"), true);
|
||||||
|
|
||||||
statbarMenu->Append(StatusBar_SetStyle, _T("Field style"), statbarStyleMenu);
|
statbarMenu->Append(StatusBar_SetStyle, _T("Field style"), statbarStyleMenu);
|
||||||
|
|
||||||
statbarMenu->Append(StatusBar_ResetFieldsWidth, _T("Reset field widths"),
|
statbarMenu->Append(StatusBar_ResetFieldsWidth, _T("Reset field widths"),
|
||||||
@ -401,6 +410,34 @@ void MyFrame::DoCreateStatusBar(MyFrame::StatBarKind kind)
|
|||||||
m_statbarKind = kind;
|
m_statbarKind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// main frame - event handlers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void MyFrame::OnUpdateSetStatusTexts(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
// only allow the settings of the text of status fields for the default
|
||||||
|
// status bar
|
||||||
|
wxStatusBar *sb = GetStatusBar();
|
||||||
|
event.Enable(sb == m_statbarDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnSetStatusTexts(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxStatusBar *sb = GetStatusBar();
|
||||||
|
|
||||||
|
wxString txt;
|
||||||
|
for (int i=0; i<sb->GetFieldsCount(); i++)
|
||||||
|
{
|
||||||
|
txt =
|
||||||
|
wxGetTextFromUser(wxString::Format("Enter the text for the %d-th field:", i+1),
|
||||||
|
"Input field text", "A dummy test string", this);
|
||||||
|
|
||||||
|
sb->SetStatusText(txt, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnUpdateSetStatusFields(wxUpdateUIEvent& event)
|
void MyFrame::OnUpdateSetStatusFields(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
// only allow the settings of the number of status fields for the default
|
// only allow the settings of the number of status fields for the default
|
||||||
@ -409,7 +446,6 @@ void MyFrame::OnUpdateSetStatusFields(wxUpdateUIEvent& event)
|
|||||||
event.Enable(sb == m_statbarDefault);
|
event.Enable(sb == m_statbarDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
// event handlers
|
|
||||||
void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxStatusBar *sb = GetStatusBar();
|
wxStatusBar *sb = GetStatusBar();
|
||||||
|
Loading…
Reference in New Issue
Block a user