- 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);
+ long rc = wxGetNumberFromUser
+ (
+ "Configure the field index to be used by the set, push "
+ "and pop text commands in the menu.\n"
+ "\n"
+ "0 corresponds to the first field, 1 to the second one "
+ "and so on.",
+ "Field &index:",
+ SAMPLE_DIALOGS_TITLE,
+ m_field,
+ 0,
+ sb->GetFieldsCount() - 1,
+ NULL
+ );
+
+ if ( rc == -1 )
+ return;
+
+ m_field = rc;
+
+ wxLogStatus("Status bar text will be set for field #%d", m_field);
+}
+
+void MyFrame::OnSetStatusText(wxCommandEvent& WXUNUSED(event))
+{
+ wxStatusBar *sb = GetStatusBar();
+ if (!sb)
+ return;
+
+ wxString txt = wxGetTextFromUser
+ (
+ wxString::Format
+ (
+ "Enter the text from for the field #%d",
+ m_field
+ ),
+ SAMPLE_DIALOGS_TITLE,
+ sb->GetStatusText(m_field),
+ this
+ );
+
+ if ( txt.empty() )
+ return;
+
+ sb->SetStatusText(txt, m_field);
+}
+
+// the current depth of the stack used by Push/PopStatusText()
+static int gs_depth = 0;
+
+void MyFrame::OnPushStatusText(wxCommandEvent& WXUNUSED(event))
+{
+ wxStatusBar *sb = GetStatusBar();
+ if (!sb)
+ return;
+
+ static int s_countPush = 0;
+ sb->PushStatusText(wxString::Format
+ (
+ "Pushed message #%d (depth = %d)",
+ ++s_countPush, ++gs_depth
+ ), m_field);
+}