1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/toolkit/morebtn.hxx>
21 #include <vcl/stdtext.hxx>
23 struct ImplMoreButtonData
29 void MoreButton::ImplInit( vcl::Window
* pParent
, WinBits nStyle
)
31 mpMBData
.reset(new ImplMoreButtonData
);
34 PushButton::ImplInit( pParent
, nStyle
);
36 mpMBData
->maMoreText
= GetStandardText( StandardButtonType::More
);
37 mpMBData
->maLessText
= GetStandardText( StandardButtonType::Less
);
41 SetSymbolAlign(SymbolAlign::RIGHT
);
42 SetImageAlign(ImageAlign::Right
); //Resolves: fdo#31849 ensure button remains vertically centered
45 if ( ! ( nStyle
& ( WB_RIGHT
| WB_LEFT
) ) )
52 void MoreButton::ShowState()
56 SetSymbol( SymbolType::PAGEUP
);
57 SetText( mpMBData
->maLessText
);
61 SetSymbol( SymbolType::PAGEDOWN
);
62 SetText( mpMBData
->maMoreText
);
66 MoreButton::MoreButton( vcl::Window
* pParent
, WinBits nStyle
) :
67 PushButton( WindowType::MOREBUTTON
)
69 ImplInit( pParent
, nStyle
);
72 MoreButton::~MoreButton()
77 void MoreButton::dispose()
80 PushButton::dispose();
83 void MoreButton::Click()
85 vcl::Window
* pParent
= GetParent();
86 Size
aSize( pParent
->GetSizePixel() );
87 tools::Long nDeltaPixel
= LogicToPixel(Size(0, 0), MapMode(MapUnit::MapPixel
)).Height();
93 // Update the windows according to the status
97 Point
aPos( pParent
->GetPosPixel() );
98 tools::Rectangle
aDeskRect( pParent
->ImplGetFrameWindow()->GetDesktopRectPixel() );
100 aSize
.AdjustHeight(nDeltaPixel
);
101 if ( (aPos
.Y()+aSize
.Height()) > aDeskRect
.Bottom() )
103 aPos
.setY( aDeskRect
.Bottom()-aSize
.Height() );
105 if ( aPos
.Y() < aDeskRect
.Top() )
106 aPos
.setY( aDeskRect
.Top() );
108 pParent
->SetPosSizePixel( aPos
, aSize
);
111 pParent
->SetSizePixel( aSize
);
116 aSize
.AdjustHeight( -nDeltaPixel
);
117 pParent
->SetSizePixel( aSize
);
119 // Call Click handler here, so that we can initialize the Controls
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */