1*766ce4d0SZheng Fan /**************************************************************
2*766ce4d0SZheng Fan  *
3*766ce4d0SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
4*766ce4d0SZheng Fan  * or more contributor license agreements.  See the NOTICE file
5*766ce4d0SZheng Fan  * distributed with this work for additional information
6*766ce4d0SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
7*766ce4d0SZheng Fan  * to you under the Apache License, Version 2.0 (the
8*766ce4d0SZheng Fan  * "License"); you may not use this file except in compliance
9*766ce4d0SZheng Fan  * with the License.  You may obtain a copy of the License at
10*766ce4d0SZheng Fan  *
11*766ce4d0SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
12*766ce4d0SZheng Fan  *
13*766ce4d0SZheng Fan  * Unless required by applicable law or agreed to in writing,
14*766ce4d0SZheng Fan  * software distributed under the License is distributed on an
15*766ce4d0SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*766ce4d0SZheng Fan  * KIND, either express or implied.  See the License for the
17*766ce4d0SZheng Fan  * specific language governing permissions and limitations
18*766ce4d0SZheng Fan  * under the License.
19*766ce4d0SZheng Fan  *
20*766ce4d0SZheng Fan  *************************************************************/
21*766ce4d0SZheng Fan 
22*766ce4d0SZheng Fan #include "precompiled_svx.hxx"
23*766ce4d0SZheng Fan #include "ParaBulletsControl.hxx"
24*766ce4d0SZheng Fan #include "ParaPropertyPanel.hrc"
25*766ce4d0SZheng Fan #include <sfx2/sidebar/propertypanel.hrc>
26*766ce4d0SZheng Fan #include <svx/dialogs.hrc>
27*766ce4d0SZheng Fan #include <svx/dialmgr.hxx>
28*766ce4d0SZheng Fan #include <unotools/viewoptions.hxx>
29*766ce4d0SZheng Fan #include <editeng/kernitem.hxx>
30*766ce4d0SZheng Fan #include <sfx2/bindings.hxx>
31*766ce4d0SZheng Fan #include <sfx2/dispatch.hxx>
32*766ce4d0SZheng Fan #include <sfx2/sidebar/Theme.hxx>
33*766ce4d0SZheng Fan #include <svtools/unitconv.hxx>
34*766ce4d0SZheng Fan #include <svx/nbdtmg.hxx>
35*766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx>
36*766ce4d0SZheng Fan 
37*766ce4d0SZheng Fan namespace svx { namespace sidebar {
38*766ce4d0SZheng Fan 
39*766ce4d0SZheng Fan ParaBulletsControl::ParaBulletsControl(Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel):
40*766ce4d0SZheng Fan 	PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_BULLETS)),
41*766ce4d0SZheng Fan 	mrParaPropertyPanel(rPanel),
42*766ce4d0SZheng Fan 	mpBindings(NULL),
43*766ce4d0SZheng Fan 	maBulletsVS(this,SVX_RES(VS_VALUES)),
44*766ce4d0SZheng Fan 	maFISep(this,SVX_RES(IMG_SEPERATOR_BULLET)),
45*766ce4d0SZheng Fan 	maMoreButton(this,SVX_RES(CB_BULLET_MORE))
46*766ce4d0SZheng Fan {
47*766ce4d0SZheng Fan 	FreeResource();
48*766ce4d0SZheng Fan 	mpBindings = mrParaPropertyPanel.GetBindings();
49*766ce4d0SZheng Fan 	maBulletsVS.SetColCount(3);
50*766ce4d0SZheng Fan 	maBulletsVS.SetLineCount(3);
51*766ce4d0SZheng Fan 	maBulletsVS.SetStyle( maBulletsVS.GetStyle() | WB_ITEMBORDER |WB_NO_DIRECTSELECT);
52*766ce4d0SZheng Fan 	maBulletsVS.SetExtraSpacing(BULLET_IMAGE_SPACING);
53*766ce4d0SZheng Fan 	if(GetSettings().GetStyleSettings().GetHighContrastMode())
54*766ce4d0SZheng Fan 		maBulletsVS.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
55*766ce4d0SZheng Fan 	else
56*766ce4d0SZheng Fan 		maBulletsVS.SetBackground(Color(244,245,249));
57*766ce4d0SZheng Fan 
58*766ce4d0SZheng Fan 	maBulletsVS.SetItemWidth(BULLET_IMAGE_WIDTH);
59*766ce4d0SZheng Fan 	maBulletsVS.SetItemHeight(BULLET_IMAGE_HEIGHT);
60*766ce4d0SZheng Fan  	maBulletsVS.InsertItem( DEFAULT_NONE );
61*766ce4d0SZheng Fan  	for( sal_uInt16 nVSIdx = 1; nVSIdx <= DEFAULT_BULLET_TYPES; ++nVSIdx )
62*766ce4d0SZheng Fan     	{
63*766ce4d0SZheng Fan        	maBulletsVS.InsertItem( nVSIdx );
64*766ce4d0SZheng Fan     	}
65*766ce4d0SZheng Fan 
66*766ce4d0SZheng Fan 	maBulletsVS.SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
67*766ce4d0SZheng Fan 	NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
68*766ce4d0SZheng Fan 	if ( pBullets )
69*766ce4d0SZheng Fan 	{
70*766ce4d0SZheng Fan 		for( sal_uInt16 nIndex = 0; nIndex < DEFAULT_BULLET_TYPES; ++nIndex )
71*766ce4d0SZheng Fan 		{
72*766ce4d0SZheng Fan 			maBulletsVS.SetItemText( nIndex + 1, pBullets->GetDescription(nIndex) );
73*766ce4d0SZheng Fan 		}
74*766ce4d0SZheng Fan 	}
75*766ce4d0SZheng Fan 
76*766ce4d0SZheng Fan     maBulletsVS.Show();
77*766ce4d0SZheng Fan 	maBulletsVS.SetSelectHdl(LINK(this, ParaBulletsControl, BulletSelectHdl_Impl));
78*766ce4d0SZheng Fan 
79*766ce4d0SZheng Fan 	/*maMoreButton.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
80*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
81*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_DropDownBackground ));//Color(244,245,249)//for high contract
82*766ce4d0SZheng Fan 	maMoreButton.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
83*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
84*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );//Color( 93, 120, 163 )
85*766ce4d0SZheng Fan 	maMoreButton.SetHoverTxtColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_PanelTitleFont ) );//Color( 255, 255, 255 )
86*766ce4d0SZheng Fan 	maMoreButton.SetIcoPosX( 2);*/
87*766ce4d0SZheng Fan 	maBulletsVS.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
88*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
89*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
90*766ce4d0SZheng Fan 	maBulletsVS.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
91*766ce4d0SZheng Fan 		GetSettings().GetStyleSettings().GetMenuColor():
92*766ce4d0SZheng Fan 		sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
93*766ce4d0SZheng Fan 
94*766ce4d0SZheng Fan 	maMoreButton.SetClickHdl(LINK(this, ParaBulletsControl, MoreButtonClickHdl_Impl));
95*766ce4d0SZheng Fan 
96*766ce4d0SZheng Fan }
97*766ce4d0SZheng Fan 
98*766ce4d0SZheng Fan ParaBulletsControl::~ParaBulletsControl()
99*766ce4d0SZheng Fan {
100*766ce4d0SZheng Fan 
101*766ce4d0SZheng Fan }
102*766ce4d0SZheng Fan 
103*766ce4d0SZheng Fan void ParaBulletsControl::UpdateValueSet()
104*766ce4d0SZheng Fan {
105*766ce4d0SZheng Fan 	maBulletsVS.StateChanged(STATE_CHANGE_STYLE);
106*766ce4d0SZheng Fan 	maBulletsVS.StateChanged(STATE_CHANGE_INITSHOW);
107*766ce4d0SZheng Fan }
108*766ce4d0SZheng Fan void ParaBulletsControl::ToGetFocus()
109*766ce4d0SZheng Fan {
110*766ce4d0SZheng Fan 	sal_uInt16 nTypeIndex = (sal_uInt16)0xFFFF;
111*766ce4d0SZheng Fan 	mrParaPropertyPanel.GetBulletTypeIndex();
112*766ce4d0SZheng Fan 	if ( nTypeIndex != (sal_uInt16)0xFFFF )
113*766ce4d0SZheng Fan 		maBulletsVS.SelectItem( nTypeIndex );
114*766ce4d0SZheng Fan 	else
115*766ce4d0SZheng Fan 	{
116*766ce4d0SZheng Fan 		maBulletsVS.SelectItem(0);
117*766ce4d0SZheng Fan 	}
118*766ce4d0SZheng Fan 	maMoreButton.GrabFocus();
119*766ce4d0SZheng Fan }
120*766ce4d0SZheng Fan 
121*766ce4d0SZheng Fan IMPL_LINK(ParaBulletsControl, BulletSelectHdl_Impl, ValueSet*, EMPTYARG)
122*766ce4d0SZheng Fan {
123*766ce4d0SZheng Fan 	sal_uInt16 nIdx = maBulletsVS.GetSelectItemId();
124*766ce4d0SZheng Fan 	SfxUInt16Item aItem(FN_SVX_SET_BULLET, nIdx);
125*766ce4d0SZheng Fan 	if (mpBindings)
126*766ce4d0SZheng Fan 		mpBindings->GetDispatcher()->Execute( FN_SVX_SET_BULLET, SFX_CALLMODE_RECORD, &aItem, 0L );
127*766ce4d0SZheng Fan 
128*766ce4d0SZheng Fan 	mrParaPropertyPanel.EndBulletsPopupMode();
129*766ce4d0SZheng Fan 
130*766ce4d0SZheng Fan 	return 0;
131*766ce4d0SZheng Fan }
132*766ce4d0SZheng Fan 
133*766ce4d0SZheng Fan IMPL_LINK(ParaBulletsControl, MoreButtonClickHdl_Impl, void*, EMPTYARG)
134*766ce4d0SZheng Fan {
135*766ce4d0SZheng Fan 	if (mpBindings)
136*766ce4d0SZheng Fan 		mpBindings->GetDispatcher()->Execute( SID_OUTLINE_BULLET, SFX_CALLMODE_ASYNCHRON );
137*766ce4d0SZheng Fan 
138*766ce4d0SZheng Fan 	mrParaPropertyPanel.EndBulletsPopupMode();
139*766ce4d0SZheng Fan 
140*766ce4d0SZheng Fan 	return 0;
141*766ce4d0SZheng Fan }
142*766ce4d0SZheng Fan 
143*766ce4d0SZheng Fan }} // end of namespace sidebar
144*766ce4d0SZheng Fan 
145*766ce4d0SZheng Fan 
146