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