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 #include "precompiled_svx.hxx"
23 #include "ParaBulletsControl.hxx"
24 #include "ParaPropertyPanel.hrc"
25 #include <sfx2/sidebar/propertypanel.hrc>
26 #include <svx/dialogs.hrc>
27 #include <svx/dialmgr.hxx>
28 #include <unotools/viewoptions.hxx>
29 #include <editeng/kernitem.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <sfx2/sidebar/Theme.hxx>
33 #include <svtools/unitconv.hxx>
34 #include <svx/nbdtmg.hxx>
35 #include <svx/nbdtmgfact.hxx>
36 
37 namespace svx { namespace sidebar {
38 
39 ParaBulletsControl::ParaBulletsControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel):
40 	PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_BULLETS)),
41 	mrParaPropertyPanel(rPanel),
42 	mpBindings(NULL),
43 	maBulletsVS(this,SVX_RES(VS_VALUES)),
44 	maFISep(this,SVX_RES(IMG_SEPERATOR_BULLET)),
45 	maMoreButton(this,SVX_RES(CB_BULLET_MORE))
46 {
47 	FreeResource();
48 	mpBindings = mrParaPropertyPanel.GetBindings();
49 	maBulletsVS.SetColCount(3);
50 	maBulletsVS.SetLineCount(3);
51 	maBulletsVS.SetStyle( maBulletsVS.GetStyle() | WB_ITEMBORDER |WB_NO_DIRECTSELECT);
52 	maBulletsVS.SetExtraSpacing(BULLET_IMAGE_SPACING);
53 	if(GetSettings().GetStyleSettings().GetHighContrastMode())
54 		maBulletsVS.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
55 	else
56 		maBulletsVS.SetBackground(Color(244,245,249));
57 
58 	maBulletsVS.SetItemWidth(BULLET_IMAGE_WIDTH);
59 	maBulletsVS.SetItemHeight(BULLET_IMAGE_HEIGHT);
60  	maBulletsVS.InsertItem( DEFAULT_NONE );
61  	for( sal_uInt16 nVSIdx = 1; nVSIdx <= DEFAULT_BULLET_TYPES; ++nVSIdx )
62     	{
63        	maBulletsVS.InsertItem( nVSIdx );
64     	}
65 
66 	maBulletsVS.SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
67 	NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
68 	if ( pBullets )
69 	{
70 		for( sal_uInt16 nIndex = 0; nIndex < DEFAULT_BULLET_TYPES; ++nIndex )
71 		{
72 			maBulletsVS.SetItemText( nIndex + 1, pBullets->GetDescription(nIndex) );
73 		}
74 	}
75 
76     maBulletsVS.Show();
77 	maBulletsVS.SetSelectHdl(LINK(this, ParaBulletsControl, BulletSelectHdl_Impl));
78 
79 	/*maMoreButton.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
80 		GetSettings().GetStyleSettings().GetMenuColor():
81 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_DropDownBackground ));//Color(244,245,249)//for high contract
82 	maMoreButton.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
83 		GetSettings().GetStyleSettings().GetMenuColor():
84 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );//Color( 93, 120, 163 )
85 	maMoreButton.SetHoverTxtColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_PanelTitleFont ) );//Color( 255, 255, 255 )
86 	maMoreButton.SetIcoPosX( 2);*/
87 	maBulletsVS.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
88 		GetSettings().GetStyleSettings().GetMenuColor():
89 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
90 	maBulletsVS.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
91 		GetSettings().GetStyleSettings().GetMenuColor():
92 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
93 
94 	maMoreButton.SetClickHdl(LINK(this, ParaBulletsControl, MoreButtonClickHdl_Impl));
95 
96 }
97 
98 ParaBulletsControl::~ParaBulletsControl()
99 {
100 
101 }
102 
103 void ParaBulletsControl::UpdateValueSet()
104 {
105 	maBulletsVS.StateChanged(STATE_CHANGE_STYLE);
106 	maBulletsVS.StateChanged(STATE_CHANGE_INITSHOW);
107 }
108 void ParaBulletsControl::ToGetFocus()
109 {
110 	sal_uInt16 nTypeIndex = (sal_uInt16)0xFFFF;
111 	mrParaPropertyPanel.GetBulletTypeIndex();
112 	if ( nTypeIndex != (sal_uInt16)0xFFFF )
113 		maBulletsVS.SelectItem( nTypeIndex );
114 	else
115 	{
116 		maBulletsVS.SelectItem(0);
117 	}
118 	maMoreButton.GrabFocus();
119 }
120 
121 IMPL_LINK(ParaBulletsControl, BulletSelectHdl_Impl, ValueSet*, EMPTYARG)
122 {
123 	sal_uInt16 nIdx = maBulletsVS.GetSelectItemId();
124 	SfxUInt16Item aItem(FN_SVX_SET_BULLET, nIdx);
125 	if (mpBindings)
126 		mpBindings->GetDispatcher()->Execute( FN_SVX_SET_BULLET, SFX_CALLMODE_RECORD, &aItem, 0L );
127 
128 	mrParaPropertyPanel.EndBulletsPopupMode();
129 
130 	return 0;
131 }
132 
133 IMPL_LINK(ParaBulletsControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
134 {
135 	if (mpBindings)
136 		mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
137 
138 	mrParaPropertyPanel.EndBulletsPopupMode();
139 
140 	return 0;
141 }
142 
143 }} // end of namespace sidebar
144 
145 
146