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