Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv8585/src/gui
Modified Files:
wxMApp.cpp wxMainFrame.cpp
Log Message:
first attempt at making status bar handling a bit more reasonable: in
particular, they should really be dynamic which was the purpose of the
original code but this never workd so far
Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.242
retrieving revision 1.243
diff -b -u -2 -r1.242 -r1.243
--- wxMApp.cpp 4 Jul 2002 14:25:25 -0000 1.242
+++ wxMApp.cpp 27 Aug 2002 23:48:57 -0000 1.243
@@ -394,62 +394,8 @@
}
-#if 0
-// ----------------------------------------------------------------------------
-// wxMStatusBar
-// ----------------------------------------------------------------------------
-class wxMStatusBar : public wxStatusBar
-{
-public:
- wxMStatusBar(wxWindow *parent) : wxStatusBar(parent, -1)
- {
- m_show = false;
- m_OnlineIcon = new wxIcon;
- m_OfflineIcon = new wxIcon;
- *m_Onli+neIcon = ICON( "online");
- *m_OfflineIcon = ICON( "offline");
- }
-
- ~wxMStatusBar()
- {
- delete m_OnlineIcon;
- delete m_OfflineIcon;
- }
- void UpdateOnlineStatus(bool show, bool isOnline)
- {
- m_show = show; m_isOnline = isOnline;
-// Refresh();
- }
- virtual void DrawField(wxDC &dc, int i)
- {
- wxStatusBar::DrawField(dc, i);
- if(m_show)
- {
- int field = mApplication->GetStatusField(MAppBase::SF_ONLINE);
- if(i == field)
- {
- wxRect r;
- GetFieldRect(i, r);
- dc.DrawIcon(m_isOnline ?
- *m_OnlineIcon
- : *m_OfflineIcon,
- r.x, r.y+2); // +2: small vertical offset
- }
- }
- }
-private:
- wxIcon *m_OnlineIcon;
- wxIcon *m_OfflineIcon;
- /// show online status?
- bool m_show;
- /// are we online?
- bool m_isOnline;
-};
-#endif
-
// ----------------------------------------------------------------------------
// wxMApp
// ----------------------------------------------------------------------------
-
BEGIN_EVENT_TABLE(wxMApp, wxApp)
EVT_IDLE (wxMApp::OnIdle)
@@ -1689,47 +1635,4 @@
void
-wxMApp::UpdateStatusBar(int nfields, bool isminimum) const
-{
- ASSERT(nfields <= SF_MAXIMUM);
- ASSERT(nfields >= 0);
- ASSERT(m_topLevelFrame);
- ASSERT(m_topLevelFrame->GetStatusBar());
- int n = nfields;
-
- // ugly, but effective:
- //static int statusIconWidth = -1;
-
- wxStatusBar *sbar = m_topLevelFrame->GetStatusBar();
- if(isminimum && sbar->GetFieldsCount() > nfields)
- n = sbar->GetFieldsCount();
-
- int widths[SF_MAXIMUM];
- widths[0] = 100; //flexible
- widths[1] = 10; // small empty field
-
-#if 0
- if(m_DialupSupport)
- {
- if(statusIconWidth == -1)
- {
- const wxIcon & icon = ICON("online");
- // make field 1.5 times as wide as icon and add border:
- statusIconWidth = (3*icon.GetWidth())/2 + 2*sbar->GetBorderX();
- }
- widths[GetStatusField(SF_ONLINE)] = statusIconWidth;
- }
-#endif
-
-#ifdef USE_DIALUP
- if(m_DialupSupport)
- widths[GetStatusField(SF_ONLINE)] = 70;
-#endif // USE_DIALUP
-
- if(READ_APPCONFIG(MP_USE_OUTBOX))
- widths[GetStatusField(SF_OUTBOX)] = 100;
- //FIXME: wxGTK crashes after calling this repeatedly sbar->SetFieldsCount(n,
widths);
-}
-
-void
wxMApp::UpdateOutboxStatus(MailFolder *mf) const
{
@@ -1741,9 +1644,9 @@
// only enable menu item if outbox is used and contains messages:
- ASSERT(m_topLevelFrame->GetMenuBar());
+ wxMenuBar *mbar = m_topLevelFrame->GetMenuBar();
+ CHECK_RET( mbar, "no menubar in the main frame?" );
bool useOutbox = READ_APPCONFIG_BOOL(MP_USE_OUTBOX);
- m_topLevelFrame->GetMenuBar()->Enable(
- (int)WXMENU_FILE_SEND_OUTBOX,enable && useOutbox);
+ mbar->Enable(WXMENU_FILE_SEND_OUTBOX, enable && useOutbox);
if ( !useOutbox )
@@ -1759,8 +1662,9 @@
(unsigned long) nNNTP);
- int field = GetStatusField(SF_OUTBOX);
- UpdateStatusBar(field+1, TRUE);
- ASSERT(m_topLevelFrame->GetStatusBar());
- m_topLevelFrame->GetStatusBar()->SetStatusText(msg, field);
+ wxStatusBar *sbar = m_topLevelFrame->GetStatusBar();
+ CHECK_RET( sbar, "no status bar in the main frame?" );
+
+ // const_cast needed
+ sbar->SetStatusText(msg, ((wxMApp *)this)->GetStatusField(SF_OUTBOX));
}
@@ -1908,32 +1812,22 @@
if(! m_topLevelFrame)
return;
+
wxStatusBar *sbar = m_topLevelFrame->GetStatusBar();
wxMenuBar *mbar = m_topLevelFrame->GetMenuBar();
- ASSERT(sbar);
- ASSERT(mbar);
+ CHECK_RET( sbar && mbar, "no status/menu bar in the main frame?" );
if(! m_DialupSupport)
{
- mbar->Enable((int)WXMENU_FILE_NET_ON, FALSE);
- mbar->Enable((int)WXMENU_FILE_NET_OFF, FALSE);
+ mbar->Enable(WXMENU_FILE_NET_ON, FALSE);
+ mbar->Enable(WXMENU_FILE_NET_OFF, FALSE);
}
- else
+ else // we do have dialup support
{
bool online = IsOnline();
- if(online)
- {
- mbar->Enable((int)WXMENU_FILE_NET_OFF, TRUE);
- mbar->Enable((int)WXMENU_FILE_NET_ON, FALSE);
-// m_topLevelFrame->GetToolBar()->EnableItem(WXMENU_FILE_NET_OFF, m_DialupSupport);
- }
- else
- {
- mbar->Enable((int)WXMENU_FILE_NET_ON, TRUE);
- mbar->Enable((int)WXMENU_FILE_NET_OFF, FALSE);
-// m_topLevelFrame->GetToolBar()->EnableItem(WXMENU_FILE_NET_ON, m_DialupSupport);
- }
- int field = GetStatusField(SF_ONLINE);
- UpdateStatusBar(field+1, TRUE);
- sbar->SetStatusText(online ? _("Online"):_("Offline"), field);
+ mbar->Enable(WXMENU_FILE_NET_OFF, online);
+ mbar->Enable(WXMENU_FILE_NET_ON, !online);
+
+ sbar->SetStatusText(online ? _("Online"):_("Offline"),
+ GetStatusField(SF_ONLINE));
}
}
@@ -1979,4 +1873,37 @@
m_logWindow->PassMessages(!isAway);
}
+}
+
+void wxMApp::RecreateStatusBar()
+{
+ // this array is indexed by StatusFields elements
+ //
+ // SF_STANDARD is the largest and takes thrice as much space as SF_FOLDER
+ // while SF_ONLINE and SF_OUTBOX have fixed width
+ static const int s_statusWidths[] = { -3, -1, 70, 150 };
+
+ wxCOMPILE_TIME_ASSERT2( WXSIZEOF(s_statusWidths) == SF_MAXIMUM,
+ StatusWidthsNotInSync, MAppStatus );
+
+ CHECK_RET( m_topLevelFrame, "no top level frame to recreate status bar for" );
+
+ wxStatusBar *sbar = m_topLevelFrame->GetStatusBar();
+ CHECK_RET( sbar, "no status bar to recreate?" );
+
+ int widths[SF_MAXIMUM];
+ size_t n;
+ for ( n = 0; n < WXSIZEOF(m_statusPanes); n++ )
+ {
+ StatusFields field = m_statusPanes[n];
+ if ( field == SF_ILLEGAL )
+ {
+ // no more fields, SF_ILLEGAL is the termination marker
+ break;
+ }
+
+ widths[n] = s_statusWidths[field];
+ }
+
+ sbar->SetFieldsCount(n, widths);
}
Index: wxMainFrame.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMainFrame.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -b -u -2 -r1.155 -r1.156
--- wxMainFrame.cpp 27 Aug 2002 18:57:23 -0000 1.155
+++ wxMainFrame.cpp 27 Aug 2002 23:48:57 -0000 1.156
@@ -553,7 +553,5 @@
SetTitle(_("Copyright (C) 1997-2002 The Mahogany Developers Team"));
- static int widths[3] = { -1, 70, 100 }; // FIXME: temporary for debugging
- CreateStatusBar(3, wxST_SIZEGRIP, 12345); // 3 fields, id 12345
- GetStatusBar()->SetFieldsCount(3, widths);
+ CreateStatusBar();
// construct the menu and toolbar
-------------------------------------------------------
This sf.net email is sponsored by: Jabber - The world's fastest growing
real-time communications platform! Don't just IM. Build it in!
http://www.jabber.com/osdn/xim
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates