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 "TextUnderlineControl.hxx"
20 #include "TextPropertyPanel.hrc"
21 #include <sfx2/sidebar/ResourceDefinitions.hrc>
22 #include <svx/dialogs.hrc>
23 #include <svx/dialmgr.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/sidebar/Theme.hxx>
26 #include <editeng/udlnitem.hxx>
27 #include <vcl/settings.hxx>
29 namespace svx
{ namespace sidebar
{
31 TextUnderlineControl::TextUnderlineControl (
33 svx::sidebar::TextPropertyPanel
& rPanel
,
34 SfxBindings
* pBindings
)
35 : svx::sidebar::PopupControl( pParent
,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE
))
36 , mrTextPropertyPanel(rPanel
)
37 , mpBindings(pBindings
)
38 , maVSUnderline( this, SVX_RES(VS_UNDERLINE
))
39 , maPBOptions (this, SVX_RES(PB_OPTIONS
) )
41 , maIMGSingle (SVX_RES(IMG_SINGLE
))
42 , maIMGDouble (SVX_RES(IMG_DOUBLE
))
43 , maIMGBold (SVX_RES(IMG_BOLD2
))
44 , maIMGDot (SVX_RES(IMG_DOT
))
45 , maIMGDotBold (SVX_RES(IMG_DOT_BOLD
))
46 , maIMGDash (SVX_RES(IMG_DASH
))
47 , maIMGDashLong (SVX_RES(IMG_DASH_LONG
))
48 , maIMGDashDot (SVX_RES(IMG_DASH_DOT
))
49 , maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT
))
50 , maIMGWave (SVX_RES(IMG_WAVE
))
52 , maIMGSingleSel (SVX_RES(IMG_SINGLE_SEL
))
53 , maIMGDoubleSel (SVX_RES(IMG_DOUBLE_SEL
))
54 , maIMGBoldSel (SVX_RES(IMG_BOLD2_SEL
))
55 , maIMGDotSel (SVX_RES(IMG_DOT_SEL
))
56 , maIMGDotBoldSel (SVX_RES(IMG_DOT_BOLD_SEL
))
57 , maIMGDashSel (SVX_RES(IMG_DASH_SEL
))
58 , maIMGDashLongSel (SVX_RES(IMG_DASH_LONG_SEL
))
59 , maIMGDashDotSel (SVX_RES(IMG_DASH_DOT_SEL
))
60 , maIMGDashDotDotSel (SVX_RES(IMG_DASH_DOT_DOT_SEL
))
61 , maIMGWaveSel (SVX_RES(IMG_WAVE_SEL
))
68 void TextUnderlineControl::initial()
70 maVSUnderline
.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
71 GetSettings().GetStyleSettings().GetMenuColor():
72 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
));
73 maVSUnderline
.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
74 GetSettings().GetStyleSettings().GetMenuColor():
75 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
));
77 Link aLink
= LINK( this, TextUnderlineControl
, PBClickHdl
) ;
78 maPBOptions
.SetClickHdl(aLink
);
80 maVSUnderline
.SetStyle( maVSUnderline
.GetStyle()| WB_3DLOOK
| WB_NO_DIRECTSELECT
);
83 maVSUnderline
.SetStyle( maVSUnderline
.GetStyle()| WB_NONEFIELD
| WB_MENUSTYLEVALUESET
);
84 maVSUnderline
.SetText( SVX_RESSTR(STR_WITHOUT
) );
86 maVSUnderline
.InsertItem(1, maIMGSingle
, SVX_RESSTR(STR_SINGLE
));
87 maVSUnderline
.SetItemData(1, (void*)(sal_uInt64
)UNDERLINE_SINGLE
);
89 maVSUnderline
.InsertItem(2, maIMGDouble
, SVX_RESSTR(STR_DOUBLE
));
90 maVSUnderline
.SetItemData(2, (void*)(sal_uInt64
)UNDERLINE_DOUBLE
);
92 maVSUnderline
.InsertItem(3, maIMGBold
, SVX_RESSTR(STR_BOLD
));
93 maVSUnderline
.SetItemData(3,(void*)(sal_uInt64
)UNDERLINE_BOLD
);
95 maVSUnderline
.InsertItem(4, maIMGDot
, SVX_RESSTR(STR_DOT
));
96 maVSUnderline
.SetItemData(4,(void*)(sal_uInt64
)UNDERLINE_DOTTED
);
98 maVSUnderline
.InsertItem(5, maIMGDotBold
, SVX_RESSTR(STR_DOT_BOLD
));
99 maVSUnderline
.SetItemData(5,(void*)(sal_uInt64
)UNDERLINE_BOLDDOTTED
);
101 maVSUnderline
.InsertItem(6, maIMGDash
, SVX_RESSTR(STR_DASH
));
102 maVSUnderline
.SetItemData(6,(void*)(sal_uInt64
)UNDERLINE_DASH
);
104 maVSUnderline
.InsertItem(7, maIMGDashLong
, SVX_RESSTR(STR_DASH_LONG
));
105 maVSUnderline
.SetItemData(7,(void*)(sal_uInt64
)UNDERLINE_LONGDASH
);
107 maVSUnderline
.InsertItem(8, maIMGDashDot
, SVX_RESSTR(STR_DASH_DOT
));
108 maVSUnderline
.SetItemData(8,(void*)(sal_uInt64
)UNDERLINE_DASHDOT
);
110 maVSUnderline
.InsertItem(9, maIMGDashDotDot
, SVX_RESSTR(STR_DASH_DOT_DOT
));
111 maVSUnderline
.SetItemData(9,(void*)(sal_uInt64
)UNDERLINE_DASHDOTDOT
);
113 maVSUnderline
.InsertItem(10, maIMGWave
, SVX_RESSTR(STR_WAVE
));
114 maVSUnderline
.SetItemData(10,(void*)(sal_uInt64
)UNDERLINE_WAVE
);
116 maVSUnderline
.SetColCount( 1 );
117 aLink
= LINK( this, TextUnderlineControl
, VSSelectHdl
) ;
118 maVSUnderline
.SetSelectHdl(aLink
);
120 maVSUnderline
.StartSelection();
121 maVSUnderline
.Show();
125 void TextUnderlineControl::Rearrange(FontUnderline eLine
)
127 maVSUnderline
.SetItemImage(1, maIMGSingle
);
128 maVSUnderline
.SetItemImage(2, maIMGDouble
);
129 maVSUnderline
.SetItemImage(3, maIMGBold
);
130 maVSUnderline
.SetItemImage(4, maIMGDot
);
131 maVSUnderline
.SetItemImage(5, maIMGDotBold
);
132 maVSUnderline
.SetItemImage(6, maIMGDash
);
133 maVSUnderline
.SetItemImage(7, maIMGDashLong
);
134 maVSUnderline
.SetItemImage(8, maIMGDashDot
);
135 maVSUnderline
.SetItemImage(9, maIMGDashDotDot
);
136 maVSUnderline
.SetItemImage(10, maIMGWave
);
140 case UNDERLINE_SINGLE
:
141 maVSUnderline
.SetItemImage(1, maIMGSingleSel
);
142 maVSUnderline
.SelectItem(1);
143 maVSUnderline
.GrabFocus();
145 case UNDERLINE_DOUBLE
:
146 maVSUnderline
.SetItemImage(2, maIMGDoubleSel
);
147 maVSUnderline
.SelectItem(2);
148 maVSUnderline
.GrabFocus();
151 maVSUnderline
.SetItemImage(3, maIMGBoldSel
);
152 maVSUnderline
.SelectItem(3);
153 maVSUnderline
.GrabFocus();
155 case UNDERLINE_DOTTED
:
156 maVSUnderline
.SetItemImage(4, maIMGDotSel
);
157 maVSUnderline
.SelectItem(4);
158 maVSUnderline
.GrabFocus();
160 case UNDERLINE_BOLDDOTTED
:
161 maVSUnderline
.SetItemImage(5, maIMGDotBoldSel
);
162 maVSUnderline
.SelectItem(5);
163 maVSUnderline
.GrabFocus();
166 maVSUnderline
.SetItemImage(6, maIMGDashSel
);
167 maVSUnderline
.SelectItem(6);
168 maVSUnderline
.GrabFocus();
170 case UNDERLINE_LONGDASH
:
171 maVSUnderline
.SetItemImage(7, maIMGDashLongSel
);
172 maVSUnderline
.SelectItem(7);
173 maVSUnderline
.GrabFocus();
175 case UNDERLINE_DASHDOT
:
176 maVSUnderline
.SetItemImage(8, maIMGDashDotSel
);
177 maVSUnderline
.SelectItem(8);
178 maVSUnderline
.GrabFocus();
180 case UNDERLINE_DASHDOTDOT
:
181 maVSUnderline
.SetItemImage(9, maIMGDashDotDotSel
);
182 maVSUnderline
.SelectItem(9);
183 maVSUnderline
.GrabFocus();
186 maVSUnderline
.SetItemImage(10, maIMGWaveSel
);
187 maVSUnderline
.SelectItem(10);
188 maVSUnderline
.GrabFocus();
191 maVSUnderline
.SelectItem(0);
192 maVSUnderline
.GrabFocus();
195 maVSUnderline
.SelectItem(1);
196 maVSUnderline
.SetNoSelection();
197 maPBOptions
.GrabFocus();
199 maVSUnderline
.StartSelection();
203 IMPL_LINK(TextUnderlineControl
, VSSelectHdl
, void *, pControl
)
205 if ( pControl
== &maVSUnderline
)
207 const sal_uInt16 iPos
= maVSUnderline
.GetSelectItemId();
208 const FontUnderline eUnderline
= ( iPos
== 0 )
210 : (FontUnderline
)(sal_uInt64
)maVSUnderline
.GetItemData( iPos
);
212 SvxUnderlineItem
aLineItem(eUnderline
, SID_ATTR_CHAR_UNDERLINE
);
214 aLineItem
.SetColor(mrTextPropertyPanel
.GetUnderlineColor());
215 mpBindings
->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE
, SFX_CALLMODE_RECORD
, &aLineItem
, 0L);
216 mrTextPropertyPanel
.EndUnderlinePopupMode();
221 IMPL_LINK(TextUnderlineControl
, PBClickHdl
, PushButton
*, pPBtn
)
223 if(pPBtn
== &maPBOptions
)
227 SfxDispatcher
* pDisp
= mpBindings
->GetDispatcher();
228 pDisp
->Execute( SID_CHAR_DLG_EFFECT
, SFX_CALLMODE_ASYNCHRON
);
230 mrTextPropertyPanel
.EndUnderlinePopupMode();
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */