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