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_sfx2.hxx"
23
24 #include "CustomImageRadioButton.hxx"
25
26 #include "DrawHelper.hxx"
27 #include "Paint.hxx"
28 #include "sfx2/sidebar/Tools.hxx"
29
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32
33 namespace sfx2 { namespace sidebar {
34
CustomImageRadioButton(Window * pParentWindow,const ResId & rResId)35 CustomImageRadioButton::CustomImageRadioButton (
36 Window* pParentWindow,
37 const ResId& rResId )
38 : ImageRadioButton( pParentWindow, rResId )
39 {
40 SetStyle( GetStyle() | WB_NOPOINTERFOCUS );
41 }
42
~CustomImageRadioButton(void)43 CustomImageRadioButton::~CustomImageRadioButton (void)
44 {
45 }
46
Paint(const Rectangle &)47 void CustomImageRadioButton::Paint (const Rectangle& /* rUpdateArea */)
48 {
49 Rectangle aPaintRect( Rectangle(Point(0,0), GetSizePixel() ) );
50 SetMouseRect( aPaintRect );
51 SetStateRect( aPaintRect );
52
53 const Theme::ThemeItem eBackground =
54 IsMouseOver()
55 ? Theme::Paint_TabItemBackgroundHighlight
56 : Theme::Paint_PanelBackground;
57 DrawHelper::DrawRoundedRectangle(
58 *this,
59 aPaintRect,
60 Theme::GetInteger(Theme::Int_ButtonCornerRadius),
61 IsChecked() || IsMouseOver() ? Theme::GetColor(Theme::Color_TabItemBorder) : Color(0xffffffff),
62 Theme::GetPaint( eBackground ) );
63
64 const Image aIcon (GetModeRadioImage(Theme::IsHighContrastMode()
65 ? BMP_COLOR_HIGHCONTRAST
66 : BMP_COLOR_NORMAL));
67 const Size aIconSize (aIcon.GetSizePixel());
68 const Point aIconLocation(
69 (GetSizePixel().Width() - aIconSize.Width())/2,
70 (GetSizePixel().Height() - aIconSize.Height())/2 );
71 DrawImage(
72 aIconLocation,
73 aIcon,
74 IsEnabled() ? 0 : IMAGE_DRAW_DISABLE );
75 }
76
77 } } // end of namespace sfx2::sidebar
78
79 /* vim: set noet sw=4 ts=4: */
80