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