xref: /aoo41x/main/svx/inc/svx/dlgctrl.hxx (revision ed6b2054)
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 #ifndef _SVX_DLG_CTRL_HXX
24 #define _SVX_DLG_CTRL_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <svtools/ctrlbox.hxx>
29 #include <sfx2/tabdlg.hxx>
30 #include "svx/svxdllapi.h"
31 #include <svx/rectenum.hxx>
32 #include <vcl/graph.hxx>
33 #ifndef _XTABLE_HXX
34 class XBitmapEntry;
35 class XBitmapList;
36 class XColorEntry;
37 class XColorList;
38 class XDash;
39 class XDashEntry;
40 class XDashList;
41 class XGradient;
42 class XGradientEntry;
43 class XGradientList;
44 class XHatch;
45 class XHatchEntry;
46 class XHatchList;
47 class XLineEndEntry;
48 class XLineEndList;
49 class XFillAttrSetItem;
50 #endif
51 
52 class XOBitmap;
53 class XOutdevItemPool;
54 
55 namespace com { namespace sun { namespace star { namespace awt {
56 	struct Point;
57 } } } }
58 
59 /*************************************************************************
60 |*
61 |* Von SfxTabPage abgeleitet, um vom Control ueber virtuelle Methode
62 |* benachrichtigt werden zu koennen.
63 |*
64 \************************************************************************/
65 class SvxTabPage : public SfxTabPage
66 {
67 
68 public:
69 	SvxTabPage( Window* pParent, ResId Id, const SfxItemSet& rInAttrs  ) :
70 		SfxTabPage( pParent, Id, rInAttrs ) {}
71 
72 	virtual void PointChanged( Window* pWindow, RECT_POINT eRP ) = 0;
73 };
74 
75 /*************************************************************************
76 |*
77 |*	Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
78 |*	eines Objekts
79 |*
80 \************************************************************************/
81 typedef sal_uInt16 CTL_STATE;
82 #define CS_NOHORZ	1		// no horizontal input information is used
83 #define CS_NOVERT	2		// no vertikal input information is used
84 
85 class SvxRectCtlAccessibleContext;
86 
87 class SVX_DLLPUBLIC SvxRectCtl : public Control
88 {
89 private:
90 	SVX_DLLPRIVATE void				InitSettings( sal_Bool bForeground, sal_Bool bBackground );
91 	SVX_DLLPRIVATE void				InitRectBitmap( void );
92 	SVX_DLLPRIVATE Bitmap&          GetRectBitmap( void );
93     SVX_DLLPRIVATE void             Resize_Impl();
94 
95 protected:
96 	SvxRectCtlAccessibleContext*	pAccContext;
97 	sal_uInt16							nBorderWidth;
98 	sal_uInt16							nRadius;
99 	Size							aSize;
100 	Point							aPtLT, aPtMT, aPtRT;
101 	Point							aPtLM, aPtMM, aPtRM;
102 	Point							aPtLB, aPtMB, aPtRB;
103 	Point							aPtNew;
104 	RECT_POINT						eRP, eDefRP;
105 	CTL_STYLE						eCS;
106 	Bitmap*							pBitmap;
107 	CTL_STATE						m_nState;
108 
109 	// #103516# Added a possibility to completely disable this control
110 	sal_Bool						mbCompleteDisable;
111 
112 	RECT_POINT			GetRPFromPoint( Point ) const;
113 	Point				GetPointFromRP( RECT_POINT ) const;
114 	void				SetFocusRect( const Rectangle* pRect = NULL );		// pRect == NULL -> calculate rectangle in method
115 	Point				SetActualRPWithoutInvalidate( RECT_POINT eNewRP );	// returns the last point
116 
117 	virtual void		GetFocus();
118 	virtual void		LoseFocus();
119 
120 	Point				GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
121 public:
122 	SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt = RP_MM,
123 				sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT );
124 	virtual ~SvxRectCtl();
125 
126 	virtual void 		Paint( const Rectangle& rRect );
127 	virtual void 		MouseButtonDown( const MouseEvent& rMEvt );
128     virtual void        KeyInput( const KeyEvent& rKeyEvt );
129 	virtual void		StateChanged( StateChangedType nStateChange );
130 	virtual void		DataChanged( const DataChangedEvent& rDCEvt );
131     virtual void        Resize();
132 
133 	void				Reset();
134 	RECT_POINT			GetActualRP() const;
135 	void				SetActualRP( RECT_POINT eNewRP );
136 
137 	void				SetState( CTL_STATE nState );
138 
139 	sal_uInt8				GetNumOfChilds( void ) const;	// returns number of usable radio buttons
140 
141 	Rectangle			CalculateFocusRectangle( void ) const;
142 	Rectangle			CalculateFocusRectangle( RECT_POINT eRectPoint ) const;
143 
144     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
145 
146 	RECT_POINT			GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& rPixelPoint ) const;
147 
148 	// #103516# Added a possibility to completely disable this control
149 	sal_Bool IsCompletelyDisabled() const { return mbCompleteDisable; }
150 	void DoCompletelyDisable(sal_Bool bNew);
151 };
152 
153 /*************************************************************************
154 |*
155 |*	Control zur Darstellung und Auswahl des Winkels der Eckpunkte
156 |*	eines Objekts
157 |*
158 \************************************************************************/
159 class SvxAngleCtl : public SvxRectCtl
160 {
161 private:
162 	void	Initialize();
163 
164 protected:
165 	Font	aFont;
166 	Size	aFontSize;
167 	sal_Bool	bPositive;
168 
169 public:
170 			SvxAngleCtl( Window* pParent, const ResId& rResId );
171 			SvxAngleCtl( Window* pParent, const ResId& rResId, Size aSize );
172 
173 	void	ChangeMetric()
174 				{ bPositive = !bPositive; }
175 	virtual void Paint( const Rectangle& rRect );
176 };
177 
178 /*************************************************************************
179 |*
180 |*	Preview-Control zur Darstellung von Bitmaps
181 |*
182 \************************************************************************/
183 
184 class SVX_DLLPUBLIC SvxBitmapCtl
185 {
186 protected:
187 	Size			aSize;
188 	sal_uInt16			nLines;
189 	Color			aPixelColor, aBackgroundColor;
190 	const sal_uInt16*	pBmpArray;
191 
192 public:
193 			SvxBitmapCtl( Window* pParent, const Size& rSize );
194 			~SvxBitmapCtl();
195 
196 	BitmapEx GetBitmapEx();
197 
198 	void	SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; }
199 	void	SetLines( sal_uInt16 nLns ) { nLines = nLns; }
200 	void	SetPixelColor( Color aColor ) { aPixelColor = aColor; }
201 	void	SetBackgroundColor( Color aColor ) { aBackgroundColor = aColor; }
202 };
203 
204 /*************************************************************************
205 |*
206 |*	Control zum Editieren von Bitmaps
207 |*
208 \************************************************************************/
209 class SVX_DLLPUBLIC SvxPixelCtl : public Control
210 {
211 private:
212     using OutputDevice::SetLineColor;
213 
214 protected:
215 	sal_uInt16		nLines, nSquares;
216 	Color		aPixelColor;
217 	Color		aBackgroundColor;
218 	Color		aLineColor;
219 	Size		aRectSize;
220 	sal_uInt16* 	pPixel;
221 	sal_Bool		bPaintable;
222 
223 	void	ChangePixel( sal_uInt16 nPixel );
224 
225 public:
226 			SvxPixelCtl( Window* pParent, const ResId& rResId,
227 						sal_uInt16 nNumber = 8 );
228 			~SvxPixelCtl();
229 
230 	virtual void Paint( const Rectangle& rRect );
231 	virtual void MouseButtonDown( const MouseEvent& rMEvt );
232 
233 	void	SetXBitmap( const BitmapEx& rBitmapEx );
234 
235 	void	SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
236 	void	SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
237 	void	SetLineColor( const Color& rCol ) { aLineColor = rCol; }
238 
239 	sal_uInt16	GetLineCount() const { return nLines; }
240 	Color	GetPixelColor() const { return aPixelColor; }
241 	Color	GetBackgroundColor() const { return aBackgroundColor; }
242 
243 	sal_uInt16	GetBitmapPixel( const sal_uInt16 nPixelNumber );
244 	sal_uInt16* GetBitmapPixelPtr() { return pPixel; }
245 
246 	void	SetPaintable( sal_Bool bTmp ) { bPaintable = bTmp; }
247 	void	Reset();
248 };
249 
250 /*************************************************************************
251 |*
252 |* ColorLB kann mit Farben und Namen gefuellt werden
253 |*
254 \************************************************************************/
255 class SVX_DLLPUBLIC ColorLB : public ColorListBox
256 {
257 
258 public:
259 		 ColorLB( Window* pParent, ResId Id ) : ColorListBox( pParent, Id ) {}
260 		 ColorLB( Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {}
261 
262 	virtual void Fill( const XColorList* pTab );
263 
264 	void Append( XColorEntry* pEntry, Bitmap* pBmp = NULL );
265 	void Modify( XColorEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp = NULL );
266 };
267 
268 /*************************************************************************
269 |*
270 |* HatchingLB
271 |*
272 \************************************************************************/
273 class SVX_DLLPUBLIC HatchingLB : public ListBox
274 {
275 
276 public:
277 		 HatchingLB( Window* pParent, ResId Id, sal_Bool bUserDraw = sal_True );
278 		 HatchingLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw = sal_True );
279 
280 	virtual void Fill( const XHatchList* pList );
281 	virtual void UserDraw( const UserDrawEvent& rUDEvt );
282 
283 	void	Append( XHatchEntry* pEntry, Bitmap* pBmp = NULL );
284 	void	Modify( XHatchEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp = NULL );
285 	void	SelectEntryByList( const XHatchList* pList, const String& rStr,
286 						const XHatch& rXHatch, sal_uInt16 nDist = 0 );
287 
288 private:
289 	XHatchList*		mpList;
290 	sal_Bool			mbUserDraw;
291 };
292 
293 /*************************************************************************
294 |*
295 |* GradientLB
296 |*
297 \************************************************************************/
298 class SVX_DLLPUBLIC GradientLB : public ListBox
299 {
300 public:
301 	GradientLB( Window* pParent, ResId Id, sal_Bool bUserDraw = sal_True );
302 	GradientLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw = sal_True );
303 
304 	virtual void Fill( const XGradientList* pList );
305 	virtual void UserDraw( const UserDrawEvent& rUDEvt );
306 
307 	void	Append( XGradientEntry* pEntry, Bitmap* pBmp = NULL );
308 	void	Modify( XGradientEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp = NULL );
309 	void	SelectEntryByList( const XGradientList* pList, const String& rStr,
310 						const XGradient& rXGradient, sal_uInt16 nDist = 0 );
311 
312 private:
313 	XGradientList* mpList;
314 	sal_Bool			mbUserDraw;
315 };
316 
317 /*************************************************************************
318 |*
319 |* BitmapLB
320 |*
321 \************************************************************************/
322 class SVX_DLLPUBLIC BitmapLB : public ListBox
323 {
324 public:
325     BitmapLB(Window* pParent, ResId Id, bool bUserDraw = true);
326 
327 	virtual void Fill(const XBitmapList* pList);
328 	virtual void UserDraw(const UserDrawEvent& rUDEvt);
329 
330 	void Append(const Size& rSize, const XBitmapEntry& rEntry, BitmapEx* pBmpEx = 0);
331 	void Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos, BitmapEx* pBmpEx = 0);
332 	void SelectEntryByList(const XBitmapList* pList, const String& rStr);
333 
334 private:
335 	VirtualDevice	maVD;
336 	BitmapEx        maBitmapEx;
337 
338 	XBitmapList*	mpList;
339 	bool            mbUserDraw;
340 
341 	SVX_DLLPRIVATE void SetVirtualDevice(const Size& rSize);
342 };
343 
344 /*************************************************************************
345 |*
346 |* FillAttrLB vereint alle Fuellattribute in einer ListBox
347 |*
348 \************************************************************************/
349 class FillAttrLB : public ColorListBox
350 {
351 private:
352 	VirtualDevice	maVD;
353 	BitmapEx		maBitmapEx;
354 
355 	void SetVirtualDevice(const Size& rSize);
356 
357 public:
358     FillAttrLB( Window* pParent, ResId Id );
359     FillAttrLB( Window* pParent, WinBits aWB );
360 
361 	virtual void Fill( const XColorList* pTab );
362 	virtual void Fill( const XHatchList* pList );
363 	virtual void Fill( const XGradientList* pList );
364 	virtual void Fill( const XBitmapList* pList );
365 
366 	void SelectEntryByList(const XBitmapList* pList, const String& rStr);
367 };
368 
369 /*************************************************************************
370 |*
371 |* FillTypeLB
372 |*
373 \************************************************************************/
374 class FillTypeLB : public ListBox
375 {
376 
377 public:
378 		 FillTypeLB( Window* pParent, ResId Id ) : ListBox( pParent, Id ) {}
379 		 FillTypeLB( Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
380 
381 	virtual void Fill();
382 };
383 
384 /*************************************************************************
385 |*
386 |* LineLB
387 |*
388 \************************************************************************/
389 class SVX_DLLPUBLIC LineLB : public ListBox
390 {
391 private:
392     /// bitfield
393     /// defines if standard fields (none, solid) are added, default is true
394     bool        mbAddStandardFields : 1;
395 
396 public:
397     LineLB(Window* pParent, ResId Id);
398     LineLB(Window* pParent, WinBits aWB);
399     virtual ~LineLB();
400 
401     virtual void Fill(const XDashList* pList);
402 
403     bool getAddStandardFields() const { return mbAddStandardFields; }
404     void setAddStandardFields(bool bNew);
405 
406     void Append(XDashEntry* pEntry, const Bitmap* pBmp = 0);
407     void Modify(XDashEntry* pEntry, sal_uInt16 nPos, const Bitmap* pBmp = 0);
408     void SelectEntryByList(const XDashList* pList, const String& rStr, const XDash& rDash, sal_uInt16 nDist = 0);
409 };
410 
411 /*************************************************************************
412 |*
413 |* LineEndsLB
414 |*
415 \************************************************************************/
416 class SVX_DLLPUBLIC LineEndLB : public ListBox
417 {
418 
419 public:
420                           LineEndLB( Window* pParent, ResId Id );
421                           LineEndLB( Window* pParent, WinBits aWB );
422                  virtual ~LineEndLB (void);
423 
424 	virtual void Fill( const XLineEndList* pList, sal_Bool bStart = sal_True );
425 
426 	void	Append( XLineEndEntry* pEntry, const Bitmap* pBmp = NULL,
427 					sal_Bool bStart = sal_True );
428 	void	Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, const Bitmap* pBmp = NULL,
429 					sal_Bool bStart = sal_True );
430 };
431 
432 //////////////////////////////////////////////////////////////////////////////
433 
434 class SdrObject;
435 class SdrModel;
436 
437 class SvxPreviewBase : public Control
438 {
439 private:
440 	SdrModel*										mpModel;
441     VirtualDevice*                                  mpBufferDevice;
442 
443 protected:
444 	void InitSettings(bool bForeground, bool bBackground);
445 
446     // prepare buffered paint
447     void LocalPrePaint();
448 
449     // end and output buffered paint
450     void LocalPostPaint();
451 
452 public:
453 	SvxPreviewBase( Window* pParent, const ResId& rResId );
454 	virtual ~SvxPreviewBase();
455 
456     // change support
457 	virtual void StateChanged(StateChangedType nStateChange);
458 	virtual void DataChanged(const DataChangedEvent& rDCEvt);
459 
460     // dada read access
461     SdrModel& getModel() const { return *mpModel; }
462     OutputDevice& getBufferDevice() const { return *mpBufferDevice; }
463 };
464 
465 /*************************************************************************
466 |*
467 |* SvxLinePreview
468 |*
469 \************************************************************************/
470 
471 class SVX_DLLPUBLIC SvxXLinePreview : public SvxPreviewBase
472 {
473 private:
474 	SdrObject*										mpLineObjA;
475 	SdrObject*										mpLineObjB;
476 	SdrObject*										mpLineObjC;
477 
478 	//#58425# Symbole auf einer Linie (z.B. StarChart)
479 	Graphic*										mpGraphic;
480 	sal_Bool										mbWithSymbol;
481 	Size											maSymbolSize;
482 
483 public:
484 	SvxXLinePreview( Window* pParent, const ResId& rResId );
485 	virtual ~SvxXLinePreview();
486 
487 	void SetLineAttributes(const SfxItemSet& rItemSet);
488 
489 	void ShowSymbol( sal_Bool b ) { mbWithSymbol = b; };
490 	void SetSymbol( Graphic* p, const Size& s );
491 	void ResizeSymbol( const Size& s );
492 
493 	virtual void Paint( const Rectangle& rRect );
494 };
495 
496 /*************************************************************************
497 |*
498 |* SvxXRectPreview
499 |*
500 \************************************************************************/
501 
502 class SVX_DLLPUBLIC SvxXRectPreview : public SvxPreviewBase
503 {
504 private:
505 	SdrObject*										mpRectangleObject;
506 
507 public:
508 	SvxXRectPreview( Window* pParent, const ResId& rResId );
509 	virtual ~SvxXRectPreview();
510 
511 	void SetAttributes(const SfxItemSet& rItemSet);
512 
513 	virtual void	Paint( const Rectangle& rRect );
514 };
515 
516 /*************************************************************************
517 |*
518 |* SvxXShadowPreview
519 |*
520 \************************************************************************/
521 
522 class SVX_DLLPUBLIC SvxXShadowPreview : public SvxPreviewBase
523 {
524 private:
525 	SdrObject*										mpRectangleObject;
526 	SdrObject*										mpRectangleShadow;
527 
528 public:
529 	SvxXShadowPreview( Window* pParent, const ResId& rResId );
530 	virtual ~SvxXShadowPreview();
531 
532 	void SetRectangleAttributes(const SfxItemSet& rItemSet);
533 	void SetShadowAttributes(const SfxItemSet& rItemSet);
534 	void SetShadowPosition(const Point& rPos);
535 
536 	virtual void	Paint( const Rectangle& rRect );
537 };
538 
539 #endif // _SVX_DLG_CTRL_HXX
540 
541