xref: /aoo42x/main/svtools/source/inc/property.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SV_PROPERTY_HXX
29 #define SV_PROPERTY_HXX
30 
31 #ifndef _VIRDEV_HXX //autogen
32 #include <vcl/virdev.hxx>
33 #endif
34 #ifndef SV_FIXED_HXX
35 #include <vcl/fixed.hxx>
36 #endif
37 #ifndef SV_LSTBOX_HXX
38 #include <vcl/lstbox.hxx>
39 #endif
40 #ifndef SV_GROUP_HXX
41 #include <vcl/group.hxx>
42 #endif
43 #ifndef SV_BUTTON_HXX
44 #include <vcl/button.hxx>
45 #endif
46 #ifndef SV_MOREBTN_HXX
47 #include <vcl/morebtn.hxx>
48 #endif
49 #ifndef _DIALOG_HXX //autogen
50 #include <vcl/dialog.hxx>
51 #endif
52 #include <vcl/combobox.hxx>
53 #include <vcl/field.hxx>
54 #include <svl/svarray.hxx>
55 
56 #define _SVSTDARR_USHORTS
57 #include <svl/svstdarr.hxx>
58 #include <vcl/virdev.hxx>
59 #include <vcl/scrbar.hxx>
60 #include <svl/svarray.hxx>
61 
62 #ifndef	_SVSTDARR_STRINGS
63 #define _SVSTDARR_STRINGS
64 #include <svl/svstdarr.hxx>
65 #endif
66 #include <vcl/tabpage.hxx>
67 #include <vcl/tabctrl.hxx>
68 
69 //------------------------------------------------------------------------
70 
71 //========================================================================
72 enum eKindOfControl { KOC_UNDEFINED=0,KOC_LISTBOX=1, KOC_COMBOBOX=2,
73 						KOC_EDIT=3,KOC_USERDEFINED=5};
74 
75 class SvXPropertyCtrListener;
76 
77 class SvXPropertyControl : public Control
78 {
79 public:
80 										SvXPropertyControl( Window* pParent, WinBits nWinStyle = 0 );
81 										SvXPropertyControl( Window* pParent, const ResId& rResId );
82 
83 		virtual void					SetSvXPropertyCtrListener(SvXPropertyCtrListener*)=0;
84 
85 		virtual SvXPropertyCtrListener*	GetSvXPropertyCtrListener()=0;
86 		virtual void					SetProperty(const String &rString)=0;
87 		virtual String					GetProperty()const=0;
88 		virtual sal_Bool					HasList()=0;
89 		virtual void					ClearList()=0;
90 		virtual	void					InsertEntry( const String& rString,
91 												sal_uInt16 nPos = LISTBOX_APPEND )=0;
92 
93 		virtual void					SetCtrSize(const Size& rSize)=0;
94 		virtual void					SetLocked(sal_Bool bLocked=sal_True)=0;
95 
96 		virtual void					SetMyName(const String &rString)=0;
97 		virtual String					GetMyName()const=0;
98 
99 		virtual void					SetMyData(void*)=0;
100 		virtual void*					GetMyData()=0;
101 };
102 
103 class SvXPropertyCtrListener
104 {
105 
106 public:
107 		virtual void					Modified (SvXPropertyControl *pSvXPCtr)=0;
108 		virtual void					GetFocus (SvXPropertyControl *pSvXPCtr)=0;
109 		virtual void					LoseFocus(SvXPropertyControl *pSvXPCtr)=0;
110 		virtual void					KeyInput (SvXPropertyControl *pSvXPCtr ,const KeyCode&)=0;
111 };
112 
113 
114 class SvXPropertyEdit : public SvXPropertyControl
115 {
116 private:
117 
118 		String							aName;
119 		SvXPropertyCtrListener*			pListener;
120 		Edit							aEdit;
121 		void*							pData;
122 
123 		DECL_LINK(ModifiedHdl,Edit*);
124 		DECL_LINK(GetFocusHdl,Edit*);
125 		DECL_LINK(LoseFocusHdl,Edit*);
126 
127 public:
128 										SvXPropertyEdit( Window* pParent, WinBits nWinStyle = 0 );
129 										SvXPropertyEdit( Window* pParent, const ResId& rResId );
130 
131 		virtual void					SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
132 
133 		virtual SvXPropertyCtrListener*	GetSvXPropertyCtrListener();
134 
135 		virtual void					SetProperty(const String &rString);
136 		virtual String					GetProperty()const;
137 
138 		virtual sal_Bool					HasList();
139 		virtual void					ClearList();
140 		virtual	void					InsertEntry( const String& rString,
141 												sal_uInt16 nPos = LISTBOX_APPEND );
142 
143 		virtual void					SetCtrSize(const Size& rSize);
144 		virtual void					SetLocked(sal_Bool bLocked=sal_True);
145 
146 		virtual void					SetMyName(const String &rString);
147 		virtual String					GetMyName()const;
148 
149 		virtual void					SetMyData(void*);
150 		virtual void*					GetMyData();
151 };
152 
153 
154 class SvXPropertyListBox : public SvXPropertyControl
155 {
156 private:
157 
158 		String							aName;
159 		SvXPropertyCtrListener*			pListener;
160 		ListBox							aListBox;
161 		void*							pData;
162 
163 		DECL_LINK(ModifiedHdl,ListBox*);
164 		DECL_LINK(GetFocusHdl,ListBox*);
165 		DECL_LINK(LoseFocusHdl,ListBox*);
166 
167 
168 public:
169 										SvXPropertyListBox( Window* pParent, WinBits nWinStyle = 0 );
170 										SvXPropertyListBox( Window* pParent, const ResId& rResId );
171 
172 		virtual void					SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
173 
174 		virtual SvXPropertyCtrListener*	GetSvXPropertyCtrListener();
175 
176 		ListBox*						GetListBox();
177 
178 		virtual void					SetProperty(const String &rString);
179 		virtual String					GetProperty()const;
180 
181 		virtual sal_Bool					HasList();
182 		virtual void					ClearList();
183 		virtual	void					InsertEntry( const String& rString,
184 												sal_uInt16 nPos = LISTBOX_APPEND );
185 
186 		virtual void					SetCtrSize(const Size& rSize);
187 		virtual void					SetLocked(sal_Bool bLocked=sal_True);
188 
189 		virtual void					SetMyName(const String &rString);
190 		virtual String					GetMyName()const;
191 
192 		virtual void					SetMyData(void*);
193 		virtual void*					GetMyData();
194 };
195 
196 class SvXPropertyComboBox : public SvXPropertyControl
197 {
198 private:
199 
200 		String							aName;
201 		SvXPropertyCtrListener*			pListener;
202 		ComboBox						aComboBox;
203 		void*							pData;
204 
205 		DECL_LINK(ModifiedHdl,ComboBox*);
206 		DECL_LINK(GetFocusHdl,ComboBox*);
207 		DECL_LINK(LoseFocusHdl,ComboBox*);
208 
209 
210 public:
211 										SvXPropertyComboBox( Window* pParent, WinBits nWinStyle = 0 );
212 										SvXPropertyComboBox( Window* pParent, const ResId& rResId );
213 
214 		virtual void					SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
215 
216 		virtual SvXPropertyCtrListener*	GetSvXPropertyCtrListener();
217 
218 		ComboBox*						GetComboBox();
219 
220 		virtual void					SetProperty(const String &rString);
221 		virtual String					GetProperty()const;
222 
223 		virtual sal_Bool					HasList();
224 		virtual void					ClearList();
225 		virtual	void					InsertEntry( const String& rString,
226 												sal_uInt16 nPos = LISTBOX_APPEND );
227 
228 		virtual void					SetCtrSize(const Size& rSize);
229 		virtual void					SetLocked(sal_Bool bLocked=sal_True);
230 
231 		virtual void					SetMyName(const String &rString);
232 		virtual String					GetMyName()const;
233 
234 		virtual void					SetMyData(void*);
235 		virtual void*					GetMyData();
236 };
237 
238 
239 
240 class SvPropertyLine : public Control
241 {
242 private:
243 			FixedText			aName;
244 			sal_uInt16				nNameWidth;
245 			sal_Bool				bNeedsRepaint;
246 			SvXPropertyControl*	pSvXPropertyControl;
247 
248 			PushButton			aXButton;
249 			sal_Bool				bIsLocked;
250 			sal_Bool				bHasXButton;
251 			sal_Bool				bIsHyperlink;
252 			eKindOfControl		eKindOfCtr;
253 
254 protected:
255 			virtual void		Resize();
256 
257 public:
258 			SvPropertyLine( Window* pParent,
259 							WinBits nWinStyle = 0 );
260 			SvPropertyLine( Window* pParent,
261 							const ResId& rResId );
262 
263 			sal_Bool				NeedsRepaint();
264 			void				SetNeedsRepaint(sal_Bool bFlag);
265 			void				SetSvXPropertyControl(SvXPropertyControl*);
266 			SvXPropertyControl*	GetSvXPropertyControl();
267 
268 			void				SetKindOfControl(eKindOfControl);
269 			eKindOfControl		GetKindOfControl();
270 
271 			void				SetName(const String& rString );
272 			String				GetName() const;
273 			void				SetNameWidth(sal_uInt16);
274 
275 			void				ShowXButton();
276 			void				HideXButton();
277 			sal_Bool				IsVisibleXButton();
278 			void				ShowAsHyperLink(sal_Bool nFlag=sal_True);
279 			sal_Bool				IsShownAsHyperlink();
280 
281 			void				Locked(sal_Bool nFlag=sal_True);
282 			sal_Bool				IsLineLocked();
283 
284 			void				SetClickHdl(const Link&);
285 
286 };
287 
288 
289 class SvPropertyData
290 {
291 public:
292 		eKindOfControl			eKind;
293 		String					aName;
294 		String					aValue;
295 		SvStrings				theValues; // ???
296 
297 		sal_Bool					bHasVisibleXButton;
298 		sal_Bool					bIsHyperLink;
299 		sal_Bool					bIsLocked;
300 		void*					pDataPtr;
301 		SvXPropertyControl*		pControl;
302 };
303 
304 class SvPropertyDataObjectControl
305 {
306 };
307 
308 class SvPropertyDataControl
309 {
310 public:
311 		virtual void					Modified(	const String& aName,
312 													const String& aVal,
313 													void* pData)=0;
314 
315 		virtual void					Clicked(	const String& aName,
316 													const String& aVal,
317 													void* pData)=0;
318 
319 		virtual void					Commit(		const String& aName,
320 													const String& aVal,
321 													void* pData)=0;
322 
323 		virtual void					Select(		const String& aName,
324 													void* pData)=0;
325 
326 		virtual void					LinkClicked(const String& aName,
327 													void* pData)=0;
328 };
329 
330 class SvXPropEvListener: public SvXPropertyCtrListener
331 {
332 		Link							aModifyLink;
333 		Link							aGetFocusLink;
334 		Link							aLoseFocusLink;
335 		Link							aKeyInputLink;
336 		String							aModifiedResult;
337 
338 		SvXPropertyControl *			pTheActiveControl;
339 		KeyCode							aKeyCode;
340 
341 public:
342 										SvXPropEvListener();
343         virtual                        ~SvXPropEvListener();
344 
345 		virtual void					Modified (SvXPropertyControl *pSvXPCtr);
346 		virtual void					GetFocus (SvXPropertyControl *pSvXPCtr);
347 		virtual void					LoseFocus(SvXPropertyControl *pSvXPCtr);
348 		virtual void					KeyInput(SvXPropertyControl *pSvXPCtr ,const KeyCode&);
349 
350 		SvXPropertyControl *				GetPropertyControl();
351 		KeyCode							GetKeyCode() const;
352 
353 		void							SetModifyHdl( const Link& rLink ) { aModifyLink = rLink; }
354 		const Link&						GetModifyHdl() const { return aModifyLink; }
355 
356 		void							SetGetFocusHdl( const Link& rLink ) { aGetFocusLink = rLink; }
357 		const Link&						GetGetFocusHdl() const { return aGetFocusLink; }
358 
359 		void							SetLoseFocusHdl( const Link& rLink ) { aLoseFocusLink = rLink; }
360 		const Link&						GetLoseFocusHdl() const { return aLoseFocusLink; }
361 
362 		void							SetKeyInputHdl( const Link& rLink ) { aKeyInputLink = rLink; }
363 		const Link&						GetKeyInputHdl() const { return aKeyInputLink; }
364 
365 
366 };
367 
368 typedef SvPropertyLine * SvPropertyLinePtr;
369 
370 SV_DECL_PTRARR(SvPropLineArray,SvPropertyLinePtr,1,1)
371 
372 class SvListBoxForProperties: public Control
373 {
374 private:
375 
376 			SvXPropEvListener		aListener;
377 			Window					aPlayGround;
378 			ScrollBar				aVScroll;
379 			SvPropLineArray			PLineArray;
380 			SvPropertyDataControl*	pPropDataControl;
381 			sal_uInt16					nRowHeight;
382 			sal_Bool					bUpdate;
383 			sal_uInt16					nTheNameSize;
384 			long					nYOffset;
385 
386 			DECL_LINK(   ScrollHdl,ScrollBar*);
387 			DECL_LINK(	 ClickHdl ,PushButton*);
388 
389 			DECL_LINK(   ModifyHdl,SvXPropEvListener*);
390 			DECL_LINK( GetFocusHdl,SvXPropEvListener*);
391 			DECL_LINK(LoseFocusHdl,SvXPropEvListener*);
392 			DECL_LINK( KeyInputHdl,SvXPropEvListener*);
393 
394 protected:
395 			void					UpdateAll();
396 			void					UpdatePosNSize();
397 			void					UpdatePlayGround();
398 			void					UpdateVScroll();
399 
400 			void					Resize();
401 
402 public:
403 									SvListBoxForProperties( Window* pParent, WinBits nWinStyle = 0 );
404 									SvListBoxForProperties( Window* pParent, const ResId& rResId );
405 
406 									~SvListBoxForProperties();
407 
408 			virtual sal_uInt16			CalcVisibleLines();
409 			virtual void			EnableUpdate();
410 			virtual void			DisableUpdate();
411 
412 			virtual void			SetController(SvPropertyDataControl *);
413 
414 			virtual void			Clear();
415 
416 			virtual sal_uInt16 			InsertEntry( const SvPropertyData&, sal_uInt16 nPos = LISTBOX_APPEND );
417 
418 			virtual void			ChangeEntry( const SvPropertyData&, sal_uInt16 nPos);
419 
420 			virtual sal_uInt16 			AppendEntry( const SvPropertyData&);
421 
422 			virtual void			SetPropertyValue( const String & rEntryName, const String & rValue );
423 
424 			virtual void			SetFirstVisibleEntry(sal_uInt16 nPos);
425 			virtual sal_uInt16			GetFirstVisibleEntry();
426 
427 			virtual void			SetSelectedEntry(sal_uInt16 nPos);
428 			virtual sal_uInt16			GetSelectedEntry();
429 };
430 
431 class SvTabPageForProperties: public TabPage
432 {
433 
434 private:
435 
436 			SvListBoxForProperties	aLbProp;
437 
438 protected:
439 
440 			virtual void			Resize();
441 
442 public:
443 			SvTabPageForProperties(Window* pParent,WinBits nWinStyle = 0 );
444 
445 			SvListBoxForProperties*   GetTheListBox();
446 };
447 
448 
449 class SvBasicPropertyDataControl: public SvPropertyDataControl
450 {
451 private:
452 
453 		sal_Bool							bCorrectness;
454 		String							aEntryName;
455 		String							aEntryProperty;
456 		String							aCorrectProperty;
457 		void*							pTheData;
458 		Link							aModifyLink;
459 		Link							aClickedLink;
460 		Link							aCommitLink;
461 		Link							aSelectLink;
462 
463 public:
464         virtual ~SvBasicPropertyDataControl();
465 
466 		virtual void					Modified(	const String& aName,
467 													const String& aVal,
468 													void* pData);		//User has modified Property
469 
470 		virtual void					Clicked(	const String& aName,
471 													const String& aVal,
472 													void* pData);		//Xtension-Button pressed
473 
474 		virtual void					Commit(		const String& aName,
475 													const String& aVal,
476 													void* pData);		//User accept changes
477 
478 		virtual void					Select(		const String& aName,
479 													void* pData);		//User select new Row
480 
481 		virtual void					LinkClicked(const String& aName,
482 													void* pData);
483 
484 		virtual void					SetIsCorrect(sal_Bool nFlag);
485 
486 		//virtual String					GetTheCorrectProperty()const;
487 		virtual void					SetTheCorrectProperty(const String& aName);
488 
489 		String							GetName() const; //Tell's the name of the Property
490 		String							GetProperty() const; //Tell's the content of the Property
491 		void*							GetData(); //Tell's the storage
492 
493 
494 		void							SetModifyHdl( const Link& rLink ) { aModifyLink = rLink; }
495 		const Link&						GetModifyHdl() const { return aModifyLink; }
496 
497 		void							SetClickedHdl( const Link& rLink ) { aClickedLink = rLink; }
498 		const Link&						GetClickedHdl() const { return aClickedLink; }
499 
500 		void							SetCommitHdl( const Link& rLink ) { aCommitLink = rLink; }
501 		const Link&						GetCommitHdl() const { return aCommitLink; }
502 
503 		void							SetSelectHdl( const Link& rLink ) { aSelectLink = rLink; }
504 		const Link&						GetSelectHdl() const { return aSelectLink; }
505 
506 };
507 
508 
509 class SvPropertyBox: public Control
510 {
511 private:
512 			SvPropertyDataControl*		pThePropDataCtr;
513 			TabControl					aTabControl;
514 
515 protected:
516 			virtual void				Resize();
517 
518 public:
519 										SvPropertyBox	( Window* pParent, WinBits nWinStyle = 0 );
520 										SvPropertyBox	( Window* pParent, const ResId& rResId );
521 
522 										~SvPropertyBox();
523 
524 			virtual sal_uInt16				CalcVisibleLines();
525 			virtual void				EnableUpdate();		// auch IDL?
526 			virtual void				DisableUpdate();	// auch IDL?
527 
528 			// AB: Hier beginnt das 'offizielle' Interface, das in IDL uebernommen werden soll
529 			virtual void				SetController(SvPropertyDataControl *);
530 
531 			virtual sal_uInt16 				AppendPage( const String & r );
532 			virtual void				SetPage( sal_uInt16 );
533 			virtual sal_uInt16 				GetCurPage();
534 			virtual void				ClearAll();
535 			virtual void				ClearTable();
536 
537 			virtual void				SetPropertyValue( const String & rEntryName, const String & rValue );
538 
539 			virtual sal_uInt16 				InsertEntry( const SvPropertyData&, sal_uInt16 nPos = LISTBOX_APPEND );
540 			virtual void				ChangeEntry( const SvPropertyData&, sal_uInt16 nPos);
541 			virtual sal_uInt16 				AppendEntry( const SvPropertyData&);
542 
543 			virtual void				SetFirstVisibleEntry(sal_uInt16 nPos);
544 			virtual sal_uInt16				GetFirstVisibleEntry();
545 
546 			virtual void				SetSelectedEntry(sal_uInt16 nPos);
547 			virtual sal_uInt16				GetSelectedEntry();
548 };
549 
550 
551 
552 /*
553 class ScPropertyDlg : public ModalDialog
554 {
555 private:
556 			SvBasicPropertyDataControl	aBaProDatCtr;
557 			OKButton					anOk;
558 			CancelButton				aCancel;
559 			sal_uInt16						nCount;
560 			sal_uInt16						nClickCount;
561 
562 			SvPropertyData				aProperty;
563 			SvPropertyBox				aPropListBox;
564 
565 			ListBox						aKindOfListBox;
566 			FixedText					aModAnswer;
567 			FixedText					aClickAnswer;
568 			FixedText					aCommitAnswer;
569 			FixedText					aSelectAnswer;
570 
571 			DECL_LINK( ModifiedHdl, ListBox*);
572 
573 			DECL_LINK( RowModifiedHdl, SvBasicPropertyDataControl*);
574 			DECL_LINK( ClickHdl		 , SvBasicPropertyDataControl*);
575 			DECL_LINK( SelectHdl	 , SvBasicPropertyDataControl*);
576 			DECL_LINK( CommitHdl	 , SvBasicPropertyDataControl*);
577 
578 public:
579 			ScPropertyDlg( Window*	pParent);
580 			~ScPropertyDlg();
581 };
582 */
583 #endif // SC_AUTOFMT_HXX
584 
585 
586