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 "PageColumnControl.hxx" 27 #include "PagePropertyPanel.hxx" 28 #include "PagePropertyPanel.hrc" 29 30 #include <cmdid.h> 31 #include <swtypes.hxx> 32 33 #include <svx/sidebar/ValueSetWithTextControl.hxx> 34 #include <sfx2/bindings.hxx> 35 #include <sfx2/dispatch.hxx> 36 37 namespace sw { namespace sidebar { 38 39 PageColumnControl::PageColumnControl( 40 Window* pParent, 41 PagePropertyPanel& rPanel, 42 const sal_uInt16 nColumnType, 43 const bool bLandscape ) 44 : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_COLUMN) ) 45 , mpColumnValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_COLUMN) ) ) 46 , maMoreButton( this, SW_RES(CB_COLUMN_MORE) ) 47 , mnColumnType( nColumnType ) 48 , mrPagePropPanel(rPanel) 49 { 50 mpColumnValueSet->SetStyle( mpColumnValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT ); 51 mpColumnValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor()); 52 53 if ( bLandscape ) 54 { 55 mpColumnValueSet->AddItem( SW_RES(IMG_ONE_L), 0, SW_RES(STR_ONE), 0 ); 56 mpColumnValueSet->AddItem( SW_RES(IMG_TWO_L), 0, SW_RES(STR_TWO), 0 ); 57 mpColumnValueSet->AddItem( SW_RES(IMG_THREE_L), 0, SW_RES(STR_THREE), 0 ); 58 mpColumnValueSet->AddItem( SW_RES(IMG_LEFT_L), 0, SW_RES(STR_LEFT), 0 ); 59 mpColumnValueSet->AddItem( SW_RES(IMG_RIGHT_L), 0, SW_RES(STR_RIGHT), 0 ); 60 } 61 else 62 { 63 mpColumnValueSet->AddItem( SW_RES(IMG_ONE), 0, SW_RES(STR_ONE), 0 ); 64 mpColumnValueSet->AddItem( SW_RES(IMG_TWO), 0, SW_RES(STR_TWO), 0 ); 65 mpColumnValueSet->AddItem( SW_RES(IMG_THREE), 0, SW_RES(STR_THREE), 0 ); 66 mpColumnValueSet->AddItem( SW_RES(IMG_LEFT), 0, SW_RES(STR_LEFT), 0 ); 67 mpColumnValueSet->AddItem( SW_RES(IMG_RIGHT), 0, SW_RES(STR_RIGHT), 0 ); 68 } 69 70 mpColumnValueSet->SetNoSelection(); 71 mpColumnValueSet->SetSelectHdl( LINK(this, PageColumnControl,ImplColumnHdl ) ); 72 mpColumnValueSet->Show(); 73 mpColumnValueSet->SelectItem( mnColumnType ); 74 mpColumnValueSet->Format(); 75 mpColumnValueSet->StartSelection(); 76 77 maMoreButton.SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) ); 78 maMoreButton.GrabFocus(); 79 80 FreeResource(); 81 } 82 83 84 PageColumnControl::~PageColumnControl(void) 85 { 86 delete mpColumnValueSet; 87 } 88 89 90 IMPL_LINK(PageColumnControl, ImplColumnHdl, void *, pControl) 91 { 92 mpColumnValueSet->SetNoSelection(); 93 if ( pControl == mpColumnValueSet ) 94 { 95 const sal_uInt32 nColumnType = mpColumnValueSet->GetSelectItemId(); 96 if ( nColumnType != mnColumnType ) 97 { 98 mnColumnType = nColumnType; 99 mrPagePropPanel.ExecuteColumnChange( mnColumnType ); 100 } 101 } 102 103 mrPagePropPanel.ClosePageColumnPopup(); 104 return 0; 105 } 106 107 IMPL_LINK(PageColumnControl, MoreButtonClickHdl_Impl, void *, EMPTYARG) 108 { 109 mrPagePropPanel.GetBindings()->GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SFX_CALLMODE_ASYNCHRON ); 110 111 mrPagePropPanel.ClosePageColumnPopup(); 112 return 0; 113 } 114 115 116 } } // end of namespace sw::sidebar 117 118 /* vim: set noet sw=4 ts=4: */ 119