1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "ParaBulletsControl.hxx"
20 #include "ParaPropertyPanel.hrc"
21 #include <sfx2/sidebar/ResourceDefinitions.hrc>
22 #include <svx/dialogs.hrc>
23 #include <svx/dialmgr.hxx>
24 #include <unotools/viewoptions.hxx>
25 #include <editeng/kernitem.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include <sfx2/sidebar/Theme.hxx>
29 #include <svtools/unitconv.hxx>
30 #include <svx/nbdtmg.hxx>
31 #include <svx/nbdtmgfact.hxx>
32 #include <vcl/settings.hxx>
34 namespace svx
{ namespace sidebar
{
36 ParaBulletsControl::ParaBulletsControl(
38 svx::sidebar::ParaPropertyPanel
& rPanel
)
39 : PopupControl( pParent
,SVX_RES(RID_POPUPPANEL_PARAPAGE_BULLETS
) )
40 , maBulletsVS( this,SVX_RES(VS_VALUES
) )
41 , maMoreButton( this,SVX_RES(CB_BULLET_MORE
) )
42 , mrParaPropertyPanel( rPanel
)
43 , mpBindings( mrParaPropertyPanel
.GetBindings() )
47 maBulletsVS
.SetColCount(3);
48 maBulletsVS
.SetLineCount(3);
49 maBulletsVS
.SetStyle( maBulletsVS
.GetStyle() | WB_ITEMBORDER
|WB_NO_DIRECTSELECT
);
50 maBulletsVS
.SetExtraSpacing(BULLET_IMAGE_SPACING
);
51 maBulletsVS
.SetItemWidth(BULLET_IMAGE_WIDTH
);
52 maBulletsVS
.SetItemHeight(BULLET_IMAGE_HEIGHT
);
53 maBulletsVS
.InsertItem( DEFAULT_NONE
);
54 for( sal_uInt16 nVSIdx
= 1; nVSIdx
<= DEFAULT_BULLET_TYPES
; ++nVSIdx
)
56 maBulletsVS
.InsertItem( nVSIdx
);
59 maBulletsVS
.SetItemText( DEFAULT_NONE
, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE
));
60 NBOTypeMgrBase
* pBullets
= NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS
);
63 for( sal_uInt16 nIndex
= 0; nIndex
< DEFAULT_BULLET_TYPES
; ++nIndex
)
65 maBulletsVS
.SetItemText( nIndex
+ 1, pBullets
->GetDescription(nIndex
) );
70 maBulletsVS
.SetSelectHdl(LINK(this, ParaBulletsControl
, BulletSelectHdl_Impl
));
72 maBulletsVS
.SetColor( GetSettings().GetStyleSettings().GetHighContrastMode()
73 ? GetSettings().GetStyleSettings().GetMenuColor()
74 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
) );
75 maBulletsVS
.SetBackground( GetSettings().GetStyleSettings().GetHighContrastMode()
76 ? GetSettings().GetStyleSettings().GetMenuColor()
77 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
) );
79 maMoreButton
.SetClickHdl(LINK(this, ParaBulletsControl
, MoreButtonClickHdl_Impl
));
84 ParaBulletsControl::~ParaBulletsControl()
89 void ParaBulletsControl::UpdateValueSet()
91 maBulletsVS
.StateChanged(STATE_CHANGE_STYLE
);
92 maBulletsVS
.StateChanged(STATE_CHANGE_INITSHOW
);
94 const sal_uInt16 nTypeIndex
= mrParaPropertyPanel
.GetBulletTypeIndex();
95 if ( nTypeIndex
!= (sal_uInt16
)0xFFFF )
96 maBulletsVS
.SelectItem( nTypeIndex
);
99 maBulletsVS
.SelectItem(0);
101 maMoreButton
.GrabFocus();
105 IMPL_LINK(ParaBulletsControl
, BulletSelectHdl_Impl
, ValueSet
*, EMPTYARG
)
107 const sal_uInt16 nIdx
= maBulletsVS
.GetSelectItemId();
108 SfxUInt16Item
aItem( FN_SVX_SET_BULLET
, nIdx
);
110 mpBindings
->GetDispatcher()->Execute( FN_SVX_SET_BULLET
, SFX_CALLMODE_RECORD
, &aItem
, 0L );
112 mrParaPropertyPanel
.EndBulletsPopupMode();
118 IMPL_LINK(ParaBulletsControl
, MoreButtonClickHdl_Impl
, void*, EMPTYARG
)
121 mpBindings
->GetDispatcher()->Execute( SID_OUTLINE_BULLET
, SFX_CALLMODE_ASYNCHRON
);
123 mrParaPropertyPanel
.EndBulletsPopupMode();
128 }} // end of namespace sidebar
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */