Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
10 : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : * contributor license agreements. See the NOTICE file distributed
12 : * with this work for additional information regarding copyright
13 : * ownership. The ASF licenses this file to you under the Apache
14 : * License, Version 2.0 (the "License"); you may not use this file
15 : * except in compliance with the License. You may obtain a copy of
16 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : */
18 :
19 : #include "PageOrientationControl.hxx"
20 : #include "PagePropertyPanel.hxx"
21 : #include "PagePropertyPanel.hrc"
22 :
23 : #include <swtypes.hxx>
24 :
25 : #include <svx/sidebar/ValueSetWithTextControl.hxx>
26 :
27 : namespace sw { namespace sidebar {
28 :
29 0 : PageOrientationControl::PageOrientationControl(
30 : Window* pParent,
31 : PagePropertyPanel& rPanel,
32 : const sal_Bool bLandscape )
33 : : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
34 0 : , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
35 : , mbLandscape( bLandscape )
36 0 : , mrPagePropPanel(rPanel)
37 : {
38 0 : mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
39 0 : mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
40 :
41 : // initialize <ValueSetWithText> control
42 : {
43 0 : mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 );
44 0 : mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 );
45 : }
46 :
47 0 : Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
48 0 : mpOrientationValueSet->SetSelectHdl(aLink);
49 0 : mpOrientationValueSet->SetNoSelection();
50 0 : mpOrientationValueSet->StartSelection();
51 0 : mpOrientationValueSet->Show();
52 0 : mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
53 0 : mpOrientationValueSet->GrabFocus();
54 0 : mpOrientationValueSet->Format();
55 0 : mpOrientationValueSet->StartSelection();
56 :
57 0 : FreeResource();
58 0 : }
59 :
60 :
61 0 : PageOrientationControl::~PageOrientationControl(void)
62 : {
63 0 : delete mpOrientationValueSet;
64 0 : }
65 :
66 :
67 0 : IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
68 : {
69 0 : mpOrientationValueSet->SetNoSelection();
70 0 : if ( pControl == mpOrientationValueSet )
71 : {
72 0 : const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
73 0 : const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
74 0 : ( ( iPos == 2 ) && !mbLandscape );
75 0 : if ( bChanged )
76 : {
77 0 : mbLandscape = !mbLandscape;
78 0 : mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
79 : }
80 : }
81 :
82 0 : mrPagePropPanel.ClosePageOrientationPopup();
83 0 : return 0;
84 : }
85 :
86 :
87 99 : } } // end of namespace sw::sidebar
88 :
|