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: morebtn.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_vcl.hxx"
33 #include <vcl/morebtn.hxx>
41 // =======================================================================
43 DECLARE_LIST( ImplMoreWindowList
, Window
* )
45 struct ImplMoreButtonData
47 ImplMoreWindowList
*mpItemList
;
52 // =======================================================================
54 void MoreButton::ImplInit( Window
* pParent
, WinBits nStyle
)
56 mpMBData
= new ImplMoreButtonData
;
61 mpMBData
->mpItemList
= NULL
;
63 PushButton::ImplInit( pParent
, nStyle
);
65 mpMBData
->maMoreText
= Button::GetStandardText( BUTTON_MORE
);
66 mpMBData
->maLessText
= Button::GetStandardText( BUTTON_LESS
);
68 SetHelpText( Button::GetStandardHelpText( BUTTON_MORE
) );
72 SetSymbolAlign( SYMBOLALIGN_RIGHT
);
73 ImplSetSmallSymbol( TRUE
);
75 if ( ! ( nStyle
& ( WB_RIGHT
| WB_LEFT
) ) )
82 // -----------------------------------------------------------------------
83 void MoreButton::ShowState()
87 SetSymbol( SYMBOL_PAGEUP
);
88 SetText( mpMBData
->maLessText
);
92 SetSymbol( SYMBOL_PAGEDOWN
);
93 SetText( mpMBData
->maMoreText
);
97 // -----------------------------------------------------------------------
99 MoreButton::MoreButton( Window
* pParent
, WinBits nStyle
) :
100 PushButton( WINDOW_MOREBUTTON
)
102 ImplInit( pParent
, nStyle
);
105 // -----------------------------------------------------------------------
107 MoreButton::MoreButton( Window
* pParent
, const ResId
& rResId
) :
108 PushButton( WINDOW_MOREBUTTON
)
110 rResId
.SetRT( RSC_MOREBUTTON
);
111 WinBits nStyle
= ImplInitRes( rResId
);
112 ImplInit( pParent
, nStyle
);
113 ImplLoadRes( rResId
);
115 if ( !(nStyle
& WB_HIDE
) )
119 // -----------------------------------------------------------------------
121 void MoreButton::ImplLoadRes( const ResId
& rResId
)
123 PushButton::ImplLoadRes( rResId
);
125 ULONG nObjMask
= ReadLongRes();
127 if ( nObjMask
& RSC_MOREBUTTON_STATE
)
129 // Nicht Methode rufen, da Dialog nicht umgeschaltet werden soll
130 mbState
= (BOOL
)ReadShortRes();
131 // SetText( GetText() );
134 if ( nObjMask
& RSC_MOREBUTTON_MAPUNIT
)
135 meUnit
= (MapUnit
)ReadLongRes();
136 if ( nObjMask
& RSC_MOREBUTTON_DELTA
)
137 // Groesse fuer Erweitern des Dialogs
138 mnDelta
= ReadShortRes();
141 // -----------------------------------------------------------------------
143 MoreButton::~MoreButton()
145 if ( mpMBData
->mpItemList
)
146 delete mpMBData
->mpItemList
;
150 // -----------------------------------------------------------------------
152 void MoreButton::Click()
154 Window
* pParent
= GetParent();
155 Size
aSize( pParent
->GetSizePixel() );
156 Window
* pWindow
= (mpMBData
->mpItemList
) ? mpMBData
->mpItemList
->First() : NULL
;
157 long nDeltaPixel
= LogicToPixel( Size( 0, mnDelta
), meUnit
).Height();
163 // Hier den Click-Handler rufen, damit vorher die Controls initialisiert
167 // Je nach Status die Fenster updaten
174 pWindow
= mpMBData
->mpItemList
->Next();
177 // Dialogbox anpassen
178 Point
aPos( pParent
->GetPosPixel() );
179 Rectangle
aDeskRect( pParent
->ImplGetFrameWindow()->GetDesktopRectPixel() );
181 aSize
.Height() += nDeltaPixel
;
182 if ( (aPos
.Y()+aSize
.Height()) > aDeskRect
.Bottom() )
184 aPos
.Y() = aDeskRect
.Bottom()-aSize
.Height();
186 if ( aPos
.Y() < aDeskRect
.Top() )
187 aPos
.Y() = aDeskRect
.Top();
189 pParent
->SetPosSizePixel( aPos
, aSize
);
192 pParent
->SetSizePixel( aSize
);
196 // Dialogbox anpassen
197 aSize
.Height() -= nDeltaPixel
;
198 pParent
->SetSizePixel( aSize
);
200 // Fenster nicht mehr anzeigen
204 pWindow
= mpMBData
->mpItemList
->Next();
209 // -----------------------------------------------------------------------
211 void MoreButton::AddWindow( Window
* pWindow
)
213 if ( !mpMBData
->mpItemList
)
214 mpMBData
->mpItemList
= new ImplMoreWindowList( 1024, 16, 16 );
216 mpMBData
->mpItemList
->Insert( pWindow
, LIST_APPEND
);
224 // -----------------------------------------------------------------------
226 void MoreButton::RemoveWindow( Window
* pWindow
)
228 if ( mpMBData
->mpItemList
)
229 mpMBData
->mpItemList
->Remove( pWindow
);
232 // -----------------------------------------------------------------------
234 void MoreButton::SetText( const XubString
& rText
)
236 PushButton::SetText( rText
);
239 // -----------------------------------------------------------------------
241 XubString
MoreButton::GetText() const
243 return PushButton::GetText();
246 // -----------------------------------------------------------------------
247 void MoreButton::SetMoreText( const XubString
& rText
)
250 mpMBData
->maMoreText
= rText
;
256 // -----------------------------------------------------------------------
257 XubString
MoreButton::GetMoreText() const
260 return mpMBData
->maMoreText
;
262 return PushButton::GetText();
265 // -----------------------------------------------------------------------
266 void MoreButton::SetLessText( const XubString
& rText
)
269 mpMBData
->maLessText
= rText
;
275 // -----------------------------------------------------------------------
276 XubString
MoreButton::GetLessText() const
279 return mpMBData
->maLessText
;
281 return PushButton::GetText();