update credits
[LibreOffice.git] / sw / source / ui / sidebar / PageOrientationControl.cxx
blobe1268ab35558785db2facd54baf5a6bcba18ef66
1 /*
2 * This file is part of the LibreOffice project.
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/.
8 * This file incorporates work covered by the following license notice:
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 .
19 #include "PageOrientationControl.hxx"
20 #include "PagePropertyPanel.hxx"
21 #include "PagePropertyPanel.hrc"
23 #include <swtypes.hxx>
25 #include <svx/sidebar/ValueSetWithTextControl.hxx>
27 namespace sw { namespace sidebar {
29 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 , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
35 , mbLandscape( bLandscape )
36 , mrPagePropPanel(rPanel)
38 mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
39 mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
41 // initialize <ValueSetWithText> control
43 mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 );
44 mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 );
47 Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
48 mpOrientationValueSet->SetSelectHdl(aLink);
49 mpOrientationValueSet->SetNoSelection();
50 mpOrientationValueSet->StartSelection();
51 mpOrientationValueSet->Show();
52 mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
53 mpOrientationValueSet->GrabFocus();
54 mpOrientationValueSet->Format();
55 mpOrientationValueSet->StartSelection();
57 FreeResource();
61 PageOrientationControl::~PageOrientationControl(void)
63 delete mpOrientationValueSet;
67 IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
69 mpOrientationValueSet->SetNoSelection();
70 if ( pControl == mpOrientationValueSet )
72 const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
73 const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
74 ( ( iPos == 2 ) && !mbLandscape );
75 if ( bChanged )
77 mbLandscape = !mbLandscape;
78 mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
82 mrPagePropPanel.ClosePageOrientationPopup();
83 return 0;
87 } } // end of namespace sw::sidebar