Update of /cvsroot/mahogany/M/src/classes
In directory usw-pr-cvs1:/tmp/cvs-serv8585/src/classes
Modified Files:
MApplication.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: MApplication.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MApplication.cpp,v
retrieving revision 1.258
retrieving revision 1.259
diff -b -u -2 -r1.258 -r1.259
--- MApplication.cpp 17 Jul 2002 14:43:55 -0000 1.258
+++ MApplication.cpp 27 Aug 2002 23:48:57 -0000 1.259
@@ -154,4 +154,5 @@
m_mimeManager = NULL;
+ m_statusPanes[0] = SF_ILLEGAL; // will be really initialized later
m_cycle = Initializing;
@@ -1178,30 +1179,78 @@
}
+// ----------------------------------------------------------------------------
+// status bar support
+// ----------------------------------------------------------------------------
int
-MAppBase::GetStatusField(enum StatusFields function) const
+MAppBase::GetStatusField(StatusFields field)
{
- // re-setting the statusbar causes crashes on wxGTK, keep it with
- // three fields always for now:
- switch(function)
- {
- case SF_STANDARD:
- return 0;
- case SF_ONLINE:
- return 1;
- case SF_OUTBOX:
- return 2;
- default:
- ASSERT(0);
- return 0;
+ // status bar can't be empty except right after program startup, so if it is
+ // initialize it with the default values
+ if ( m_statusPanes[0] == SF_ILLEGAL )
+ {
+ StatusFields *p = m_statusPanes;
+ *p++ = SF_STANDARD;
+ *p++ = SF_FOLDER;
+
+#ifdef USE_DIALUP
+ if ( m_DialupSupport )
+ *p++ = SF_ONLINE;
+#endif // USE_DIALUP
+
+ if ( m_UseOutbox )
+ *p++ = SF_OUTBOX;
}
-#if 0
- int field = 0;
- if( function > SF_STANDARD)
- field++;
- if(function > SF_ONLINE && m_DialupSupport)
- field++;
- return field;
-#endif
+
+ // look for the field in the sorted array using linear search (for an array
+ // of 4 elements this isn't wasteful)
+ for ( size_t n = 0; n < WXSIZEOF(m_statusPanes); n++ )
+ {
+ if ( m_statusPanes[n] == field )
+ {
+ // found the position at which this field appears
+ return n;
+ }
+
+ if ( m_statusPanes[n] > field )
+ {
+ // we insert the status field here to keep the array sorted
+ for ( size_t m = n + 1; m < WXSIZEOF(m_statusPanes); m++ )
+ {
+ m_statusPanes[m] = m_statusPanes[m - 1];
+ }
+
+ m_statusPanes[n] = field;
+
+ RecreateStatusBar();
+
+ return n;
+ }
+ }
+
+ FAIL_MSG( "logic error in GetStatusField" );
+
+ return -1;
+}
+
+void MAppBase::RemoveStatusField(StatusFields field)
+{
+ for ( size_t n = 0; n < WXSIZEOF(m_statusPanes); n++ )
+ {
+ if ( m_statusPanes[n] == field )
+ {
+ for ( size_t m = n + 1; m <= WXSIZEOF(m_statusPanes); m++ )
+ {
+ m_statusPanes[m - 1] =
+ m == WXSIZEOF(m_statusPanes) ? SF_ILLEGAL : m_statusPanes[m];
+ }
+
+ RecreateStatusBar();
+
+ return;
+ }
+ }
+
+ FAIL_MSG( "RemoveStatusField(): no such field shown" );
}
-------------------------------------------------------
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