Update ooo320-m1
[ooovba.git] / svtools / inc / property.hxx
blob31c75012d41971b629c3240f9e5b422f491949aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: property.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SV_PROPERTY_HXX
32 #define SV_PROPERTY_HXX
34 #ifndef _VIRDEV_HXX //autogen
35 #include <vcl/virdev.hxx>
36 #endif
37 #ifndef SV_FIXED_HXX
38 #include <vcl/fixed.hxx>
39 #endif
40 #ifndef SV_LSTBOX_HXX
41 #include <vcl/lstbox.hxx>
42 #endif
43 #ifndef SV_GROUP_HXX
44 #include <vcl/group.hxx>
45 #endif
46 #ifndef SV_BUTTON_HXX
47 #include <vcl/button.hxx>
48 #endif
49 #ifndef SV_MOREBTN_HXX
50 #include <vcl/morebtn.hxx>
51 #endif
52 #ifndef _DIALOG_HXX //autogen
53 #include <vcl/dialog.hxx>
54 #endif
55 #include <vcl/combobox.hxx>
56 #include <vcl/field.hxx>
57 #include <svtools/svarray.hxx>
59 #define _SVSTDARR_USHORTS
60 #include <svtools/svstdarr.hxx>
61 #include <vcl/virdev.hxx>
62 #include <vcl/scrbar.hxx>
63 #include <svtools/svarray.hxx>
65 #ifndef _SVSTDARR_STRINGS
66 #define _SVSTDARR_STRINGS
67 #include <svtools/svstdarr.hxx>
68 #endif
69 #include <vcl/tabpage.hxx>
70 #include <vcl/tabctrl.hxx>
72 //------------------------------------------------------------------------
74 //========================================================================
75 enum eKindOfControl { KOC_UNDEFINED=0,KOC_LISTBOX=1, KOC_COMBOBOX=2,
76 KOC_EDIT=3,KOC_USERDEFINED=5};
78 class SvXPropertyCtrListener;
80 class SvXPropertyControl : public Control
82 public:
83 SvXPropertyControl( Window* pParent, WinBits nWinStyle = 0 );
84 SvXPropertyControl( Window* pParent, const ResId& rResId );
86 virtual void SetSvXPropertyCtrListener(SvXPropertyCtrListener*)=0;
88 virtual SvXPropertyCtrListener* GetSvXPropertyCtrListener()=0;
89 virtual void SetProperty(const String &rString)=0;
90 virtual String GetProperty()const=0;
91 virtual BOOL HasList()=0;
92 virtual void ClearList()=0;
93 virtual void InsertEntry( const String& rString,
94 USHORT nPos = LISTBOX_APPEND )=0;
96 virtual void SetCtrSize(const Size& rSize)=0;
97 virtual void SetLocked(BOOL bLocked=TRUE)=0;
99 virtual void SetMyName(const String &rString)=0;
100 virtual String GetMyName()const=0;
102 virtual void SetMyData(void*)=0;
103 virtual void* GetMyData()=0;
106 class SvXPropertyCtrListener
109 public:
110 virtual void Modified (SvXPropertyControl *pSvXPCtr)=0;
111 virtual void GetFocus (SvXPropertyControl *pSvXPCtr)=0;
112 virtual void LoseFocus(SvXPropertyControl *pSvXPCtr)=0;
113 virtual void KeyInput (SvXPropertyControl *pSvXPCtr ,const KeyCode&)=0;
117 class SvXPropertyEdit : public SvXPropertyControl
119 private:
121 String aName;
122 SvXPropertyCtrListener* pListener;
123 Edit aEdit;
124 void* pData;
126 DECL_LINK(ModifiedHdl,Edit*);
127 DECL_LINK(GetFocusHdl,Edit*);
128 DECL_LINK(LoseFocusHdl,Edit*);
130 public:
131 SvXPropertyEdit( Window* pParent, WinBits nWinStyle = 0 );
132 SvXPropertyEdit( Window* pParent, const ResId& rResId );
134 virtual void SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
136 virtual SvXPropertyCtrListener* GetSvXPropertyCtrListener();
138 virtual void SetProperty(const String &rString);
139 virtual String GetProperty()const;
141 virtual BOOL HasList();
142 virtual void ClearList();
143 virtual void InsertEntry( const String& rString,
144 USHORT nPos = LISTBOX_APPEND );
146 virtual void SetCtrSize(const Size& rSize);
147 virtual void SetLocked(BOOL bLocked=TRUE);
149 virtual void SetMyName(const String &rString);
150 virtual String GetMyName()const;
152 virtual void SetMyData(void*);
153 virtual void* GetMyData();
157 class SvXPropertyListBox : public SvXPropertyControl
159 private:
161 String aName;
162 SvXPropertyCtrListener* pListener;
163 ListBox aListBox;
164 void* pData;
166 DECL_LINK(ModifiedHdl,ListBox*);
167 DECL_LINK(GetFocusHdl,ListBox*);
168 DECL_LINK(LoseFocusHdl,ListBox*);
171 public:
172 SvXPropertyListBox( Window* pParent, WinBits nWinStyle = 0 );
173 SvXPropertyListBox( Window* pParent, const ResId& rResId );
175 virtual void SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
177 virtual SvXPropertyCtrListener* GetSvXPropertyCtrListener();
179 ListBox* GetListBox();
181 virtual void SetProperty(const String &rString);
182 virtual String GetProperty()const;
184 virtual BOOL HasList();
185 virtual void ClearList();
186 virtual void InsertEntry( const String& rString,
187 USHORT nPos = LISTBOX_APPEND );
189 virtual void SetCtrSize(const Size& rSize);
190 virtual void SetLocked(BOOL bLocked=TRUE);
192 virtual void SetMyName(const String &rString);
193 virtual String GetMyName()const;
195 virtual void SetMyData(void*);
196 virtual void* GetMyData();
199 class SvXPropertyComboBox : public SvXPropertyControl
201 private:
203 String aName;
204 SvXPropertyCtrListener* pListener;
205 ComboBox aComboBox;
206 void* pData;
208 DECL_LINK(ModifiedHdl,ComboBox*);
209 DECL_LINK(GetFocusHdl,ComboBox*);
210 DECL_LINK(LoseFocusHdl,ComboBox*);
213 public:
214 SvXPropertyComboBox( Window* pParent, WinBits nWinStyle = 0 );
215 SvXPropertyComboBox( Window* pParent, const ResId& rResId );
217 virtual void SetSvXPropertyCtrListener(SvXPropertyCtrListener*);
219 virtual SvXPropertyCtrListener* GetSvXPropertyCtrListener();
221 ComboBox* GetComboBox();
223 virtual void SetProperty(const String &rString);
224 virtual String GetProperty()const;
226 virtual BOOL HasList();
227 virtual void ClearList();
228 virtual void InsertEntry( const String& rString,
229 USHORT nPos = LISTBOX_APPEND );
231 virtual void SetCtrSize(const Size& rSize);
232 virtual void SetLocked(BOOL bLocked=TRUE);
234 virtual void SetMyName(const String &rString);
235 virtual String GetMyName()const;
237 virtual void SetMyData(void*);
238 virtual void* GetMyData();
243 class SvPropertyLine : public Control
245 private:
246 FixedText aName;
247 USHORT nNameWidth;
248 BOOL bNeedsRepaint;
249 SvXPropertyControl* pSvXPropertyControl;
251 PushButton aXButton;
252 BOOL bIsLocked;
253 BOOL bHasXButton;
254 BOOL bIsHyperlink;
255 eKindOfControl eKindOfCtr;
257 protected:
258 virtual void Resize();
260 public:
261 SvPropertyLine( Window* pParent,
262 WinBits nWinStyle = 0 );
263 SvPropertyLine( Window* pParent,
264 const ResId& rResId );
266 BOOL NeedsRepaint();
267 void SetNeedsRepaint(BOOL bFlag);
268 void SetSvXPropertyControl(SvXPropertyControl*);
269 SvXPropertyControl* GetSvXPropertyControl();
271 void SetKindOfControl(eKindOfControl);
272 eKindOfControl GetKindOfControl();
274 void SetName(const String& rString );
275 String GetName() const;
276 void SetNameWidth(USHORT);
278 void ShowXButton();
279 void HideXButton();
280 BOOL IsVisibleXButton();
281 void ShowAsHyperLink(BOOL nFlag=TRUE);
282 BOOL IsShownAsHyperlink();
284 void Locked(BOOL nFlag=TRUE);
285 BOOL IsLineLocked();
287 void SetClickHdl(const Link&);
292 class SvPropertyData
294 public:
295 eKindOfControl eKind;
296 String aName;
297 String aValue;
298 SvStrings theValues; // ???
300 BOOL bHasVisibleXButton;
301 BOOL bIsHyperLink;
302 BOOL bIsLocked;
303 void* pDataPtr;
304 SvXPropertyControl* pControl;
307 class SvPropertyDataObjectControl
311 class SvPropertyDataControl
313 public:
314 virtual void Modified( const String& aName,
315 const String& aVal,
316 void* pData)=0;
318 virtual void Clicked( const String& aName,
319 const String& aVal,
320 void* pData)=0;
322 virtual void Commit( const String& aName,
323 const String& aVal,
324 void* pData)=0;
326 virtual void Select( const String& aName,
327 void* pData)=0;
329 virtual void LinkClicked(const String& aName,
330 void* pData)=0;
333 class SvXPropEvListener: public SvXPropertyCtrListener
335 Link aModifyLink;
336 Link aGetFocusLink;
337 Link aLoseFocusLink;
338 Link aKeyInputLink;
339 String aModifiedResult;
341 SvXPropertyControl * pTheActiveControl;
342 KeyCode aKeyCode;
344 public:
345 SvXPropEvListener();
346 virtual ~SvXPropEvListener();
348 virtual void Modified (SvXPropertyControl *pSvXPCtr);
349 virtual void GetFocus (SvXPropertyControl *pSvXPCtr);
350 virtual void LoseFocus(SvXPropertyControl *pSvXPCtr);
351 virtual void KeyInput(SvXPropertyControl *pSvXPCtr ,const KeyCode&);
353 SvXPropertyControl * GetPropertyControl();
354 KeyCode GetKeyCode() const;
356 void SetModifyHdl( const Link& rLink ) { aModifyLink = rLink; }
357 const Link& GetModifyHdl() const { return aModifyLink; }
359 void SetGetFocusHdl( const Link& rLink ) { aGetFocusLink = rLink; }
360 const Link& GetGetFocusHdl() const { return aGetFocusLink; }
362 void SetLoseFocusHdl( const Link& rLink ) { aLoseFocusLink = rLink; }
363 const Link& GetLoseFocusHdl() const { return aLoseFocusLink; }
365 void SetKeyInputHdl( const Link& rLink ) { aKeyInputLink = rLink; }
366 const Link& GetKeyInputHdl() const { return aKeyInputLink; }
371 typedef SvPropertyLine * SvPropertyLinePtr;
373 SV_DECL_PTRARR(SvPropLineArray,SvPropertyLinePtr,1,1)
375 class SvListBoxForProperties: public Control
377 private:
379 SvXPropEvListener aListener;
380 Window aPlayGround;
381 ScrollBar aVScroll;
382 SvPropLineArray PLineArray;
383 SvPropertyDataControl* pPropDataControl;
384 USHORT nRowHeight;
385 BOOL bUpdate;
386 USHORT nTheNameSize;
387 long nYOffset;
389 DECL_LINK( ScrollHdl,ScrollBar*);
390 DECL_LINK( ClickHdl ,PushButton*);
392 DECL_LINK( ModifyHdl,SvXPropEvListener*);
393 DECL_LINK( GetFocusHdl,SvXPropEvListener*);
394 DECL_LINK(LoseFocusHdl,SvXPropEvListener*);
395 DECL_LINK( KeyInputHdl,SvXPropEvListener*);
397 protected:
398 void UpdateAll();
399 void UpdatePosNSize();
400 void UpdatePlayGround();
401 void UpdateVScroll();
403 void Resize();
405 public:
406 SvListBoxForProperties( Window* pParent, WinBits nWinStyle = 0 );
407 SvListBoxForProperties( Window* pParent, const ResId& rResId );
409 ~SvListBoxForProperties();
411 virtual USHORT CalcVisibleLines();
412 virtual void EnableUpdate();
413 virtual void DisableUpdate();
415 virtual void SetController(SvPropertyDataControl *);
417 virtual void Clear();
419 virtual USHORT InsertEntry( const SvPropertyData&, USHORT nPos = LISTBOX_APPEND );
421 virtual void ChangeEntry( const SvPropertyData&, USHORT nPos);
423 virtual USHORT AppendEntry( const SvPropertyData&);
425 virtual void SetPropertyValue( const String & rEntryName, const String & rValue );
427 virtual void SetFirstVisibleEntry(USHORT nPos);
428 virtual USHORT GetFirstVisibleEntry();
430 virtual void SetSelectedEntry(USHORT nPos);
431 virtual USHORT GetSelectedEntry();
434 class SvTabPageForProperties: public TabPage
437 private:
439 SvListBoxForProperties aLbProp;
441 protected:
443 virtual void Resize();
445 public:
446 SvTabPageForProperties(Window* pParent,WinBits nWinStyle = 0 );
448 SvListBoxForProperties* GetTheListBox();
452 class SvBasicPropertyDataControl: public SvPropertyDataControl
454 private:
456 BOOL bCorrectness;
457 String aEntryName;
458 String aEntryProperty;
459 String aCorrectProperty;
460 void* pTheData;
461 Link aModifyLink;
462 Link aClickedLink;
463 Link aCommitLink;
464 Link aSelectLink;
466 public:
467 virtual ~SvBasicPropertyDataControl();
469 virtual void Modified( const String& aName,
470 const String& aVal,
471 void* pData); //User has modified Property
473 virtual void Clicked( const String& aName,
474 const String& aVal,
475 void* pData); //Xtension-Button pressed
477 virtual void Commit( const String& aName,
478 const String& aVal,
479 void* pData); //User accept changes
481 virtual void Select( const String& aName,
482 void* pData); //User select new Row
484 virtual void LinkClicked(const String& aName,
485 void* pData);
487 virtual void SetIsCorrect(BOOL nFlag);
489 //virtual String GetTheCorrectProperty()const;
490 virtual void SetTheCorrectProperty(const String& aName);
492 String GetName() const; //Tell's the name of the Property
493 String GetProperty() const; //Tell's the content of the Property
494 void* GetData(); //Tell's the storage
497 void SetModifyHdl( const Link& rLink ) { aModifyLink = rLink; }
498 const Link& GetModifyHdl() const { return aModifyLink; }
500 void SetClickedHdl( const Link& rLink ) { aClickedLink = rLink; }
501 const Link& GetClickedHdl() const { return aClickedLink; }
503 void SetCommitHdl( const Link& rLink ) { aCommitLink = rLink; }
504 const Link& GetCommitHdl() const { return aCommitLink; }
506 void SetSelectHdl( const Link& rLink ) { aSelectLink = rLink; }
507 const Link& GetSelectHdl() const { return aSelectLink; }
512 class SvPropertyBox: public Control
514 private:
515 SvPropertyDataControl* pThePropDataCtr;
516 TabControl aTabControl;
518 protected:
519 virtual void Resize();
521 public:
522 SvPropertyBox ( Window* pParent, WinBits nWinStyle = 0 );
523 SvPropertyBox ( Window* pParent, const ResId& rResId );
525 ~SvPropertyBox();
527 virtual USHORT CalcVisibleLines();
528 virtual void EnableUpdate(); // auch IDL?
529 virtual void DisableUpdate(); // auch IDL?
531 // AB: Hier beginnt das 'offizielle' Interface, das in IDL uebernommen werden soll
532 virtual void SetController(SvPropertyDataControl *);
534 virtual USHORT AppendPage( const String & r );
535 virtual void SetPage( USHORT );
536 virtual USHORT GetCurPage();
537 virtual void ClearAll();
538 virtual void ClearTable();
540 virtual void SetPropertyValue( const String & rEntryName, const String & rValue );
542 virtual USHORT InsertEntry( const SvPropertyData&, USHORT nPos = LISTBOX_APPEND );
543 virtual void ChangeEntry( const SvPropertyData&, USHORT nPos);
544 virtual USHORT AppendEntry( const SvPropertyData&);
546 virtual void SetFirstVisibleEntry(USHORT nPos);
547 virtual USHORT GetFirstVisibleEntry();
549 virtual void SetSelectedEntry(USHORT nPos);
550 virtual USHORT GetSelectedEntry();
556 class ScPropertyDlg : public ModalDialog
558 private:
559 SvBasicPropertyDataControl aBaProDatCtr;
560 OKButton anOk;
561 CancelButton aCancel;
562 USHORT nCount;
563 USHORT nClickCount;
565 SvPropertyData aProperty;
566 SvPropertyBox aPropListBox;
568 ListBox aKindOfListBox;
569 FixedText aModAnswer;
570 FixedText aClickAnswer;
571 FixedText aCommitAnswer;
572 FixedText aSelectAnswer;
574 DECL_LINK( ModifiedHdl, ListBox*);
576 DECL_LINK( RowModifiedHdl, SvBasicPropertyDataControl*);
577 DECL_LINK( ClickHdl , SvBasicPropertyDataControl*);
578 DECL_LINK( SelectHdl , SvBasicPropertyDataControl*);
579 DECL_LINK( CommitHdl , SvBasicPropertyDataControl*);
581 public:
582 ScPropertyDlg( Window* pParent);
583 ~ScPropertyDlg();
586 #endif // SC_AUTOFMT_HXX