1 /************************************************************** 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 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 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. 19 * 20 *************************************************************/ 21 22 23 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 34 namespace sw { namespace sidebar { 35 36 PageOrientationControl::PageOrientationControl( 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) 44 { 45 mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT ); 46 mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 47 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 } 53 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(); 63 64 FreeResource(); 65 } 66 67 68 PageOrientationControl::~PageOrientationControl(void) 69 { 70 delete mpOrientationValueSet; 71 } 72 73 74 IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl) 75 { 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 } 88 89 mrPagePropPanel.ClosePageOrientationPopup(); 90 return 0; 91 } 92 93 94 } } // end of namespace sw::sidebar 95 96 /* vim: set noet sw=4 ts=4: */ 97