• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ap_StatusBar.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 #ifndef AP_STATUSBAR_H
00023 #define AP_STATUSBAR_H
00024 
00025 #include <limits.h>
00026 // Class for dealing with the status bar at the bottom of
00027 // the frame.
00028 
00029 #include "ut_types.h"
00030 #include "ut_misc.h"
00031 #include "ut_units.h"
00032 #include "ut_vector.h"
00033 #include "ap_Prefs.h"
00034 #include "ap_Prefs_SchemeIds.h"
00035 #include "xav_Listener.h"
00036 #include "ut_string_class.h"
00037 
00038 class XAP_Frame;
00039 class GR_Graphics;
00040 
00041 #define AP_MAX_MESSAGE_FIELD            (256*MB_LEN_MAX)
00042 
00043 /*****************************************************************/
00044 /*****************************************************************/
00045 
00046 #define PROGRESS_CMD_MASK 0x3       /* 0,1,2,3 Operational values */
00047 enum _progress_flags {
00048     PROGRESS_RESERVED1  = 0x0,
00049     PROGRESS_STARTBAR   = 0x1,      /* Start using the progress bar */
00050     PROGRESS_STOPBAR    = 0x2,      /* Stop using the progress bar */
00051     PROGRESS_RESERVED2  = 0x3,
00052     PROGRESS_SHOW_MSG   = 0x4,      /* Allow message to be displayed */
00053     PROGRESS_SHOW_RAW   = 0x8,      /* Allow raw value to be displayed */
00054     PROGRESS_SHOW_PERCENT = 0x10,   /* Allow calculation of percent value */
00055     PROGRESS_INDEFINATE = 0x20      /* Don't know how long operation will take*/
00056 };
00057 
00058 #include "ut_timer.h"
00059 
00060 // NOTE BY WILL LACHANCE (Tue. Oct 22/2002): This code is less of a mess than it used to be, but
00061 // it is still far from ideal. We pretty much statically define the statusbar here (and
00062 // have classes for each statusbar element, to boot). Ideally, we would somehow create a statusbar
00063 // at run-time using an XML file. But it's too much work, for too little benefit, to do that right now.
00064 
00065 class AP_StatusBarField;
00066 
00067 class AP_StatusBarField_ProgressBar;
00068 
00069 class ABI_EXPORT AP_StatusBar : public AV_Listener
00070 {
00071 public:
00072     AP_StatusBar(XAP_Frame * pFrame);
00073     virtual ~AP_StatusBar(void);
00074 
00075     XAP_Frame *         getFrame(void) const;
00076     virtual void        setView(AV_View * pView);
00077     void            setStatusMessage(const char * pbuf, int redraw = true);
00078     const std::string &     getStatusMessage(void) const;
00079 
00080     void            setStatusProgressType(int start, int end, int flags);
00081     void            setStatusProgressValue(int value);
00082 
00083     // These shoulld be abstract but we don't want to screw other platforms
00084 
00085     virtual void        showProgressBar(void) {}
00086     virtual void        hideProgressBar(void) {}
00087     virtual void        show(void) {}
00088     virtual void        hide(void) {}
00089 
00090     /* used with AV_Listener */
00091     virtual bool            notify(AV_View * pView, const AV_ChangeMask mask);
00092     virtual AV_ListenerType getType(void) { return AV_LISTENER_STATUSBAR;}
00093 
00094 
00095     UT_GenericVector<AP_StatusBarField*> *             getFields() { return &m_vecFields; }
00096 protected:
00097 
00098     XAP_Frame *         m_pFrame;
00099     AV_View *           m_pView;
00100 
00101     bool            m_bInitFields;
00102     UT_GenericVector<AP_StatusBarField*> m_vecFields;           /* vector of 'ap_sb_Field *' */
00103     void *          m_pStatusMessageField;  /* actually 'AP_StatusBarField_StatusMessage *' */
00104     AP_StatusBarField_ProgressBar * m_pStatusProgressField;
00105     std::string     m_sStatusMessage;
00106 };
00107 
00108 // abstract class which "listens" for changes in the status bar fields in the base classes
00109 // intended for platform specific code
00110 class AP_StatusBarField; // fwd decl
00111 
00112 class ABI_EXPORT AP_StatusBarFieldListener
00113 {
00114 public:
00115     AP_StatusBarFieldListener(AP_StatusBarField *pStatusBarField) { m_pStatusBarField = pStatusBarField; }
00116     virtual ~AP_StatusBarFieldListener() {}
00117     virtual void notify() = 0;
00118 
00119 protected:
00120     AP_StatusBarField *m_pStatusBarField;
00121 };
00122 
00123 // alignment/fill properties for the upper level gui
00124 enum _statusbar_element_fill_method {
00125     REPRESENTATIVE_STRING,
00126     PROGRESS_BAR,
00127     MAX_POSSIBLE
00128 };
00129 
00130 enum _statusbar_textelement_alignment_method {
00131     LEFT,
00132     CENTER
00133 };
00134 
00135 // AP_StatusBarField: abstract base class for a status bar field
00136 class ABI_EXPORT AP_StatusBarField
00137 {
00138 public:
00139     AP_StatusBarField(AP_StatusBar * pSB);
00140     virtual ~AP_StatusBarField(void);
00141 
00142     virtual void        notify(AV_View * pView, const AV_ChangeMask mask) = 0;
00143     void setListener(AP_StatusBarFieldListener *pStatusBarFieldListener) { m_pStatusBarFieldListener = pStatusBarFieldListener; }
00144     AP_StatusBarFieldListener * getListener() { return m_pStatusBarFieldListener; }
00145 
00146     _statusbar_element_fill_method getFillMethod() { return m_fillMethod; }
00147     AP_StatusBar * getApStatusBar(){return m_pSB;}
00148 protected:
00149     AP_StatusBar *      m_pSB;
00150     AP_StatusBarFieldListener *m_pStatusBarFieldListener;
00151     _statusbar_element_fill_method m_fillMethod;
00152 };
00153 
00154 class ABI_EXPORT AP_StatusBarField_TextInfo : public AP_StatusBarField
00155 {
00156 public:
00157     AP_StatusBarField_TextInfo(AP_StatusBar * pSB);
00158     //virtual ~AP_StatusBarField_TextInfo(void) {}
00159     const std::string & getBuf() { return m_sBuf; }
00160     // getRepresentativeString: give a "guess" as to how long the string will be. it's not a big deal
00161     // if it's wrong; we should resize fixed-length status bar elements in platform specific code
00162     // if they're not big enough to show the string correctly
00163     const char * getRepresentativeString(void)
00164         { return m_sRepresentativeString.c_str(); }
00165     _statusbar_textelement_alignment_method getAlignmentMethod() { return m_alignmentMethod; }
00166 
00167 protected:
00168     std::string m_sBuf;
00169     std::string m_sRepresentativeString;
00170     _statusbar_textelement_alignment_method m_alignmentMethod;
00171 };
00172 
00173 // PROGRESSBAR. Now used for gtk builds. Should be implemented for Windows and OSX
00174 
00175 class ABI_EXPORT AP_StatusBarField_ProgressBar : public AP_StatusBarField
00176 {
00177 public:
00178     AP_StatusBarField_ProgressBar(AP_StatusBar * pSB);
00179     virtual ~AP_StatusBarField_ProgressBar(void);
00180 
00181     virtual void        notify(AV_View * pView, const AV_ChangeMask mask);
00182     void setStatusProgressType(int start, int end, int flags);
00183     void setStatusProgressValue(int value);
00184     double              getFraction(void);
00185     bool                isDefinate(void);
00186 protected:
00187     UT_sint32           m_ProgressStart;
00188     UT_sint32           m_ProgressEnd;
00189     UT_sint32           m_ProgressValue;
00190     UT_sint32           m_ProgressStartPoint;
00191     UT_uint32           m_ProgressFlags;
00192     UT_Timer            *m_ProgressTimer;
00193 };
00194 #endif /* AP_STATUSBAR_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1