1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: property.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
38 //------------------------------------------------------------------
40 //#include "Svitems.hxx"
42 #include "property.hxx"
44 #include "property.hrc"
45 #include "Scresid.hxx"
47 #define FRAME_OFFSET 4
50 SvXPropertyControl::SvXPropertyControl( Window
* pParent
, WinBits nWinStyle
)
51 : Control(pParent
,nWinStyle
)
55 SvXPropertyControl::SvXPropertyControl( Window
* pParent
, const ResId
& rResId
)
56 : Control(pParent
,rResId
)
60 //------------------------------------------------------------------
62 SvXPropertyEdit::SvXPropertyEdit( Window
* pParent
, WinBits nWinStyle
)
63 : SvXPropertyControl(pParent
,nWinStyle
),
64 aEdit(this,WB_BORDER
| WB_TABSTOP
)
68 LINK( this, SvXPropertyEdit
, ModifiedHdl
));
70 LINK( this, SvXPropertyEdit
, GetFocusHdl
));
71 aEdit
.SetLoseFocusHdl(
72 LINK( this, SvXPropertyEdit
, LoseFocusHdl
));
77 SvXPropertyEdit::SvXPropertyEdit( Window
* pParent
, const ResId
& rResId
)
78 : SvXPropertyControl(pParent
,rResId
),
79 aEdit(this,WB_BORDER
| WB_TABSTOP
)
83 LINK( this, SvXPropertyEdit
, ModifiedHdl
));
85 LINK( this, SvXPropertyEdit
, GetFocusHdl
));
86 aEdit
.SetLoseFocusHdl(
87 LINK( this, SvXPropertyEdit
, LoseFocusHdl
));
89 Size aSize
=GetSizePixel();
94 void SvXPropertyEdit::SetSvXPropertyCtrListener(SvXPropertyCtrListener
* pCtrListener
)
96 pListener
=pCtrListener
;
99 SvXPropertyCtrListener
* SvXPropertyEdit::GetSvXPropertyCtrListener()
105 void SvXPropertyEdit::SetCtrSize(const Size
& rSize
)
108 Size aSize
=GetOutputSizePixel();
110 aEdit
.SetPosPixel(aPos
);
111 aEdit
.SetSizePixel(aSize
);
114 void SvXPropertyEdit::SetLocked(BOOL bLocked
)
122 void SvXPropertyEdit::SetProperty(const String
&rString
)
124 aEdit
.SetText(rString
);
127 String
SvXPropertyEdit::GetProperty() const
129 return aEdit
.GetText();
132 BOOL
SvXPropertyEdit::HasList()
138 void SvXPropertyEdit::ClearList()
142 void SvXPropertyEdit::InsertEntry( const String
&,USHORT
)
147 void SvXPropertyEdit::SetMyName(const String
&rString
)
152 String
SvXPropertyEdit::GetMyName()const
157 void SvXPropertyEdit::SetMyData(void* pDat
)
162 void* SvXPropertyEdit::GetMyData()
168 IMPL_LINK( SvXPropertyEdit
, ModifiedHdl
, Edit
*, EMPTYARG
)
171 pListener
->Modified(this);
175 IMPL_LINK( SvXPropertyEdit
, GetFocusHdl
, Edit
*, EMPTYARG
)
178 pListener
->GetFocus(this);
182 IMPL_LINK( SvXPropertyEdit
, LoseFocusHdl
, Edit
*, EMPTYARG
)
185 pListener
->LoseFocus(this);
189 //------------------------------------------------------------------
191 SvXPropertyListBox::SvXPropertyListBox( Window
* pParent
, WinBits nWinStyle
)
192 : SvXPropertyControl(pParent
,nWinStyle
),
193 aListBox(this,WB_BORDER
| WB_DROPDOWN
| WB_TABSTOP
)
196 aListBox
.SetSelectHdl(
197 LINK( this, SvXPropertyListBox
, ModifiedHdl
));
198 aListBox
.SetGetFocusHdl(
199 LINK( this, SvXPropertyListBox
, GetFocusHdl
));
200 aListBox
.SetLoseFocusHdl(
201 LINK( this, SvXPropertyListBox
, LoseFocusHdl
));
205 SvXPropertyListBox::SvXPropertyListBox( Window
* pParent
, const ResId
& rResId
)
206 : SvXPropertyControl(pParent
,rResId
),
207 aListBox(this,WB_BORDER
| WB_DROPDOWN
| WB_TABSTOP
)
210 aListBox
.SetSelectHdl(
211 LINK( this, SvXPropertyListBox
, ModifiedHdl
));
212 aListBox
.SetGetFocusHdl(
213 LINK( this, SvXPropertyListBox
, GetFocusHdl
));
214 aListBox
.SetLoseFocusHdl(
215 LINK( this, SvXPropertyListBox
, LoseFocusHdl
));
217 Size aSize
=GetSizePixel();
222 void SvXPropertyListBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener
* pCtrListener
)
224 pListener
=pCtrListener
;
227 SvXPropertyCtrListener
* SvXPropertyListBox::GetSvXPropertyCtrListener()
233 void SvXPropertyListBox::SetCtrSize(const Size
& rSize
)
236 Size aSize
=GetOutputSizePixel();
238 aListBox
.SetPosPixel(aPos
);
239 aListBox
.SetSizePixel(aSize
);
242 void SvXPropertyListBox::SetLocked(BOOL bLocked
)
250 void SvXPropertyListBox::SetProperty(const String
&rString
)
252 aListBox
.SelectEntry(rString
);
255 String
SvXPropertyListBox::GetProperty()const
257 return aListBox
.GetSelectEntry();
260 BOOL
SvXPropertyListBox::HasList()
266 void SvXPropertyListBox::ClearList()
271 void SvXPropertyListBox::InsertEntry( const String
& rString
,USHORT nPos
)
273 aListBox
.InsertEntry(rString
,nPos
);
276 void SvXPropertyListBox::SetMyName(const String
&rString
)
281 String
SvXPropertyListBox::GetMyName()const
286 void SvXPropertyListBox::SetMyData(void* pDat
)
291 void* SvXPropertyListBox::GetMyData()
296 IMPL_LINK( SvXPropertyListBox
, ModifiedHdl
, ListBox
*, EMPTYARG
)
299 pListener
->Modified(this);
303 IMPL_LINK( SvXPropertyListBox
, GetFocusHdl
, ListBox
*, EMPTYARG
)
306 pListener
->GetFocus(this);
310 IMPL_LINK( SvXPropertyListBox
, LoseFocusHdl
, ListBox
*, EMPTYARG
)
313 pListener
->LoseFocus(this);
317 //------------------------------------------------------------------
320 SvXPropertyComboBox::SvXPropertyComboBox( Window
* pParent
, WinBits nWinStyle
)
321 : SvXPropertyControl(pParent
,nWinStyle
),
322 aComboBox(this,WB_BORDER
| WB_DROPDOWN
| WB_TABSTOP
)
325 aComboBox
.SetModifyHdl(
326 LINK( this, SvXPropertyComboBox
, ModifiedHdl
));
327 aComboBox
.SetGetFocusHdl(
328 LINK( this, SvXPropertyComboBox
, GetFocusHdl
));
329 aComboBox
.SetLoseFocusHdl(
330 LINK( this, SvXPropertyComboBox
, LoseFocusHdl
));
334 SvXPropertyComboBox::SvXPropertyComboBox( Window
* pParent
, const ResId
& rResId
)
335 : SvXPropertyControl(pParent
,rResId
),
336 aComboBox(this,WB_BORDER
| WB_DROPDOWN
| WB_TABSTOP
)
339 aComboBox
.SetModifyHdl(
340 LINK( this, SvXPropertyComboBox
, ModifiedHdl
));
341 aComboBox
.SetGetFocusHdl(
342 LINK( this, SvXPropertyComboBox
, GetFocusHdl
));
343 aComboBox
.SetLoseFocusHdl(
344 LINK( this, SvXPropertyComboBox
, LoseFocusHdl
));
346 Size aSize
=GetSizePixel();
351 void SvXPropertyComboBox::SetLocked(BOOL bLocked
)
359 void SvXPropertyComboBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener
* pCtrListener
)
361 pListener
=pCtrListener
;
364 SvXPropertyCtrListener
* SvXPropertyComboBox::GetSvXPropertyCtrListener()
370 void SvXPropertyComboBox::SetCtrSize(const Size
& rSize
)
373 Size aSize
=GetOutputSizePixel();
375 aComboBox
.SetPosPixel(aPos
);
376 aComboBox
.SetSizePixel(aSize
);
380 void SvXPropertyComboBox::SetProperty(const String
&rString
)
382 aComboBox
.SetText(rString
);
385 String
SvXPropertyComboBox::GetProperty() const
387 return aComboBox
.GetText();
390 BOOL
SvXPropertyComboBox::HasList()
395 void SvXPropertyComboBox::ClearList()
400 void SvXPropertyComboBox::InsertEntry( const String
& rString
,USHORT nPos
)
402 aComboBox
.InsertEntry(rString
,nPos
);
405 void SvXPropertyComboBox::SetMyName(const String
&rString
)
410 String
SvXPropertyComboBox::GetMyName()const
415 void SvXPropertyComboBox::SetMyData(void* pDat
)
420 void* SvXPropertyComboBox::GetMyData()
425 IMPL_LINK( SvXPropertyComboBox
, ModifiedHdl
, ComboBox
*, EMPTYARG
)
428 pListener
->Modified(this);
432 IMPL_LINK( SvXPropertyComboBox
, GetFocusHdl
, ComboBox
*, EMPTYARG
)
435 pListener
->GetFocus(this);
439 IMPL_LINK( SvXPropertyComboBox
, LoseFocusHdl
, ComboBox
*, EMPTYARG
)
442 pListener
->LoseFocus(this);
445 //------------------------------------------------------------------
447 SvPropertyLine::SvPropertyLine( Window
* pParent
,WinBits nWinStyle
)
448 : Control(pParent
,nWinStyle
),
449 aName(this,WB_BORDER
),
450 pSvXPropertyControl(NULL
),
451 aXButton(this,WB_BORDER
),
455 bNeedsRepaint
= TRUE
;
457 aXButton
.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
460 eKindOfCtr
= KOC_UNDEFINED
;
461 Wallpaper aWall
= GetBackground();
462 aWall
.SetColor( Color( COL_TRANSPARENT
) );
463 SetBackground( aWall
);
466 SvPropertyLine::SvPropertyLine( Window
* pParent
,const ResId
& rResId
)
467 : Control(pParent
,rResId
),
468 aName (this,WB_BORDER
),
469 pSvXPropertyControl(NULL
),
470 aXButton (this,WB_BORDER
),
474 bNeedsRepaint
= TRUE
;
476 eKindOfCtr
= KOC_UNDEFINED
;
477 aXButton
.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
480 Wallpaper aWall
= GetBackground();
481 aWall
.SetColor( Color( COL_TRANSPARENT
) );
482 SetBackground( aWall
);
486 void SvPropertyLine::SetSvXPropertyControl(SvXPropertyControl
* pXControl
)
488 pSvXPropertyControl
=pXControl
;
489 pSvXPropertyControl
->Show();
493 SvXPropertyControl
* SvPropertyLine::GetSvXPropertyControl()
495 return pSvXPropertyControl
;
498 void SvPropertyLine::Resize()
500 Size aSize
=GetOutputSizePixel();
503 aSize
.Width()=nNameWidth
;
504 a2Size
.Width()-=nNameWidth
;
507 aName
.SetPosPixel(aPos
);
508 aName
.SetSizePixel(aSize
);
510 USHORT nXButtonWidth
=0;
514 nXButtonWidth
=(USHORT
)aSize
.Height();
516 a2Size
.Width()=a2Size
.Width()-nXButtonWidth
;
518 aPos
.X()+=aSize
.Width();
520 if(pSvXPropertyControl
!=NULL
)
522 pSvXPropertyControl
->SetPosPixel(aPos
);
523 pSvXPropertyControl
->SetCtrSize(a2Size
);
528 aPos
.X()=GetOutputSizePixel().Width()
530 aSize
.Width()=nXButtonWidth
;
531 aXButton
.SetSizePixel(aSize
);
532 aXButton
.SetPosPixel(aPos
);
536 void SvPropertyLine::SetNeedsRepaint(BOOL bFlag
)
541 BOOL
SvPropertyLine::NeedsRepaint()
543 return bNeedsRepaint
;
546 void SvPropertyLine::SetName(const String
& rString
)
548 aName
.SetText(rString
);
552 String
SvPropertyLine::GetName() const
554 return aName
.GetText();
557 void SvPropertyLine::SetKindOfControl(eKindOfControl eKOC
)
562 eKindOfControl
SvPropertyLine::GetKindOfControl()
567 void SvPropertyLine::ShowXButton()
573 void SvPropertyLine::HideXButton()
579 BOOL
SvPropertyLine::IsVisibleXButton()
584 void SvPropertyLine::ShowAsHyperLink(BOOL nFlag
)
589 Font aFont
=GetFont();
590 aFont
.SetUnderline(UNDERLINE_SINGLE
);
591 aFont
.SetColor(Color(COL_BLUE
));
592 aName
.SetFont(aFont
);
596 Font aFont
=GetFont();
597 aName
.SetFont(aFont
);
601 BOOL
SvPropertyLine::IsShownAsHyperlink()
606 void SvPropertyLine::Locked(BOOL nFlag
)
609 if(pSvXPropertyControl
!=NULL
)
610 pSvXPropertyControl
->SetLocked(nFlag
);
613 BOOL
SvPropertyLine::IsLineLocked()
618 void SvPropertyLine::SetNameWidth(USHORT nWidth
)
624 void SvPropertyLine::SetClickHdl(const Link
& rLink
)
626 aXButton
.SetClickHdl(rLink
);
629 //----------------------------------------------------------
631 SvXPropEvListener::SvXPropEvListener()
633 pTheActiveControl
=NULL
;
636 SvXPropEvListener::~SvXPropEvListener()
640 void SvXPropEvListener::Modified (SvXPropertyControl
*pSvXPCtr
)
642 pTheActiveControl
=pSvXPCtr
;
643 aModifyLink
.Call(this);
646 void SvXPropEvListener::GetFocus (SvXPropertyControl
*pSvXPCtr
)
648 pTheActiveControl
=pSvXPCtr
;
649 aGetFocusLink
.Call(this);
652 void SvXPropEvListener::LoseFocus (SvXPropertyControl
*pSvXPCtr
)
654 pTheActiveControl
=pSvXPCtr
;
655 aLoseFocusLink
.Call(this);
658 void SvXPropEvListener::KeyInput (SvXPropertyControl
*pSvXPCtr
,const KeyCode
& theKeyCode
)
660 pTheActiveControl
=pSvXPCtr
;
662 aKeyInputLink
.Call(this);
665 SvXPropertyControl
* SvXPropEvListener::GetPropertyControl()
667 return pTheActiveControl
;
670 KeyCode
SvXPropEvListener::GetKeyCode() const
675 //------------------------------------------------------------------
677 SvListBoxForProperties::SvListBoxForProperties( Window
* pParent
, WinBits nWinStyle
)
678 : Control(pParent
,nWinStyle
),
679 aPlayGround(this,WB_DIALOGCONTROL
),
680 aVScroll(this,WB_VSCROLL
|WB_REPEAT
|WB_DRAG
),
681 pPropDataControl(NULL
)
684 aListener
.SetModifyHdl (LINK( this, SvListBoxForProperties
, ModifyHdl
));
685 aListener
.SetGetFocusHdl (LINK( this, SvListBoxForProperties
, GetFocusHdl
));
686 aListener
.SetLoseFocusHdl(LINK( this, SvListBoxForProperties
,LoseFocusHdl
));
687 aListener
.SetKeyInputHdl (LINK( this, SvListBoxForProperties
, KeyInputHdl
));
691 ListBox
aListBox(this,WB_DROPDOWN
);
692 aListBox
.SetPosSizePixel(Point(0,0),Size(100,100));
693 nRowHeight
=(USHORT
)aListBox
.GetSizePixel().Height();
694 Wallpaper aWall
= aPlayGround
.GetBackground();
695 aWall
.SetColor( Color( COL_TRANSPARENT
) );
696 aPlayGround
.SetBackground( aWall
);
699 aVScroll
.SetScrollHdl(
700 LINK( this, SvListBoxForProperties
, ScrollHdl
));
705 SvListBoxForProperties::SvListBoxForProperties( Window
* pParent
, const ResId
& rResId
)
706 : Control(pParent
,rResId
),
708 aVScroll(this,WB_VSCROLL
|WB_REPEAT
|WB_DRAG
),
709 pPropDataControl(NULL
)
713 ListBox
aListBox(this,WB_DROPDOWN
);
714 aListBox
.SetPosSizePixel(Point(0,0),Size(100,100));
715 nRowHeight
=(USHORT
)aListBox
.GetSizePixel().Height();
716 Wallpaper aWall
= aPlayGround
.GetBackground();
717 aWall
.SetColor( Color( COL_TRANSPARENT
) );
718 aPlayGround
.SetBackground( aWall
);
721 aVScroll
.SetScrollHdl( LINK( this, SvListBoxForProperties
, ScrollHdl
) );
726 SvListBoxForProperties::~SvListBoxForProperties()
731 void SvListBoxForProperties::Clear()
733 for(USHORT i
=0;i
<PLineArray
.Count();i
++)
735 SvPropertyLine
* pPropLine
=PLineArray
[i
];
737 switch(pPropLine
->GetKindOfControl())
741 case KOC_EDIT
: delete pPropLine
->GetSvXPropertyControl();
748 PLineArray
.Remove(0,PLineArray
.Count());
752 void SvListBoxForProperties::Resize()
754 Size aSize
=GetOutputSizePixel();
758 if(aVScroll
.IsVisible())
761 aVScrollSize
=aVScroll
.GetSizePixel();
762 aVScrollSize
.Height()=aSize
.Height();
763 a2Size
.Width()-=aVScrollSize
.Width();
764 aPos
.X()=a2Size
.Width();
765 aVScroll
.SetPosPixel(aPos
);
766 aVScroll
.SetSizePixel(aVScrollSize
);
769 aPlayGround
.SetPosPixel(Point(0,0));
770 aPlayGround
.SetSizePixel(a2Size
);
774 void SvListBoxForProperties::SetController( SvPropertyDataControl
*pPDC
)
776 pPropDataControl
=pPDC
;
779 USHORT
SvListBoxForProperties::CalcVisibleLines()
781 Size aSize
=aPlayGround
.GetOutputSizePixel();
784 nResult
=(USHORT
) aSize
.Height()/nRowHeight
;
789 void SvListBoxForProperties::UpdateVScroll()
791 USHORT nLines
=CalcVisibleLines();
792 aVScroll
.SetPageSize(nLines
-1);
793 aVScroll
.SetVisibleSize(nLines
-1);
794 aVScroll
.SetRange(Range(0,PLineArray
.Count()-1));
795 if(PLineArray
.Count()<=nLines
)
801 BOOL bFlag
=aVScroll
.IsVisible();
809 void SvListBoxForProperties::UpdatePosNSize()
811 Point
aPos(0,nYOffset
);
813 for(USHORT i
=0; i
<PLineArray
.Count();i
++)
815 if((PLineArray
[i
])->NeedsRepaint())
817 (PLineArray
[i
])->SetPosPixel(aPos
);
818 Size aSize
=aPlayGround
.GetOutputSizePixel();
819 aSize
.Height()=nRowHeight
;
820 (PLineArray
[i
])->SetSizePixel(aSize
);
821 (PLineArray
[i
])->SetNameWidth(nTheNameSize
+2*FRAME_OFFSET
);
822 (PLineArray
[i
])->Invalidate();
823 (PLineArray
[i
])->Update();
824 (PLineArray
[i
])->Show();
825 (PLineArray
[i
])->SetNeedsRepaint(FALSE
);
829 if((PLineArray
[i
])->IsVisible())
831 Size aSize
=aPlayGround
.GetOutputSizePixel();
832 aSize
.Height()=nRowHeight
;
833 (PLineArray
[i
])->SetSizePixel(aSize
);
834 (PLineArray
[i
])->SetNameWidth(nTheNameSize
+2*FRAME_OFFSET
);
835 (PLineArray
[i
])->Invalidate();
839 aPos
.Y()+=nRowHeight
;
841 aPlayGround
.Invalidate();
842 aPlayGround
.Update();
845 void SvListBoxForProperties::UpdatePlayGround()
848 long nThumbPos
=aVScroll
.GetThumbPos();
849 long nLines
=aVScroll
.GetPageSize();
850 long nDelta
=aVScroll
.GetDelta();
853 Size aSize
=aPlayGround
.GetOutputSizePixel();
855 aPEnd
.X()=aSize
.Width();
859 nStart
=(USHORT
)(nThumbPos
+nLines
+1-nDelta
);
860 nEnd
=(USHORT
)(nThumbPos
+nLines
);
861 aPos
.Y()=(nLines
+1-nDelta
)*nRowHeight
;
865 nStart
=(USHORT
)nThumbPos
;
866 nEnd
=(USHORT
)(nThumbPos
-nDelta
);
867 aPEnd
.Y()=(nThumbPos
-nDelta
)*nRowHeight
;;
870 aSize
.Height()=nRowHeight
;
872 nDelta
=-nDelta
*nRowHeight
;
874 aPlayGround
.Scroll(0,nDelta
,SCROLL_CHILDREN
);
876 for(USHORT i
=nStart
; i
<=nEnd
;i
++)
878 (PLineArray
[i
])->SetPosSizePixel(aPos
,aSize
);
879 (PLineArray
[i
])->SetNameWidth(nTheNameSize
+2*FRAME_OFFSET
);
880 (PLineArray
[i
])->Show();
881 aPos
.Y()+=nRowHeight
;
883 aPlayGround
.Update();
886 void SvListBoxForProperties::UpdateAll()
893 void SvListBoxForProperties::DisableUpdate()
898 void SvListBoxForProperties::EnableUpdate()
904 void SvListBoxForProperties::SetPropertyValue( const String
& rEntryName
, const String
& rValue
)
906 USHORT i
, iEnd
= PLineArray
.Count();
907 for( i
= 0 ; i
< iEnd
; i
++ )
909 SvPropertyLine
* pPropLine
= PLineArray
[ i
];
910 SvXPropertyControl
* pSvXPCtr
=pPropLine
->GetSvXPropertyControl();
911 if( pSvXPCtr
&& pSvXPCtr
->GetMyName() == rEntryName
)
913 pSvXPCtr
->SetProperty( rValue
);
918 USHORT
SvListBoxForProperties::AppendEntry( const SvPropertyData
& aPropData
)
920 return InsertEntry(aPropData
);
923 USHORT
SvListBoxForProperties::InsertEntry( const SvPropertyData
& aPropData
, USHORT nPos
)
926 SvPropertyLine
* pPropLine
=new SvPropertyLine(&aPlayGround
,WB_TABSTOP
| WB_DIALOGCONTROL
);
928 if(nPos
==LISTBOX_APPEND
)
930 nInsPos
=PLineArray
.Count();
931 PLineArray
.Insert(pPropLine
,nInsPos
);
935 PLineArray
.Insert(pPropLine
,nPos
);
937 pPropLine
->SetNameWidth(nTheNameSize
);
940 ChangeEntry(aPropData
,nInsPos
);
944 void SvListBoxForProperties::ChangeEntry( const SvPropertyData
& aPropData
, USHORT nPos
)
946 if(nPos
<PLineArray
.Count())
948 SvPropertyLine
* pPropLine
=PLineArray
[nPos
];
950 switch(pPropLine
->GetKindOfControl())
954 case KOC_EDIT
: delete pPropLine
->GetSvXPropertyControl();
960 switch(aPropData
.eKind
)
963 pPropLine
->SetSvXPropertyControl(
964 new SvXPropertyComboBox(pPropLine
,WB_TABSTOP
));
965 pPropLine
->SetKindOfControl(aPropData
.eKind
);
968 pPropLine
->SetSvXPropertyControl(
969 new SvXPropertyComboBox(pPropLine
,WB_TABSTOP
));
970 pPropLine
->SetKindOfControl(aPropData
.eKind
);
973 pPropLine
->SetSvXPropertyControl(
974 new SvXPropertyEdit(pPropLine
,WB_TABSTOP
));
975 pPropLine
->SetKindOfControl(aPropData
.eKind
);
977 case KOC_USERDEFINED
:
978 pPropLine
->SetSvXPropertyControl(aPropData
.pControl
);
979 aPropData
.pControl
->SetParent(pPropLine
);
980 pPropLine
->SetKindOfControl(aPropData
.eKind
);
983 pPropLine
->SetSvXPropertyControl(NULL
);
984 pPropLine
->SetKindOfControl(KOC_UNDEFINED
);
988 SvXPropertyControl
* pSvXPCtr
=pPropLine
->GetSvXPropertyControl();
992 pSvXPCtr
->SetSvXPropertyCtrListener(&aListener
);
993 pSvXPCtr
->SetProperty(aPropData
.aValue
);
994 pSvXPCtr
->SetMyData(aPropData
.pDataPtr
);
995 pSvXPCtr
->SetMyName(aPropData
.aName
);
997 if(pSvXPCtr
->HasList())
999 for(USHORT i
=0;i
<aPropData
.theValues
.Count();i
++)
1001 pSvXPCtr
->InsertEntry(*(aPropData
.theValues
[i
]));
1006 pPropLine
->SetName(aPropData
.aName
);
1008 USHORT nTextWidth
=(USHORT
)aPlayGround
.GetTextWidth(aPropData
.aName
);
1010 if ( nTheNameSize
< nTextWidth
)
1011 nTheNameSize
= nTextWidth
;
1013 if ( aPropData
.bHasVisibleXButton
)
1015 pPropLine
->SetClickHdl(LINK( this, SvListBoxForProperties
, ClickHdl
) );
1016 pPropLine
->ShowXButton();
1019 pPropLine
->HideXButton();
1021 pPropLine
->Locked(aPropData
.bIsLocked
);
1023 pPropLine
->ShowAsHyperLink(aPropData
.bIsHyperLink
);
1024 pPropLine
->SetData(aPropData
.pDataPtr
);
1028 USHORT
SvListBoxForProperties::GetFirstVisibleEntry()
1032 void SvListBoxForProperties::SetFirstVisibleEntry(USHORT
)
1037 void SvListBoxForProperties::SetSelectedEntry(USHORT
)
1042 USHORT
SvListBoxForProperties::GetSelectedEntry()
1047 IMPL_LINK( SvListBoxForProperties
, ScrollHdl
, ScrollBar
*, pSB
)
1051 long nDelta
=aVScroll
.GetDelta();
1052 nYOffset
=-aVScroll
.GetThumbPos()*nRowHeight
;
1053 //aPlayGround.SetUpdateMode(FALSE);
1055 long nThumbPos
=aVScroll
.GetThumbPos();
1056 long nLines
=aVScroll
.GetPageSize();
1060 for(long i
=nThumbPos
-nDelta
; i
<nThumbPos
+nLines
-nDelta
;i
++)
1062 if(i
>=nThumbPos
&& i
<=nThumbPos
+nLines
)
1064 (PLineArray
[sal::static_int_cast
< USHORT
>(i
)])->
1065 SetNeedsRepaint(TRUE
);
1069 (PLineArray
[sal::static_int_cast
< USHORT
>(i
)])->Hide();
1070 (PLineArray
[sal::static_int_cast
< USHORT
>(i
)])->
1071 SetNeedsRepaint(FALSE
);
1078 IMPL_LINK( SvListBoxForProperties
, ClickHdl
, PushButton
*,pPB
)
1082 SvPropertyLine
*pPropLine
=(SvPropertyLine
*)pPB
->GetParent();
1083 SvXPropertyControl
* pSvXPCtr
=pPropLine
->GetSvXPropertyControl();
1084 pPropDataControl
->Clicked(pSvXPCtr
->GetMyName(),
1085 pSvXPCtr
->GetProperty(),pSvXPCtr
->GetMyData());
1090 IMPL_LINK( SvListBoxForProperties
, ModifyHdl
,SvXPropEvListener
*, pSvXPEvL
)
1092 if(pSvXPEvL
!=NULL
&& pPropDataControl
!=NULL
)
1095 SvXPropertyControl
* pSvXPCtr
=aListener
.GetPropertyControl();
1097 pPropDataControl
->Modified(pSvXPCtr
->GetMyName(),
1098 pSvXPCtr
->GetProperty(),pSvXPCtr
->GetMyData());
1104 IMPL_LINK( SvListBoxForProperties
, GetFocusHdl
,SvXPropEvListener
*, pSvXPEvL
)
1106 if(pSvXPEvL
!=NULL
&& pPropDataControl
!=NULL
)
1108 SvXPropertyControl
* pSvXPCtr
=aListener
.GetPropertyControl();
1110 pPropDataControl
->Select(pSvXPCtr
->GetMyName(),pSvXPCtr
->GetMyData());
1115 IMPL_LINK( SvListBoxForProperties
, LoseFocusHdl
,SvXPropEvListener
*, pSvXPEvL
)
1117 if(pSvXPEvL
!=NULL
&& pPropDataControl
!=NULL
)
1119 SvXPropertyControl
* pSvXPCtr
=aListener
.GetPropertyControl();
1121 pPropDataControl
->Commit(pSvXPCtr
->GetMyName(),
1122 pSvXPCtr
->GetProperty(),pSvXPCtr
->GetMyData());
1125 pSvXPCtr->SetProperty(
1126 pPropDataControl->GetTheCorrectProperty());
1133 IMPL_LINK( SvListBoxForProperties
, KeyInputHdl
,SvXPropEvListener
*, pSvXPEvL
)
1135 // FIXME - This code does not make a lot of sense.
1136 if(pSvXPEvL
!=NULL
&& pPropDataControl
!=NULL
)
1138 /*SvXPropertyControl* pSvXPCtr=*/aListener
.GetPropertyControl();
1146 SvTabPageForProperties::SvTabPageForProperties(Window
* pParent
,WinBits nWinStyle
)
1147 : TabPage(pParent
,nWinStyle
),
1153 void SvTabPageForProperties::Resize()
1156 Size aSize
=GetOutputSizePixel();
1160 aLbProp
.SetPosSizePixel(aPos
,aSize
);
1163 SvListBoxForProperties
* SvTabPageForProperties::GetTheListBox()
1169 SvPropertyBox::SvPropertyBox( Window
* pParent
, WinBits nWinStyle
)
1170 : Control(pParent
,nWinStyle
),
1176 SvPropertyBox::SvPropertyBox( Window
* pParent
, const ResId
& rResId
)
1177 : Control(pParent
,rResId
),
1184 SvPropertyBox::~SvPropertyBox()
1190 void SvPropertyBox::ClearAll()
1192 USHORT nCount
=aTabControl
.GetPageCount();
1194 for(USHORT i
=nCount
;i
>=1;i
--)
1196 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1197 aTabControl
.GetTabPage(i
);
1198 aTabControl
.RemovePage(i
);
1204 void SvPropertyBox::Resize()
1207 Size aSize
=GetOutputSizePixel();
1211 aTabControl
.SetPosSizePixel(aPos
,aSize
);
1213 USHORT nCount
=aTabControl
.GetPageCount();
1215 aSize
=aTabControl
.GetTabPageSizePixel();
1216 for(USHORT i
=1;i
<=nCount
;i
++)
1218 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1219 aTabControl
.GetTabPage(i
);
1220 pPage
->SetSizePixel(aSize
);
1226 USHORT
SvPropertyBox::AppendPage( const String
& rText
)
1228 USHORT nId
=aTabControl
.GetPageCount()+1;
1229 aTabControl
.InsertPage( nId
,rText
);
1230 SvTabPageForProperties
* pPage
=new SvTabPageForProperties(&aTabControl
);
1231 pPage
->SetSizePixel(aTabControl
.GetTabPageSizePixel());
1232 pPage
->GetTheListBox()->SetController(pThePropDataCtr
);
1233 aTabControl
.SetTabPage( nId
, pPage
);
1234 aTabControl
.SetCurPageId(nId
);
1238 void SvPropertyBox::SetPage( USHORT nId
)
1240 aTabControl
.SetCurPageId(nId
);
1243 USHORT
SvPropertyBox::GetCurPage()
1245 return aTabControl
.GetCurPageId();
1248 USHORT
SvPropertyBox::CalcVisibleLines()
1250 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1251 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1252 return pPage
->GetTheListBox()->CalcVisibleLines();
1254 void SvPropertyBox::EnableUpdate()
1256 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1257 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1258 pPage
->GetTheListBox()->EnableUpdate();
1261 void SvPropertyBox::DisableUpdate()
1263 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1264 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1265 pPage
->GetTheListBox()->DisableUpdate();
1268 void SvPropertyBox::SetController(SvPropertyDataControl
*pDataCtr
)
1270 pThePropDataCtr
=pDataCtr
;
1271 USHORT nCount
=aTabControl
.GetPageCount();
1273 for(USHORT i
=1;i
<=nCount
;i
++)
1275 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1276 aTabControl
.GetTabPage(i
);
1278 pPage
->GetTheListBox()->SetController(pThePropDataCtr
);
1283 USHORT
SvPropertyBox::InsertEntry( const SvPropertyData
& rData
, USHORT nPos
)
1285 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1286 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1287 return pPage
->GetTheListBox()->InsertEntry(rData
,nPos
);
1290 void SvPropertyBox::ChangeEntry( const SvPropertyData
& rData
, USHORT nPos
)
1292 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1293 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1294 pPage
->GetTheListBox()->ChangeEntry(rData
,nPos
);
1297 USHORT
SvPropertyBox::AppendEntry( const SvPropertyData
& rData
)
1299 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1300 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1301 return pPage
->GetTheListBox()->AppendEntry(rData
);
1304 void SvPropertyBox::SetPropertyValue( const String
& rEntryName
, const String
& rValue
)
1306 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1307 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1308 pPage
->GetTheListBox()->SetPropertyValue( rEntryName
, rValue
);
1311 void SvPropertyBox::SetFirstVisibleEntry(USHORT nPos
)
1313 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1314 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1315 pPage
->GetTheListBox()->SetFirstVisibleEntry(nPos
);
1317 USHORT
SvPropertyBox::GetFirstVisibleEntry()
1319 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1320 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1321 return pPage
->GetTheListBox()->GetFirstVisibleEntry();
1324 void SvPropertyBox::SetSelectedEntry(USHORT nPos
)
1326 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1327 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1328 pPage
->GetTheListBox()->SetSelectedEntry(nPos
);
1330 USHORT
SvPropertyBox::GetSelectedEntry()
1332 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1333 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1334 return pPage
->GetTheListBox()->GetSelectedEntry();
1337 void SvPropertyBox::ClearTable()
1339 SvTabPageForProperties
* pPage
=(SvTabPageForProperties
*)
1340 aTabControl
.GetTabPage(aTabControl
.GetCurPageId());
1341 pPage
->GetTheListBox()->Clear();
1344 SvBasicPropertyDataControl::~SvBasicPropertyDataControl()
1348 void SvBasicPropertyDataControl::Modified(const String
& aName
,
1349 const String
& aVal
,void* pData
)
1352 aEntryProperty
=aVal
;
1354 aModifyLink
.Call(this);
1357 void SvBasicPropertyDataControl::Clicked( const String
& aName
,
1359 void* pData
) //Xtension-Button pressed
1362 aEntryProperty
=aVal
;
1364 aClickedLink
.Call(this);
1367 void SvBasicPropertyDataControl::Commit( const String
& aName
,
1369 void* pData
) //User accept changes
1372 aEntryProperty
=aVal
;
1374 aCommitLink
.Call(this);
1377 void SvBasicPropertyDataControl::Select( const String
& aName
,
1378 void* pData
) //User select new Row
1382 aSelectLink
.Call(this);
1385 void SvBasicPropertyDataControl::LinkClicked(const String
&, void*)
1390 String
SvBasicPropertyDataControl::GetName() const //Tell's the name of the Property
1395 String
SvBasicPropertyDataControl::GetProperty() const //Tell's the content of the Property
1397 return aEntryProperty
;
1400 void* SvBasicPropertyDataControl::GetData() //Tell's the storage
1406 String SvBasicPropertyDataControl::GetTheCorrectProperty() const
1408 return aCorrectProperty;
1412 void SvBasicPropertyDataControl::SetTheCorrectProperty(const String
& aString
)
1414 aCorrectProperty
=aString
;
1417 void SvBasicPropertyDataControl::SetIsCorrect(BOOL nFlag
)
1424 //========================================================================
1426 /* zum TESTEN im CALC*/
1427 //========================================================================
1429 ScPropertyDlg::ScPropertyDlg( Window* pParent) :
1430 ModalDialog ( pParent, ScResId( RID_SCDLG_PROPERTIES) ),
1431 aPropListBox ( this, ResId( CTR_PROPLINE) ),
1432 aKindOfListBox (this,ResId( LB_KIND_OF_PROP)),
1433 aModAnswer (this,ResId(FT_ANSMOD )),
1434 aClickAnswer (this,ResId(FT_ANSCLICK )),
1435 aCommitAnswer (this,ResId(FT_ANSCOMMIT)),
1436 aSelectAnswer (this,ResId(FT_ANSSELECT)),
1437 anOk(this,ResId( BTN_OK)),
1438 aCancel(this,ResId( BTN_CANCEL))
1442 aKindOfListBox.SelectEntryPos(0);
1443 aKindOfListBox.SetSelectHdl(
1444 LINK( this, ScPropertyDlg, ModifiedHdl ));
1448 String aString("Don't know ");
1450 aBaProDatCtr.SetModifyHdl (LINK( this, ScPropertyDlg, RowModifiedHdl ));
1451 aBaProDatCtr.SetClickedHdl(LINK( this, ScPropertyDlg, ClickHdl ));
1452 aBaProDatCtr.SetCommitHdl (LINK( this, ScPropertyDlg, SelectHdl ));
1453 aBaProDatCtr.SetSelectHdl (LINK( this, ScPropertyDlg, CommitHdl ));
1455 aPropListBox.SetController(&aBaProDatCtr);
1457 USHORT nPageId=aPropListBox.AppendPage("YabbaDabbaDo");
1458 aPropListBox.SetPage(nPageId);
1459 aProperty.eKind=KOC_EDIT;
1460 aProperty.aName=aString;
1461 aProperty.aName+=String((USHORT)++nCount);
1462 aProperty.aValue=sizeof ComboBox;
1463 aProperty.bHasVisibleXButton=FALSE;
1464 aProperty.bIsHyperLink=FALSE;
1465 aProperty.bIsLocked=FALSE;
1466 aProperty.pDataPtr=NULL;
1467 aProperty.pControl=NULL;
1468 aProperty.theValues.Insert(new String("1"),aProperty.theValues.Count());
1469 aProperty.theValues.Insert(new String("2"),aProperty.theValues.Count());
1470 aProperty.theValues.Insert(new String("3"),aProperty.theValues.Count());
1471 aProperty.theValues.Insert(new String("4"),aProperty.theValues.Count());
1472 aPropListBox.InsertEntry(aProperty);
1473 aProperty.bHasVisibleXButton=TRUE;
1474 aProperty.aName=aString;
1475 aProperty.aName+=String((USHORT)++nCount);
1476 aProperty.aValue="42";
1477 aProperty.eKind=KOC_LISTBOX;
1478 aPropListBox.InsertEntry(aProperty);
1479 aProperty.aName=aString;
1480 aProperty.aName+=String((USHORT)++nCount);
1481 aProperty.eKind=KOC_COMBOBOX;
1482 aProperty.bHasVisibleXButton=FALSE;
1483 aPropListBox.InsertEntry(aProperty);
1486 ScPropertyDlg::~ScPropertyDlg()
1488 delete aProperty.theValues[0];
1489 delete aProperty.theValues[1];
1490 delete aProperty.theValues[2];
1491 delete aProperty.theValues[3];
1494 IMPL_LINK( ScPropertyDlg, ModifiedHdl, ListBox*, pLB )
1498 String aString("Don't know ");
1499 aProperty.aName=aString;
1500 aProperty.aName+=String((USHORT)++nCount);
1503 String aStr("Yabba ");
1504 aStr+=aPropListBox.GetCurPage();
1505 USHORT nPageId=aPropListBox.AppendPage(aStr);
1506 aPropListBox.SetPage(nPageId);
1510 aProperty.eKind=(eKindOfControl)(aKindOfListBox.GetSelectEntryPos()+1);
1511 aProperty.bHasVisibleXButton=FALSE;
1512 if((nCount % 5)==0) aProperty.bHasVisibleXButton=TRUE;
1513 aPropListBox.InsertEntry(aProperty);
1518 IMPL_LINK( ScPropertyDlg, RowModifiedHdl, SvBasicPropertyDataControl* ,pProCtr)
1522 aModAnswer.SetText(aBaProDatCtr.GetProperty());
1523 aModAnswer.Invalidate();
1524 aBaProDatCtr.SetIsCorrect(TRUE);
1529 IMPL_LINK( ScPropertyDlg, CommitHdl, SvBasicPropertyDataControl*,pProCtr)
1533 aCommitAnswer.SetText(aBaProDatCtr.GetProperty());
1534 aCommitAnswer.Invalidate();
1535 aBaProDatCtr.SetIsCorrect(TRUE);
1540 IMPL_LINK( ScPropertyDlg, ClickHdl, SvBasicPropertyDataControl*,pProCtr)
1544 aClickAnswer.SetText(aBaProDatCtr.GetName());
1545 aClickAnswer.Invalidate();
1546 aBaProDatCtr.SetIsCorrect(TRUE);
1551 IMPL_LINK( ScPropertyDlg, SelectHdl, SvBasicPropertyDataControl*,pProCtr)
1555 aSelectAnswer.SetText(aBaProDatCtr.GetName());
1556 aSelectAnswer.Invalidate();
1557 aBaProDatCtr.SetIsCorrect(TRUE);