Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
10 : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : * contributor license agreements. See the NOTICE file distributed
12 : * with this work for additional information regarding copyright
13 : * ownership. The ASF licenses this file to you under the Apache
14 : * License, Version 2.0 (the "License"); you may not use this file
15 : * except in compliance with the License. You may obtain a copy of
16 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : */
18 :
19 : #include "PageColumnControl.hxx"
20 : #include "PagePropertyPanel.hxx"
21 : #include "PagePropertyPanel.hrc"
22 :
23 : #include <cmdid.h>
24 : #include <swtypes.hxx>
25 :
26 : #include <svx/sidebar/ValueSetWithTextControl.hxx>
27 : #include <sfx2/bindings.hxx>
28 : #include <sfx2/dispatch.hxx>
29 :
30 : namespace sw { namespace sidebar {
31 :
32 0 : PageColumnControl::PageColumnControl(
33 : Window* pParent,
34 : PagePropertyPanel& rPanel,
35 : const sal_uInt16 nColumnType,
36 : const bool bLandscape )
37 : : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_COLUMN) )
38 0 : , mpColumnValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_COLUMN) ) )
39 : , maMoreButton( this, SW_RES(CB_COLUMN_MORE) )
40 : , mnColumnType( nColumnType )
41 0 : , mrPagePropPanel(rPanel)
42 : {
43 0 : mpColumnValueSet->SetStyle( mpColumnValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
44 0 : mpColumnValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
45 :
46 0 : if ( bLandscape )
47 : {
48 0 : mpColumnValueSet->AddItem( SW_RES(IMG_ONE_L), 0, SW_RES(STR_ONE), 0 );
49 0 : mpColumnValueSet->AddItem( SW_RES(IMG_TWO_L), 0, SW_RES(STR_TWO), 0 );
50 0 : mpColumnValueSet->AddItem( SW_RES(IMG_THREE_L), 0, SW_RES(STR_THREE), 0 );
51 0 : mpColumnValueSet->AddItem( SW_RES(IMG_LEFT_L), 0, SW_RES(STR_LEFT), 0 );
52 0 : mpColumnValueSet->AddItem( SW_RES(IMG_RIGHT_L), 0, SW_RES(STR_RIGHT), 0 );
53 : }
54 : else
55 : {
56 0 : mpColumnValueSet->AddItem( SW_RES(IMG_ONE), 0, SW_RES(STR_ONE), 0 );
57 0 : mpColumnValueSet->AddItem( SW_RES(IMG_TWO), 0, SW_RES(STR_TWO), 0 );
58 0 : mpColumnValueSet->AddItem( SW_RES(IMG_THREE), 0, SW_RES(STR_THREE), 0 );
59 0 : mpColumnValueSet->AddItem( SW_RES(IMG_LEFT), 0, SW_RES(STR_LEFT), 0 );
60 0 : mpColumnValueSet->AddItem( SW_RES(IMG_RIGHT), 0, SW_RES(STR_RIGHT), 0 );
61 : }
62 :
63 0 : mpColumnValueSet->SetNoSelection();
64 0 : mpColumnValueSet->SetSelectHdl( LINK(this, PageColumnControl,ImplColumnHdl ) );
65 0 : mpColumnValueSet->Show();
66 0 : mpColumnValueSet->SelectItem( mnColumnType );
67 0 : mpColumnValueSet->Format();
68 0 : mpColumnValueSet->StartSelection();
69 :
70 0 : maMoreButton.SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
71 0 : maMoreButton.GrabFocus();
72 :
73 0 : FreeResource();
74 0 : }
75 :
76 :
77 0 : PageColumnControl::~PageColumnControl(void)
78 : {
79 0 : delete mpColumnValueSet;
80 0 : }
81 :
82 :
83 0 : IMPL_LINK(PageColumnControl, ImplColumnHdl, void *, pControl)
84 : {
85 0 : mpColumnValueSet->SetNoSelection();
86 0 : if ( pControl == mpColumnValueSet )
87 : {
88 0 : const sal_uInt32 nColumnType = mpColumnValueSet->GetSelectItemId();
89 0 : if ( nColumnType != mnColumnType )
90 : {
91 0 : mnColumnType = nColumnType;
92 0 : mrPagePropPanel.ExecuteColumnChange( mnColumnType );
93 : }
94 : }
95 :
96 0 : mrPagePropPanel.ClosePageColumnPopup();
97 0 : return 0;
98 : }
99 :
100 0 : IMPL_LINK(PageColumnControl, MoreButtonClickHdl_Impl, void *, EMPTYARG)
101 : {
102 0 : mrPagePropPanel.GetBindings()->GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SFX_CALLMODE_ASYNCHRON );
103 :
104 0 : mrPagePropPanel.ClosePageColumnPopup();
105 0 : return 0;
106 : }
107 :
108 :
109 99 : } } // end of namespace sw::sidebar
110 :
|