1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Alexander Olk, alex.olk@googlemail.com
25 // based on ThemeWin32Classic
27 // - You can activate this Theme with export MONO_THEME=clearlooks
29 // This theme tries to match clearlooks theme
32 // - if an other control draws over a ScrollBar button you can see artefacts on the rounded edges
33 // (maybe use theme backcolor, but that looks ugly on a white background, need to find a way to get the backcolor of the parent control)
34 // - more correct drawing of disabled controls
37 using System.Drawing.Drawing2D;
38 using System.Drawing.Imaging;
39 using System.Drawing.Text;
41 namespace System.Windows.Forms {
42 internal class ThemeClearlooks : ThemeWin32Classic {
43 public override Version Version {
45 return new Version( 0, 0, 0, 2 );
49 static readonly Color theme_back_color = Color.FromArgb( 239, 235, 231 );
51 static readonly Color gradient_first_color = Color.FromArgb( 250, 248, 247 );
52 static readonly Color gradient_second_color = Color.FromArgb( 226, 219, 212 );
53 static readonly Color gradient_second_color_nr2 = Color.FromArgb( 234, 229, 224 );
54 static readonly Color pressed_gradient_first_color = Color.FromArgb( 217, 207, 202 );
55 static readonly Color pressed_gradient_second_color = Color.FromArgb( 199, 193, 187 );
56 static readonly Color border_normal_dark_color = Color.FromArgb( 129, 117, 106 );
57 static readonly Color border_normal_light_color = Color.FromArgb( 158, 145, 131 );
58 static readonly Color border_pressed_dark_color = Color.FromArgb( 109, 103, 98 );
59 static readonly Color border_pressed_light_color = Color.FromArgb( 120, 114, 107 );
60 static readonly Color button_outer_border_dark_color = Color.FromArgb( 232, 226, 220 );
61 static readonly Color button_outer_border_light_color = Color.FromArgb( 250, 248, 247 );
62 static readonly Color inner_border_dark_color = Color.FromArgb( 226, 219, 212 );
63 static readonly Color pressed_inner_border_dark_color = Color.FromArgb( 192, 181, 169 );
64 static readonly Color edge_top_inner_color = Color.FromArgb( 206, 200, 194 );
65 static readonly Color edge_bottom_inner_color = Color.FromArgb( 215, 209, 202 );
66 static readonly Color button_edge_top_outer_color = Color.FromArgb( 237, 233, 228 );
67 static readonly Color button_edge_bottom_outer_color = Color.FromArgb( 243, 239, 236 );
68 static readonly Color button_focus_color = Color.FromArgb( 101, 94, 86 );
69 static readonly Color button_mouse_entered_second_gradient_color = Color.FromArgb( 230, 226, 219 );
71 static readonly Color scrollbar_background_color = Color.FromArgb( 209, 200, 191 );
72 static readonly Color scrollbar_border_color = Color.FromArgb( 170, 156, 143 );
73 static readonly Color scrollbar_gradient_first_color = Color.FromArgb( 248, 247, 245 );
74 static readonly Color scrollbar_gradient_second_color = Color.FromArgb( 234, 229, 224 );
76 static readonly Color arrow_color = Color.FromArgb( 16, 16, 16 );
78 static readonly Color tab_border_color = Color.FromArgb( 166, 151, 138 );
79 static readonly Color tab_not_selected_gradient_first_color = Color.FromArgb( 227, 223, 220 );
80 static readonly Color tab_not_selected_gradient_second_color = Color.FromArgb( 214, 209, 204 );
81 static readonly Color tab_selected_gradient_first_color = Color.FromArgb( 243, 239, 236 );
82 static readonly Color tab_selected_gradient_second_color = Color.FromArgb( 234, 228, 223 );
83 static readonly Color tab_edge_color = Color.FromArgb( 200, 196, 191 );
84 static readonly Color tab_inner_border_color = Color.FromArgb( 221, 212, 205 );
85 static readonly Color tab_top_border_focus_color = Color.FromArgb( 70, 91, 110 );
86 static readonly Color tab_focus_color = Color.FromArgb( 105, 147, 185 );
88 static readonly Color menuitem_gradient_first_color = Color.FromArgb( 98, 140, 178 );
89 static readonly Color menuitem_gradient_second_color = Color.FromArgb( 81, 113, 142 );
90 static readonly Color menuitem_border_color = Color.FromArgb( 80, 112, 141 );
91 static readonly Color menu_separator_color = Color.FromArgb( 219, 211, 203 );
92 static readonly Color menu_background_color = Color.FromArgb( 248, 245, 242 );
93 static readonly Color menu_border_color = Color.FromArgb( 141, 122, 104 );
94 static readonly Color menu_inner_border_color = Color.FromArgb( 236, 228, 221 );
96 static readonly Color combobox_border_color = Color.FromArgb( 159, 146, 132 );
97 static readonly Color combobox_focus_border_color = Color.FromArgb( 70, 91, 110 );
98 static readonly Color combobox_focus_inner_border_color = Color.FromArgb( 167, 198, 225 );
99 static readonly Color combobox_button_second_gradient_color = Color.FromArgb( 226, 220, 213 );
101 static readonly Color progressbar_edge_dot_color = Color.FromArgb( 219, 212, 205 );
102 static readonly Color progressbar_inner_border_color = Color.FromArgb( 139, 176, 209 );
103 static readonly Color progressbar_first_gradient_color = Color.FromArgb( 104, 146, 184 );
104 static readonly Color progressbar_second_gradient_color = Color.FromArgb( 91, 133, 172 );
106 static readonly Color checkbox_inner_boder_color = Color.FromArgb( 237, 234, 231 );
107 static readonly Color checkbox_pressed_inner_boder_color = Color.FromArgb( 203, 196, 189 );
108 static readonly Color checkbox_pressed_backcolor = Color.FromArgb( 212, 207, 202 );
110 static readonly Color trackbar_second_gradient_color = Color.FromArgb( 114, 154, 190 );
111 static readonly Color trackbar_third_gradient_color = Color.FromArgb( 130, 168, 202 );
112 static readonly Color trackbar_inner_first_gradient_color = Color.FromArgb( 238, 233, 229 );
113 static readonly Color trackbar_inner_second_gradient_color = Color.FromArgb( 223, 215, 208 );
114 static readonly Color trackbar_inner_pressed_second_gradient_color = Color.FromArgb( 224, 217, 210 );
116 static readonly Color disabled_color_foreground = Color.FromArgb( 182, 180, 173 );
118 static readonly Color active_caption = Color.FromArgb( 85, 152, 215 );
120 static readonly Color radio_button_border_circle_color = Color.FromArgb( 126, 118, 105 );
121 static readonly Color radio_button_dot_color = Color.FromArgb( 94, 160, 221 );
123 const int SEPARATOR_HEIGHT = 7;
124 const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
125 const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
127 int platform = (int) Environment.OSVersion.Platform;
129 static Color control_parent_backcolor;
131 #region Principal Theme Methods
132 public ThemeClearlooks( ) {
133 ColorControl = theme_back_color;
134 always_draw_hotkeys = true;
137 public override Color DefaultControlBackColor {
138 get { return theme_back_color; }
141 public override Color DefaultWindowBackColor {
142 get { return theme_back_color; }
145 public override Color ColorControl {
146 get { return theme_back_color;}
149 public override Color ColorHighlight {
150 get { return menuitem_gradient_first_color; }
153 public override Color ColorActiveCaption {
154 get { return active_caption; }
157 public override Size Border3DSize {
159 return new Size( 3, 3 );
163 public override Image Images(UIIcon index, int size) {
165 case UIIcon.PlacesRecentDocuments:
166 if ((platform == 4) || (platform == 128))
167 return MimeIconEngine.GetIconForMimeTypeAndSize( "recently/recently", new Size(size, size) );
169 return base.Images (UIIcon.PlacesRecentDocuments, size);
170 case UIIcon.PlacesDesktop:
171 if ((platform == 4) || (platform == 128))
172 return MimeIconEngine.GetIconForMimeTypeAndSize( "desktop/desktop", new Size(size, size) );
174 return base.Images (UIIcon.PlacesDesktop, size);
175 case UIIcon.PlacesPersonal:
176 if ((platform == 4) || (platform == 128))
177 return MimeIconEngine.GetIconForMimeTypeAndSize( "directory/home", new Size(size, size) );
179 return base.Images (UIIcon.PlacesPersonal, size);
180 case UIIcon.PlacesMyComputer:
181 if ((platform == 4) || (platform == 128))
182 return MimeIconEngine.GetIconForMimeTypeAndSize( "workplace/workplace", new Size(size, size) );
184 return base.Images (UIIcon.PlacesMyComputer, size);
185 case UIIcon.PlacesMyNetwork:
186 if ((platform == 4) || (platform == 128))
187 return MimeIconEngine.GetIconForMimeTypeAndSize( "network/network", new Size(size, size) );
189 return base.Images (UIIcon.PlacesMyNetwork, size);
191 // Icons for message boxes
192 case UIIcon.MessageBoxError: return base.Images (UIIcon.MessageBoxError, size);
193 case UIIcon.MessageBoxInfo: return base.Images (UIIcon.MessageBoxInfo, size);
194 case UIIcon.MessageBoxQuestion: return base.Images (UIIcon.MessageBoxQuestion, size);
195 case UIIcon.MessageBoxWarning: return base.Images (UIIcon.MessageBoxWarning, size);
198 case UIIcon.NormalFolder:
199 if ((platform == 4) || (platform == 128))
200 return MimeIconEngine.GetIconForMimeTypeAndSize( "inode/directory", new Size(size, size) );
202 return base.Images (UIIcon.NormalFolder, size);
205 throw new ArgumentException("Invalid Icon type requested", "index");
209 #endregion // Internal Methods
212 protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc ) {
213 dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
215 Color first_gradient_color = gradient_first_color;
216 Color second_gradient_color = gradient_second_color;
218 if (((button is CheckBox) && (((CheckBox)button).check_state == CheckState.Checked)) ||
219 ((button is RadioButton) && (((RadioButton)button).check_state == CheckState.Checked))) {
220 first_gradient_color = button.is_entered ? gradient_second_color : pressed_gradient_first_color;
221 second_gradient_color = button.is_entered ? gradient_second_color : pressed_gradient_second_color;
223 if (!button.is_enabled) {
224 button.is_entered = false;
226 if (button.is_entered) {
227 if (!button.is_pressed) {
228 first_gradient_color = Color.White;
229 second_gradient_color = button_mouse_entered_second_gradient_color;
231 first_gradient_color = pressed_gradient_first_color;
232 second_gradient_color = pressed_gradient_second_color;
236 bool paint_acceptbutton_black_border = false;
237 Form form = button.TopLevelControl as Form;
239 if (form != null && (form.AcceptButton == button as IButtonControl))
240 paint_acceptbutton_black_border = true;
242 CL_Draw_Button(dc, button.ClientRectangle, button.flat_style,
243 button.is_entered, button.is_enabled, button.is_pressed,
244 first_gradient_color, second_gradient_color,
245 paint_acceptbutton_black_border);
248 private void CL_Draw_Button(Graphics dc, Rectangle buttonRectangle, FlatStyle flat_style,
249 bool is_entered, bool is_enabled, bool is_pressed,
250 Color first_gradient_color, Color second_gradient_color,
251 bool paint_acceptbutton_black_border)
253 Rectangle lgbRectangle = new Rectangle (buttonRectangle.X + 3, buttonRectangle.Y + 3,
254 is_pressed ? buttonRectangle.Width - 5 : buttonRectangle.Width - 6,
255 buttonRectangle.Height - 6);
257 if (flat_style != FlatStyle.Popup || ((flat_style == FlatStyle.Popup) && is_entered)) {
258 LinearGradientBrush lgbr;
259 if (flat_style == FlatStyle.Flat) {
260 lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
261 new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
262 second_gradient_color, first_gradient_color);
264 lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
265 new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
266 first_gradient_color, second_gradient_color);
268 dc.FillRectangle (lgbr, lgbRectangle);
271 Point[] points_top = {
272 new Point (buttonRectangle.X + 2, buttonRectangle.Y + 2),
273 new Point (buttonRectangle.X + 3, buttonRectangle.Y + 1),
274 new Point (buttonRectangle.Right - 4, buttonRectangle.Y + 1),
275 new Point (buttonRectangle.Right - 3 , buttonRectangle.Y + 2)
278 Point[] points_bottom = {
279 new Point (buttonRectangle.X + 2, buttonRectangle.Bottom - 3),
280 new Point (buttonRectangle.X + 3, buttonRectangle.Bottom - 2),
281 new Point (buttonRectangle.Right - 4, buttonRectangle.Bottom - 2),
282 new Point (buttonRectangle.Right - 3, buttonRectangle.Bottom - 3)
285 Point[] points_top_outer = {
286 new Point (buttonRectangle.X + 1, buttonRectangle.Y + 1),
287 new Point (buttonRectangle.X + 2, buttonRectangle.Y),
288 new Point (buttonRectangle.Right - 3, buttonRectangle.Y),
289 new Point (buttonRectangle.Right - 2 , buttonRectangle.Y + 1)
292 Point[] points_bottom_outer = {
293 new Point (buttonRectangle.X + 1, buttonRectangle.Bottom - 2),
294 new Point (buttonRectangle.X + 2, buttonRectangle.Bottom - 1),
295 new Point (buttonRectangle.Right - 3, buttonRectangle.Bottom - 1),
296 new Point (buttonRectangle.Right - 2, buttonRectangle.Bottom - 2)
303 Color top_color = Color.Black;
304 Color bottom_color = Color.Black;
306 if (!paint_acceptbutton_black_border) {
307 top_color = is_pressed ? border_pressed_dark_color : border_normal_dark_color;
308 bottom_color = is_pressed ? border_pressed_light_color : border_normal_light_color;
311 pen = ResPool.GetPen (top_color);
312 dc.DrawLines (pen, points_top);
313 pen = ResPool.GetPen (bottom_color);
314 dc.DrawLines (pen, points_bottom);
316 using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
317 new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
318 top_color, bottom_color)) {
319 dc.FillRectangle (lgbr2, buttonRectangle.X + 1, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
320 dc.FillRectangle (lgbr2, buttonRectangle.Right - 2, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
323 Point[] points_button_complete = {
324 new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3),
325 new Point (buttonRectangle.X + 3, buttonRectangle.Y + 1),
326 new Point (buttonRectangle.Right - 4, buttonRectangle.Y + 1),
327 new Point (buttonRectangle.Right - 2, buttonRectangle.Y + 3),
328 new Point (buttonRectangle.Right - 2, buttonRectangle.Bottom - 4),
329 new Point (buttonRectangle.Right - 4, buttonRectangle.Bottom - 2),
330 new Point (buttonRectangle.X + 3, buttonRectangle.Bottom - 2),
331 new Point (buttonRectangle.X + 1, buttonRectangle.Bottom - 4),
332 new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3)
335 pen = ResPool.GetPen (pressed_inner_border_dark_color);
336 dc.DrawLines (pen, points_button_complete);
340 pen = ResPool.GetPen (button_outer_border_dark_color);
341 dc.DrawLines (pen, points_top_outer);
342 pen = ResPool.GetPen (button_outer_border_light_color);
343 dc.DrawLines (pen, points_bottom_outer);
345 using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 2),
346 new Point (buttonRectangle.X, buttonRectangle.Bottom - 1),
347 button_outer_border_dark_color, button_outer_border_light_color)) {
348 dc.FillRectangle (lgbr2, buttonRectangle.X, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
349 dc.FillRectangle (lgbr2, buttonRectangle.Right - 1, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
353 pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : inner_border_dark_color);
355 dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 4);
357 dc.DrawLine (pen, buttonRectangle.X + 3, buttonRectangle.Bottom - 3, buttonRectangle.Right - 4, buttonRectangle.Bottom - 3);
358 pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : Color.White);
359 dc.DrawLine (pen, buttonRectangle.X + 2, buttonRectangle.Y + 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 4);
360 dc.DrawLine (pen, buttonRectangle.X + 3 , buttonRectangle.Y + 2, buttonRectangle.Right - 4, buttonRectangle.Y + 2);
363 pen = ResPool.GetPen (edge_top_inner_color);
364 dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Y + 2, buttonRectangle.X + 2, buttonRectangle.Y + 1);
365 dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 1, buttonRectangle.Right - 2, buttonRectangle.Y + 2);
367 pen = ResPool.GetPen (button_edge_top_outer_color);
368 dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Y + 1, buttonRectangle.X + 1, buttonRectangle.Y);
369 dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Y, buttonRectangle.Right - 1, buttonRectangle.Y + 1);
371 pen = ResPool.GetPen (edge_bottom_inner_color);
372 dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Bottom - 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 2);
373 dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Bottom - 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 2);
375 pen = ResPool.GetPen (button_edge_bottom_outer_color);
376 dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Bottom - 2, buttonRectangle.X + 1, buttonRectangle.Bottom - 1);
377 dc.DrawLine (pen, buttonRectangle.Right - 1, buttonRectangle.Bottom - 2, buttonRectangle.Right - 2, buttonRectangle.Bottom - 1);
381 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc ) {
383 if ( !button.is_enabled || button.flat_style == FlatStyle.Popup )
386 Pen pen = ResPool.GetPen( button_focus_color );
387 DashStyle old_dash_style = pen.DashStyle;
388 pen.DashStyle = DashStyle.Dot;
390 Rectangle focus_rect = new Rectangle( button.ClientRectangle.X + 4, button.ClientRectangle.Y + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9 );
392 dc.DrawRectangle( pen, focus_rect );
394 pen.DashStyle = old_dash_style;
397 // FIXME: remove if libgdiplus DrawOrMeasureString is fixed
398 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc ) {
399 if ( !( button is CheckBox ) && !( button is RadioButton ) ) {
400 Rectangle buttonRectangle = button.ClientRectangle;
401 Rectangle text_rect = Rectangle.Inflate( buttonRectangle, -4, -4 );
403 string text = button.Text;
405 if ( text.Length > 1 ) {
406 SizeF sizef = dc.MeasureString( text, button.Font, text_rect.Width, button.text_format );
408 if ( (int)sizef.Width > text_rect.Width - 3 ) {
409 for ( int i = 1; i < text.Length + 1; i++ ) {
410 sizef = dc.MeasureString( text.Substring( 0, i ), button.Font, text_rect.Width, button.text_format );
412 if ( (int)sizef.Width > text_rect.Width - 3 ) {
413 text = text.Substring( 0, i - 1 );
420 if ( button.is_pressed ) {
425 if ( button.is_enabled ) {
426 dc.DrawString( text, button.Font, ResPool.GetSolidBrush( button.ForeColor ), text_rect, button.text_format );
428 if ( button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup ) {
429 dc.DrawString( text, button.Font, ResPool.GetSolidBrush( ControlPaint.DarkDark( this.ColorControl ) ), text_rect, button.text_format );
431 CPDrawStringDisabled( dc, text, button.Font, ColorControlText, text_rect, button.text_format );
436 #endregion // ButtonBase
439 public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e ) {
440 StringFormat string_format;
441 Rectangle rect_text = e.Bounds;
443 if ( item.Visible == false )
446 if ( item.MenuBar ) {
447 string_format = string_format_menu_menubar_text;
449 string_format = string_format_menu_text;
452 if ( item.Separator ) {
453 e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
454 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 1 );
456 e.Graphics.DrawLine( ResPool.GetPen( Color.White ),
457 e.Bounds.X, e.Bounds.Y + 2, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 2 );
463 rect_text.X += MenuCheckSize.Width;
465 if ( item.BarBreak ) { /* Draw vertical break bar*/
466 Rectangle rect = e.Bounds;
469 rect.Height = item.MenuHeight - 6;
471 e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
472 rect.X, rect.Y , rect.X, rect.Y + rect.Height );
474 e.Graphics.DrawLine( ResPool.GetPen( ColorControlLight ),
475 rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
478 Color color_text = ColorMenuText;
481 /* Draw background */
482 Rectangle rect_back = e.Bounds;
484 rect_back.Width -= 2;
486 if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected ) {
487 color_text = ColorHighlightText;
488 color_back = item.MenuBar ? theme_back_color : menu_background_color;
490 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rect_back.X, rect_back.Y + 1 ), new Point( rect_back.X, rect_back.Bottom - 1 ), menuitem_gradient_first_color, menuitem_gradient_second_color ) ) {
491 e.Graphics.FillRectangle( lgbr, rect_back.X + 1, rect_back.Y + 1, rect_back.Width - 1, rect_back.Height - 1 );
495 Pen tmp_pen = ResPool.GetPen( menuitem_border_color );
496 e.Graphics.DrawLine( tmp_pen, rect_back.X + 1, rect_back.Y, rect_back.Right - 1, rect_back.Y );
497 e.Graphics.DrawLine( tmp_pen, rect_back.Right, rect_back.Y + 1, rect_back.Right, rect_back.Bottom - 1 );
498 e.Graphics.DrawLine( tmp_pen, rect_back.Right - 1, rect_back.Bottom, rect_back.X + 1, rect_back.Bottom );
499 e.Graphics.DrawLine( tmp_pen, rect_back.X, rect_back.Bottom - 1, rect_back.X, rect_back.Y + 1 );
501 color_text = ColorMenuText;
502 color_back = item.MenuBar ? theme_back_color : menu_background_color;
504 e.Graphics.FillRectangle( ResPool.GetSolidBrush( color_back ), rect_back );
507 if ( item.Enabled ) {
508 e.Graphics.DrawString( item.Text, e.Font,
509 ResPool.GetSolidBrush( color_text ),
510 rect_text, string_format );
512 if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut ) {
513 string str = item.GetShortCutText( );
514 Rectangle rect = rect_text;
516 rect.Width -= item.XTab;
518 e.Graphics.DrawString( str, e.Font, ResPool.GetSolidBrush( color_text ),
519 rect, string_format_menu_shortcut );
522 ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
523 Color.Black, rect_text, string_format );
527 if ( item.MenuBar == false && item.IsPopup ) {
528 int cx = MenuCheckSize.Width;
529 int cy = MenuCheckSize.Height;
530 using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
531 using ( Graphics dc = Graphics.FromImage( bmp ) ) {
532 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
533 dc.SmoothingMode = SmoothingMode.AntiAlias;
535 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
536 ControlPaint.DrawMenuGlyph( dc, rect_arrow, MenuGlyph.Arrow );
537 bmp.MakeTransparent( );
539 if ( item.Enabled ) {
540 e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
541 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
543 ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
544 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
547 dc.SmoothingMode = old_smoothing_mode;
552 /* Draw checked or radio */
553 if ( item.MenuBar == false && item.Checked ) {
555 Rectangle area = e.Bounds;
556 int cx = MenuCheckSize.Width;
557 int cy = MenuCheckSize.Height;
558 using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
559 using ( Graphics gr = Graphics.FromImage( bmp ) ) {
560 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
562 if ( item.RadioCheck )
563 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
565 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
567 bmp.MakeTransparent( );
568 e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
574 public override void DrawPopupMenu( Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect ) {
576 dc.FillRectangle( ResPool.GetSolidBrush
577 ( menu_background_color ), cliparea );
579 /* Draw menu borders */
580 dc.DrawRectangle( ResPool.GetPen( menu_border_color ), rect.X, rect.Y, rect.Width - 1, rect.Height - 1 );
583 Pen tmp_pen = ResPool.GetPen( Color.White );
584 dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 1, rect.Right - 2, rect.Y + 1 );
585 dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 2, rect.X + 1, rect.Bottom - 2 );
587 tmp_pen = ResPool.GetPen( menu_inner_border_color );
588 dc.DrawLine( tmp_pen, rect.Right - 2, rect.Y + 2, rect.Right - 2, rect.Bottom - 2 );
589 dc.DrawLine( tmp_pen, rect.Right - 3, rect.Bottom - 2, rect.X + 2, rect.Bottom - 2 );
591 for ( int i = 0; i < menu.MenuItems.Count; i++ )
592 if ( cliparea.IntersectsWith( menu.MenuItems[ i ].bounds ) ) {
593 MenuItem item = menu.MenuItems[ i ];
594 item.MenuHeight = menu.Height;
595 item.PerformDrawItem( new DrawItemEventArgs( dc, MenuFont,
596 item.bounds, i, item.Status ) );
602 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl ) {
603 Rectangle client_area = ctrl.client_area;
605 Rectangle bar = ctrl.client_area;
607 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
609 bar.Width = barpos_pixels + 1;
611 // Draw bar background
612 dc.FillRectangle( ResPool.GetSolidBrush( menu_separator_color ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
615 Pen tmp_pen = ResPool.GetPen( progressbar_edge_dot_color );
616 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1 );
617 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
618 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1 );
619 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
621 tmp_pen = ResPool.GetPen( scrollbar_border_color );
622 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Y );
623 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
624 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Bottom - 1 );
625 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
627 if ( barpos_pixels <= 0 )
630 if ((bar.Width - 2) <= 0 || (bar.Height - 1) <= 0)
634 dc.DrawRectangle( ResPool.GetPen( combobox_focus_border_color ), bar.X - 1, bar.Y - 1, bar.Width, bar.Height + 1 );
635 tmp_pen = ResPool.GetPen( progressbar_inner_border_color );
636 dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.Right - 2, bar.Y );
637 dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.X, bar.Bottom - 1 );
639 using ( Bitmap bmp = new Bitmap( bar.Width - 2, bar.Height - 1 ) ) {
640 using ( Graphics gr = Graphics.FromImage( bmp ) ) {
641 gr.FillRectangle( ResPool.GetSolidBrush( tab_focus_color ), 0, 0, bmp.Width, bmp.Height );
643 LinearGradientBrush lgbr = new LinearGradientBrush( new Rectangle( 0, 0, bmp.Height, bmp.Height ), progressbar_first_gradient_color, progressbar_second_gradient_color, 0.0f, true );
645 lgbr.RotateTransform( 45.0f, MatrixOrder.Append );
647 float pen_width = bmp.Height / 2;
649 Pen pen = new Pen( lgbr, pen_width );
651 int add = bmp.Height + (int)pen.Width / 2;
654 int x_bottom = - bmp.Height;
656 while ( x_bottom < bmp.Width ) {
657 gr.DrawLine( pen, x_top, 0, x_bottom, bmp.Height );
665 dc.DrawImage( bmp, bar.X + 1, bar.Y + 1 );
668 #endregion // ProgressBar
672 // renders a radio button with the Flat and Popup FlatStyle
673 protected override void DrawFlatStyleRadioButton (Graphics dc, Rectangle rectangle, RadioButton radio_button)
675 if (radio_button.Enabled) {
676 // draw the outer flatstyle arcs
677 if (radio_button.FlatStyle == FlatStyle.Flat) {
678 dc.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
680 // fill in the area depending on whether or not the mouse is hovering
681 if (radio_button.is_entered && radio_button.Capture) {
682 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
684 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
687 // must be a popup radio button
689 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
691 if (radio_button.is_entered || radio_button.Capture) {
692 // draw the popup 3d button knob
693 dc.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
695 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
696 dc.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
699 // just draw lighter flatstyle outer circle
700 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);
705 // fill control background color regardless of actual backcolor
706 dc.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
707 // draw the ark as control dark
708 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
712 if (radio_button.Checked) {
713 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
714 dc.SmoothingMode = SmoothingMode.AntiAlias;
716 CL_Draw_RadioButton_Dot (dc, rectangle, true, false);
718 dc.SmoothingMode = old_smoothing_mode;
721 #endregion // RadioButton
724 public override void DrawScrollBar( Graphics dc, Rectangle clip, ScrollBar bar ) {
725 int scrollbutton_width = bar.scrollbutton_width;
726 int scrollbutton_height = bar.scrollbutton_height;
727 Rectangle first_arrow_area;
728 Rectangle second_arrow_area;
731 thumb_pos = bar.ThumbPos;
734 first_arrow_area = new Rectangle( 0, 0, bar.Width, scrollbutton_height + 1 );
735 bar.FirstArrowArea = first_arrow_area;
737 second_arrow_area = new Rectangle( 0, bar.ClientRectangle.Height - scrollbutton_height - 1, bar.Width, scrollbutton_height + 1 );
738 bar.SecondArrowArea = second_arrow_area;
740 thumb_pos.Width = bar.Width;
741 bar.ThumbPos = thumb_pos;
744 switch ( bar.thumb_moving ) {
745 case ScrollBar.ThumbMoving.None: {
746 ScrollBar_Vertical_Draw_ThumbMoving_None( scrollbutton_height, bar, clip, dc );
749 case ScrollBar.ThumbMoving.Forward: {
750 ScrollBar_Vertical_Draw_ThumbMoving_Forward( scrollbutton_height, bar, thumb_pos, clip, dc );
754 case ScrollBar.ThumbMoving.Backwards: {
755 ScrollBar_Vertical_Draw_ThumbMoving_Backwards( scrollbutton_height, bar, thumb_pos, clip, dc );
764 if ( clip.IntersectsWith( first_arrow_area ) )
765 CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state );
766 if ( clip.IntersectsWith( second_arrow_area ) )
767 CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state );
769 first_arrow_area = new Rectangle( 0, 0, scrollbutton_width + 1, bar.Height );
770 bar.FirstArrowArea = first_arrow_area;
772 second_arrow_area = new Rectangle( bar.ClientRectangle.Width - scrollbutton_width - 1, 0, scrollbutton_width + 1, bar.Height );
773 bar.SecondArrowArea = second_arrow_area;
775 thumb_pos.Height = bar.Height;
776 bar.ThumbPos = thumb_pos;
779 switch ( bar.thumb_moving ) {
780 case ScrollBar.ThumbMoving.None: {
781 ScrollBar_Horizontal_Draw_ThumbMoving_None( scrollbutton_width, bar, clip, dc );
785 case ScrollBar.ThumbMoving.Forward: {
786 ScrollBar_Horizontal_Draw_ThumbMoving_Forward( scrollbutton_width, thumb_pos, bar, clip, dc );
790 case ScrollBar.ThumbMoving.Backwards: {
791 ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( scrollbutton_width, thumb_pos, bar, clip, dc );
797 if ( clip.IntersectsWith( first_arrow_area ) )
798 CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state );
799 if ( clip.IntersectsWith( second_arrow_area ) )
800 CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state );
804 ScrollBar_DrawThumb( bar, thumb_pos, clip, dc );
807 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
808 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
809 DrawScrollBarThumb( dc, thumb_pos, bar );
812 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc ) {
813 Rectangle r = new Rectangle( 0,
814 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
815 Rectangle intersect = Rectangle.Intersect( clip, r );
817 if ( intersect != Rectangle.Empty ) {
818 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
819 Pen pen = ResPool.GetPen( scrollbar_border_color );
820 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
821 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
825 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
826 Rectangle r = new Rectangle( 0, scrollbutton_height,
827 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
828 Rectangle intersect = Rectangle.Intersect( clip, r );
830 if ( intersect != Rectangle.Empty ) {
831 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
832 Pen pen = ResPool.GetPen( scrollbar_border_color );
833 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
834 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
838 r.Y = thumb_pos.Y + thumb_pos.Height;
839 r.Width = bar.ClientRectangle.Width;
840 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
842 intersect = Rectangle.Intersect( clip, r );
843 if ( intersect != Rectangle.Empty ) {
844 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
845 Pen pen = ResPool.GetPen( scrollbar_border_color );
846 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
847 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
851 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
852 Rectangle r = new Rectangle( 0, scrollbutton_height,
853 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
854 Rectangle intersect = Rectangle.Intersect( clip, r );
856 if ( intersect != Rectangle.Empty ) {
857 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
858 Pen pen = ResPool.GetPen( scrollbar_border_color );
859 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
860 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
864 r.Y = thumb_pos.Y + thumb_pos.Height;
865 r.Width = bar.ClientRectangle.Width;
866 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
868 intersect = Rectangle.Intersect( clip, r );
869 if ( intersect != Rectangle.Empty ) {
870 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
871 Pen pen = ResPool.GetPen( scrollbar_border_color );
872 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
873 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
877 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc ) {
878 Rectangle r = new Rectangle( scrollbutton_width,
879 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
880 Rectangle intersect = Rectangle.Intersect( clip, r );
882 if ( intersect != Rectangle.Empty ) {
883 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
884 Pen pen = ResPool.GetPen( scrollbar_border_color );
885 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
886 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
890 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
891 Rectangle r = new Rectangle( scrollbutton_width, 0,
892 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
893 Rectangle intersect = Rectangle.Intersect( clip, r );
895 if ( intersect != Rectangle.Empty ) {
896 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
897 Pen pen = ResPool.GetPen( scrollbar_border_color );
898 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
899 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
902 r.X = thumb_pos.X + thumb_pos.Width;
904 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
905 r.Height = bar.ClientRectangle.Height;
907 intersect = Rectangle.Intersect( clip, r );
908 if ( intersect != Rectangle.Empty ) {
909 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
910 Pen pen = ResPool.GetPen( scrollbar_border_color );
911 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
912 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
916 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
917 Rectangle r = new Rectangle( scrollbutton_width, 0,
918 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
919 Rectangle intersect = Rectangle.Intersect( clip, r );
921 if ( intersect != Rectangle.Empty ) {
922 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
923 Pen pen = ResPool.GetPen( scrollbar_border_color );
924 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
925 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
928 r.X = thumb_pos.X + thumb_pos.Width;
930 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
931 r.Height = bar.ClientRectangle.Height;
933 intersect = Rectangle.Intersect( clip, r );
934 if ( intersect != Rectangle.Empty ) {
935 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
936 Pen pen = ResPool.GetPen( scrollbar_border_color );
937 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
938 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
941 #endregion // ScrollBar
944 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
945 Brush br_forecolor, StatusBarPanel panel ) {
946 int border_size = 3; // this is actually const, even if the border style is none
948 area.Height -= border_size;
949 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None ) {
950 dc.DrawRectangle( ResPool.GetPen( pressed_inner_border_dark_color ), area );
953 if ( panel.Style == StatusBarPanelStyle.OwnerDraw ) {
954 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
955 dc, panel.Parent.Font, area, index, DrawItemState.Default,
956 panel, panel.Parent.ForeColor, panel.Parent.BackColor );
957 panel.Parent.OnDrawItemInternal( e );
961 int left = area.Left;
962 if ( panel.Icon != null ) {
964 dc.DrawIcon( panel.Icon, left, area.Top );
965 left += panel.Icon.Width;
968 if ( panel.Text == String.Empty )
971 string text = panel.Text;
972 StringFormat string_format = new StringFormat( );
973 string_format.Trimming = StringTrimming.Character;
974 string_format.FormatFlags = StringFormatFlags.NoWrap;
976 if ( text[ 0 ] == '\t' ) {
977 string_format.Alignment = StringAlignment.Center;
978 text = text.Substring( 1 );
979 if ( text[ 0 ] == '\t' ) {
980 string_format.Alignment = StringAlignment.Far;
981 text = text.Substring( 1 );
985 int x = left + border_size;
986 int y = border_size + 2;
987 Rectangle r = new Rectangle( x, y,
988 area.Right - x - border_size,
989 area.Bottom - y - border_size );
991 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
993 #endregion // StatusBar
995 // FIXME: regions near the borders don't get filled with the correct backcolor
996 // TODO: TabAlignment.Left and TabAlignment.Bottom
997 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab ) {
998 if (tab.Parent != null)
999 dc.FillRectangle( ResPool.GetSolidBrush( tab.Parent.BackColor ), area );
1001 dc.FillRectangle( ResPool.GetSolidBrush( tab.BackColor ), area );
1002 Rectangle panel_rect = GetTabPanelRectExt( tab );
1004 if ( tab.Appearance == TabAppearance.Normal ) {
1006 switch ( tab.Alignment ) {
1007 case TabAlignment.Top:
1009 Pen pen = ResPool.GetPen( Color.White );
1011 dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top, panel_rect.Left + 1, panel_rect.Bottom - 1 );
1012 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top , panel_rect.Right - 2, panel_rect.Top );
1014 pen = ResPool.GetPen( tab_inner_border_color );
1015 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
1016 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
1019 pen = ResPool.GetPen( tab_border_color );
1021 dc.DrawLine( pen, panel_rect.Left, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Top - 1 );
1022 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Bottom - 2 );
1023 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom - 2, panel_rect.Right - 3, panel_rect.Bottom );
1024 dc.DrawLine( pen, panel_rect.Right - 3, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
1025 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
1026 dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top - 1 );
1029 // FIXME: the size of the tab page is to big to draw the upper inner white border
1030 case TabAlignment.Right:
1032 pen = ResPool.GetPen( Color.White );
1034 dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top + 1, panel_rect.Left + 1, panel_rect.Bottom - 1 );
1035 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top + 1 , panel_rect.Right - 2, panel_rect.Top + 1 );
1037 pen = ResPool.GetPen( tab_inner_border_color );
1038 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
1039 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
1042 pen = ResPool.GetPen( tab_border_color );
1044 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top, panel_rect.Right - 1, panel_rect.Top );
1045 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top, panel_rect.Right - 1, panel_rect.Bottom );
1046 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
1047 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
1048 dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top + 2 );
1049 dc.DrawLine( pen, panel_rect.Left, panel_rect.Top + 2, panel_rect.Left + 2, panel_rect.Top );
1054 if (tab.Alignment == TabAlignment.Top) {
1055 for (int r = tab.TabPages.Count; r > 0; r--) {
1056 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
1057 if (i == tab.SelectedIndex)
1059 if (r != tab.TabPages [i].Row)
1061 Rectangle rect = tab.GetTabRect (i);
1062 if (!rect.IntersectsWith (area))
1064 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1068 for (int r = 0; r < tab.TabPages.Count; r++) {
1069 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
1070 if (i == tab.SelectedIndex)
1072 if (r != tab.TabPages [i].Row)
1074 Rectangle rect = tab.GetTabRect (i);
1075 if (!rect.IntersectsWith (area))
1077 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1082 if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
1083 Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
1084 if (rect.IntersectsWith (area))
1085 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
1088 if (tab.ShowSlider) {
1089 Rectangle right = GetTabControlRightScrollRect (tab);
1090 Rectangle left = GetTabControlLeftScrollRect (tab);
1091 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
1092 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
1096 protected override int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
1098 int FlatButtonSpacing = 8;
1100 int res = bounds.Width;
1102 if (page.BackColor != tab_selected_gradient_second_color)
1103 page.BackColor = tab_selected_gradient_second_color;
1105 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
1107 StringFormat string_format = new StringFormat ();
1109 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
1110 dc.FillRectangle (ResPool.GetSolidBrush (tab_selected_gradient_second_color), bounds);
1113 if (tab.Appearance == TabAppearance.FlatButtons) {
1114 int width = bounds.Width;
1115 bounds.Width += (FlatButtonSpacing - 2);
1117 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
1118 bounds.Width = width;
1122 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
1123 } else if (tab.Appearance != TabAppearance.FlatButtons) {
1124 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
1127 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
1129 string_format.Alignment = StringAlignment.Center;
1130 string_format.LineAlignment = StringAlignment.Center;
1131 string_format.FormatFlags = StringFormatFlags.NoWrap;
1133 Color tab_first_color = is_selected ? tab_selected_gradient_first_color : tab_not_selected_gradient_first_color;
1134 Color tab_second_color = is_selected ? tab_selected_gradient_second_color : tab_not_selected_gradient_second_color;
1136 switch (tab.Alignment) {
1137 case TabAlignment.Top:
1139 Rectangle tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
1141 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Left + 2, bounds.Bottom), tab_first_color, tab_second_color)) {
1142 dc.FillRectangle (lgbr, tab_interior);
1146 Pen tmp_pen = ResPool.GetPen (tab_edge_color);
1147 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 1, bounds.Left + 1, bounds.Top);
1148 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top, bounds.Right, bounds.Top + 1);
1151 tmp_pen = ResPool.GetPen (Color.White);
1152 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 1);
1153 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 1, bounds.Top + 1);
1156 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1157 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
1158 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
1159 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
1161 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_dark_color, border_pressed_light_color)) {
1162 int diff = is_selected ? 4 : 3;
1163 dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
1164 dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
1168 tmp_pen = ResPool.GetPen (tab_focus_color);
1169 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Right - 1, bounds.Top + 2);
1170 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
1172 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1173 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
1174 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
1175 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
1178 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1180 string_format.Alignment = StringAlignment.Center;
1181 string_format.LineAlignment = StringAlignment.Center;
1182 string_format.FormatFlags = StringFormatFlags.NoWrap;
1186 case TabAlignment.Bottom:
1188 tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
1190 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Left + 2, bounds.Bottom - 1), tab_first_color, tab_second_color)) {
1191 dc.FillRectangle (lgbr, tab_interior);
1195 tmp_pen = ResPool.GetPen (tab_edge_color);
1196 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
1197 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom, bounds.Right, bounds.Bottom - 1);
1200 tmp_pen = ResPool.GetPen (Color.White);
1201 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 2);
1202 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
1205 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1206 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1207 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
1208 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
1210 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_light_color, border_pressed_dark_color)) {
1211 int diff = is_selected ? 4 : 3;
1212 dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
1213 dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
1217 tmp_pen = ResPool.GetPen (tab_focus_color);
1218 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Bottom - 2);
1219 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
1221 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1222 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1223 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
1224 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
1227 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1229 string_format.Alignment = StringAlignment.Center;
1230 string_format.LineAlignment = StringAlignment.Center;
1231 string_format.FormatFlags = StringFormatFlags.NoWrap;
1235 case TabAlignment.Left:
1237 int w_diff = is_selected ? 2 : 0;
1239 tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2 - w_diff, bounds.Height - 2);
1241 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left + 2, bounds.Top + 2), new Point (bounds.Right - w_diff, bounds.Top + 2), tab_first_color, tab_second_color)) {
1242 dc.FillRectangle (lgbr, tab_interior);
1246 tmp_pen = ResPool.GetPen (tab_edge_color);
1247 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top, bounds.Left, bounds.Top + 1);
1248 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
1251 tmp_pen = ResPool.GetPen (Color.White);
1252 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 3, bounds.Top + 1);
1253 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
1256 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1257 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Left, bounds.Top + 2);
1258 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 2);
1259 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1261 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_dark_color, border_pressed_light_color)) {
1262 int diff = is_selected ? 4 : 2;
1264 dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Top, bounds.Width - diff, 1);
1265 dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Bottom, bounds.Width - diff, 1);
1269 tmp_pen = ResPool.GetPen (tab_focus_color);
1270 dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top + 1, bounds.Left + 3, bounds.Bottom - 1);
1271 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 2, bounds.Left + 2, bounds.Bottom - 2);
1273 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1274 dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top, bounds.Left + 1, bounds.Top + 2);
1275 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
1276 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom);
1279 interior = new Rectangle (bounds.Left + 2, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1281 string_format.Alignment = StringAlignment.Center;
1282 string_format.LineAlignment = StringAlignment.Center;
1283 string_format.FormatFlags = StringFormatFlags.NoWrap;
1284 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
1289 // TabAlignment.Right
1291 tab_interior = new Rectangle (bounds.Left, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2);
1293 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right, bounds.Top + 2), tab_second_color, tab_first_color)) {
1294 dc.FillRectangle (lgbr, tab_interior);
1297 int l_diff = is_selected ? 2 : 0;
1300 tmp_pen = ResPool.GetPen (tab_edge_color);
1301 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right - 1, bounds.Top + 1);
1302 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom);
1305 tmp_pen = ResPool.GetPen (Color.White);
1306 dc.DrawLine (tmp_pen, bounds.Left + l_diff, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
1307 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
1310 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1311 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
1312 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
1313 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
1315 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_light_color, border_pressed_dark_color)) {
1316 int diff = is_selected ? 4 : 2;
1318 dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Top, bounds.Width - diff, 1);
1319 dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Bottom, bounds.Width - diff, 1);
1323 tmp_pen = ResPool.GetPen (tab_focus_color);
1324 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top + 1, bounds.Right - 3, bounds.Bottom - 1);
1325 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
1327 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1328 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
1329 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
1330 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
1333 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1335 string_format.Alignment = StringAlignment.Center;
1336 string_format.LineAlignment = StringAlignment.Center;
1337 string_format.FormatFlags = StringFormatFlags.NoWrap;
1338 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
1344 if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
1345 if (tab.Alignment == TabAlignment.Left) {
1346 int wo = interior.Width / 2;
1347 int ho = interior.Height / 2;
1348 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
1349 dc.RotateTransform (180);
1350 dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
1351 dc.ResetTransform ();
1353 dc.DrawString (page.Text, page.Font,
1354 ResPool.GetSolidBrush (SystemColors.ControlText),
1355 interior, string_format);
1357 } else if (page.Text != null) {
1358 DrawItemState state = DrawItemState.None;
1359 if (page == tab.SelectedTab)
1360 state |= DrawItemState.Selected;
1361 DrawItemEventArgs e = new DrawItemEventArgs (dc,
1362 tab.Font, bounds, tab.IndexForTabPage (page),
1363 state, page.ForeColor, page.BackColor);
1364 tab.OnDrawItemInternal (e);
1371 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state ) {
1372 Point[] arrow = new Point[ 3 ];
1382 bool pushed = false;
1384 Color first_color = Color.White;
1385 Color second_color = combobox_button_second_gradient_color;
1387 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1389 if ( state == ButtonState.Pushed ) {
1390 first_color = pressed_gradient_first_color;
1391 second_color = pressed_gradient_second_color;
1395 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y + 2 ), new Point( rectangle.X, rectangle.Bottom - 2 ), first_color, second_color ) ) {
1396 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
1400 Pen tmp_pen = ResPool.GetPen( !pushed ? Color.White : pressed_inner_border_dark_color );
1401 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 1 );
1402 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 2 );
1404 tmp_pen = ResPool.GetPen( !pushed ? inner_border_dark_color : pressed_inner_border_dark_color );
1405 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y + 2, rectangle.Right - 2, rectangle.Bottom - 2 );
1406 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 2 );
1409 Point[] points = new Point[] {
1410 new Point( rectangle.X, rectangle.Y ),
1411 new Point( rectangle.Right - 3, rectangle.Y ),
1412 new Point( rectangle.Right - 1, rectangle.Y + 2 ),
1413 new Point( rectangle.Right - 1, rectangle.Bottom - 3 ),
1414 new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
1415 new Point( rectangle.X, rectangle.Bottom - 1 ),
1416 new Point( rectangle.X, rectangle.Y )
1419 dc.DrawPolygon( ResPool.GetPen( pushed ? border_pressed_dark_color : border_normal_dark_color ), points );
1421 // edges on right side
1422 tmp_pen = ResPool.GetPen( control_parent_backcolor );
1423 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
1424 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
1426 tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
1427 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
1428 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
1430 rect = new Rectangle( rectangle.X + 1 + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2 - 1, rectangle.Height / 2 );
1431 centerX = rect.Left + rect.Width / 2;
1432 centerY = rect.Top + rect.Height / 2;
1433 shiftX = Math.Max( 1, rect.Width / 8 );
1434 shiftY = Math.Max( 1, rect.Height / 8 );
1436 if ( ( state & ButtonState.Pushed ) != 0 ) {
1444 P1 = new Point( rect.Left, centerY );
1445 P2 = new Point( centerX, rect.Bottom );
1446 P3 = new Point( rect.Right, centerY );
1452 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1453 dc.SmoothingMode = SmoothingMode.AntiAlias;
1455 /* Draw the arrow */
1456 if ( state == ButtonState.Inactive ) {
1457 /* Move away from the shadow */
1458 P1.X += 1; P1.Y += 1;
1459 P2.X += 1; P2.Y += 1;
1460 P3.X += 1; P3.Y += 1;
1466 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) ) {
1467 dc.DrawLines( pen, arrow );
1470 P1 = new Point( rect.Left, centerY );
1471 P2 = new Point( centerX, rect.Bottom );
1472 P3 = new Point( rect.Right, centerY );
1478 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) ) {
1479 dc.DrawLines( pen, arrow );
1482 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) ) {
1483 dc.DrawLines( pen, arrow );
1487 dc.SmoothingMode = old_smoothing_mode;
1490 /* Scroll button: regular button + direction arrow */
1491 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state ) {
1492 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1494 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1499 color_arrow = arrow_color;
1501 color_arrow = ColorGrayText;
1505 int centerX = area.Left + area.Width / 2;
1506 int centerY = area.Top + area.Height / 2;
1510 if ( ( state & ButtonState.Pushed ) != 0 )
1515 if ( area.Width < 12 || area.Height < 12 ) {
1520 Point[] arrow = new Point[ 4 ];
1522 switch (scroll_button_type) {
1523 case ScrollButton.Down:
1524 centerY += shift + 1;
1525 arrow [0] = new Point (centerX - min_4, centerY - min_2);
1526 arrow [1] = new Point (centerX, centerY + min_2);
1527 arrow [2] = new Point (centerX + min_4, centerY - min_2);
1528 arrow [3] = new Point (centerX - min_4, centerY - min_2);
1530 case ScrollButton.Up:
1532 arrow [0] = new Point (centerX - min_4, centerY + min_2);
1533 arrow [1] = new Point (centerX, centerY - min_2);
1534 arrow [2] = new Point (centerX + min_4, centerY + min_2);
1535 arrow [3] = new Point (centerX - min_4, centerY + min_2);
1537 case ScrollButton.Left:
1539 arrow [0] = new Point (centerX + min_2, centerY - min_4);
1540 arrow [1] = new Point (centerX + min_2, centerY + min_4);
1541 arrow [2] = new Point (centerX - min_2, centerY);
1542 arrow [3] = new Point (centerX + min_2, centerY - min_4);
1544 case ScrollButton.Right:
1545 centerX += shift + 1;
1546 arrow [0] = new Point (centerX - min_2, centerY - min_4);
1547 arrow [1] = new Point (centerX + min_2, centerY);
1548 arrow [2] = new Point (centerX - min_2, centerY + min_4);
1549 arrow [3] = new Point (centerX - min_2, centerY - min_4);
1555 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1556 dc.SmoothingMode = SmoothingMode.AntiAlias;
1557 dc.FillPolygon( ResPool.GetSolidBrush( color_arrow ), arrow );
1558 dc.SmoothingMode = old_smoothing_mode;
1561 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds ) {
1562 Point pt1 = new Point( bounds.Right - 3, bounds.Bottom );
1563 Point pt2 = new Point( bounds.Right, bounds.Bottom - 3 );
1566 Pen tmp_pen = ResPool.GetPen( Color.White );
1567 for ( int i = 0; i < 4; i++ ) {
1568 dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
1574 tmp_pen = ResPool.GetPen( pressed_inner_border_dark_color );
1575 for ( int i = 0; i < 4; i++ ) {
1576 dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
1580 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar ) {
1581 LinearGradientBrush lgbr = null;
1584 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.Right - 2, area.Y + 2 ), scrollbar_gradient_first_color, scrollbar_gradient_second_color );
1586 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), scrollbar_gradient_first_color, scrollbar_gradient_second_color );
1588 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1593 Pen pen = ResPool.GetPen( border_normal_dark_color );
1595 dc.DrawRectangle( pen, area.X, area.Y, area.Width - 1, area.Height - 1 );
1598 pen = ResPool.GetPen( Color.White );
1599 dc.DrawLine( pen, area.X + 1, area.Bottom - 2, area.X + 1, area.Y + 1 );
1600 dc.DrawLine( pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1602 pen = ResPool.GetPen( inner_border_dark_color );
1603 dc.DrawLine( pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1604 dc.DrawLine( pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1607 if ( area.Height > 12 ) {
1608 int mid_y = area.Y + ( area.Height / 2 );
1609 int mid_x = area.X + ( area.Width / 2 );
1611 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1612 dc.DrawLine( pen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1613 dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x + 3, mid_y - 3 );
1614 dc.DrawLine( pen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1616 Pen spen = ResPool.GetPen( Color.White );
1617 dc.DrawLine( spen, mid_x - 3, mid_y + 1, mid_x + 3, mid_y + 1 );
1618 dc.DrawLine( spen, mid_x - 3, mid_y - 2, mid_x + 3, mid_y - 2 );
1619 dc.DrawLine( spen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1622 // draw grip lines only if there is enough space
1623 if ( area.Width > 12 ) {
1624 int mid_x = area.X + ( area.Width / 2 );
1625 int mid_y = area.Y + ( area.Height / 2 );
1627 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1628 dc.DrawLine( pen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1629 dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x - 3, mid_y + 3 );
1630 dc.DrawLine( pen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1632 Pen spen = ResPool.GetPen( Color.White );
1633 dc.DrawLine( spen, mid_x + 1, mid_y - 3, mid_x + 1, mid_y + 3 );
1634 dc.DrawLine( spen, mid_x - 2, mid_y - 3, mid_x - 2, mid_y + 3 );
1635 dc.DrawLine( spen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1640 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type ) {
1641 Pen pen = ResPool.GetPen( border_normal_dark_color );
1643 Color first_gradient_color = gradient_first_color;
1644 Color second_gradient_color = gradient_second_color_nr2;
1646 bool pushed = false;
1648 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed ) {
1649 first_gradient_color = pressed_gradient_first_color;
1650 second_gradient_color = pressed_gradient_second_color;
1654 Point[] points = null;
1656 LinearGradientBrush lgbr = null;
1658 switch ( scroll_button_type ) {
1659 case ScrollButton.Left:
1660 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1661 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.X, area.Bottom - 1 );
1663 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), first_gradient_color, second_gradient_color );
1664 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
1666 Pen tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1667 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 2, area.X + 1, area.Bottom - 2 );
1668 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1670 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1671 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1672 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1674 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1675 dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
1676 dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
1678 points = new Point[] {
1679 new Point( area.X + 2, area.Y ),
1680 new Point( area.Right - 1, area.Y ),
1681 new Point( area.Right - 1, area.Bottom - 1 ),
1682 new Point( area.X + 2, area.Bottom - 1 ),
1683 new Point( area.X, area.Bottom - 3 ),
1684 new Point( area.X, area.Y + 2 ),
1685 new Point( area.X + 2, area.Y )
1687 dc.DrawPolygon( pen, points );
1689 case ScrollButton.Right:
1690 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1691 dc.DrawLine( ResPool.GetPen( ColorControl ), area.Right - 1, area.Y, area.Right - 1, area.Bottom - 1 );
1693 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y + 2 ), new Point( area.X + 2, area.Bottom - 2 ), first_gradient_color, second_gradient_color );
1694 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
1696 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1697 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1698 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1700 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1701 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1702 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1704 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1705 dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
1706 dc.DrawLine( tmp_pen, area.Right - 1, area.Bottom - 2, area.Right - 2, area.Bottom - 1 );
1708 points = new Point[] {
1709 new Point( area.X, area.Y ),
1710 new Point( area.Right - 3, area.Y ),
1711 new Point( area.Right - 1, area.Y + 2 ),
1712 new Point( area.Right - 1, area.Bottom - 3 ),
1713 new Point( area.Right - 3, area.Bottom - 1 ),
1714 new Point( area.X, area.Bottom - 1 ),
1715 new Point( area.X, area.Y ),
1717 dc.DrawPolygon( pen, points );
1719 case ScrollButton.Up:
1720 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1721 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.Right - 1, area.Y );
1723 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
1724 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1726 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1727 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1728 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1730 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1731 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1732 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1734 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1735 dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
1736 dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
1738 points = new Point[] {
1739 new Point( area.X + 2, area.Y ),
1740 new Point( area.Right - 3, area.Y ),
1741 new Point( area.Right - 1, area.Y + 2 ),
1742 new Point( area.Right - 1, area.Bottom - 1 ),
1743 new Point( area.X, area.Bottom - 1 ),
1744 new Point( area.X, area.Y + 2 ),
1745 new Point( area.X + 2, area.Y )
1747 dc.DrawPolygon( pen, points );
1749 case ScrollButton.Down:
1750 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1751 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Bottom - 1, area.Right - 1, area.Bottom - 1 );
1753 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
1754 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1756 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1757 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1758 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1760 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1761 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1762 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1764 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1765 dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
1766 dc.DrawLine( tmp_pen, area.Right - 2, area.Bottom - 1, area.Right - 1, area.Bottom - 2 );
1768 points = new Point[] {
1769 new Point( area.X, area.Y ),
1770 new Point( area.Right - 1, area.Y ),
1771 new Point( area.Right - 1, area.Bottom - 3 ),
1772 new Point( area.Right - 3, area.Bottom - 1 ),
1773 new Point( area.X + 2, area.Bottom - 1 ),
1774 new Point( area.X, area.Bottom - 3 ),
1775 new Point( area.X, area.Y )
1777 dc.DrawPolygon( pen, points );
1785 public override bool ToolBarInvalidateEntireButton {
1786 get { return true; }
1788 #endregion // ToolBar
1791 public override void DrawGroupBox( Graphics dc, Rectangle area, GroupBox box ) {
1792 StringFormat text_format;
1798 rect = box.ClientRectangle;
1800 dc.FillRectangle( ResPool.GetSolidBrush( box.BackColor ), rect );
1802 text_format = new StringFormat( );
1803 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1805 size = dc.MeasureString( box.Text, box.Font );
1806 width = (int) size.Width;
1808 if ( width > box.Width - 16 )
1809 width = box.Width - 16;
1811 y = box.Font.Height / 2;
1813 Pen pen = ResPool.GetPen( pressed_inner_border_dark_color );
1817 new Point( 8 + width, y ),
1818 new Point( box.Width - 3, y ),
1819 new Point( box.Width - 1, y + 2 ),
1820 new Point( box.Width - 1, box.Height - 3 ),
1821 new Point( box.Width - 3, box.Height - 1 ),
1822 new Point( 2, box.Height - 1 ),
1823 new Point( 0, box.Height - 3 ),
1824 new Point( 0, y + 2 ),
1828 dc.DrawLines( pen, points );
1831 if ( box.Enabled ) {
1832 dc.DrawString( box.Text, box.Font, ResPool.GetSolidBrush( box.ForeColor ), 10, 0, text_format );
1834 CPDrawStringDisabled( dc, box.Text, box.Font, box.ForeColor,
1835 new RectangleF( 10, 0, width, box.Font.Height ), text_format );
1837 text_format.Dispose( );
1842 private void DrawTrackBar_Vertical( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
1843 ref Rectangle thumb_pos, ref Rectangle thumb_area,
1844 float ticks, int value_pos, bool mouse_value ) {
1846 Point toptick_startpoint = new Point( );
1847 Point bottomtick_startpoint = new Point( );
1848 Point channel_startpoint = new Point( );
1850 float pixels_betweenticks;
1851 const int space_from_right = 8;
1852 const int space_from_left = 8;
1853 Rectangle area = tb.ClientRectangle;
1855 switch ( tb.TickStyle ) {
1856 case TickStyle.BottomRight:
1857 case TickStyle.None:
1858 channel_startpoint.Y = 8;
1859 channel_startpoint.X = 9;
1860 bottomtick_startpoint.Y = 13;
1861 bottomtick_startpoint.X = 24;
1863 case TickStyle.TopLeft:
1864 channel_startpoint.Y = 8;
1865 channel_startpoint.X = 19;
1866 toptick_startpoint.Y = 13;
1867 toptick_startpoint.X = 8;
1869 case TickStyle.Both:
1870 channel_startpoint.Y = 8;
1871 channel_startpoint.X = 18;
1872 bottomtick_startpoint.Y = 13;
1873 bottomtick_startpoint.X = 32;
1874 toptick_startpoint.Y = 13;
1875 toptick_startpoint.X = 8;
1881 thumb_area.X = area.X + channel_startpoint.X;
1882 thumb_area.Y = area.Y + channel_startpoint.Y;
1883 thumb_area.Height = area.Height - space_from_right - space_from_left;
1884 thumb_area.Width = 4;
1886 pixel_len = thumb_area.Height - 11;
1887 pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
1889 /* Convert thumb position from mouse position to value*/
1890 if ( mouse_value ) {
1892 if ( value_pos >= channel_startpoint.Y )
1893 value_pos = (int)( ( (float) ( value_pos - channel_startpoint.Y ) ) / pixels_betweenticks );
1897 if ( value_pos + tb.Minimum > tb.Maximum )
1898 value_pos = tb.Maximum - tb.Minimum;
1900 tb.Value = value_pos + tb.Minimum;
1903 thumb_pos.Width = 13;
1904 thumb_pos.Height = 29;
1906 thumb_pos.Y = channel_startpoint.Y + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Height / 3 );
1908 if ( thumb_pos.Y < channel_startpoint.Y )
1909 thumb_pos.Y = channel_startpoint.Y;
1911 if ( thumb_pos.Y > thumb_area.Bottom - 29 )
1912 thumb_pos.Y = thumb_area.Bottom - 29;
1916 Pen pen = ResPool.GetPen( tab_top_border_focus_color );
1917 dc.DrawLine( pen, channel_startpoint.X, thumb_pos.Y + 29, channel_startpoint.X, thumb_area.Bottom );
1918 dc.DrawLine( pen, channel_startpoint.X, thumb_area.Bottom, channel_startpoint.X + 4, thumb_area.Bottom );
1919 dc.DrawLine( pen, channel_startpoint.X + 4, thumb_pos.Y + 29, channel_startpoint.X + 4, thumb_area.Bottom );
1921 pen = ResPool.GetPen( menuitem_gradient_first_color );
1922 dc.DrawLine( pen, channel_startpoint.X + 1, thumb_pos.Y + 28, channel_startpoint.X + 1, thumb_area.Bottom - 1 );
1923 pen = ResPool.GetPen( trackbar_second_gradient_color );
1924 dc.DrawLine( pen, channel_startpoint.X + 2, thumb_pos.Y + 28, channel_startpoint.X + 2, thumb_area.Bottom - 1 );
1925 pen = ResPool.GetPen( trackbar_third_gradient_color );
1926 dc.DrawLine( pen, channel_startpoint.X + 3, thumb_pos.Y + 28, channel_startpoint.X + 3, thumb_area.Bottom - 1 );
1929 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1930 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, channel_startpoint.X + 1, thumb_pos.Y );
1931 dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), channel_startpoint.X + 2, channel_startpoint.Y + 1, 1, thumb_pos.Y );
1933 pen = ResPool.GetPen( scrollbar_border_color );
1934 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, thumb_pos.Y );
1935 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X + 4, channel_startpoint.Y );
1936 dc.DrawLine( pen, channel_startpoint.X + 4, channel_startpoint.Y, channel_startpoint.X + 4, thumb_pos.Y );
1939 thumb_pos.X = channel_startpoint.X - 4;
1942 pen = ResPool.GetPen( Color.White );
1943 dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
1944 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
1946 pen = ResPool.GetPen( menu_separator_color );
1947 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
1948 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
1952 new Point( thumb_pos.X + 2, thumb_pos.Y ),
1953 new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
1954 new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
1955 new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
1956 new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
1957 new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
1958 new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
1959 new Point( thumb_pos.X, thumb_pos.Y + 2 ),
1960 new Point( thumb_pos.X + 2, thumb_pos.Y )
1963 dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
1965 Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
1966 Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
1968 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( thumb_pos.X, thumb_pos.Y + 2 ), new Point( thumb_pos.X, thumb_pos.Bottom - 2 ), first_gradient_color, second_gradient_color ) ) {
1969 dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
1973 pen = ResPool.GetPen( edge_top_inner_color );
1974 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
1975 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
1977 pen = ResPool.GetPen( edge_bottom_inner_color );
1978 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
1979 dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
1982 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1983 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 11, thumb_pos.X + 8, thumb_pos.Y + 11 );
1984 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 14, thumb_pos.X + 8, thumb_pos.Y + 14 );
1985 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 17, thumb_pos.X + 8, thumb_pos.Y + 17 );
1987 pen = ResPool.GetPen( Color.White );
1988 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 12, thumb_pos.X + 8, thumb_pos.Y + 12 );
1989 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 15, thumb_pos.X + 8, thumb_pos.Y + 15 );
1990 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 18, thumb_pos.X + 8, thumb_pos.Y + 18 );
1992 pixel_len = thumb_area.Height - 11;
1993 pixels_betweenticks = pixel_len / ticks;
1996 thumb_area.X = thumb_pos.X;
1997 thumb_area.Y = channel_startpoint.Y;
1998 thumb_area.Width = thumb_pos.Width;
2000 Region outside = new Region( area );
2001 outside.Exclude( thumb_area );
2003 if ( outside.IsVisible( clip_rectangle ) ) {
2004 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
2005 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2007 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2008 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2009 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
2010 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc );
2012 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
2013 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc );
2017 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
2018 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2020 pixel_len = thumb_area.Height - 11;
2021 pixels_betweenticks = pixel_len / ticks;
2023 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2024 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2025 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
2026 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
2028 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
2029 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
2038 private void DrawTrackBar_Horizontal( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
2039 ref Rectangle thumb_pos, ref Rectangle thumb_area,
2040 float ticks, int value_pos, bool mouse_value ) {
2041 Point toptick_startpoint = new Point( );
2042 Point bottomtick_startpoint = new Point( );
2043 Point channel_startpoint = new Point( );
2045 float pixels_betweenticks;
2046 const int space_from_right = 8;
2047 const int space_from_left = 8;
2048 Rectangle area = tb.ClientRectangle;
2050 switch ( tb.TickStyle ) {
2051 case TickStyle.BottomRight:
2052 case TickStyle.None:
2053 channel_startpoint.X = 8;
2054 channel_startpoint.Y = 9;
2055 bottomtick_startpoint.X = 13;
2056 bottomtick_startpoint.Y = 24;
2058 case TickStyle.TopLeft:
2059 channel_startpoint.X = 8;
2060 channel_startpoint.Y = 19;
2061 toptick_startpoint.X = 13;
2062 toptick_startpoint.Y = 8;
2064 case TickStyle.Both:
2065 channel_startpoint.X = 8;
2066 channel_startpoint.Y = 18;
2067 bottomtick_startpoint.X = 13;
2068 bottomtick_startpoint.Y = 32;
2069 toptick_startpoint.X = 13;
2070 toptick_startpoint.Y = 8;
2076 thumb_area.X = area.X + channel_startpoint.X;
2077 thumb_area.Y = area.Y + channel_startpoint.Y;
2078 thumb_area.Width = area.Width - space_from_right - space_from_left;
2079 thumb_area.Height = 4;
2081 pixel_len = thumb_area.Width - 11;
2082 pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
2084 /* Convert thumb position from mouse position to value*/
2085 if ( mouse_value ) {
2086 if ( value_pos >= channel_startpoint.X )
2087 value_pos = (int)( ( (float) ( value_pos - channel_startpoint.X ) ) / pixels_betweenticks );
2091 if ( value_pos + tb.Minimum > tb.Maximum )
2092 value_pos = tb.Maximum - tb.Minimum;
2094 tb.Value = value_pos + tb.Minimum;
2097 thumb_pos.Width = 29;
2098 thumb_pos.Height = 13;
2100 thumb_pos.X = channel_startpoint.X + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Width / 3 );
2102 if ( thumb_pos.X < channel_startpoint.X )
2103 thumb_pos.X = channel_startpoint.X;
2105 if ( thumb_pos.X > thumb_area.Right - 29 )
2106 thumb_pos.X = thumb_area.Right - 29;
2110 Pen pen = ResPool.GetPen( tab_top_border_focus_color );
2111 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, thumb_pos.X, channel_startpoint.Y );
2112 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, channel_startpoint.Y + 4 );
2113 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y + 4, thumb_pos.X, channel_startpoint.Y + 4 );
2115 pen = ResPool.GetPen( menuitem_gradient_first_color );
2116 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, thumb_pos.X, channel_startpoint.Y + 1 );
2117 pen = ResPool.GetPen( trackbar_second_gradient_color );
2118 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 2, thumb_pos.X, channel_startpoint.Y + 2 );
2119 pen = ResPool.GetPen( trackbar_third_gradient_color );
2120 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 3, thumb_pos.X, channel_startpoint.Y + 3 );
2123 pen = ResPool.GetPen( pressed_inner_border_dark_color );
2124 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 1, thumb_area.Right - 1, channel_startpoint.Y + 1 );
2125 dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), thumb_pos.X + 29, channel_startpoint.Y + 2, thumb_area.Right - thumb_pos.X - 30, 1 );
2127 pen = ResPool.GetPen( scrollbar_border_color );
2128 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y );
2129 dc.DrawLine( pen, thumb_area.Right, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y + 4 );
2130 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 4, thumb_area.Right, channel_startpoint.Y + 4 );
2134 thumb_pos.Y = channel_startpoint.Y - 4;
2137 pen = ResPool.GetPen( Color.White );
2138 dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
2139 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
2141 pen = ResPool.GetPen( menu_separator_color );
2142 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
2143 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
2147 new Point( thumb_pos.X + 2, thumb_pos.Y ),
2148 new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
2149 new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
2150 new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
2151 new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
2152 new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
2153 new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
2154 new Point( thumb_pos.X, thumb_pos.Y + 2 ),
2155 new Point( thumb_pos.X + 2, thumb_pos.Y )
2158 dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
2160 Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
2161 Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
2163 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( thumb_pos.X, thumb_pos.Y + 2 ), new Point( thumb_pos.X, thumb_pos.Bottom - 2 ), first_gradient_color, second_gradient_color ) ) {
2164 dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
2168 pen = ResPool.GetPen( edge_top_inner_color );
2169 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
2170 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
2172 pen = ResPool.GetPen( edge_bottom_inner_color );
2173 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
2174 dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
2177 pen = ResPool.GetPen( pressed_inner_border_dark_color );
2178 dc.DrawLine( pen, thumb_pos.X + 11, thumb_pos.Y + 4, thumb_pos.X + 11, thumb_pos.Y + 8 );
2179 dc.DrawLine( pen, thumb_pos.X + 14, thumb_pos.Y + 4, thumb_pos.X + 14, thumb_pos.Y + 8 );
2180 dc.DrawLine( pen, thumb_pos.X + 17, thumb_pos.Y + 4, thumb_pos.X + 17, thumb_pos.Y + 8 );
2182 pen = ResPool.GetPen( Color.White );
2183 dc.DrawLine( pen, thumb_pos.X + 12, thumb_pos.Y + 4, thumb_pos.X + 12, thumb_pos.Y + 8 );
2184 dc.DrawLine( pen, thumb_pos.X + 15, thumb_pos.Y + 4, thumb_pos.X + 15, thumb_pos.Y + 8 );
2185 dc.DrawLine( pen, thumb_pos.X + 18, thumb_pos.Y + 4, thumb_pos.X + 18, thumb_pos.Y + 8 );
2187 pixel_len = thumb_area.Width - 11;
2188 pixels_betweenticks = pixel_len / ticks;
2191 thumb_area.Y = thumb_pos.Y;
2192 thumb_area.X = channel_startpoint.X;
2193 thumb_area.Height = thumb_pos.Height;
2194 Region outside = new Region( area );
2195 outside.Exclude( thumb_area );
2197 if ( outside.IsVisible( clip_rectangle ) ) {
2198 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
2199 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2201 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2202 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2203 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
2204 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3 );
2206 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
2207 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2 );
2211 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
2212 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2214 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2215 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2216 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
2217 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y );
2219 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
2220 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
2228 public override void DrawTrackBar( Graphics dc, Rectangle clip_rectangle, TrackBar tb ) {
2231 float ticks = ( tb.Maximum - tb.Minimum ) / tb.tickFrequency; /* N of ticks draw*/
2233 Rectangle thumb_pos = tb.ThumbPos;
2234 Rectangle thumb_area = tb.ThumbArea;
2236 if ( tb.thumb_pressed ) {
2237 value_pos = tb.thumb_mouseclick;
2240 value_pos = tb.Value - tb.Minimum;
2241 mouse_value = false;
2244 area = tb.ClientRectangle;
2246 /* Control Background */
2247 if ( tb.BackColor == DefaultControlBackColor ) {
2248 dc.FillRectangle( ResPool.GetSolidBrush( ColorControl ), clip_rectangle );
2250 dc.FillRectangle( ResPool.GetSolidBrush( tb.BackColor ), clip_rectangle );
2253 if ( tb.Orientation == Orientation.Vertical ) {
2254 DrawTrackBar_Vertical( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
2255 ticks, value_pos, mouse_value );
2258 DrawTrackBar_Horizontal( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
2259 ticks, value_pos, mouse_value );
2262 // TODO: draw better focus rectangle
2264 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, area.Width - 1, 1 );
2265 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y + area.Height - 1, area.Width - 1, 1 );
2266 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, 1, area.Height - 1 );
2267 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X + area.Width - 1, area.Y, 1, area.Height - 1 );
2270 tb.ThumbPos = thumb_pos;
2271 tb.ThumbArea = thumb_area;
2273 #endregion // TrackBar
2276 // draws the ListViewItem of the given index
2277 protected override void DrawListViewItem( Graphics dc, ListView control, ListViewItem item ) {
2278 Rectangle rect_checkrect = item.CheckRectReal;
2279 Rectangle rect_iconrect = item.GetBounds( ItemBoundsPortion.Icon );
2280 Rectangle full_rect = item.GetBounds( ItemBoundsPortion.Entire );
2281 Rectangle text_rect = item.GetBounds( ItemBoundsPortion.Label );
2283 if ( control.CheckBoxes ) {
2284 if ( control.StateImageList == null ) {
2285 // Make sure we've got at least a line width of 1
2286 int check_wd = Math.Max( 3, rect_checkrect.Width / 6 );
2287 int scale = Math.Max( 1, rect_checkrect.Width / 12 );
2289 // set the checkbox background
2290 dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorWindow ),
2292 // define a rectangle inside the border area
2293 Rectangle rect = new Rectangle( rect_checkrect.X + 2,
2294 rect_checkrect.Y + 2,
2295 rect_checkrect.Width - 4,
2296 rect_checkrect.Height - 4 );
2297 Pen pen = new Pen( this.ColorWindowText, 2 );
2298 dc.DrawRectangle( pen, rect );
2300 // Need to draw a check-mark
2301 if ( item.Checked ) {
2303 // adjustments to get the check-mark at the right place
2304 rect.X ++; rect.Y ++;
2305 // following logic is taken from DrawFrameControl method
2306 for ( int i = 0; i < check_wd; i++ ) {
2307 dc.DrawLine( pen, rect.Left + check_wd / 2,
2308 rect.Top + check_wd + i,
2309 rect.Left + check_wd / 2 + 2 * scale,
2310 rect.Top + check_wd + 2 * scale + i );
2312 rect.Left + check_wd / 2 + 2 * scale,
2313 rect.Top + check_wd + 2 * scale + i,
2314 rect.Left + check_wd / 2 + 6 * scale,
2315 rect.Top + check_wd - 2 * scale + i );
2319 if ( item.Checked && control.StateImageList.Images.Count > 1 )
2320 control.StateImageList.Draw( dc,
2321 rect_checkrect.Location, 1 );
2322 else if ( ! item.Checked && control.StateImageList.Images.Count > 0 )
2323 control.StateImageList.Draw( dc,
2324 rect_checkrect.Location, 0 );
2328 // Item is drawn as a special case, as it is not just text
2329 if ( control.View == View.LargeIcon ) {
2330 if ( item.ImageIndex > -1 &&
2331 control.LargeImageList != null &&
2332 item.ImageIndex < control.LargeImageList.Images.Count ) {
2334 Point image_location = rect_iconrect.Location;
2335 Image image = control.LargeImageList.Images[ item.ImageIndex ];
2336 if ( image.Width < rect_iconrect.Width ) {
2337 int icon_rect_middle = rect_iconrect.Width / 2;
2338 int image_middle = image.Width / 2;
2339 image_location.X = image_location.X + icon_rect_middle - image_middle;
2341 control.LargeImageList.Draw( dc, image_location,
2345 if ( item.ImageIndex > -1 &&
2346 control.SmallImageList != null &&
2347 item.ImageIndex < control.SmallImageList.Images.Count )
2348 control.SmallImageList.Draw( dc, rect_iconrect.Location,
2352 // draw the item text
2353 // format for the item text
2354 StringFormat format = new StringFormat( );
2355 format.LineAlignment = StringAlignment.Center;
2356 if ( control.View == View.LargeIcon )
2357 format.Alignment = StringAlignment.Center;
2359 format.Alignment = StringAlignment.Near;
2361 if ( !control.LabelWrap )
2362 format.FormatFlags = StringFormatFlags.NoWrap;
2364 if ( item.Selected ) {
2365 if ( control.View == View.Details ) {
2366 if ( control.FullRowSelect ) {
2367 // fill the entire rect excluding the checkbox
2368 full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
2369 dc.FillRectangle( this.ResPool.GetSolidBrush
2370 ( this.ColorHighlight ), full_rect );
2372 Size text_size = Size.Ceiling( dc.MeasureString( item.Text,
2374 text_rect.Width = text_size.Width;
2375 dc.FillRectangle( this.ResPool.GetSolidBrush
2376 ( this.ColorHighlight ), text_rect );
2379 /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
2381 Point loc = text_rect.Location;
2382 loc.X += (text_rect.Width - text_size.Width) / 2;
2383 text_rect.Width = text_size.Width;*/
2384 dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorHighlight ),
2388 dc.FillRectangle( ResPool.GetSolidBrush( item.BackColor ), text_rect );
2390 if ( item.Text != null && item.Text.Length > 0 ) {
2392 if ( control.View != View.LargeIcon ) {
2393 if ( item.Selected )
2394 dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
2395 ( this.ColorHighlightText ), text_rect, format );
2397 dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
2398 ( item.ForeColor ), text_rect, format );
2400 // ListView CalcTextSize says wrapping is done for two lines only !?!
2401 // text is centered for the complete text_rect but it should be centered per available row/line
2403 // calculate how much lines we get out of text_rect and current item.Font
2404 int nr_lines = text_rect.Height / item.Font.Height;
2405 int rest = text_rect.Height % item.Font.Height;
2406 int line_height = item.Font.Height + ( rest > 1 ? 2 : 0 );
2408 Rectangle[] text_rects = new Rectangle[ nr_lines ];
2410 for ( int i = 0; i < nr_lines; i++ ) {
2411 text_rects[ i ].X = text_rect.X;
2412 text_rects[ i ].Y = text_rect.Y + i * line_height;
2413 text_rects[ i ].Width = text_rect.Width;
2414 text_rects[ i ].Height = line_height;
2417 string[] lines = new string[ nr_lines ];
2419 string text = item.Text;
2422 int current_pos = 0;
2423 for ( int k = 1; k <= text.Length; k++ ) {
2424 lines[ line_nr ] = text.Substring( current_pos, k - current_pos );
2426 // FIXME: Graphics.MeasureString returns wrong results if there is a
2427 // space char in the string
2428 SizeF sizef = dc.MeasureString( lines[ line_nr ], item.Font, text_rect.Width, format );
2430 if ( (int)sizef.Width > text_rect.Width - 3 ) {
2431 lines[ line_nr ] = lines[ line_nr ].Remove( lines[ line_nr ].Length - 1, 1 );
2435 if ( line_nr == nr_lines )
2441 foreach ( Rectangle t_rect in text_rects ) {
2442 if ( item.Selected )
2443 dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
2444 ( this.ColorHighlightText ), t_rect, format );
2446 dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
2447 ( item.ForeColor ), t_rect, format );
2453 if ( control.View == View.Details && control.Columns.Count > 0 ) {
2454 // draw subitems for details view
2455 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
2456 int count = ( control.Columns.Count < subItems.Count ?
2457 control.Columns.Count : subItems.Count );
2461 ListViewItem.ListViewSubItem subItem;
2462 Rectangle sub_item_rect = text_rect;
2464 // set the format for subitems
2465 format.FormatFlags = StringFormatFlags.NoWrap;
2466 format.Alignment = StringAlignment.Near;
2468 // 0th subitem is the item already drawn
2469 for ( int index = 1; index < count; index++ ) {
2470 subItem = subItems[ index ];
2471 col = control.Columns[ index ];
2472 sub_item_rect.X = col.Rect.Left;
2473 sub_item_rect.Width = col.Wd;
2474 sub_item_rect.X -= control.h_marker;
2476 SolidBrush sub_item_back_br = null;
2477 SolidBrush sub_item_fore_br = null;
2478 Font sub_item_font = null;
2480 if ( item.UseItemStyleForSubItems ) {
2481 sub_item_back_br = this.ResPool.GetSolidBrush
2483 sub_item_fore_br = this.ResPool.GetSolidBrush
2485 sub_item_font = item.Font;
2487 sub_item_back_br = this.ResPool.GetSolidBrush
2488 ( subItem.BackColor );
2489 sub_item_fore_br = this.ResPool.GetSolidBrush
2490 ( subItem.ForeColor );
2491 sub_item_font = subItem.Font;
2494 // In case of fullrowselect, background is filled
2495 // for the entire rect above
2496 if ( item.Selected && control.FullRowSelect ) {
2497 if ( subItem.Text != null && subItem.Text.Length > 0 )
2498 dc.DrawString( subItem.Text, sub_item_font,
2499 this.ResPool.GetSolidBrush
2500 ( this.ColorHighlightText ),
2501 sub_item_rect, format );
2503 dc.FillRectangle( sub_item_back_br, sub_item_rect );
2504 if ( subItem.Text != null && subItem.Text.Length > 0 )
2505 dc.DrawString( subItem.Text, sub_item_font,
2507 sub_item_rect, format );
2509 sub_item_rect.X += col.Wd;
2514 if ( item.Focused ) {
2515 if ( item.Selected )
2516 CPDrawFocusRectangle( dc, text_rect, ColorHighlightText, ColorHighlight );
2518 CPDrawFocusRectangle( dc, text_rect, control.ForeColor, control.BackColor );
2525 #region DateTimePicker
2526 public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
2527 // if not showing the numeric updown control then render border
2528 if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
2529 // draw the outer border
2530 Rectangle button_bounds = dtp.ClientRectangle;
2531 CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
2533 // deflate by the border width
2534 if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
2535 button_bounds.Inflate (-2,-2);
2536 ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
2537 Rectangle button_rect = new Rectangle(dtp.drop_down_arrow_rect.X, dtp.drop_down_arrow_rect.Y + 1,
2538 dtp.drop_down_arrow_rect.Width - 1, dtp.drop_down_arrow_rect.Height - 2);
2539 this.CPDrawComboButton (
2546 // render the date part
2547 if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
2548 // fill the background
2549 Rectangle date_area_rect = new Rectangle( dtp.date_area_rect.X + 1, dtp.date_area_rect.Y + 1,
2550 dtp.date_area_rect.Width - 2, dtp.date_area_rect.Height - 2);
2551 dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), date_area_rect);
2553 // fill the currently highlighted area
2554 if (dtp.hilight_date_area != Rectangle.Empty) {
2555 dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
2558 // draw the text part
2559 // TODO: if date format is CUstom then we need to draw the dates as separate parts
2560 StringFormat text_format = new StringFormat();
2561 text_format.LineAlignment = StringAlignment.Center;
2562 text_format.Alignment = StringAlignment.Near;
2563 dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
2564 text_format.Dispose ();
2567 #endregion // DateTimePicker
2569 #region MonthCalendar
2570 // draw the month calendar
2571 public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
2573 Rectangle client_rectangle = mc.ClientRectangle;
2574 Size month_size = mc.SingleMonthSize;
2575 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2576 Size calendar_spacing = (Size)((object)mc.calendar_spacing);
2577 Size date_cell_size = (Size)((object)mc.date_cell_size);
2579 // draw the singlecalendars
2582 // adjust for the position of the specific month
2583 for (int i=0; i < mc.CalendarDimensions.Height; i++)
2587 y_offset += month_size.Height + calendar_spacing.Height;
2589 // now adjust for x position
2590 for (int j=0; j < mc.CalendarDimensions.Width; j++)
2594 x_offset += month_size.Width + calendar_spacing.Width;
2601 Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
2602 if (month_rect.IntersectsWith (clip_rectangle)) {
2614 Rectangle bottom_rect = new Rectangle (
2616 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
2617 client_rectangle.Width,
2618 date_cell_size.Height + 2);
2619 // draw the today date if it's set
2620 if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
2622 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
2624 int today_offset = 5;
2625 if (mc.ShowTodayCircle)
2627 Rectangle today_circle_rect = new Rectangle (
2628 client_rectangle.X + 5,
2629 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
2630 date_cell_size.Width,
2631 date_cell_size.Height);
2632 DrawTodayCircle (dc, today_circle_rect);
2633 today_offset += date_cell_size.Width + 5;
2635 // draw today's date
2636 StringFormat text_format = new StringFormat();
2637 text_format.LineAlignment = StringAlignment.Center;
2638 text_format.Alignment = StringAlignment.Near;
2639 Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2640 Rectangle today_rect = new Rectangle (
2641 today_offset + client_rectangle.X,
2642 Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
2643 Math.Max(client_rectangle.Width - today_offset, 0),
2644 date_cell_size.Height);
2645 dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
2646 text_format.Dispose ();
2647 bold_font.Dispose ();
2651 // finally paint the borders of the calendars as required
2652 for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
2653 if (i == 0 && clip_rectangle.X == client_rectangle.X) {
2654 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
2655 } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
2656 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
2658 Rectangle rect = new Rectangle (
2659 client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
2661 calendar_spacing.Width,
2662 client_rectangle.Height);
2663 if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2664 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2668 for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
2669 if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
2670 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
2671 } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
2672 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
2674 Rectangle rect = new Rectangle (
2676 client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
2677 client_rectangle.Width,
2678 calendar_spacing.Height);
2679 if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2680 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2685 // draw the drop down border if need
2686 if (mc.owner != null) {
2687 Rectangle bounds = mc.ClientRectangle;
2688 if (clip_rectangle.Contains (mc.Location)) {
2689 // find out if top or left line to draw
2690 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2692 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
2694 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2695 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
2698 if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
2699 // find out if bottom or right line to draw
2700 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2701 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
2703 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2704 dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
2710 // darws a single part of the month calendar (with one month)
2711 private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
2713 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2714 Size title_size = (Size)((object)mc.title_size);
2715 Size date_cell_size = (Size)((object)mc.date_cell_size);
2716 DateTime current_month = (DateTime)((object)mc.current_month);
2718 // set up some standard string formating variables
2719 StringFormat text_format = new StringFormat();
2720 text_format.LineAlignment = StringAlignment.Center;
2721 text_format.Alignment = StringAlignment.Center;
2724 // draw the title back ground
2725 DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
2726 Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
2727 if (title_rect.IntersectsWith (clip_rectangle)) {
2728 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
2730 string title_text = this_month.ToString ("MMMM yyyy");
2731 dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
2733 // draw previous and next buttons if it's time
2734 if (row == 0 && col == 0)
2736 // draw previous button
2737 DrawMonthCalendarButton (
2743 (System.Drawing.Size)((object)mc.button_size),
2746 if (row == 0 && col == mc.CalendarDimensions.Width-1)
2749 DrawMonthCalendarButton (
2755 (System.Drawing.Size)((object)mc.button_size),
2760 // set the week offset and draw week nums if needed
2761 int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
2762 Rectangle day_name_rect = new Rectangle(
2764 rectangle.Y + title_size.Height,
2765 (7 + col_offset) * date_cell_size.Width,
2766 date_cell_size.Height);
2767 if (day_name_rect.IntersectsWith (clip_rectangle)) {
2768 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
2769 // draw the day names
2770 DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
2771 for (int i=0; i < 7; i++)
2773 int position = i - (int) first_day_of_week;
2776 position = 7 + position;
2779 Rectangle day_rect = new Rectangle(
2780 day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
2782 date_cell_size.Width,
2783 date_cell_size.Height);
2784 dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
2787 // draw the vertical divider
2788 int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
2790 ResPool.GetPen (mc.ForeColor),
2791 rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
2792 rectangle.Y + vert_divider_y,
2793 rectangle.Right - mc.divider_line_offset,
2794 rectangle.Y + vert_divider_y);
2798 // draw the actual date items in the grid (including the week numbers)
2799 Rectangle date_rect = new Rectangle (
2801 rectangle.Y + title_size.Height + date_cell_size.Height,
2802 date_cell_size.Width,
2803 date_cell_size.Height);
2804 int month_row_count = 0;
2805 bool draw_week_num_divider = false;
2806 DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
2807 for (int i=0; i < 6; i++)
2809 // establish if this row is in our clip_area
2810 Rectangle row_rect = new Rectangle (
2812 rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
2813 date_cell_size.Width * 7,
2814 date_cell_size.Height);
2815 if (mc.ShowWeekNumbers) {
2816 row_rect.Width += date_cell_size.Width;
2819 bool draw_row = row_rect.IntersectsWith (clip_rectangle);
2821 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
2823 // establish if this is a valid week to draw
2824 if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
2825 month_row_count = i;
2828 // draw the week number if required
2829 if (mc.ShowWeekNumbers && month_row_count == i) {
2830 if (!draw_week_num_divider) {
2831 draw_week_num_divider = draw_row;
2833 // get the week for this row
2834 int week = mc.GetWeekOfYear (current_date);
2840 ResPool.GetSolidBrush (mc.TitleBackColor),
2844 date_rect.Offset(date_cell_size.Width, 0);
2847 // only draw the days if we have to
2848 if(month_row_count == i) {
2849 for (int j=0; j < 7; j++)
2852 DrawMonthCalendarDate (
2863 current_date = current_date.AddDays(1);
2864 date_rect.Offset(date_cell_size.Width, 0);
2867 // shift the rectangle down one row
2868 int offset = (mc.ShowWeekNumbers) ? -8 : -7;
2869 date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
2873 // month_row_count is zero based, so add one
2876 // draw week numbers if required
2877 if (draw_week_num_divider) {
2880 ResPool.GetPen (mc.ForeColor),
2881 rectangle.X + date_cell_size.Width - 1,
2882 rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
2883 rectangle.X + date_cell_size.Width - 1,
2884 rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
2886 text_format.Dispose ();
2889 // draws the pervious or next button
2890 private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
2892 bool is_clicked = false;
2893 Rectangle button_rect;
2894 Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
2895 Point[] arrow_path = new Point[3];
2896 // prepare the button
2899 is_clicked = mc.is_previous_clicked;
2900 button_rect = new Rectangle (
2901 rectangle.X + 1 + x_offset,
2902 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2903 Math.Max(button_size.Width - 1, 0),
2904 Math.Max(button_size.Height - 1, 0));
2905 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2906 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2908 arrow_rect.Offset(1,1);
2910 arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
2911 arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
2912 arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
2916 is_clicked = mc.is_next_clicked;
2917 button_rect = new Rectangle (
2918 rectangle.Right - 1 - x_offset - button_size.Width,
2919 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2920 Math.Max(button_size.Width - 1, 0),
2921 Math.Max(button_size.Height - 1, 0));
2922 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2923 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2925 arrow_rect.Offset(1,1);
2927 arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
2928 arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
2929 arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
2932 // fill the background
2933 dc.FillRectangle (ResPool.GetSolidBrush(mc.TitleBackColor), button_rect);
2936 Color first_gradient_color = is_clicked ? pressed_gradient_first_color : gradient_first_color;
2937 Color second_gradient_color = is_clicked ? pressed_gradient_second_color : gradient_second_color;
2939 CL_Draw_Button (dc, button_rect, FlatStyle.Standard,
2940 false, true, is_clicked,
2941 first_gradient_color, second_gradient_color,
2945 SmoothingMode old_smooting_mode = dc.SmoothingMode;
2946 dc.SmoothingMode = SmoothingMode.AntiAlias;
2947 dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
2948 dc.SmoothingMode = old_smooting_mode;
2952 // draws one day in the calendar grid
2953 private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
2954 Color date_color = mc.ForeColor;
2955 Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
2957 // find out if we are the lead of the first calendar or the trail of the last calendar
2958 if (date.Year != month.Year || date.Month != month.Month) {
2959 DateTime check_date = month.AddMonths (-1);
2960 // check if it's the month before
2961 if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
2962 date_color = mc.TrailingForeColor;
2964 // check if it's the month after
2965 check_date = month.AddMonths (1);
2966 if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
2967 date_color = mc.TrailingForeColor;
2973 date_color = mc.ForeColor;
2977 if (date == mc.SelectionStart && date == mc.SelectionEnd) {
2978 // see if the date is in the start of selection
2979 date_color = mc.BackColor;
2980 // draw the left hand of the back ground
2981 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2982 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
2983 } else if (date == mc.SelectionStart) {
2984 // see if the date is in the start of selection
2985 date_color = mc.BackColor;
2986 // draw the left hand of the back ground
2987 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2988 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
2989 // fill the other side as a straight rect
2990 if (date < mc.SelectionEnd)
2992 // use rectangle instead of rectangle to go all the way to edge of rect
2993 selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
2994 selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
2995 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2997 } else if (date == mc.SelectionEnd) {
2998 // see if it is the end of selection
2999 date_color = mc.BackColor;
3000 // draw the left hand of the back ground
3001 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
3002 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
3003 // fill the other side as a straight rect
3004 if (date > mc.SelectionStart) {
3005 selection_rect.X = rectangle.X;
3006 selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
3007 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
3009 } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
3010 // now see if it's in the middle
3011 date_color = mc.BackColor;
3012 // draw the left hand of the back ground
3013 Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
3014 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
3017 // set up some standard string formating variables
3018 StringFormat text_format = new StringFormat();
3019 text_format.LineAlignment = StringAlignment.Center;
3020 text_format.Alignment = StringAlignment.Center;
3023 // establish if it's a bolded font
3025 if (mc.IsBoldedDate (date)) {
3026 font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
3031 // just draw the date now
3032 dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
3034 // today circle if needed
3035 if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
3036 DrawTodayCircle (dc, interior);
3039 // draw the selection grid
3040 if (mc.is_date_clicked && mc.clicked_date == date) {
3041 using (Pen pen = new Pen (Color.Black, 1) ) {
3042 pen.DashStyle = DashStyle.Dot;
3043 dc.DrawRectangle (pen, interior);
3046 text_format.Dispose ();
3049 private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
3050 Color circle_color = Color.FromArgb (248, 0, 0);
3051 // draw the left hand of the circle
3052 Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
3053 Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
3054 Point [] curve_points = new Point [3];
3055 curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
3056 curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
3057 curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
3059 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
3060 dc.SmoothingMode = SmoothingMode.AntiAlias;
3062 using (Pen pen = new Pen (circle_color, 2)) {
3063 dc.DrawArc (pen, lhs_circle_rect, 90, 180);
3064 dc.DrawArc (pen, rhs_circle_rect, 270, 180);
3065 dc.DrawCurve (pen, curve_points);
3066 dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
3069 dc.SmoothingMode = old_smoothing_mode;
3071 #endregion // MonthCalendar
3073 public override void CPDrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides ) {
3074 CPDrawBorder3D( graphics, rectangle, style, sides, ColorControl );
3077 protected override void CPDrawBorder3D( Graphics dc, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color ) {
3078 // currently we don't take care of Border3DStyle or Border3DSide
3080 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
3081 dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 1 );
3082 dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1 );
3084 Pen tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
3085 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 2, rectangle.Y + 1 );
3086 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 2 );
3087 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 3 );
3088 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Bottom - 3, rectangle.X + 2, rectangle.Bottom - 2 );
3090 tmp_pen = ResPool.GetPen( theme_back_color );
3091 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 2, rectangle.Right - 3, rectangle.Y + 2 );
3092 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 3, rectangle.X + 2, rectangle.Bottom - 3 );
3094 tmp_pen = ResPool.GetPen( Color.White );
3095 dc.DrawLine( tmp_pen, rectangle.X + 3, rectangle.Bottom - 3, rectangle.Right - 3, rectangle.Bottom - 3 );
3096 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 3, rectangle.Right - 3, rectangle.Bottom - 3 );
3099 new Point( rectangle.X + 3, rectangle.Y + 1 ),
3100 new Point( rectangle.Right - 4, rectangle.Y + 1 ),
3101 new Point( rectangle.Right - 2, rectangle.Y + 3 ),
3102 new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
3103 new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
3104 new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
3105 new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
3106 new Point( rectangle.X + 1, rectangle.Y + 3 ),
3107 new Point( rectangle.X + 3, rectangle.Y + 1 )
3110 dc.DrawLines( ResPool.GetPen( combobox_border_color ), points );
3112 Point[] points_top_outer = {
3113 new Point( rectangle.X + 1, rectangle.Y + 1 ),
3114 new Point( rectangle.X + 2, rectangle.Y ),
3115 new Point( rectangle.Right - 3, rectangle.Y ),
3116 new Point( rectangle.Right - 2 , rectangle.Y + 1 )
3119 Point[] points_bottom_outer = {
3120 new Point( rectangle.X + 1, rectangle.Bottom - 2 ),
3121 new Point( rectangle.X + 2, rectangle.Bottom - 1 ),
3122 new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
3123 new Point( rectangle.Right - 2, rectangle.Bottom - 2 )
3127 tmp_pen = ResPool.GetPen( button_outer_border_dark_color );
3128 dc.DrawLines( tmp_pen, points_top_outer );
3129 tmp_pen = ResPool.GetPen( button_outer_border_light_color );
3130 dc.DrawLines( tmp_pen, points_bottom_outer );
3132 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 2 ), new Point( 0, rectangle.Height - 1 ), button_outer_border_dark_color, button_outer_border_light_color ) ) {
3133 dc.FillRectangle( lgbr, rectangle.X, rectangle.Y + 2, 1, rectangle.Height - 4 );
3134 dc.FillRectangle( lgbr, rectangle.Right - 1, rectangle.Y + 2, 1, rectangle.Height - 4 );
3137 tmp_pen = ResPool.GetPen( button_edge_top_outer_color );
3138 dc.DrawLine( tmp_pen, rectangle.X, rectangle.Y + 1, rectangle.X + 1, rectangle.Y );
3139 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
3141 tmp_pen = ResPool.GetPen( button_edge_bottom_outer_color );
3142 dc.DrawLine( tmp_pen, rectangle.X, rectangle.Bottom - 2, rectangle.X + 1, rectangle.Bottom - 1 );
3143 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 1 );
3146 public override void CPDrawBorder( Graphics dc, Rectangle bounds, Color leftColor, int leftWidth,
3147 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
3148 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
3149 int bottomWidth, ButtonBorderStyle bottomStyle ) {
3150 dc.DrawRectangle( ResPool.GetPen( combobox_border_color ), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1 );
3153 // TODO: inactive...
3154 public override void CPDrawCheckBox( Graphics dc, Rectangle rectangle, ButtonState state ) {
3156 bool pushed = ( state & ButtonState.Pushed ) != 0;
3163 dc.FillRectangle( ResPool.GetSolidBrush( pushed ? checkbox_pressed_backcolor : Color.White ), rectangle );
3166 dc.DrawRectangle( ResPool.GetPen( scrollbar_border_color ), rectangle );
3168 Color inner_border_color = pushed ? checkbox_pressed_inner_boder_color : checkbox_inner_boder_color;
3170 Pen tmp_pen = ResPool.GetPen( inner_border_color );
3171 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 1, rectangle.Y + 1 );
3172 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 1, rectangle.Bottom - 1 );
3174 /* Make sure we've got at least a line width of 1 */
3175 lineWidth = Math.Max( 3, rectangle.Width / 6 );
3176 scale = Math.Max( 1, rectangle.Width / 12 );
3178 // define a rectangle inside the border area
3179 rect = new Rectangle( rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
3180 if ( ( state & ButtonState.Inactive ) != 0 ) {
3181 tmp_pen = SystemPens.ControlDark;
3183 tmp_pen = SystemPens.ControlText;
3186 if ( ( state & ButtonState.Checked ) != 0 ) {
3187 /* Need to draw a check-mark */
3188 for ( int i=0; i < lineWidth; i++ ) {
3189 dc.DrawLine( tmp_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * scale, rect.Top + lineWidth + 2 * scale + i );
3190 dc.DrawLine( tmp_pen, rect.Left + lineWidth / 2 + 2 * scale, rect.Top + lineWidth + 2 * scale + i, rect.Left + lineWidth / 2 + 6 * scale, rect.Top + lineWidth - 2 * scale + i );
3195 public override void CPDrawStringDisabled( Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
3196 StringFormat format ) {
3198 graphics.DrawString( s, font, ResPool.GetSolidBrush( ColorGrayText), layoutRectangle, format );
3202 public override void CPDrawButton (Graphics dc, Rectangle buttonRectangle, ButtonState state)
3204 bool is_enabled = true;
3205 FlatStyle flat_style = FlatStyle.Standard;
3206 bool is_pressed = false;
3208 if ((state & ButtonState.Pushed) != 0) {
3212 // if ((state & ButtonState.Checked)!=0) {
3213 // dfcs |= DrawFrameControlStates.Checked;
3216 if ((state & ButtonState.Flat) != 0) {
3217 flat_style = FlatStyle.Flat;
3220 if ((state & ButtonState.Inactive) != 0) {
3224 Color first_gradient_color = gradient_first_color;
3225 Color second_gradient_color = gradient_second_color;
3228 first_gradient_color = pressed_gradient_first_color;
3229 second_gradient_color = pressed_gradient_second_color;
3232 CL_Draw_Button (dc, buttonRectangle, flat_style,
3233 false, is_enabled, is_pressed,
3234 first_gradient_color, second_gradient_color,
3238 public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
3240 bool is_checked = false;
3241 bool is_inactive = false;
3243 if ((state & ButtonState.Checked) != 0) {
3247 if ((state & ButtonState.Inactive) != 0) {
3251 SmoothingMode old_smooting_mode = dc.SmoothingMode;
3252 dc.SmoothingMode = SmoothingMode.AntiAlias;
3254 dc.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
3256 dc.DrawArc (ResPool.GetPen (radio_button_border_circle_color), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
3258 CL_Draw_RadioButton_Dot (dc, rectangle, is_checked, is_inactive);
3260 dc.SmoothingMode = old_smooting_mode;
3263 private void CL_Draw_RadioButton_Dot (Graphics dc, Rectangle rectangle, bool is_checked, bool is_inactive)
3266 int lineWidth = Math.Max (1, Math.Min (rectangle.Width, rectangle.Height) / 4);
3268 SolidBrush buttonBrush;
3271 buttonBrush = SystemBrushes.ControlDark as SolidBrush;
3273 buttonBrush = ResPool.GetSolidBrush (radio_button_dot_color);
3275 dc.FillPie (buttonBrush, rectangle.X + lineWidth, rectangle.Y + lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height - lineWidth * 2, 0, 359);
3277 // the white shiny dott
3278 buttonBrush = ResPool.GetSolidBrush (ColorWindow);
3279 dc.FillPie (buttonBrush, rectangle.X + lineWidth + lineWidth / 2, rectangle.Y + lineWidth + lineWidth / 2, (rectangle.Width - lineWidth * 2) / 3, (rectangle.Height - lineWidth * 2) / 3, 0, 359);