@@ -51,15 +51,16 @@ void UiWindowX11::_display()
51
51
52
52
for ( size_t i = 0u ; i < _point.size (); ++i ) {
53
53
const Point2d & point = _point[i].point ;
54
- XSetForeground ( _uiDisplay, defaultGC, _point[i].color );
54
+ const uint32_t foreground = UiWindowX11::_convertColor ( _point[i].color );
55
+ XSetForeground ( _uiDisplay, defaultGC, foreground );
55
56
XDrawLine ( _uiDisplay, _window, defaultGC, static_cast <int >( point.x - 1 ), static_cast <int >( point.y - 1 ), static_cast <int >( point.x + 1 ),
56
57
static_cast <int >( point.y + 1 ) );
57
58
}
58
59
59
60
for ( size_t i = 0u ; i < _lines.size (); ++i ) {
60
61
const Point2d & start = _lines[i].start ;
61
62
const Point2d & end = _lines[i].end ;
62
- const uint32_t & foreground = _lines[i].color ;
63
+ const uint32_t foreground = UiWindowX11::_convertColor ( _lines[i].color ) ;
63
64
64
65
XSetForeground ( _uiDisplay, defaultGC, foreground );
65
66
XDrawLine ( _uiDisplay, _window, defaultGC, static_cast <int >( start.x ), static_cast <int >( start.y ), static_cast <int >( end.x ),
@@ -70,29 +71,34 @@ void UiWindowX11::_display()
70
71
const Point2d & position = _ellipses[i].topLeft ;
71
72
const double & width = _ellipses[i].width ;
72
73
const double & height = _ellipses[i].height ;
73
- const uint32_t & foreground = _ellipses[i].color ;
74
+ const uint32_t foreground = UiWindowX11::_convertColor ( _ellipses[i].color ) ;
74
75
75
76
XSetForeground ( _uiDisplay, defaultGC, foreground );
76
- XDrawArc ( _uiDisplay, _window, defaultGC, static_cast <int >( position.x ), static_cast <int >( position.y ), static_cast <int >( width ),
77
- static_cast <int >( height ), 0 , 360 * 64 );
77
+ XDrawArc ( _uiDisplay, _window, defaultGC, static_cast <int >( position.x ), static_cast <int >( position.y ), static_cast <uint32_t >( width ),
78
+ static_cast <uint32_t >( height ), 0 , 360 * 64 );
78
79
}
79
80
80
81
for ( size_t i = 0u ; i < _rectangles.size (); ++i ) {
81
82
const Point2d & topLeft = _rectangles[i].topLeft ;
82
83
const double & width = _rectangles[i].width ;
83
84
const double & height = _rectangles[i].height ;
84
- const uint32_t & foreground = _rectangles[i].color ;
85
+ const uint32_t foreground = UiWindowX11::_convertColor ( _rectangles[i].color ) ;
85
86
86
87
XSetForeground ( _uiDisplay, defaultGC, foreground );
87
- XDrawRectangle ( _uiDisplay, _window, defaultGC, static_cast <int >( topLeft.x ), static_cast <int >( topLeft.y ), static_cast <int >( width ),
88
- static_cast <int >( height ) );
88
+ XDrawRectangle ( _uiDisplay, _window, defaultGC, static_cast <int >( topLeft.x ), static_cast <int >( topLeft.y ), static_cast <uint32_t >( width ),
89
+ static_cast <uint32_t >( height ) );
89
90
}
90
91
}
91
92
else if ( (e.type == ClientMessage) && (static_cast <unsigned int >(e.xclient .data .l [0 ]) == _deleteWindowEvent) )
92
93
break ;
93
94
}
94
95
}
95
96
97
+ uint32_t UiWindowX11::_convertColor (const PaintColor &color)
98
+ {
99
+ return static_cast <uint32_t >( ( color.red << 16 ) + ( color.green << 8 ) + color.blue );
100
+ }
101
+
96
102
void UiWindowX11::_setupImage ( const penguinV::Image & image )
97
103
{
98
104
if ( image.empty () )
@@ -141,25 +147,25 @@ void UiWindowX11::_setupImage( const penguinV::Image & image )
141
147
142
148
void UiWindowX11::drawPoint ( const Point2d & point, const PaintColor & color )
143
149
{
144
- _point.push_back ( PointToDraw ( point, ( color. red << 16 ) + ( color. green << 8 ) + color. blue ) );
150
+ _point.push_back ( PointToDraw ( point, color ) );
145
151
}
146
152
147
153
void UiWindowX11::drawLine ( const Point2d & start, const Point2d & end, const PaintColor & color )
148
154
{
149
- _lines.push_back ( LineToDraw ( start, end, ( color. red << 16 ) + ( color. green << 8 ) + color. blue ) );
155
+ _lines.push_back ( LineToDraw ( start, end, color ) );
150
156
}
151
157
152
158
void UiWindowX11::drawEllipse ( const Point2d & center, double xRadius, double yRadius, const PaintColor & color )
153
159
{
154
160
// XDrawArc needs x and y coordinates of the upper-left corner of the bounding rectangle but not the center of the ellipse.
155
161
const Point2d position ( center.x - xRadius, center.y - yRadius );
156
162
157
- _ellipses.push_back ( EllipseToDraw ( position, xRadius * 2 , yRadius * 2 , ( color. red << 16 ) + ( color. green << 8 ) + color. blue ) );
163
+ _ellipses.push_back ( EllipseToDraw ( position, xRadius * 2 , yRadius * 2 , color ) );
158
164
}
159
165
160
166
void UiWindowX11::drawRectangle ( const Point2d & topLeftCorner, double width, double height, const PaintColor & color )
161
167
{
162
- _rectangles.push_back ( RectangleToDraw ( topLeftCorner, width, height, ( color. red << 16 ) + ( color. green << 8 ) + color. blue ) );
168
+ _rectangles.push_back ( RectangleToDraw ( topLeftCorner, width, height, color ) );
163
169
}
164
170
165
171
#endif
0 commit comments