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

ap_Dialog_Tab.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef AP_DIALOG_TAB_H
00021 #define AP_DIALOG_TAB_H
00022 
00023 #include "xap_Frame.h"
00024 #include "xap_Dialog.h"
00025 #include "xav_View.h"
00026 #include "ut_units.h"
00027 #include "fl_BlockLayout.h"
00028 
00029 class XAP_Frame;
00030 class AP_Dialog_Tab;
00031 class FV_View;
00032 
00033 #define MAX_TAB_LENGTH 15 // the maximum length the the tab input can have
00034 
00035 typedef void (*TabSaveCallBack)(AP_Dialog_Tab * pDlg,
00036                                 FV_View *pView, const char * szTabStops,
00037                                 const char * szDflTabStop, void * closure);
00038 
00039 class ABI_EXPORT AP_Dialog_Tab : public XAP_Dialog_NonPersistent
00040 {
00041  public:
00042 
00043     AP_Dialog_Tab(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00044     virtual ~AP_Dialog_Tab(void);
00045 
00046     virtual void    runModal(XAP_Frame * pFrame) = 0;
00047 
00048     // answer from dialog
00049     typedef enum { a_OK, a_CANCEL } tAnswer;
00050 
00051     // control ids
00052     typedef enum { id_EDIT_TAB = 0, id_LIST_TAB,
00053                    id_SPIN_DEFAULT_TAB_STOP,
00054 
00055                    // should be in same order as eTabType (fl_BlockLayout.h)
00056                    id_ALIGN_LEFT, id_ALIGN_CENTER, id_ALIGN_RIGHT, id_ALIGN_DECIMAL, id_ALIGN_BAR,
00057 
00058                    // should be in same order as eTabLeader (fl_BlockLayout.h)
00059                    id_LEADER_NONE, id_LEADER_DOT, id_LEADER_DASH, id_LEADER_UNDERLINE,
00060 
00061                    id_BUTTON_SET, id_BUTTON_CLEAR, id_BUTTON_CLEAR_ALL,
00062                    id_BUTTON_OK, id_BUTTON_CANCEL,
00063 
00064                    id_last } tControl;
00065 
00066     AP_Dialog_Tab::tAnswer  getAnswer(void) const;
00067 
00068     // clear the tab list
00069     void clearList();
00070 
00071     static unsigned char AlignmentToChar( eTabType a );
00072     static eTabType      CharToAlignment( unsigned char ch );
00073 
00074     void setSaveCallback (TabSaveCallBack, void * closure);
00075 
00076  protected:
00077 
00078     // to enable/disable a control
00079     virtual void _controlEnable( tControl id, bool value )=0;
00080 
00081     // disable controls appropriately
00082     void _initEnableControls();
00083 
00084     // initial population / final storage of window data
00085     void _populateWindowData(void);
00086     void _storeWindowData(void);
00087 
00088     // grab tab from the current text/align/leader controls
00089     bool buildTab( UT_String & buffer );
00090 
00091     UT_Dimension _getDimension () { return m_dim; }
00092     char *_getTabDimensionString(UT_sint32 tabIndex);
00093     char *_getTabString(fl_TabStop *pTabInfo);
00094     void _deleteTabFromTabString(fl_TabStop *pTabInfo);
00095     void _doSpin( tControl id, UT_sint32 amount);
00096 
00097     // the actual access functions
00098 #define SET_GATHER(a,u) virtual u _gather##a(void) = 0; \
00099                         virtual void    _set##a( u ) = 0
00100     SET_GATHER          (Alignment,         eTabType);
00101     SET_GATHER          (Leader,            eTabLeader);
00102     SET_GATHER          (DefaultTabStop,    const gchar*);
00103 
00104     // to populate the whole list
00105     virtual void _setTabList(UT_uint32 count) = 0;
00106 
00107     // get/set the selected tab
00108     // the list of n tabs are index 0..(n-1)
00109     // -1 deselects everything
00110     SET_GATHER          (SelectTab,         UT_sint32);
00111 
00112     // a pointer to the text in the edit box, MUST BE FREEd on get
00113     SET_GATHER          (TabEdit,           const char *);
00114 #undef SET_GATHER
00115 
00116     // clear all the items from the tab list - only gui side
00117     virtual void _clearList()=0;
00118 
00119  protected:
00120     tAnswer             m_answer;
00121     XAP_Frame *         m_pFrame;
00122     UT_Dimension        m_dim;
00123 
00124     char *      m_pszTabStops;  // from rulerInfo
00125     UT_GenericVector<fl_TabStop*>   m_tabInfo;      // list of fl_TabStop *
00126 
00127     // AP level handlers
00128     void _event_TabChange(void);        // when the edit box changes
00129     void _event_TabSelected( UT_sint32 index);  // when a list item is selected
00130     void _event_AlignmentChange(void);
00131 
00132     void _event_Set(void);              // buttons
00133     void _event_Update(void);
00134     void _event_Clear(void);
00135     void _event_ClearAll(void);
00136 
00137     void _event_somethingChanged();         // when anything changes - text, align, or leader
00138 
00139 private:
00140     TabSaveCallBack m_pCallbackFn;
00141     void * m_closure;
00142 
00143     char buf[20];
00144 
00145 };
00146 
00147 #endif /* AP_DIALOG_PARAGRAPH_H */

Generated on Sat May 25 2013 for AbiWord by  doxygen 1.7.1