Permalink
Browse files

Refactor logic into method.

  • Loading branch information...
1 parent 7f8b50b commit ef9e81c1ba905d9bd49b7b9eac788978284d98b3 @adamv adamv committed May 5, 2009
Showing with 7 additions and 14 deletions.
  1. +5 −14 src/StatusBar.cpp
  2. +2 −0 src/StatusBar.h
View
@@ -49,18 +49,11 @@ StatusBar::StatusBar(EditorFrame& parent, wxWindowID id, TmSyntaxHandler& syntax
SetFieldsCount(WXSIZEOF(widths), widths);
}
-void StatusBar::UpdateBarFromActiveEditor() {
-/*
-
- Ask the parent frame, if the editor change state is not different, then leave.
- Get the active editor (a narrower interface to it, actually.)
- If NULL, then leave.
-
- Get the new change state.
- Proceed with work (updating the status bar panels.)
-
-*/
+void StatusBar::SetPanelTextIfDifferent(const wxString& newText, const int panelIndex) {
+ if (GetStatusText(panelIndex) != newText) SetStatusText(newText, panelIndex);
+}
+void StatusBar::UpdateBarFromActiveEditor() {
EditorCtrl* editorCtrl = m_parentFrame.GetEditorCtrl();
if (!editorCtrl) return;
@@ -96,9 +89,7 @@ void StatusBar::UpdateBarFromActiveEditor() {
}
// Syntax
- if (GetStatusText(1) != editorCtrl->GetSyntaxName()) {
- SetStatusText(editorCtrl->GetSyntaxName(), 1);
- }
+ SetPanelTextIfDifferent(editorCtrl->GetSyntaxName(), 1);
// Only reload symbol list if doc has changed
bool symbolsChanged = false;
View
@@ -50,6 +50,8 @@ class StatusBar : public wxStatusBar {
void PopupSyntaxMenu(wxRect& menuPos);
+ void SetPanelTextIfDifferent(const wxString& newText, const int panelIndex);
+
void OnIdle(wxIdleEvent& event);
void OnMouseLeftDown(wxMouseEvent& event);
void OnMenuTabs2(wxCommandEvent& event);

0 comments on commit ef9e81c

Please sign in to comment.