00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 class XAP_Frame;
00031 class AP_Preview_Paragraph;
00032
00033 #define SPIN_BUF_TEXT_SIZE 20
00034
00035 class ABI_EXPORT AP_Dialog_Paragraph : public XAP_Dialog_NonPersistent
00036 {
00037
00038
00039 friend class AP_Preview_Paragraph;
00040 friend class AP_Preview_Paragraph_Block;
00041
00042 public:
00043
00044 typedef enum { align_UNDEF = 0, align_LEFT, align_CENTERED, align_RIGHT, align_JUSTIFIED } tAlignState;
00045 typedef enum { indent_UNDEF = 0, indent_NONE, indent_FIRSTLINE, indent_HANGING } tIndentState;
00046 typedef enum { spacing_UNDEF = 0, spacing_SINGLE, spacing_ONEANDHALF, spacing_DOUBLE,
00047 spacing_ATLEAST, spacing_EXACTLY, spacing_MULTIPLE } tSpacingState;
00048
00049 typedef enum { id_MENU_ALIGNMENT = 0, id_SPIN_LEFT_INDENT,
00050 id_SPIN_RIGHT_INDENT, id_MENU_SPECIAL_INDENT,
00051 id_SPIN_SPECIAL_INDENT, id_SPIN_BEFORE_SPACING,
00052 id_SPIN_AFTER_SPACING, id_MENU_SPECIAL_SPACING,
00053 id_SPIN_SPECIAL_SPACING, id_CHECK_WIDOW_ORPHAN,
00054 id_CHECK_KEEP_LINES, id_CHECK_PAGE_BREAK,
00055 id_CHECK_SUPPRESS, id_CHECK_NO_HYPHENATE,
00056 id_CHECK_KEEP_NEXT,
00057 id_CHECK_DOMDIRECTION
00058 } tControl;
00059
00060 AP_Dialog_Paragraph(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00061 virtual ~AP_Dialog_Paragraph(void);
00062
00063 virtual void runModal(XAP_Frame * pFrame) = 0;
00064
00065
00066 typedef enum { a_OK, a_CANCEL, a_TABS } tAnswer;
00067
00068 bool setDialogData(const gchar ** pProps);
00069 bool getDialogData(const gchar **& pProps);
00070
00071
00072 void setMaxWidth(UT_sint32 width) { m_iMaxWidth = UT_inchesFromPaperUnits(width); }
00073
00074 AP_Dialog_Paragraph::tAnswer getAnswer(void) const;
00075
00076
00077
00078 typedef enum { check_FALSE = 0, check_TRUE, check_INDETERMINATE } tCheckState;
00079
00080 typedef enum { op_INIT = 0, op_UICHANGE, op_SYNC } tOperation;
00081
00082 protected:
00083
00084
00085 void _createPreviewFromGC(GR_Graphics * gc, UT_uint32 width, UT_uint32 height);
00086
00087 void _setMenuItemValue(tControl item, UT_sint32 value, tOperation = op_UICHANGE);
00088 UT_sint32 _getMenuItemValue(tControl item);
00089 void _setCheckItemValue(tControl item, tCheckState value, tOperation = op_UICHANGE);
00090 tCheckState _getCheckItemValue(tControl item);
00091 void _setSpinItemValue(tControl item, const gchar * value, tOperation = op_UICHANGE);
00092 const gchar * _getSpinItemValue(tControl item);
00093 const gchar * _makeAbsolute(const gchar * value);
00094
00095 void _doSpin(tControl edit, UT_sint32 amt);
00096 virtual void _syncControls(tControl changed, bool bAll = false);
00097
00098 bool _wasChanged(tControl item);
00099
00100
00101 tAnswer m_answer;
00102
00103 gchar * m_pageLeftMargin;
00104 gchar * m_pageRightMargin;
00105
00106
00107 AP_Preview_Paragraph * m_paragraphPreview;
00108
00109 XAP_Frame * m_pFrame;
00110
00111 private:
00112 class ABI_EXPORT sControlData
00113 {
00114 private:
00115 UT_sint32 m_siData;
00116 tCheckState m_csData;
00117 gchar * m_szData;
00118
00119 bool m_bChanged;
00120
00121 public:
00122 sControlData (UT_sint32 data);
00123 sControlData (tCheckState data);
00124 sControlData (gchar * data = 0);
00125
00126 sControlData (const sControlData & rhs);
00127
00128 ~sControlData ();
00129
00130 sControlData & operator= (const sControlData & rhs);
00131
00132 inline bool getData (UT_sint32 & data) const
00133 {
00134 data = m_siData;
00135 return true;
00136 }
00137 inline bool getData (tCheckState & data) const
00138 {
00139 data = m_csData;
00140 return true;
00141 }
00142 inline bool getData (const gchar *& data) const
00143 {
00144 data = m_szData;
00145 return (data != NULL);
00146 }
00147
00148 inline bool setData (UT_sint32 data)
00149 {
00150 m_siData = data;
00151 return true;
00152 }
00153 inline bool setData (tCheckState data)
00154 {
00155 m_csData = data;
00156 return true;
00157 }
00158 bool setData (const gchar * data);
00159
00160 inline bool changed () const { return m_bChanged; }
00161 inline void changed (bool c) { m_bChanged = c; }
00162 };
00163
00164 UT_GenericVector<sControlData *> m_vecProperties;
00165
00166 void _addPropertyItem (tControl index, const sControlData & control_data);
00167 inline sControlData * _getPropertyItem (tControl index) const
00168 {
00169 return m_vecProperties.getNthItem (static_cast<UT_uint32>(index));
00170 }
00171
00172
00173 UT_Dimension m_dim;
00174
00175
00176 double m_iMaxWidth;
00177 };
00178
00179 #endif