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

ap_Dialog_Tab.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */
00002 /* AbiWord
00003  * Copyright (C) 1998 AbiSource, Inc.
00004  * Copyright (c) 2016 Hubert Figuiere
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_DIALOG_TAB_H
00023 #define AP_DIALOG_TAB_H
00024 
00025 #include "xap_Frame.h"
00026 #include "xap_Dialog.h"
00027 #include "xav_View.h"
00028 #include "ut_units.h"
00029 #include "fl_BlockLayout.h"
00030 
00031 class XAP_Frame;
00032 class AP_Dialog_Tab;
00033 class FV_View;
00034 
00035 #define MAX_TAB_LENGTH 15 // the maximum length the the tab input can have
00036 
00037 typedef void (*TabSaveCallBack)(AP_Dialog_Tab * pDlg,
00038                                 FV_View *pView, const char * szTabStops,
00039                                 const char * szDflTabStop, void * closure);
00040 
00041 class ABI_EXPORT AP_Dialog_Tab : public XAP_Dialog_NonPersistent
00042 {
00043  public:
00044 
00045     AP_Dialog_Tab(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00046     virtual ~AP_Dialog_Tab(void);
00047 
00048     virtual void    runModal(XAP_Frame * pFrame) = 0;
00049 
00050     // answer from dialog
00051     typedef enum { a_OK, a_CANCEL } tAnswer;
00052 
00053     // control ids
00054     typedef enum { id_EDIT_TAB = 0, id_LIST_TAB,
00055                    id_SPIN_DEFAULT_TAB_STOP,
00056 
00057                    // should be in same order as eTabType (fl_BlockLayout.h)
00058                    id_ALIGN_LEFT, id_ALIGN_CENTER, id_ALIGN_RIGHT, id_ALIGN_DECIMAL, id_ALIGN_BAR,
00059 
00060                    // should be in same order as eTabLeader (fl_BlockLayout.h)
00061                    id_LEADER_NONE, id_LEADER_DOT, id_LEADER_DASH, id_LEADER_UNDERLINE,
00062 
00063                    id_BUTTON_SET, id_BUTTON_CLEAR, id_BUTTON_CLEAR_ALL,
00064                    id_BUTTON_OK, id_BUTTON_CANCEL,
00065 
00066                    id_last } tControl;
00067 
00068     AP_Dialog_Tab::tAnswer  getAnswer(void) const;
00069 
00070     // clear the tab list
00071     void clearList();
00072 
00073     static unsigned char AlignmentToChar( eTabType a );
00074     static eTabType      CharToAlignment( unsigned char ch );
00075 
00076     void setSaveCallback (TabSaveCallBack, void * closure);
00077 
00078  protected:
00079 
00080     // to enable/disable a control
00081     virtual void _controlEnable( tControl id, bool value )=0;
00082 
00083     // disable controls appropriately
00084     void _initEnableControls();
00085 
00086     // initial population / final storage of window data
00087     void _populateWindowData(void);
00088     void _storeWindowData(void);
00089 
00090     // grab tab from the current text/align/leader controls
00091     bool buildTab( UT_String & buffer );
00092 
00093     UT_Dimension _getDimension () { return m_dim; }
00094     char *_getTabDimensionString(UT_sint32 tabIndex);
00095     char *_getTabString(fl_TabStop *pTabInfo);
00096     void _deleteTabFromTabString(fl_TabStop *pTabInfo);
00097     void _doSpin( tControl id, UT_sint32 amount);
00098 
00099     // the actual access functions
00100 #define SET_GATHER(a,u) virtual u _gather##a(void) = 0; \
00101                         virtual void    _set##a( u ) = 0
00102     SET_GATHER          (Alignment,         eTabType);
00103     SET_GATHER          (Leader,            eTabLeader);
00104     SET_GATHER          (DefaultTabStop,    const gchar*);
00105 
00106     // to populate the whole list
00107     virtual void _setTabList(UT_uint32 count) = 0;
00108 
00109     // get/set the selected tab
00110     // the list of n tabs are index 0..(n-1)
00111     // -1 deselects everything
00112     SET_GATHER          (SelectTab,         UT_sint32);
00113 
00114     // a pointer to the text in the edit box, MUST BE FREEd on get
00115     SET_GATHER          (TabEdit,           const char *);
00116 #undef SET_GATHER
00117 
00118     // clear all the items from the tab list - only gui side
00119     virtual void _clearList()=0;
00120 
00121  protected:
00122     tAnswer             m_answer;
00123     XAP_Frame *         m_pFrame;
00124     UT_Dimension        m_dim;
00125 
00126     std::string     m_pszTabStops;  // from rulerInfo
00127     UT_GenericVector<fl_TabStop*>   m_tabInfo;      // list of fl_TabStop *
00128 
00129     // AP level handlers
00130     void _event_TabChange(void);        // when the edit box changes
00131     void _event_TabSelected( UT_sint32 index);  // when a list item is selected
00132     void _event_AlignmentChange(void);
00133 
00134     void _event_Set(void);              // buttons
00135     void _event_Update(void);
00136     void _event_Clear(void);
00137     void _event_ClearAll(void);
00138 
00139     void _event_somethingChanged();         // when anything changes - text, align, or leader
00140 
00141 private:
00142     TabSaveCallBack m_pCallbackFn;
00143     void * m_closure;
00144 
00145     char buf[20];
00146 
00147 };
00148 
00149 #endif /* AP_DIALOG_PARAGRAPH_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1