xref: /aoo4110/main/basctl/source/inc/dlged.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BASCTL_DLGED_HXX
25 #define _BASCTL_DLGED_HXX
26 
27 #include <com/sun/star/container/XNameContainer.hpp>
28 #include <com/sun/star/awt/XControlContainer.hpp>
29 #include <com/sun/star/datatransfer/DataFlavor.hpp>
30 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
31 #include <tools/link.hxx>
32 #include <tools/gen.hxx>
33 #include <vcl/timer.hxx>
34 #include <svl/hint.hxx>
35 #include <svl/brdcst.hxx>
36 
37 #define DLGED_PAGE_WIDTH_MIN    1280
38 #define DLGED_PAGE_HEIGHT_MIN   1024
39 
40 
41 //============================================================================
42 // DlgEdHint
43 //============================================================================
44 
45 enum DlgEdHintKind
46 {
47 	DLGED_HINT_UNKNOWN,
48 	DLGED_HINT_WINDOWSCROLLED,
49 	DLGED_HINT_LAYERCHANGED,
50 	DLGED_HINT_OBJORDERCHANGED,
51 	DLGED_HINT_SELECTIONCHANGED
52 };
53 
54 class DlgEdObj;
55 
56 class DlgEdHint: public SfxHint
57 {
58 private:
59 	DlgEdHintKind	eHintKind;
60 	DlgEdObj*		pDlgEdObj;
61 
62 public:
63 	TYPEINFO();
64 	DlgEdHint( DlgEdHintKind eHint );
65 	DlgEdHint( DlgEdHintKind eHint, DlgEdObj* pObj );
66 	virtual ~DlgEdHint();
67 
GetKind() const68 	DlgEdHintKind	GetKind() const	{ return eHintKind; }
GetObject() const69 	DlgEdObj*		GetObject() const { return pDlgEdObj; }
70 };
71 
72 
73 //============================================================================
74 // DlgEditor
75 //============================================================================
76 
77 enum DlgEdMode { DLGED_INSERT, DLGED_SELECT, DLGED_TEST, DLGED_READONLY };
78 
79 class ScrollBar;
80 class DlgEdModel;
81 class DlgEdPage;
82 class DlgEdView;
83 class DlgEdForm;
84 class DlgEdFactory;
85 class DlgEdFunc;
86 class Printer;
87 class KeyEvent;
88 class MouseEvent;
89 class Timer;
90 class Window;
91 
92 class DlgEditor: public SfxBroadcaster
93 {
94 private:
95 	DECL_LINK( PaintTimeout, Timer * );
96 	DECL_LINK( MarkTimeout, Timer * );
97 
98     void Print( Printer* pPrinter, const String& rTitle );
99 
100 protected:
101 	ScrollBar*			pHScroll;
102 	ScrollBar*			pVScroll;
103 	DlgEdModel*			pDlgEdModel;
104 	DlgEdPage*			pDlgEdPage;
105 	DlgEdView*			pDlgEdView;
106 	DlgEdForm*			pDlgEdForm;
107 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >		m_xUnoControlDialogModel;
108 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >        m_xControlContainer;
109 	::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >		m_ClipboardDataFlavors;
110 	::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >		m_ClipboardDataFlavorsResource;
111     ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >  m_xSupplier;
112 	DlgEdFactory*		pObjFac;
113 	Window*				pWindow;
114 	DlgEdFunc*			pFunc;
115 	DlgEdMode			eMode;
116 	sal_uInt16				eActObj;
117 	sal_Bool				bFirstDraw;
118 	Size				aGridSize;
119 	sal_Bool				bGridVisible;
120 	sal_Bool				bGridSnap;
121 	sal_Bool				bCreateOK;
122 	Timer				aPaintTimer;
123 	Rectangle			aPaintRect;
124 	sal_Bool				bDialogModelChanged;
125     Timer               aMarkTimer;
126 	long				mnPaintGuard;
127 
128 public:
129 	DlgEditor();
130 	~DlgEditor();
131 
132 	void			SetWindow( Window* pWindow );
GetWindow() const133 	Window*			GetWindow() const { return pWindow; }
134 
135     /** returns the control container associated with our window
136         @see GetWindow
137         @see SetWindow
138     */
139     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
140                     GetWindowControlContainer();
141 
SetDlgEdForm(DlgEdForm * pForm)142 	void			SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
GetDlgEdForm() const143 	DlgEdForm*		GetDlgEdForm() const { return pDlgEdForm; }
144 
145 	void			SetScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
146     void            InitScrollBars();
GetHScroll() const147 	ScrollBar* 		GetHScroll() const { return pHScroll; }
GetVScroll() const148 	ScrollBar*		GetVScroll() const { return pVScroll; }
149 	void			DoScroll( ScrollBar* pActScroll );
150 	void			UpdateScrollBars();
151 
152 	void			SetDialog( ::com::sun::star::uno::Reference<
153 						::com::sun::star::container::XNameContainer > xUnoControlDialogModel );
154 	void			ResetDialog( void );
GetDialog() const155 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >	GetDialog() const
156 						{return m_xUnoControlDialogModel;}
157 
158     ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > const & GetNumberFormatsSupplier();
159 
GetModel() const160 	DlgEdModel*		GetModel() 		const { return pDlgEdModel; }
GetView() const161 	DlgEdView*		GetView() 	 	const { return pDlgEdView; }
GetPage() const162 	DlgEdPage*		GetPage()		const { return pDlgEdPage; }
163 
164 	void			ShowDialog();
165 
166 	sal_Bool			UnmarkDialog();
167 	sal_Bool			RemarkDialog();
168 
SetDialogModelChanged(sal_Bool bChanged=sal_True)169 	void			SetDialogModelChanged( sal_Bool bChanged = sal_True ) { bDialogModelChanged = bChanged; }
IsDialogModelChanged() const170 	sal_Bool			IsDialogModelChanged() const { return bDialogModelChanged; }
171 
172 	sal_Bool			IsModified() const;
173 	void			ClearModifyFlag();
174 
175 	void			MouseButtonDown( const MouseEvent& rMEvt );
176 	void			MouseButtonUp( const MouseEvent& rMEvt );
177 	void			MouseMove( const MouseEvent& rMEvt );
178 	void			Paint( const Rectangle& rRect );
179 	sal_Bool			KeyInput( const KeyEvent& rKEvt );
180 
181 	void 			SetMode( DlgEdMode eMode );
182 	void			SetInsertObj( sal_uInt16 eObj );
183 	sal_uInt16    		GetInsertObj() const;
184 	void			CreateDefaultObject();
GetMode() const185 	DlgEdMode   	GetMode() const { return eMode; }
IsCreateOK() const186 	sal_Bool			IsCreateOK() const { return bCreateOK; }
187 
188 	void			Cut();
189 	void			Copy();
190 	void			Paste();
191 	void			Delete();
192     sal_Bool            IsPasteAllowed();
193 
194 	void			ShowProperties();
195     void            UpdatePropertyBrowserDelayed();
196 
197     sal_Int32       countPages( Printer* pPrinter );
198     void            printPage( sal_Int32 nPage, Printer* pPrinter, const String& );
199 
200     bool            AdjustPageSize();
201 
isInPaint() const202 	bool			isInPaint() const { return mnPaintGuard > 0; }
203 };
204 
205 #endif //_BASCTL_DLGED_HXX
206