PageOrientationControl.cxx (ff0525f2) PageOrientationControl.cxx (fb399032)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
20 *************************************************************/
21
22
23
22#include "precompiled_sw.hxx"
23
24#include "PageOrientationControl.hxx"
25#include "PagePropertyPanel.hxx"
26#include "PagePropertyPanel.hrc"
27
28#include <swtypes.hxx>
29
30#include <svx/sidebar/ValueSetWithTextControl.hxx>
31
32namespace sw { namespace sidebar {
33
34PageOrientationControl::PageOrientationControl(
24#include "precompiled_sw.hxx"
25
26#include "PageOrientationControl.hxx"
27#include "PagePropertyPanel.hxx"
28#include "PagePropertyPanel.hrc"
29
30#include <swtypes.hxx>
31
32#include <svx/sidebar/ValueSetWithTextControl.hxx>
33
34namespace sw { namespace sidebar {
35
36PageOrientationControl::PageOrientationControl(
35 Window* pParent,
36 PagePropertyPanel& rPanel,
37 const sal_Bool bLandscape )
38 : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
39 , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
40 , mbLandscape( bLandscape )
41 , mrPagePropPanel(rPanel)
37 Window* pParent,
38 PagePropertyPanel& rPanel,
39 const sal_Bool bLandscape )
40 : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
41 , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
42 , mbLandscape( bLandscape )
43 , mrPagePropPanel(rPanel)
42{
44{
43 mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
44 mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
45 mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
46 mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
45
47
46 // initialize <ValueSetWithText> control
47 {
48 mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 );
49 mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 );
50 }
48 // initialize <ValueSetWithText> control
49 {
50 mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 );
51 mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 );
52 }
51
53
52 Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
53 mpOrientationValueSet->SetSelectHdl(aLink);
54 mpOrientationValueSet->SetNoSelection();
55 mpOrientationValueSet->StartSelection();
56 mpOrientationValueSet->Show();
57 mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
58 mpOrientationValueSet->GrabFocus();
59 mpOrientationValueSet->Format();
60 mpOrientationValueSet->StartSelection();
54 Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
55 mpOrientationValueSet->SetSelectHdl(aLink);
56 mpOrientationValueSet->SetNoSelection();
57 mpOrientationValueSet->StartSelection();
58 mpOrientationValueSet->Show();
59 mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
60 mpOrientationValueSet->GrabFocus();
61 mpOrientationValueSet->Format();
62 mpOrientationValueSet->StartSelection();
61
63
62 FreeResource();
64 FreeResource();
63}
64
65
66PageOrientationControl::~PageOrientationControl(void)
67{
65}
66
67
68PageOrientationControl::~PageOrientationControl(void)
69{
68 delete mpOrientationValueSet;
70 delete mpOrientationValueSet;
69}
70
71
72IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
73{
71}
72
73
74IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
75{
74 mpOrientationValueSet->SetNoSelection();
75 if ( pControl == mpOrientationValueSet )
76 {
77 const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
78 const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
79 ( ( iPos == 2 ) && !mbLandscape );
80 if ( bChanged )
81 {
82 mbLandscape = !mbLandscape;
83 mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
84 }
85 }
76 mpOrientationValueSet->SetNoSelection();
77 if ( pControl == mpOrientationValueSet )
78 {
79 const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
80 const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
81 ( ( iPos == 2 ) && !mbLandscape );
82 if ( bChanged )
83 {
84 mbLandscape = !mbLandscape;
85 mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
86 }
87 }
86
88
87 mrPagePropPanel.ClosePageOrientationPopup();
88 return 0;
89 mrPagePropPanel.ClosePageOrientationPopup();
90 return 0;
89}
90
91
92} } // end of namespace sw::sidebar
93
91}
92
93
94} } // end of namespace sw::sidebar
95
96/* vim: set noet sw=4 ts=4: */