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

ap_Dialog_Paragraph.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998-2000 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_DIALOG_PARAGRAPH_H
00023 #define AP_DIALOG_PARAGRAPH_H
00024 
00025 #include "xap_Frame.h"
00026 #include "xap_Dialog.h"
00027 #include "xav_View.h"
00028 #include "xap_CustomWidget.h"
00029 
00030 #include "pp_Property.h"
00031 
00032 class XAP_Frame;
00033 class AP_Preview_Paragraph;
00034 
00035 #define SPIN_BUF_TEXT_SIZE  20
00036 
00037 class ABI_EXPORT AP_Dialog_Paragraph : public XAP_Dialog_NonPersistent
00038 {
00039     // the preview's block classes want to use some of our protected enums
00040     // below for similar alignment, etc.
00041     friend class AP_Preview_Paragraph;
00042     friend class AP_Preview_Paragraph_Block;
00043 
00044  public:
00045 
00046     typedef enum { align_UNDEF = 0, align_LEFT, align_CENTERED, align_RIGHT, align_JUSTIFIED } tAlignState;
00047     typedef enum { indent_UNDEF = 0, indent_NONE, indent_FIRSTLINE, indent_HANGING } tIndentState;
00048     typedef enum { spacing_UNDEF = 0, spacing_SINGLE, spacing_ONEANDHALF, spacing_DOUBLE,
00049                    spacing_ATLEAST, spacing_EXACTLY, spacing_MULTIPLE } tSpacingState;
00050     /* these are public because we must be able to identify widgets out this class (NSWindowController)*/
00051     typedef enum { id_MENU_ALIGNMENT = 0, id_SPIN_LEFT_INDENT,
00052                    id_SPIN_RIGHT_INDENT, id_MENU_SPECIAL_INDENT,
00053                    id_SPIN_SPECIAL_INDENT, id_SPIN_BEFORE_SPACING,
00054                    id_SPIN_AFTER_SPACING, id_MENU_SPECIAL_SPACING,
00055                    id_SPIN_SPECIAL_SPACING, id_CHECK_WIDOW_ORPHAN,
00056                    id_CHECK_KEEP_LINES, id_CHECK_PAGE_BREAK,
00057                    id_CHECK_SUPPRESS, id_CHECK_NO_HYPHENATE,
00058                    id_CHECK_KEEP_NEXT,
00059                    id_CHECK_DOMDIRECTION
00060                    } tControl;
00061 
00062     AP_Dialog_Paragraph(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00063     virtual ~AP_Dialog_Paragraph(void);
00064 
00065     virtual void    runModal(XAP_Frame * pFrame) = 0;
00066 
00067     // answer from dialog
00068     typedef enum { a_OK, a_CANCEL, a_TABS } tAnswer;
00069 
00070     bool setDialogData(const PP_PropertyVector & pProps);
00071     bool getDialogData(PP_PropertyVector & pProps);
00072 
00073     // expects a width in paper units.
00074     void setMaxWidth(UT_sint32 width) { m_iMaxWidth = UT_inchesFromPaperUnits(width); }
00075 
00076     AP_Dialog_Paragraph::tAnswer    getAnswer(void) const;
00077 
00078     // must be public, otherwise MSVC bails out
00079     // enumerated types for drop-down lists (option menus)
00080     typedef enum { check_FALSE = 0, check_TRUE, check_INDETERMINATE } tCheckState;
00081 
00082     typedef enum { op_INIT = 0, op_UICHANGE, op_SYNC } tOperation;
00083 
00084  protected:
00085 
00086     // handle the XP-job of attaching something to our m_paragraphPreview
00087     void _createPreviewFromGC(GR_Graphics * gc, UT_uint32 width, UT_uint32 height);
00088 
00089     void                _setMenuItemValue(tControl item, UT_sint32 value, tOperation = op_UICHANGE);
00090     UT_sint32           _getMenuItemValue(tControl item);
00091     void                _setCheckItemValue(tControl item, tCheckState value, tOperation = op_UICHANGE);
00092     tCheckState         _getCheckItemValue(tControl item);
00093     void                _setSpinItemValue(tControl item, const gchar * value, tOperation = op_UICHANGE);
00094     const gchar *   _getSpinItemValue(tControl item);
00095     const gchar *   _makeAbsolute(const gchar * value);
00096 
00097     void                _doSpin(tControl edit, UT_sint32 amt);
00098     virtual void        _syncControls(tControl changed, bool bAll = false);
00099 
00100     bool                _wasChanged(tControl item);
00101 
00102     // final dialog answer
00103     tAnswer                 m_answer;
00104 
00105     std::string         m_pageLeftMargin;
00106     std::string         m_pageRightMargin;
00107 
00108     // store a pointer to our preview control
00109     AP_Preview_Paragraph *  m_paragraphPreview;
00110 
00111     XAP_Frame *             m_pFrame;
00112 
00113 private:
00114     class ABI_EXPORT sControlData
00115     {
00116     private:
00117         UT_sint32       m_siData;
00118         tCheckState     m_csData;
00119         gchar *     m_szData;
00120 
00121         bool            m_bChanged;
00122 
00123     public:
00124         sControlData (UT_sint32 data);
00125         sControlData (tCheckState data);
00126         sControlData (gchar * data = 0); // default is empty string
00127 
00128         sControlData (const sControlData & rhs);
00129 
00130         ~sControlData ();
00131 
00132         sControlData & operator= (const sControlData & rhs);
00133 
00134         inline bool getData (UT_sint32 & data) const
00135         {
00136             data = m_siData;
00137             return true;
00138         }
00139         inline bool getData (tCheckState & data) const
00140         {
00141             data = m_csData;
00142             return true;
00143         }
00144         inline bool getData (const gchar *& data) const
00145         {
00146             data = m_szData;
00147             return (data != NULL);
00148         }
00149 
00150         inline bool setData (UT_sint32 data)
00151         {
00152             m_siData = data;
00153             return true;
00154         }
00155         inline bool setData (tCheckState data)
00156         {
00157             m_csData = data;
00158             return true;
00159         }
00160         bool setData (const gchar * data);
00161 
00162         inline bool changed () const { return m_bChanged; }
00163         inline void changed (bool c) { m_bChanged = c; }
00164     };
00165 
00166     UT_GenericVector<sControlData *> m_vecProperties; // properties stored as a vector
00167 
00168     void                    _addPropertyItem (tControl index, const sControlData & control_data);
00169     inline sControlData *   _getPropertyItem (tControl index) const
00170     {
00171         return m_vecProperties.getNthItem (static_cast<UT_uint32>(index));
00172     }
00173 
00174     // which dimension system we're using as "native" for this document
00175     UT_Dimension            m_dim;
00176 
00177     // current column width, in inches.
00178     double              m_iMaxWidth;
00179 };
00180 
00181 #endif /* AP_DIALOG_PARAGRAPH_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1