1 /* AbiWord
2  * Copyright (C) 1998 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #ifndef AP_Dialog_Columns_H
21 #define AP_Dialog_Columns_H
22 
23 #include "xap_Frame.h"
24 #include "xap_Dialog.h"
25 #include "fv_View.h"
26 #include "pd_Document.h"
27 
28 
29 class XAP_Frame;
30 class AP_Dialog_Columns;
31 
32 #include "xap_Preview.h"
33 
34 // this is needed to get the ruler units.
35 #include "ap_StatusBar.h"
36 #include "ut_units.h"
37 
38 
39 class ABI_EXPORT AP_Columns_preview_drawer
40 {
41 public:
42 
43 	void			draw(GR_Graphics *gc, UT_Rect &rect, UT_sint32 iColumns, bool bLines, double maxHeightPercent, double SpaceAfterPercent);
44 };
45 
46 class ABI_EXPORT AP_Columns_preview : public XAP_Preview
47 {
48 public:
49 
50 	AP_Columns_preview(GR_Graphics * gc, AP_Dialog_Columns * pColumns);
51 	virtual ~AP_Columns_preview(void);
52 
53 	// data twiddlers
54 	void			draw(const UT_Rect *clip=NULL);
55 
set(UT_uint32 iColumns,bool bLines)56 	void			set(UT_uint32 iColumns, bool bLines)
57 					{
58 						m_iColumns = iColumns;
59 						m_bLineBetween = bLines;
60 						draw();
61 					}
62 
63 private:
64 	AP_Columns_preview_drawer	m_previewDrawer;
65 	AP_Dialog_Columns *  m_pColumns;
66 protected:
67 
68 	UT_uint32		m_iColumns;
69 	bool			m_bLineBetween;
70 
71 };
72 
73 class ABI_EXPORT AP_Dialog_Columns : public XAP_Dialog_NonPersistent
74 {
75 public:
76 	AP_Dialog_Columns(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
77 	virtual ~AP_Dialog_Columns(void);
78 
79 	virtual void					runModal(XAP_Frame * pFrame) = 0;
80 	virtual void					enableLineBetweenControl(bool bState = true) = 0;
81 
82 
83 	void							setColumns(UT_uint32 iColumns);
84 
85 	typedef enum { a_OK, a_CANCEL } tAnswer;
86 	AP_Dialog_Columns::tAnswer getAnswer(void) const;
getColumns(void)87 	UT_uint32		   getColumns(void) const {return m_iColumns;}
88 
89 	void			   setLineBetween(bool bState);
getLineBetween(void)90 	bool			   getLineBetween(void) const { return m_bLineBetween;}
91 	double             getMaxHeightPercent(void);
92 	double             getSpaceAfterPercent(void);
93 	void			   setColumnOrder(UT_uint32 iOrder);
getColumnOrder(void)94 	UT_uint32		   getColumnOrder(void) const {return m_iColumnOrder;}
95 	const char *       getHeightString(void);
96 	const char *       getSpaceAfterString(void);
isSpaceAfterChanged(void)97 	bool               isSpaceAfterChanged(void) const {return m_bSpaceAfterChanged;}
isMaxHeightChanged(void)98 	bool               isMaxHeightChanged(void) const {return m_bMaxHeightChanged;}
99 
100 protected:
101 	void			   _createPreviewFromGC(GR_Graphics * gc,
102 							UT_uint32 width,
103 							UT_uint32 height);
104 	void			   _drawColumnButton(GR_Graphics *gc, UT_Rect rect, UT_uint32 iColumns);
105 	void			_convertToPreferredUnits(XAP_Frame * pFrame,const
106 	char *sz, gchar * pRet);
107 	AP_Dialog_Columns::tAnswer m_answer;
108 	AP_Columns_preview *	   m_pColumnsPreview;
109 	AP_Columns_preview_drawer  m_previewDrawer;
110 	void                       incrementMaxHeight(bool bIncrement);
111 	void                       incrementSpaceAfter(bool bIncrement);
112 	double                     getIncrement(const char * sz);
113 	void                       setViewAndDoc(XAP_Frame * pFrame);
114 	double                     getPageWidth(void);
115 	double                     getPageHeight(void);
116 	void                       setMaxHeight( const char * szHeight);
117 	void                       setSpaceAfter( const char * szAfter);
118 private:
119 
120 	UT_uint32		           m_iColumns;
121 	bool			           m_bLineBetween;
122 	UT_uint32		           m_iColumnOrder;
123 	UT_String                  m_HeightString;
124 	UT_String                  m_SpaceAfterString;
125 	PD_Document *              m_pDoc;
126 	FV_View *                  m_pView;
127 	bool                       m_bSpaceAfterChanged;
128 	bool                       m_bMaxHeightChanged;
129 	double                     m_dMarginTop;
130 	double                     m_dMarginBottom;
131 	double                     m_dMarginLeft;
132 	double                     m_dMarginRight;
133 };
134 
135 #endif /* AP_Dialog_Columns_H */
136