Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "PageOrientationControl.hxx"
21 : #include "PagePropertyPanel.hxx"
22 : #include "PagePropertyPanel.hrc"
23 :
24 : #include <swtypes.hxx>
25 :
26 : #include <svx/sidebar/ValueSetWithTextControl.hxx>
27 : #include <vcl/settings.hxx>
28 :
29 : namespace sw { namespace sidebar {
30 :
31 0 : PageOrientationControl::PageOrientationControl(
32 : vcl::Window* pParent,
33 : PagePropertyPanel& rPanel,
34 : const bool bLandscape )
35 : : svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
36 : , mpOrientationValueSet( VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
37 : , mbLandscape( bLandscape )
38 0 : , mrPagePropPanel(rPanel)
39 : {
40 0 : mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
41 0 : mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
42 :
43 : // initialize <ValueSetWithText> control
44 : {
45 : mpOrientationValueSet->AddItem(Image(SW_RES(IMG_PORTRAIT)), 0,
46 0 : SW_RES(STR_PORTRAIT), 0);
47 : mpOrientationValueSet->AddItem(Image(SW_RES(IMG_LANDSCAPE)), 0,
48 0 : SW_RES(STR_LANDSCAPE), 0 );
49 : }
50 :
51 0 : Link<> aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
52 0 : mpOrientationValueSet->SetSelectHdl(aLink);
53 0 : mpOrientationValueSet->SetNoSelection();
54 0 : mpOrientationValueSet->StartSelection();
55 0 : mpOrientationValueSet->Show();
56 0 : mpOrientationValueSet->SelectItem( mbLandscape ? 2 : 1 );
57 0 : mpOrientationValueSet->GrabFocus();
58 0 : mpOrientationValueSet->SetFormat();
59 0 : mpOrientationValueSet->Invalidate();
60 0 : mpOrientationValueSet->StartSelection();
61 :
62 0 : FreeResource();
63 0 : }
64 :
65 0 : PageOrientationControl::~PageOrientationControl()
66 : {
67 0 : disposeOnce();
68 0 : }
69 :
70 0 : void PageOrientationControl::dispose()
71 : {
72 0 : mpOrientationValueSet.disposeAndClear();
73 0 : svx::sidebar::PopupControl::dispose();
74 0 : }
75 :
76 0 : IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
77 : {
78 0 : mpOrientationValueSet->SetNoSelection();
79 0 : if ( pControl == mpOrientationValueSet )
80 : {
81 0 : const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
82 0 : const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
83 0 : ( ( iPos == 2 ) && !mbLandscape );
84 0 : if ( bChanged )
85 : {
86 0 : mbLandscape = !mbLandscape;
87 0 : mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
88 : }
89 : }
90 :
91 0 : mrPagePropPanel.ClosePageOrientationPopup();
92 0 : return 0;
93 : }
94 :
95 177 : } } // end of namespace sw::sidebar
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|