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) 2006 Alexander Olk
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 new 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.FlatStyle,
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 using (Pen lgbrpen = new Pen (lgbr2)) {
320 dc.DrawLine (lgbrpen, buttonRectangle.X + 1, buttonRectangle.Y + 3, buttonRectangle.X + 1, buttonRectangle.Bottom - 3);
321 dc.DrawLine (lgbrpen, buttonRectangle.Right - 2, buttonRectangle.Y + 3, buttonRectangle.Right - 2, buttonRectangle.Bottom - 3);
325 Point[] points_button_complete = {
326 new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3),
327 new Point (buttonRectangle.X + 3, buttonRectangle.Y + 1),
328 new Point (buttonRectangle.Right - 4, buttonRectangle.Y + 1),
329 new Point (buttonRectangle.Right - 2, buttonRectangle.Y + 3),
330 new Point (buttonRectangle.Right - 2, buttonRectangle.Bottom - 4),
331 new Point (buttonRectangle.Right - 4, buttonRectangle.Bottom - 2),
332 new Point (buttonRectangle.X + 3, buttonRectangle.Bottom - 2),
333 new Point (buttonRectangle.X + 1, buttonRectangle.Bottom - 4),
334 new Point (buttonRectangle.X + 1, buttonRectangle.Y + 3)
337 pen = ResPool.GetPen (pressed_inner_border_dark_color);
338 dc.DrawLines (pen, points_button_complete);
342 pen = ResPool.GetPen (button_outer_border_dark_color);
343 dc.DrawLines (pen, points_top_outer);
344 pen = ResPool.GetPen (button_outer_border_light_color);
345 dc.DrawLines (pen, points_bottom_outer);
347 using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 2),
348 new Point (buttonRectangle.X, buttonRectangle.Bottom - 1),
349 button_outer_border_dark_color, button_outer_border_light_color)) {
350 using (Pen lgbrpen = new Pen(lgbr2)) {
351 dc.DrawLine (lgbrpen, buttonRectangle.X, buttonRectangle.Y + 2, buttonRectangle.X, buttonRectangle.Bottom - 3);
352 dc.DrawLine (lgbrpen, buttonRectangle.Right - 1, buttonRectangle.Y + 2, buttonRectangle.Right - 1, buttonRectangle.Bottom - 3);
357 pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : inner_border_dark_color);
359 dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 4);
361 dc.DrawLine (pen, buttonRectangle.X + 3, buttonRectangle.Bottom - 3, buttonRectangle.Right - 4, buttonRectangle.Bottom - 3);
362 pen = ResPool.GetPen (is_pressed ? pressed_inner_border_dark_color : Color.White);
363 dc.DrawLine (pen, buttonRectangle.X + 2, buttonRectangle.Y + 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 4);
364 dc.DrawLine (pen, buttonRectangle.X + 3 , buttonRectangle.Y + 2, buttonRectangle.Right - 4, buttonRectangle.Y + 2);
367 pen = ResPool.GetPen (edge_top_inner_color);
368 dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Y + 2, buttonRectangle.X + 2, buttonRectangle.Y + 1);
369 dc.DrawLine (pen, buttonRectangle.Right - 3, buttonRectangle.Y + 1, buttonRectangle.Right - 2, buttonRectangle.Y + 2);
371 pen = ResPool.GetPen (button_edge_top_outer_color);
372 dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Y + 1, buttonRectangle.X + 1, buttonRectangle.Y);
373 dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Y, buttonRectangle.Right - 1, buttonRectangle.Y + 1);
375 pen = ResPool.GetPen (edge_bottom_inner_color);
376 dc.DrawLine (pen, buttonRectangle.X + 1, buttonRectangle.Bottom - 3, buttonRectangle.X + 2, buttonRectangle.Bottom - 2);
377 dc.DrawLine (pen, buttonRectangle.Right - 2, buttonRectangle.Bottom - 3, buttonRectangle.Right - 3, buttonRectangle.Bottom - 2);
379 pen = ResPool.GetPen (button_edge_bottom_outer_color);
380 dc.DrawLine (pen, buttonRectangle.X, buttonRectangle.Bottom - 2, buttonRectangle.X + 1, buttonRectangle.Bottom - 1);
381 dc.DrawLine (pen, buttonRectangle.Right - 1, buttonRectangle.Bottom - 2, buttonRectangle.Right - 2, buttonRectangle.Bottom - 1);
385 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc ) {
387 if ( !button.is_enabled || button.FlatStyle == FlatStyle.Popup )
390 Pen pen = ResPool.GetPen( button_focus_color );
391 DashStyle old_dash_style = pen.DashStyle;
392 pen.DashStyle = DashStyle.Dot;
394 Rectangle focus_rect = new Rectangle( button.ClientRectangle.X + 4, button.ClientRectangle.Y + 4, button.ClientRectangle.Width - 9, button.ClientRectangle.Height - 9 );
396 dc.DrawRectangle( pen, focus_rect );
398 pen.DashStyle = old_dash_style;
401 // FIXME: remove if libgdiplus DrawOrMeasureString is fixed
402 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc ) {
403 if ( !( button is CheckBox ) && !( button is RadioButton ) ) {
404 Rectangle buttonRectangle = button.ClientRectangle;
405 Rectangle text_rect = Rectangle.Inflate( buttonRectangle, -4, -4 );
407 string text = button.Text;
409 if ( text.Length > 1 ) {
410 SizeF sizef = dc.MeasureString( text, button.Font, text_rect.Width, button.text_format );
412 if ( (int)sizef.Width > text_rect.Width - 3 ) {
413 for ( int i = 1; i < text.Length + 1; i++ ) {
414 sizef = dc.MeasureString( text.Substring( 0, i ), button.Font, text_rect.Width, button.text_format );
416 if ( (int)sizef.Width > text_rect.Width - 3 ) {
417 text = text.Substring( 0, i - 1 );
424 if ( button.is_pressed ) {
429 if ( button.is_enabled ) {
430 dc.DrawString( text, button.Font, ResPool.GetSolidBrush( button.ForeColor ), text_rect, button.text_format );
432 if ( button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup ) {
433 dc.DrawString( text, button.Font, ResPool.GetSolidBrush( ControlPaint.DarkDark( this.ColorControl ) ), text_rect, button.text_format );
435 CPDrawStringDisabled( dc, text, button.Font, ColorControlText, text_rect, button.text_format );
440 #endregion // ButtonBase
443 public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e ) {
444 StringFormat string_format;
445 Rectangle rect_text = e.Bounds;
447 if ( item.Visible == false )
450 if ( item.MenuBar ) {
451 string_format = string_format_menu_menubar_text;
453 string_format = string_format_menu_text;
456 if ( item.Separator ) {
457 e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
458 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 1 );
460 e.Graphics.DrawLine( ResPool.GetPen( Color.White ),
461 e.Bounds.X, e.Bounds.Y + 2, e.Bounds.X + e.Bounds.Right - 4, e.Bounds.Y + 2 );
467 rect_text.X += MenuCheckSize.Width;
469 if ( item.BarBreak ) { /* Draw vertical break bar*/
470 Rectangle rect = e.Bounds;
473 rect.Height = item.MenuHeight - 6;
475 e.Graphics.DrawLine( ResPool.GetPen( menu_separator_color ),
476 rect.X, rect.Y , rect.X, rect.Y + rect.Height );
478 e.Graphics.DrawLine( ResPool.GetPen( ColorControlLight ),
479 rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
482 Color color_text = ColorMenuText;
485 /* Draw background */
486 Rectangle rect_back = e.Bounds;
488 rect_back.Width -= 2;
490 if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected ) {
491 color_text = ColorHighlightText;
492 color_back = item.MenuBar ? theme_back_color : menu_background_color;
494 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 ) ) {
495 e.Graphics.FillRectangle( lgbr, rect_back.X + 1, rect_back.Y + 1, rect_back.Width - 1, rect_back.Height - 1 );
499 Pen tmp_pen = ResPool.GetPen( menuitem_border_color );
500 e.Graphics.DrawLine( tmp_pen, rect_back.X + 1, rect_back.Y, rect_back.Right - 1, rect_back.Y );
501 e.Graphics.DrawLine( tmp_pen, rect_back.Right, rect_back.Y + 1, rect_back.Right, rect_back.Bottom - 1 );
502 e.Graphics.DrawLine( tmp_pen, rect_back.Right - 1, rect_back.Bottom, rect_back.X + 1, rect_back.Bottom );
503 e.Graphics.DrawLine( tmp_pen, rect_back.X, rect_back.Bottom - 1, rect_back.X, rect_back.Y + 1 );
505 color_text = ColorMenuText;
506 color_back = item.MenuBar ? theme_back_color : menu_background_color;
508 e.Graphics.FillRectangle( ResPool.GetSolidBrush( color_back ), rect_back );
511 if ( item.Enabled ) {
512 e.Graphics.DrawString( item.Text, e.Font,
513 ResPool.GetSolidBrush( color_text ),
514 rect_text, string_format );
516 if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut ) {
517 string str = item.GetShortCutText( );
518 Rectangle rect = rect_text;
520 rect.Width -= item.XTab;
522 e.Graphics.DrawString( str, e.Font, ResPool.GetSolidBrush( color_text ),
523 rect, string_format_menu_shortcut );
526 ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
527 Color.Black, rect_text, string_format );
531 if ( item.MenuBar == false && item.IsPopup ) {
532 int cx = MenuCheckSize.Width;
533 int cy = MenuCheckSize.Height;
534 using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
535 using ( Graphics dc = Graphics.FromImage( bmp ) ) {
536 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
537 dc.SmoothingMode = SmoothingMode.AntiAlias;
539 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
540 ControlPaint.DrawMenuGlyph( dc, rect_arrow, MenuGlyph.Arrow );
541 bmp.MakeTransparent( );
543 if ( item.Enabled ) {
544 e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
545 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
547 ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
548 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
551 dc.SmoothingMode = old_smoothing_mode;
556 /* Draw checked or radio */
557 if ( item.MenuBar == false && item.Checked ) {
559 Rectangle area = e.Bounds;
560 int cx = MenuCheckSize.Width;
561 int cy = MenuCheckSize.Height;
562 using ( Bitmap bmp = new Bitmap( cx, cy ) ) {
563 using ( Graphics gr = Graphics.FromImage( bmp ) ) {
564 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
566 if ( item.RadioCheck )
567 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
569 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
571 bmp.MakeTransparent( );
572 e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
578 public override void DrawPopupMenu( Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect ) {
580 dc.FillRectangle( ResPool.GetSolidBrush
581 ( menu_background_color ), cliparea );
583 /* Draw menu borders */
584 dc.DrawRectangle( ResPool.GetPen( menu_border_color ), rect.X, rect.Y, rect.Width - 1, rect.Height - 1 );
587 Pen tmp_pen = ResPool.GetPen( Color.White );
588 dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 1, rect.Right - 2, rect.Y + 1 );
589 dc.DrawLine( tmp_pen, rect.X + 1, rect.Y + 2, rect.X + 1, rect.Bottom - 2 );
591 tmp_pen = ResPool.GetPen( menu_inner_border_color );
592 dc.DrawLine( tmp_pen, rect.Right - 2, rect.Y + 2, rect.Right - 2, rect.Bottom - 2 );
593 dc.DrawLine( tmp_pen, rect.Right - 3, rect.Bottom - 2, rect.X + 2, rect.Bottom - 2 );
595 for ( int i = 0; i < menu.MenuItems.Count; i++ )
596 if ( cliparea.IntersectsWith( menu.MenuItems[ i ].bounds ) ) {
597 MenuItem item = menu.MenuItems[ i ];
598 item.MenuHeight = menu.Height;
599 item.PerformDrawItem( new DrawItemEventArgs( dc, MenuFont,
600 item.bounds, i, item.Status ) );
606 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl ) {
607 Rectangle client_area = ctrl.client_area;
609 Rectangle bar = ctrl.client_area;
611 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
613 bar.Width = barpos_pixels + 1;
615 // Draw bar background
616 dc.FillRectangle( ResPool.GetSolidBrush( menu_separator_color ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
619 Pen tmp_pen = ResPool.GetPen( progressbar_edge_dot_color );
620 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1 );
621 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
622 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1 );
623 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
625 tmp_pen = ResPool.GetPen( scrollbar_border_color );
626 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Y );
627 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Right - 1, ctrl.ClientRectangle.Bottom - 2 );
628 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Bottom - 1, ctrl.ClientRectangle.Right - 2, ctrl.ClientRectangle.Bottom - 1 );
629 dc.DrawLine( tmp_pen, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.X, ctrl.ClientRectangle.Bottom - 2 );
631 if ( barpos_pixels <= 0 )
634 if ((bar.Width - 2) <= 0 || (bar.Height - 1) <= 0)
638 dc.DrawRectangle( ResPool.GetPen( combobox_focus_border_color ), bar.X - 1, bar.Y - 1, bar.Width, bar.Height + 1 );
639 tmp_pen = ResPool.GetPen( progressbar_inner_border_color );
640 dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.Right - 2, bar.Y );
641 dc.DrawLine( tmp_pen, bar.X, bar.Y, bar.X, bar.Bottom - 1 );
643 using ( Bitmap bmp = new Bitmap( bar.Width - 2, bar.Height - 1 ) ) {
644 using ( Graphics gr = Graphics.FromImage( bmp ) ) {
645 gr.FillRectangle( ResPool.GetSolidBrush( tab_focus_color ), 0, 0, bmp.Width, bmp.Height );
647 LinearGradientBrush lgbr = new LinearGradientBrush( new Rectangle( 0, 0, bmp.Height, bmp.Height ), progressbar_first_gradient_color, progressbar_second_gradient_color, 0.0f, true );
649 lgbr.RotateTransform( 45.0f, MatrixOrder.Append );
651 float pen_width = bmp.Height / 2;
653 Pen pen = new Pen( lgbr, pen_width );
655 int add = bmp.Height + (int)pen.Width / 2;
658 int x_bottom = - bmp.Height;
660 while ( x_bottom < bmp.Width ) {
661 gr.DrawLine( pen, x_top, 0, x_bottom, bmp.Height );
669 dc.DrawImage( bmp, bar.X + 1, bar.Y + 1 );
672 #endregion // ProgressBar
676 // renders a radio button with the Flat and Popup FlatStyle
677 protected override void DrawFlatStyleRadioButton (Graphics dc, Rectangle rectangle, RadioButton radio_button)
679 if (radio_button.Enabled) {
680 // draw the outer flatstyle arcs
681 if (radio_button.FlatStyle == FlatStyle.Flat) {
682 dc.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
684 // fill in the area depending on whether or not the mouse is hovering
685 if (radio_button.is_entered && radio_button.Capture) {
686 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
688 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
691 // must be a popup radio button
693 dc.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
695 if (radio_button.is_entered || radio_button.Capture) {
696 // draw the popup 3d button knob
697 dc.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
699 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
700 dc.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
703 // just draw lighter flatstyle outer circle
704 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);
709 // fill control background color regardless of actual backcolor
710 dc.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
711 // draw the ark as control dark
712 dc.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
716 if (radio_button.Checked) {
717 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
718 dc.SmoothingMode = SmoothingMode.AntiAlias;
720 CL_Draw_RadioButton_Dot (dc, rectangle, true, false);
722 dc.SmoothingMode = old_smoothing_mode;
725 #endregion // RadioButton
728 public override void DrawScrollBar( Graphics dc, Rectangle clip, ScrollBar bar ) {
729 int scrollbutton_width = bar.scrollbutton_width;
730 int scrollbutton_height = bar.scrollbutton_height;
731 Rectangle first_arrow_area;
732 Rectangle second_arrow_area;
735 thumb_pos = bar.ThumbPos;
738 first_arrow_area = new Rectangle( 0, 0, bar.Width, scrollbutton_height + 1 );
739 bar.FirstArrowArea = first_arrow_area;
741 second_arrow_area = new Rectangle( 0, bar.ClientRectangle.Height - scrollbutton_height - 1, bar.Width, scrollbutton_height + 1 );
742 bar.SecondArrowArea = second_arrow_area;
744 thumb_pos.Width = bar.Width;
745 bar.ThumbPos = thumb_pos;
748 switch ( bar.thumb_moving ) {
749 case ScrollBar.ThumbMoving.None: {
750 ScrollBar_Vertical_Draw_ThumbMoving_None( scrollbutton_height, bar, clip, dc );
753 case ScrollBar.ThumbMoving.Forward: {
754 ScrollBar_Vertical_Draw_ThumbMoving_Forward( scrollbutton_height, bar, thumb_pos, clip, dc );
758 case ScrollBar.ThumbMoving.Backwards: {
759 ScrollBar_Vertical_Draw_ThumbMoving_Backwards( scrollbutton_height, bar, thumb_pos, clip, dc );
768 if ( clip.IntersectsWith( first_arrow_area ) )
769 CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state );
770 if ( clip.IntersectsWith( second_arrow_area ) )
771 CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state );
773 first_arrow_area = new Rectangle( 0, 0, scrollbutton_width + 1, bar.Height );
774 bar.FirstArrowArea = first_arrow_area;
776 second_arrow_area = new Rectangle( bar.ClientRectangle.Width - scrollbutton_width - 1, 0, scrollbutton_width + 1, bar.Height );
777 bar.SecondArrowArea = second_arrow_area;
779 thumb_pos.Height = bar.Height;
780 bar.ThumbPos = thumb_pos;
783 switch ( bar.thumb_moving ) {
784 case ScrollBar.ThumbMoving.None: {
785 ScrollBar_Horizontal_Draw_ThumbMoving_None( scrollbutton_width, bar, clip, dc );
789 case ScrollBar.ThumbMoving.Forward: {
790 ScrollBar_Horizontal_Draw_ThumbMoving_Forward( scrollbutton_width, thumb_pos, bar, clip, dc );
794 case ScrollBar.ThumbMoving.Backwards: {
795 ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( scrollbutton_width, thumb_pos, bar, clip, dc );
801 if ( clip.IntersectsWith( first_arrow_area ) )
802 CPDrawScrollButton( dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state );
803 if ( clip.IntersectsWith( second_arrow_area ) )
804 CPDrawScrollButton( dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state );
808 ScrollBar_DrawThumb( bar, thumb_pos, clip, dc );
811 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
812 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
813 DrawScrollBarThumb( dc, thumb_pos, bar );
816 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc ) {
817 Rectangle r = new Rectangle( 0,
818 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
819 Rectangle intersect = Rectangle.Intersect( clip, r );
821 if ( intersect != Rectangle.Empty ) {
822 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
823 Pen pen = ResPool.GetPen( scrollbar_border_color );
824 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
825 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
829 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
830 Rectangle r = new Rectangle( 0, scrollbutton_height,
831 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
832 Rectangle intersect = Rectangle.Intersect( clip, r );
834 if ( intersect != Rectangle.Empty ) {
835 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
836 Pen pen = ResPool.GetPen( scrollbar_border_color );
837 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
838 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
842 r.Y = thumb_pos.Y + thumb_pos.Height;
843 r.Width = bar.ClientRectangle.Width;
844 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
846 intersect = Rectangle.Intersect( clip, r );
847 if ( intersect != Rectangle.Empty ) {
848 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
849 Pen pen = ResPool.GetPen( scrollbar_border_color );
850 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
851 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
855 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc ) {
856 Rectangle r = new Rectangle( 0, scrollbutton_height,
857 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
858 Rectangle intersect = Rectangle.Intersect( clip, r );
860 if ( intersect != Rectangle.Empty ) {
861 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
862 Pen pen = ResPool.GetPen( scrollbar_border_color );
863 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
864 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
868 r.Y = thumb_pos.Y + thumb_pos.Height;
869 r.Width = bar.ClientRectangle.Width;
870 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
872 intersect = Rectangle.Intersect( clip, r );
873 if ( intersect != Rectangle.Empty ) {
874 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
875 Pen pen = ResPool.GetPen( scrollbar_border_color );
876 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.X, intersect.Bottom - 1 );
877 dc.DrawLine( pen, intersect.Right - 1, intersect.Y, intersect.Right - 1, intersect.Bottom - 1 );
881 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc ) {
882 Rectangle r = new Rectangle( scrollbutton_width,
883 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
884 Rectangle intersect = Rectangle.Intersect( clip, r );
886 if ( intersect != Rectangle.Empty ) {
887 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
888 Pen pen = ResPool.GetPen( scrollbar_border_color );
889 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
890 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
894 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
895 Rectangle r = new Rectangle( scrollbutton_width, 0,
896 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
897 Rectangle intersect = Rectangle.Intersect( clip, r );
899 if ( intersect != Rectangle.Empty ) {
900 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
901 Pen pen = ResPool.GetPen( scrollbar_border_color );
902 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
903 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
906 r.X = thumb_pos.X + thumb_pos.Width;
908 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
909 r.Height = bar.ClientRectangle.Height;
911 intersect = Rectangle.Intersect( clip, r );
912 if ( intersect != Rectangle.Empty ) {
913 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
914 Pen pen = ResPool.GetPen( scrollbar_border_color );
915 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
916 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
920 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc ) {
921 Rectangle r = new Rectangle( scrollbutton_width, 0,
922 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
923 Rectangle intersect = Rectangle.Intersect( clip, r );
925 if ( intersect != Rectangle.Empty ) {
926 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
927 Pen pen = ResPool.GetPen( scrollbar_border_color );
928 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
929 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
932 r.X = thumb_pos.X + thumb_pos.Width;
934 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
935 r.Height = bar.ClientRectangle.Height;
937 intersect = Rectangle.Intersect( clip, r );
938 if ( intersect != Rectangle.Empty ) {
939 dc.FillRectangle( ResPool.GetSolidBrush( scrollbar_background_color ), intersect );
940 Pen pen = ResPool.GetPen( scrollbar_border_color );
941 dc.DrawLine( pen, intersect.X, intersect.Y, intersect.Right - 1, intersect.Y );
942 dc.DrawLine( pen, intersect.X, intersect.Bottom - 1, intersect.Right - 1, intersect.Bottom - 1 );
945 #endregion // ScrollBar
948 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
949 Brush br_forecolor, StatusBarPanel panel ) {
950 int border_size = 3; // this is actually const, even if the border style is none
952 area.Height -= border_size;
953 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None ) {
954 dc.DrawRectangle( ResPool.GetPen( pressed_inner_border_dark_color ), area );
957 if ( panel.Style == StatusBarPanelStyle.OwnerDraw ) {
958 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
959 dc, panel.Parent.Font, area, index, DrawItemState.Default,
960 panel, panel.Parent.ForeColor, panel.Parent.BackColor );
961 panel.Parent.OnDrawItemInternal( e );
965 int left = area.Left;
966 if ( panel.Icon != null ) {
968 dc.DrawIcon( panel.Icon, left, area.Top );
969 left += panel.Icon.Width;
972 if ( panel.Text == String.Empty )
975 string text = panel.Text;
976 StringFormat string_format = new StringFormat( );
977 string_format.Trimming = StringTrimming.Character;
978 string_format.FormatFlags = StringFormatFlags.NoWrap;
980 if ( text[ 0 ] == '\t' ) {
981 string_format.Alignment = StringAlignment.Center;
982 text = text.Substring( 1 );
983 if ( text[ 0 ] == '\t' ) {
984 string_format.Alignment = StringAlignment.Far;
985 text = text.Substring( 1 );
989 int x = left + border_size;
990 int y = border_size + 2;
991 Rectangle r = new Rectangle( x, y,
992 area.Right - x - border_size,
993 area.Bottom - y - border_size );
995 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
997 #endregion // StatusBar
999 // FIXME: regions near the borders don't get filled with the correct backcolor
1000 // TODO: TabAlignment.Left and TabAlignment.Bottom
1001 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab ) {
1002 if (tab.Parent != null)
1003 dc.FillRectangle( ResPool.GetSolidBrush( tab.Parent.BackColor ), area );
1005 dc.FillRectangle( ResPool.GetSolidBrush( tab.BackColor ), area );
1006 Rectangle panel_rect = GetTabPanelRectExt( tab );
1008 if ( tab.Appearance == TabAppearance.Normal ) {
1010 switch ( tab.Alignment ) {
1011 case TabAlignment.Top:
1013 Pen pen = ResPool.GetPen( Color.White );
1015 dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top, panel_rect.Left + 1, panel_rect.Bottom - 1 );
1016 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top , panel_rect.Right - 2, panel_rect.Top );
1018 pen = ResPool.GetPen( tab_inner_border_color );
1019 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
1020 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
1023 pen = ResPool.GetPen( tab_border_color );
1025 dc.DrawLine( pen, panel_rect.Left, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Top - 1 );
1026 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top - 1, panel_rect.Right - 1, panel_rect.Bottom - 2 );
1027 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom - 2, panel_rect.Right - 3, panel_rect.Bottom );
1028 dc.DrawLine( pen, panel_rect.Right - 3, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
1029 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
1030 dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top - 1 );
1033 // FIXME: the size of the tab page is to big to draw the upper inner white border
1034 case TabAlignment.Right:
1036 pen = ResPool.GetPen( Color.White );
1038 dc.DrawLine( pen, panel_rect.Left + 1, panel_rect.Top + 1, panel_rect.Left + 1, panel_rect.Bottom - 1 );
1039 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top + 1 , panel_rect.Right - 2, panel_rect.Top + 1 );
1041 pen = ResPool.GetPen( tab_inner_border_color );
1042 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Top + 1, panel_rect.Right - 2, panel_rect.Bottom - 2 );
1043 dc.DrawLine( pen, panel_rect.Right - 2, panel_rect.Bottom - 1, panel_rect.Left + 2, panel_rect.Bottom - 1 );
1046 pen = ResPool.GetPen( tab_border_color );
1048 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Top, panel_rect.Right - 1, panel_rect.Top );
1049 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Top, panel_rect.Right - 1, panel_rect.Bottom );
1050 dc.DrawLine( pen, panel_rect.Right - 1, panel_rect.Bottom, panel_rect.Left + 2, panel_rect.Bottom );
1051 dc.DrawLine( pen, panel_rect.Left + 2, panel_rect.Bottom, panel_rect.Left, panel_rect.Bottom - 2 );
1052 dc.DrawLine( pen, panel_rect.Left, panel_rect.Bottom - 2, panel_rect.Left, panel_rect.Top + 2 );
1053 dc.DrawLine( pen, panel_rect.Left, panel_rect.Top + 2, panel_rect.Left + 2, panel_rect.Top );
1058 if (tab.Alignment == TabAlignment.Top) {
1059 for (int r = tab.TabPages.Count; r > 0; r--) {
1060 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
1061 if (i == tab.SelectedIndex)
1063 if (r != tab.TabPages [i].Row)
1065 Rectangle rect = tab.GetTabRect (i);
1066 if (!rect.IntersectsWith (area))
1068 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1072 for (int r = 0; r < tab.TabPages.Count; r++) {
1073 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
1074 if (i == tab.SelectedIndex)
1076 if (r != tab.TabPages [i].Row)
1078 Rectangle rect = tab.GetTabRect (i);
1079 if (!rect.IntersectsWith (area))
1081 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1086 if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
1087 Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
1088 if (rect.IntersectsWith (area))
1089 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
1092 if (tab.ShowSlider) {
1093 Rectangle right = GetTabControlRightScrollRect (tab);
1094 Rectangle left = GetTabControlLeftScrollRect (tab);
1095 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
1096 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
1100 protected override int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
1102 int FlatButtonSpacing = 8;
1104 int res = bounds.Width;
1106 if (page.BackColor != tab_selected_gradient_second_color)
1107 page.BackColor = tab_selected_gradient_second_color;
1109 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
1111 StringFormat string_format = new StringFormat ();
1113 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
1114 dc.FillRectangle (ResPool.GetSolidBrush (tab_selected_gradient_second_color), bounds);
1117 if (tab.Appearance == TabAppearance.FlatButtons) {
1118 int width = bounds.Width;
1119 bounds.Width += (FlatButtonSpacing - 2);
1121 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
1122 bounds.Width = width;
1126 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
1127 } else if (tab.Appearance != TabAppearance.FlatButtons) {
1128 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
1131 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
1133 string_format.Alignment = StringAlignment.Center;
1134 string_format.LineAlignment = StringAlignment.Center;
1135 string_format.FormatFlags = StringFormatFlags.NoWrap;
1137 Color tab_first_color = is_selected ? tab_selected_gradient_first_color : tab_not_selected_gradient_first_color;
1138 Color tab_second_color = is_selected ? tab_selected_gradient_second_color : tab_not_selected_gradient_second_color;
1140 switch (tab.Alignment) {
1141 case TabAlignment.Top:
1143 Rectangle tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
1145 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)) {
1146 dc.FillRectangle (lgbr, tab_interior);
1150 Pen tmp_pen = ResPool.GetPen (tab_edge_color);
1151 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 1, bounds.Left + 1, bounds.Top);
1152 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top, bounds.Right, bounds.Top + 1);
1155 tmp_pen = ResPool.GetPen (Color.White);
1156 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 1);
1157 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 1, bounds.Top + 1);
1160 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1161 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
1162 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
1163 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
1165 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)) {
1166 int diff = is_selected ? 3 : 2;
1167 using (Pen lgbrpen = new Pen (lgbr)) {
1168 dc.DrawLine (lgbrpen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - diff);
1169 dc.DrawLine (lgbrpen, bounds.Right, bounds.Top + 2, bounds.Right, bounds.Bottom - diff);
1174 tmp_pen = ResPool.GetPen (tab_focus_color);
1175 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Right - 1, bounds.Top + 2);
1176 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
1178 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1179 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left + 2, bounds.Top);
1180 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Right - 2, bounds.Top);
1181 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
1184 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1186 string_format.Alignment = StringAlignment.Center;
1187 string_format.LineAlignment = StringAlignment.Center;
1188 string_format.FormatFlags = StringFormatFlags.NoWrap;
1192 case TabAlignment.Bottom:
1194 tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 3);
1196 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)) {
1197 dc.FillRectangle (lgbr, tab_interior);
1201 tmp_pen = ResPool.GetPen (tab_edge_color);
1202 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
1203 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom, bounds.Right, bounds.Bottom - 1);
1206 tmp_pen = ResPool.GetPen (Color.White);
1207 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 1, bounds.Top + 2);
1208 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
1211 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1212 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1213 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
1214 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
1216 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)) {
1217 int diff = is_selected ? 3 : 2;
1218 using (Pen lgbrpen = new Pen (lgbr)) {
1219 dc.DrawLine (lgbrpen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 1 - diff);
1220 dc.DrawLine (lgbrpen, bounds.Right, bounds.Top + 2, bounds.Left, bounds.Bottom - 1 - diff);
1225 tmp_pen = ResPool.GetPen (tab_focus_color);
1226 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Bottom - 2);
1227 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
1229 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1230 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1231 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Bottom, bounds.Right - 2, bounds.Bottom);
1232 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
1235 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1237 string_format.Alignment = StringAlignment.Center;
1238 string_format.LineAlignment = StringAlignment.Center;
1239 string_format.FormatFlags = StringFormatFlags.NoWrap;
1243 case TabAlignment.Left:
1245 int w_diff = is_selected ? 2 : 0;
1247 tab_interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 2 - w_diff, bounds.Height - 2);
1249 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)) {
1250 dc.FillRectangle (lgbr, tab_interior);
1254 tmp_pen = ResPool.GetPen (tab_edge_color);
1255 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top, bounds.Left, bounds.Top + 1);
1256 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 1, bounds.Left + 1, bounds.Bottom);
1259 tmp_pen = ResPool.GetPen (Color.White);
1260 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 1, bounds.Right - 3, bounds.Top + 1);
1261 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
1264 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1265 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top, bounds.Left, bounds.Top + 2);
1266 dc.DrawLine (tmp_pen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 2);
1267 dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
1269 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)) {
1270 int diff = is_selected ? 3 : 1;
1272 using (Pen lgbrpen = new Pen (lgbr)) {
1273 dc.DrawLine (lgbrpen, bounds.Left + 2, bounds.Top, bounds.Right - diff, bounds.Left + 2);
1274 dc.DrawLine (lgbrpen, bounds.Left + 2, bounds.Bottom, bounds.Right - diff, bounds.Left + 2);
1279 tmp_pen = ResPool.GetPen (tab_focus_color);
1280 dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top + 1, bounds.Left + 3, bounds.Bottom - 1);
1281 dc.DrawLine (tmp_pen, bounds.Left + 2, bounds.Top + 2, bounds.Left + 2, bounds.Bottom - 2);
1283 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1284 dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top, bounds.Left + 1, bounds.Top + 2);
1285 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
1286 dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom);
1289 interior = new Rectangle (bounds.Left + 2, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1291 string_format.Alignment = StringAlignment.Center;
1292 string_format.LineAlignment = StringAlignment.Center;
1293 string_format.FormatFlags = StringFormatFlags.NoWrap;
1294 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
1299 // TabAlignment.Right
1301 tab_interior = new Rectangle (bounds.Left, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2);
1303 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)) {
1304 dc.FillRectangle (lgbr, tab_interior);
1307 int l_diff = is_selected ? 2 : 0;
1310 tmp_pen = ResPool.GetPen (tab_edge_color);
1311 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right - 1, bounds.Top + 1);
1312 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom);
1315 tmp_pen = ResPool.GetPen (Color.White);
1316 dc.DrawLine (tmp_pen, bounds.Left + l_diff, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
1317 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
1320 tmp_pen = ResPool.GetPen (border_pressed_dark_color);
1321 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
1322 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
1323 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
1325 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)) {
1326 int diff = is_selected ? 3 : 1;
1328 using (Pen lgbrpen = new Pen (lgbr)) {
1329 dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Top, bounds.Right - diff, bounds.Top);
1330 dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Bottom, bounds.Right - diff, bounds.Bottom);
1335 tmp_pen = ResPool.GetPen (tab_focus_color);
1336 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top + 1, bounds.Right - 3, bounds.Bottom - 1);
1337 dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
1339 tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
1340 dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
1341 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
1342 dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
1345 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
1347 string_format.Alignment = StringAlignment.Center;
1348 string_format.LineAlignment = StringAlignment.Center;
1349 string_format.FormatFlags = StringFormatFlags.NoWrap;
1350 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
1356 if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
1357 if (tab.Alignment == TabAlignment.Left) {
1358 int wo = interior.Width / 2;
1359 int ho = interior.Height / 2;
1360 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
1361 dc.RotateTransform (180);
1362 dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
1363 dc.ResetTransform ();
1365 dc.DrawString (page.Text, page.Font,
1366 ResPool.GetSolidBrush (SystemColors.ControlText),
1367 interior, string_format);
1369 } else if (page.Text != null) {
1370 DrawItemState state = DrawItemState.None;
1371 if (page == tab.SelectedTab)
1372 state |= DrawItemState.Selected;
1373 DrawItemEventArgs e = new DrawItemEventArgs (dc,
1374 tab.Font, bounds, tab.IndexForTabPage (page),
1375 state, page.ForeColor, page.BackColor);
1376 tab.OnDrawItemInternal (e);
1383 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state ) {
1384 Point[] arrow = new Point[ 3 ];
1394 bool pushed = false;
1396 Color first_color = Color.White;
1397 Color second_color = combobox_button_second_gradient_color;
1399 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1401 if ( state == ButtonState.Pushed ) {
1402 first_color = pressed_gradient_first_color;
1403 second_color = pressed_gradient_second_color;
1407 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y + 2 ), new Point( rectangle.X, rectangle.Bottom - 2 ), first_color, second_color ) ) {
1408 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
1412 Pen tmp_pen = ResPool.GetPen( !pushed ? Color.White : pressed_inner_border_dark_color );
1413 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 1 );
1414 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 2 );
1416 tmp_pen = ResPool.GetPen( !pushed ? inner_border_dark_color : pressed_inner_border_dark_color );
1417 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y + 2, rectangle.Right - 2, rectangle.Bottom - 2 );
1418 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 2 );
1421 Point[] points = new Point[] {
1422 new Point( rectangle.X, rectangle.Y ),
1423 new Point( rectangle.Right - 3, rectangle.Y ),
1424 new Point( rectangle.Right - 1, rectangle.Y + 2 ),
1425 new Point( rectangle.Right - 1, rectangle.Bottom - 3 ),
1426 new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
1427 new Point( rectangle.X, rectangle.Bottom - 1 ),
1428 new Point( rectangle.X, rectangle.Y )
1431 dc.DrawPolygon( ResPool.GetPen( pushed ? border_pressed_dark_color : border_normal_dark_color ), points );
1433 // edges on right side
1434 tmp_pen = ResPool.GetPen( control_parent_backcolor );
1435 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
1436 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
1438 tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
1439 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
1440 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 2 );
1442 rect = new Rectangle( rectangle.X + 1 + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2 - 1, rectangle.Height / 2 );
1443 centerX = rect.Left + rect.Width / 2;
1444 centerY = rect.Top + rect.Height / 2;
1445 shiftX = Math.Max( 1, rect.Width / 8 );
1446 shiftY = Math.Max( 1, rect.Height / 8 );
1448 if ( ( state & ButtonState.Pushed ) != 0 ) {
1456 P1 = new Point( rect.Left, centerY );
1457 P2 = new Point( centerX, rect.Bottom );
1458 P3 = new Point( rect.Right - 1, centerY );
1464 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1465 dc.SmoothingMode = SmoothingMode.AntiAlias;
1467 /* Draw the arrow */
1468 if ( state == ButtonState.Inactive ) {
1469 /* Move away from the shadow */
1470 P1.X += 1; P1.Y += 1;
1471 P2.X += 1; P2.Y += 1;
1472 P3.X += 1; P3.Y += 1;
1478 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) ) {
1479 dc.DrawLines( pen, arrow );
1482 P1 = new Point( rect.Left, centerY );
1483 P2 = new Point( centerX, rect.Bottom );
1484 P3 = new Point( rect.Right - 1, centerY );
1490 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) ) {
1491 dc.DrawLines( pen, arrow );
1494 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) ) {
1495 dc.DrawLines( pen, arrow );
1499 dc.SmoothingMode = old_smoothing_mode;
1502 /* Scroll button: regular button + direction arrow */
1503 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state ) {
1504 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1506 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1511 color_arrow = arrow_color;
1513 color_arrow = ColorGrayText;
1517 int centerX = area.Left + area.Width / 2;
1518 int centerY = area.Top + area.Height / 2;
1522 if ( ( state & ButtonState.Pushed ) != 0 )
1527 if ( area.Width < 12 || area.Height < 12 ) {
1532 Point[] arrow = new Point[ 4 ];
1534 switch (scroll_button_type) {
1535 case ScrollButton.Down:
1536 centerY += shift + 1;
1537 arrow [0] = new Point (centerX - min_4, centerY - min_2);
1538 arrow [1] = new Point (centerX, centerY + min_2);
1539 arrow [2] = new Point (centerX + min_4, centerY - min_2);
1540 arrow [3] = new Point (centerX - min_4, centerY - min_2);
1542 case ScrollButton.Up:
1544 arrow [0] = new Point (centerX - min_4, centerY + min_2);
1545 arrow [1] = new Point (centerX, centerY - min_2);
1546 arrow [2] = new Point (centerX + min_4, centerY + min_2);
1547 arrow [3] = new Point (centerX - min_4, centerY + min_2);
1549 case ScrollButton.Left:
1551 arrow [0] = new Point (centerX + min_2, centerY - min_4);
1552 arrow [1] = new Point (centerX + min_2, centerY + min_4);
1553 arrow [2] = new Point (centerX - min_2, centerY);
1554 arrow [3] = new Point (centerX + min_2, centerY - min_4);
1556 case ScrollButton.Right:
1557 centerX += shift + 1;
1558 arrow [0] = new Point (centerX - min_2, centerY - min_4);
1559 arrow [1] = new Point (centerX + min_2, centerY);
1560 arrow [2] = new Point (centerX - min_2, centerY + min_4);
1561 arrow [3] = new Point (centerX - min_2, centerY - min_4);
1567 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1568 dc.SmoothingMode = SmoothingMode.AntiAlias;
1569 dc.FillPolygon( ResPool.GetSolidBrush( color_arrow ), arrow );
1570 dc.SmoothingMode = old_smoothing_mode;
1573 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds ) {
1574 Point pt1 = new Point( bounds.Right - 3, bounds.Bottom );
1575 Point pt2 = new Point( bounds.Right, bounds.Bottom - 3 );
1578 Pen tmp_pen = ResPool.GetPen( Color.White );
1579 for ( int i = 0; i < 4; i++ ) {
1580 dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
1586 tmp_pen = ResPool.GetPen( pressed_inner_border_dark_color );
1587 for ( int i = 0; i < 4; i++ ) {
1588 dc.DrawLine( tmp_pen, pt1.X - i * 4, pt1.Y, pt2.X, pt2.Y - i * 4 );
1592 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar ) {
1593 LinearGradientBrush lgbr = null;
1596 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 );
1598 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 );
1600 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1605 Pen pen = ResPool.GetPen( border_normal_dark_color );
1607 dc.DrawRectangle( pen, area.X, area.Y, area.Width - 1, area.Height - 1 );
1610 pen = ResPool.GetPen( Color.White );
1611 dc.DrawLine( pen, area.X + 1, area.Bottom - 2, area.X + 1, area.Y + 1 );
1612 dc.DrawLine( pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1614 pen = ResPool.GetPen( inner_border_dark_color );
1615 dc.DrawLine( pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1616 dc.DrawLine( pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1619 if ( area.Height > 12 ) {
1620 int mid_y = area.Y + ( area.Height / 2 );
1621 int mid_x = area.X + ( area.Width / 2 );
1623 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1624 dc.DrawLine( pen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1625 dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x + 3, mid_y - 3 );
1626 dc.DrawLine( pen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1628 Pen spen = ResPool.GetPen( Color.White );
1629 dc.DrawLine( spen, mid_x - 3, mid_y + 1, mid_x + 3, mid_y + 1 );
1630 dc.DrawLine( spen, mid_x - 3, mid_y - 2, mid_x + 3, mid_y - 2 );
1631 dc.DrawLine( spen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1634 // draw grip lines only if there is enough space
1635 if ( area.Width > 12 ) {
1636 int mid_x = area.X + ( area.Width / 2 );
1637 int mid_y = area.Y + ( area.Height / 2 );
1639 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1640 dc.DrawLine( pen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1641 dc.DrawLine( pen, mid_x - 3, mid_y - 3, mid_x - 3, mid_y + 3 );
1642 dc.DrawLine( pen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1644 Pen spen = ResPool.GetPen( Color.White );
1645 dc.DrawLine( spen, mid_x + 1, mid_y - 3, mid_x + 1, mid_y + 3 );
1646 dc.DrawLine( spen, mid_x - 2, mid_y - 3, mid_x - 2, mid_y + 3 );
1647 dc.DrawLine( spen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1652 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type ) {
1653 Pen pen = ResPool.GetPen( border_normal_dark_color );
1655 Color first_gradient_color = gradient_first_color;
1656 Color second_gradient_color = gradient_second_color_nr2;
1658 bool pushed = false;
1660 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed ) {
1661 first_gradient_color = pressed_gradient_first_color;
1662 second_gradient_color = pressed_gradient_second_color;
1666 Point[] points = null;
1668 LinearGradientBrush lgbr = null;
1670 switch ( scroll_button_type ) {
1671 case ScrollButton.Left:
1672 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1673 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.X, area.Bottom - 1 );
1675 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 );
1676 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
1678 Pen tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1679 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 2, area.X + 1, area.Bottom - 2 );
1680 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1682 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1683 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1684 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1686 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1687 dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
1688 dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
1690 points = new Point[] {
1691 new Point( area.X + 2, area.Y ),
1692 new Point( area.Right - 1, area.Y ),
1693 new Point( area.Right - 1, area.Bottom - 1 ),
1694 new Point( area.X + 2, area.Bottom - 1 ),
1695 new Point( area.X, area.Bottom - 3 ),
1696 new Point( area.X, area.Y + 2 ),
1697 new Point( area.X + 2, area.Y )
1699 dc.DrawPolygon( pen, points );
1701 case ScrollButton.Right:
1702 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1703 dc.DrawLine( ResPool.GetPen( ColorControl ), area.Right - 1, area.Y, area.Right - 1, area.Bottom - 1 );
1705 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 );
1706 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 2 );
1708 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1709 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1710 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1712 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1713 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1714 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1716 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1717 dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
1718 dc.DrawLine( tmp_pen, area.Right - 1, area.Bottom - 2, area.Right - 2, area.Bottom - 1 );
1720 points = new Point[] {
1721 new Point( area.X, area.Y ),
1722 new Point( area.Right - 3, area.Y ),
1723 new Point( area.Right - 1, area.Y + 2 ),
1724 new Point( area.Right - 1, area.Bottom - 3 ),
1725 new Point( area.Right - 3, area.Bottom - 1 ),
1726 new Point( area.X, area.Bottom - 1 ),
1727 new Point( area.X, area.Y ),
1729 dc.DrawPolygon( pen, points );
1731 case ScrollButton.Up:
1732 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1733 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Y, area.Right - 1, area.Y );
1735 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
1736 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1738 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1739 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1740 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1742 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1743 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1744 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1746 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1747 dc.DrawLine( tmp_pen, area.X, area.Y + 1, area.X + 1, area.Y );
1748 dc.DrawLine( tmp_pen, area.Right - 2, area.Y, area.Right - 1, area.Y + 1 );
1750 points = new Point[] {
1751 new Point( area.X + 2, area.Y ),
1752 new Point( area.Right - 3, area.Y ),
1753 new Point( area.Right - 1, area.Y + 2 ),
1754 new Point( area.Right - 1, area.Bottom - 1 ),
1755 new Point( area.X, area.Bottom - 1 ),
1756 new Point( area.X, area.Y + 2 ),
1757 new Point( area.X + 2, area.Y )
1759 dc.DrawPolygon( pen, points );
1761 case ScrollButton.Down:
1762 // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
1763 dc.DrawLine( ResPool.GetPen( ColorControl ), area.X, area.Bottom - 1, area.Right - 1, area.Bottom - 1 );
1765 lgbr = new LinearGradientBrush( new Point( area.X + 2, area.Y ), new Point( area.Right - 2, area.Y ), first_gradient_color, second_gradient_color );
1766 dc.FillRectangle( lgbr, area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4 );
1768 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : Color.White );
1769 dc.DrawLine( tmp_pen, area.X + 1, area.Y + 1, area.X + 1, area.Bottom - 2 );
1770 dc.DrawLine( tmp_pen, area.X + 2, area.Y + 1, area.Right - 2, area.Y + 1 );
1772 tmp_pen = ResPool.GetPen( pushed ? pressed_inner_border_dark_color : inner_border_dark_color );
1773 dc.DrawLine( tmp_pen, area.Right - 2, area.Y + 2, area.Right - 2, area.Bottom - 2 );
1774 dc.DrawLine( tmp_pen, area.X + 2, area.Bottom - 2, area.Right - 3, area.Bottom - 2 );
1776 tmp_pen = ResPool.GetPen( edge_top_inner_color );
1777 dc.DrawLine( tmp_pen, area.X, area.Bottom - 2, area.X + 1, area.Bottom - 1 );
1778 dc.DrawLine( tmp_pen, area.Right - 2, area.Bottom - 1, area.Right - 1, area.Bottom - 2 );
1780 points = new Point[] {
1781 new Point( area.X, area.Y ),
1782 new Point( area.Right - 1, area.Y ),
1783 new Point( area.Right - 1, area.Bottom - 3 ),
1784 new Point( area.Right - 3, area.Bottom - 1 ),
1785 new Point( area.X + 2, area.Bottom - 1 ),
1786 new Point( area.X, area.Bottom - 3 ),
1787 new Point( area.X, area.Y )
1789 dc.DrawPolygon( pen, points );
1797 public override bool ToolBarInvalidateEntireButton {
1798 get { return true; }
1800 #endregion // ToolBar
1803 public override void DrawGroupBox( Graphics dc, Rectangle area, GroupBox box ) {
1804 StringFormat text_format;
1810 rect = box.ClientRectangle;
1812 dc.FillRectangle( ResPool.GetSolidBrush( box.BackColor ), rect );
1814 text_format = new StringFormat( );
1815 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1817 size = dc.MeasureString( box.Text, box.Font );
1818 width = (int) size.Width;
1820 if ( width > box.Width - 16 )
1821 width = box.Width - 16;
1823 y = box.Font.Height / 2;
1825 Pen pen = ResPool.GetPen( pressed_inner_border_dark_color );
1829 new Point( 8 + width, y ),
1830 new Point( box.Width - 3, y ),
1831 new Point( box.Width - 1, y + 2 ),
1832 new Point( box.Width - 1, box.Height - 3 ),
1833 new Point( box.Width - 3, box.Height - 1 ),
1834 new Point( 2, box.Height - 1 ),
1835 new Point( 0, box.Height - 3 ),
1836 new Point( 0, y + 2 ),
1840 dc.DrawLines( pen, points );
1843 if ( box.Enabled ) {
1844 dc.DrawString( box.Text, box.Font, ResPool.GetSolidBrush( box.ForeColor ), 10, 0, text_format );
1846 CPDrawStringDisabled( dc, box.Text, box.Font, box.ForeColor,
1847 new RectangleF( 10, 0, width, box.Font.Height ), text_format );
1849 text_format.Dispose( );
1854 private void DrawTrackBar_Vertical( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
1855 ref Rectangle thumb_pos, ref Rectangle thumb_area,
1856 float ticks, int value_pos, bool mouse_value ) {
1858 Point toptick_startpoint = new Point( );
1859 Point bottomtick_startpoint = new Point( );
1860 Point channel_startpoint = new Point( );
1862 float pixels_betweenticks;
1863 const int space_from_right = 8;
1864 const int space_from_left = 8;
1865 Rectangle area = tb.ClientRectangle;
1867 switch ( tb.TickStyle ) {
1868 case TickStyle.BottomRight:
1869 case TickStyle.None:
1870 channel_startpoint.Y = 8;
1871 channel_startpoint.X = 9;
1872 bottomtick_startpoint.Y = 13;
1873 bottomtick_startpoint.X = 24;
1875 case TickStyle.TopLeft:
1876 channel_startpoint.Y = 8;
1877 channel_startpoint.X = 19;
1878 toptick_startpoint.Y = 13;
1879 toptick_startpoint.X = 8;
1881 case TickStyle.Both:
1882 channel_startpoint.Y = 8;
1883 channel_startpoint.X = 18;
1884 bottomtick_startpoint.Y = 13;
1885 bottomtick_startpoint.X = 32;
1886 toptick_startpoint.Y = 13;
1887 toptick_startpoint.X = 8;
1893 thumb_area.X = area.X + channel_startpoint.X;
1894 thumb_area.Y = area.Y + channel_startpoint.Y;
1895 thumb_area.Height = area.Height - space_from_right - space_from_left;
1896 thumb_area.Width = 4;
1898 pixel_len = thumb_area.Height - 11;
1899 pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
1901 /* Convert thumb position from mouse position to value*/
1902 if ( mouse_value ) {
1904 if ( value_pos >= channel_startpoint.Y )
1905 value_pos = (int)( ( (float) ( value_pos - channel_startpoint.Y ) ) / pixels_betweenticks );
1909 if ( value_pos + tb.Minimum > tb.Maximum )
1910 value_pos = tb.Maximum - tb.Minimum;
1912 tb.Value = value_pos + tb.Minimum;
1915 thumb_pos.Width = 13;
1916 thumb_pos.Height = 29;
1918 thumb_pos.Y = channel_startpoint.Y + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Height / 3 );
1920 if ( thumb_pos.Y < channel_startpoint.Y )
1921 thumb_pos.Y = channel_startpoint.Y;
1923 if ( thumb_pos.Y > thumb_area.Bottom - 29 )
1924 thumb_pos.Y = thumb_area.Bottom - 29;
1928 Pen pen = ResPool.GetPen( tab_top_border_focus_color );
1929 dc.DrawLine( pen, channel_startpoint.X, thumb_pos.Y + 29, channel_startpoint.X, thumb_area.Bottom );
1930 dc.DrawLine( pen, channel_startpoint.X, thumb_area.Bottom, channel_startpoint.X + 4, thumb_area.Bottom );
1931 dc.DrawLine( pen, channel_startpoint.X + 4, thumb_pos.Y + 29, channel_startpoint.X + 4, thumb_area.Bottom );
1933 pen = ResPool.GetPen( menuitem_gradient_first_color );
1934 dc.DrawLine( pen, channel_startpoint.X + 1, thumb_pos.Y + 28, channel_startpoint.X + 1, thumb_area.Bottom - 1 );
1935 pen = ResPool.GetPen( trackbar_second_gradient_color );
1936 dc.DrawLine( pen, channel_startpoint.X + 2, thumb_pos.Y + 28, channel_startpoint.X + 2, thumb_area.Bottom - 1 );
1937 pen = ResPool.GetPen( trackbar_third_gradient_color );
1938 dc.DrawLine( pen, channel_startpoint.X + 3, thumb_pos.Y + 28, channel_startpoint.X + 3, thumb_area.Bottom - 1 );
1941 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1942 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, channel_startpoint.X + 1, thumb_pos.Y );
1943 dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), channel_startpoint.X + 2, channel_startpoint.Y + 1, 1, thumb_pos.Y );
1945 pen = ResPool.GetPen( scrollbar_border_color );
1946 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, thumb_pos.Y );
1947 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X + 4, channel_startpoint.Y );
1948 dc.DrawLine( pen, channel_startpoint.X + 4, channel_startpoint.Y, channel_startpoint.X + 4, thumb_pos.Y );
1951 thumb_pos.X = channel_startpoint.X - 4;
1954 pen = ResPool.GetPen( Color.White );
1955 dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
1956 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
1958 pen = ResPool.GetPen( menu_separator_color );
1959 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
1960 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
1964 new Point( thumb_pos.X + 2, thumb_pos.Y ),
1965 new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
1966 new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
1967 new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
1968 new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
1969 new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
1970 new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
1971 new Point( thumb_pos.X, thumb_pos.Y + 2 ),
1972 new Point( thumb_pos.X + 2, thumb_pos.Y )
1975 dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
1977 Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
1978 Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
1980 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 ) ) {
1981 dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
1985 pen = ResPool.GetPen( edge_top_inner_color );
1986 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
1987 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
1989 pen = ResPool.GetPen( edge_bottom_inner_color );
1990 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
1991 dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
1994 pen = ResPool.GetPen( pressed_inner_border_dark_color );
1995 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 11, thumb_pos.X + 8, thumb_pos.Y + 11 );
1996 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 14, thumb_pos.X + 8, thumb_pos.Y + 14 );
1997 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 17, thumb_pos.X + 8, thumb_pos.Y + 17 );
1999 pen = ResPool.GetPen( Color.White );
2000 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 12, thumb_pos.X + 8, thumb_pos.Y + 12 );
2001 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 15, thumb_pos.X + 8, thumb_pos.Y + 15 );
2002 dc.DrawLine( pen, thumb_pos.X + 4, thumb_pos.Y + 18, thumb_pos.X + 8, thumb_pos.Y + 18 );
2004 pixel_len = thumb_area.Height - 11;
2005 pixels_betweenticks = pixel_len / ticks;
2008 thumb_area.X = thumb_pos.X;
2009 thumb_area.Y = channel_startpoint.Y;
2010 thumb_area.Width = thumb_pos.Width;
2012 Region outside = new Region( area );
2013 outside.Exclude( thumb_area );
2015 if ( outside.IsVisible( clip_rectangle ) ) {
2016 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
2017 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2019 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2020 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2021 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
2022 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc );
2024 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
2025 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc );
2029 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
2030 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2032 pixel_len = thumb_area.Height - 11;
2033 pixels_betweenticks = pixel_len / ticks;
2035 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2036 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2037 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
2038 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
2040 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
2041 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc );
2050 private void DrawTrackBar_Horizontal( Graphics dc, Rectangle clip_rectangle, TrackBar tb,
2051 ref Rectangle thumb_pos, ref Rectangle thumb_area,
2052 float ticks, int value_pos, bool mouse_value ) {
2053 Point toptick_startpoint = new Point( );
2054 Point bottomtick_startpoint = new Point( );
2055 Point channel_startpoint = new Point( );
2057 float pixels_betweenticks;
2058 const int space_from_right = 8;
2059 const int space_from_left = 8;
2060 Rectangle area = tb.ClientRectangle;
2062 switch ( tb.TickStyle ) {
2063 case TickStyle.BottomRight:
2064 case TickStyle.None:
2065 channel_startpoint.X = 8;
2066 channel_startpoint.Y = 9;
2067 bottomtick_startpoint.X = 13;
2068 bottomtick_startpoint.Y = 24;
2070 case TickStyle.TopLeft:
2071 channel_startpoint.X = 8;
2072 channel_startpoint.Y = 19;
2073 toptick_startpoint.X = 13;
2074 toptick_startpoint.Y = 8;
2076 case TickStyle.Both:
2077 channel_startpoint.X = 8;
2078 channel_startpoint.Y = 18;
2079 bottomtick_startpoint.X = 13;
2080 bottomtick_startpoint.Y = 32;
2081 toptick_startpoint.X = 13;
2082 toptick_startpoint.Y = 8;
2088 thumb_area.X = area.X + channel_startpoint.X;
2089 thumb_area.Y = area.Y + channel_startpoint.Y;
2090 thumb_area.Width = area.Width - space_from_right - space_from_left;
2091 thumb_area.Height = 4;
2093 pixel_len = thumb_area.Width - 11;
2094 pixels_betweenticks = pixel_len / ( tb.Maximum - tb.Minimum );
2096 /* Convert thumb position from mouse position to value*/
2097 if ( mouse_value ) {
2098 if ( value_pos >= channel_startpoint.X )
2099 value_pos = (int)( ( (float) ( value_pos - channel_startpoint.X ) ) / pixels_betweenticks );
2103 if ( value_pos + tb.Minimum > tb.Maximum )
2104 value_pos = tb.Maximum - tb.Minimum;
2106 tb.Value = value_pos + tb.Minimum;
2109 thumb_pos.Width = 29;
2110 thumb_pos.Height = 13;
2112 thumb_pos.X = channel_startpoint.X + (int) ( pixels_betweenticks * (float) value_pos ) - ( thumb_pos.Width / 3 );
2114 if ( thumb_pos.X < channel_startpoint.X )
2115 thumb_pos.X = channel_startpoint.X;
2117 if ( thumb_pos.X > thumb_area.Right - 29 )
2118 thumb_pos.X = thumb_area.Right - 29;
2122 Pen pen = ResPool.GetPen( tab_top_border_focus_color );
2123 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, thumb_pos.X, channel_startpoint.Y );
2124 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y, channel_startpoint.X, channel_startpoint.Y + 4 );
2125 dc.DrawLine( pen, channel_startpoint.X, channel_startpoint.Y + 4, thumb_pos.X, channel_startpoint.Y + 4 );
2127 pen = ResPool.GetPen( menuitem_gradient_first_color );
2128 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 1, thumb_pos.X, channel_startpoint.Y + 1 );
2129 pen = ResPool.GetPen( trackbar_second_gradient_color );
2130 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 2, thumb_pos.X, channel_startpoint.Y + 2 );
2131 pen = ResPool.GetPen( trackbar_third_gradient_color );
2132 dc.DrawLine( pen, channel_startpoint.X + 1, channel_startpoint.Y + 3, thumb_pos.X, channel_startpoint.Y + 3 );
2135 pen = ResPool.GetPen( pressed_inner_border_dark_color );
2136 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 1, thumb_area.Right - 1, channel_startpoint.Y + 1 );
2137 dc.DrawRectangle( ResPool.GetPen( scrollbar_background_color ), thumb_pos.X + 29, channel_startpoint.Y + 2, thumb_area.Right - thumb_pos.X - 30, 1 );
2139 pen = ResPool.GetPen( scrollbar_border_color );
2140 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y );
2141 dc.DrawLine( pen, thumb_area.Right, channel_startpoint.Y, thumb_area.Right, channel_startpoint.Y + 4 );
2142 dc.DrawLine( pen, thumb_pos.X + 29, channel_startpoint.Y + 4, thumb_area.Right, channel_startpoint.Y + 4 );
2146 thumb_pos.Y = channel_startpoint.Y - 4;
2149 pen = ResPool.GetPen( Color.White );
2150 dc.DrawLine( pen, thumb_pos.X + 1, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Bottom - 2 );
2151 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Y + 1, thumb_pos.Right - 2, thumb_pos.Y + 1 );
2153 pen = ResPool.GetPen( menu_separator_color );
2154 dc.DrawLine( pen, thumb_pos.X + 2, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
2155 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y + 2, thumb_pos.Right - 2, thumb_pos.Bottom - 2 );
2159 new Point( thumb_pos.X + 2, thumb_pos.Y ),
2160 new Point( thumb_pos.Right - 3 , thumb_pos.Y ),
2161 new Point( thumb_pos.Right - 1, thumb_pos.Y + 2 ),
2162 new Point( thumb_pos.Right - 1, thumb_pos.Bottom - 3 ),
2163 new Point( thumb_pos.Right - 3, thumb_pos.Bottom - 1 ),
2164 new Point( thumb_pos.X + 2, thumb_pos.Bottom - 1 ),
2165 new Point( thumb_pos.X, thumb_pos.Bottom - 3 ),
2166 new Point( thumb_pos.X, thumb_pos.Y + 2 ),
2167 new Point( thumb_pos.X + 2, thumb_pos.Y )
2170 dc.DrawLines( ResPool.GetPen( border_normal_dark_color ), points );
2172 Color first_gradient_color = mouse_value ? button_edge_bottom_outer_color : trackbar_inner_first_gradient_color;
2173 Color second_gradient_color = mouse_value ? trackbar_inner_pressed_second_gradient_color : trackbar_inner_second_gradient_color;
2175 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 ) ) {
2176 dc.FillRectangle( lgbr, thumb_pos.X + 2, thumb_pos.Y + 2, thumb_pos.Width - 4, thumb_pos.Height - 4 );
2180 pen = ResPool.GetPen( edge_top_inner_color );
2181 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Y + 1, thumb_pos.X + 1, thumb_pos.Y );
2182 dc.DrawLine( pen, thumb_pos.Right - 2, thumb_pos.Y, thumb_pos.Right - 1, thumb_pos.Y + 1 );
2184 pen = ResPool.GetPen( edge_bottom_inner_color );
2185 dc.DrawLine( pen, thumb_pos.X, thumb_pos.Bottom - 2, thumb_pos.X + 1, thumb_pos.Bottom - 1 );
2186 dc.DrawLine( pen, thumb_pos.Right - 1, thumb_pos.Bottom - 2, thumb_pos.Right - 2, thumb_pos.Bottom - 1 );
2189 pen = ResPool.GetPen( pressed_inner_border_dark_color );
2190 dc.DrawLine( pen, thumb_pos.X + 11, thumb_pos.Y + 4, thumb_pos.X + 11, thumb_pos.Y + 8 );
2191 dc.DrawLine( pen, thumb_pos.X + 14, thumb_pos.Y + 4, thumb_pos.X + 14, thumb_pos.Y + 8 );
2192 dc.DrawLine( pen, thumb_pos.X + 17, thumb_pos.Y + 4, thumb_pos.X + 17, thumb_pos.Y + 8 );
2194 pen = ResPool.GetPen( Color.White );
2195 dc.DrawLine( pen, thumb_pos.X + 12, thumb_pos.Y + 4, thumb_pos.X + 12, thumb_pos.Y + 8 );
2196 dc.DrawLine( pen, thumb_pos.X + 15, thumb_pos.Y + 4, thumb_pos.X + 15, thumb_pos.Y + 8 );
2197 dc.DrawLine( pen, thumb_pos.X + 18, thumb_pos.Y + 4, thumb_pos.X + 18, thumb_pos.Y + 8 );
2199 pixel_len = thumb_area.Width - 11;
2200 pixels_betweenticks = pixel_len / ticks;
2203 thumb_area.Y = thumb_pos.Y;
2204 thumb_area.X = channel_startpoint.X;
2205 thumb_area.Height = thumb_pos.Height;
2206 Region outside = new Region( area );
2207 outside.Exclude( thumb_area );
2209 if ( outside.IsVisible( clip_rectangle ) ) {
2210 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.BottomRight ) == TickStyle.BottomRight ||
2211 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2213 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2214 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2215 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
2216 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3 );
2218 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
2219 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2 );
2223 if ( pixels_betweenticks > 0 && ( ( tb.TickStyle & TickStyle.TopLeft ) == TickStyle.TopLeft ||
2224 ( ( tb.TickStyle & TickStyle.Both ) == TickStyle.Both ) ) ) {
2226 for ( float inc = 0; inc < ( pixel_len + 1 ); inc += pixels_betweenticks ) {
2227 if ( inc == 0 || ( inc + pixels_betweenticks ) >= pixel_len + 1 )
2228 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
2229 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y );
2231 dc.DrawLine( ResPool.GetPen( pen_ticks_color ), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
2232 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
2240 public override void DrawTrackBar( Graphics dc, Rectangle clip_rectangle, TrackBar tb ) {
2243 float ticks = ( tb.Maximum - tb.Minimum ) / tb.tickFrequency; /* N of ticks draw*/
2245 Rectangle thumb_pos = tb.ThumbPos;
2246 Rectangle thumb_area = tb.ThumbArea;
2248 if ( tb.thumb_pressed ) {
2249 value_pos = tb.thumb_mouseclick;
2252 value_pos = tb.Value - tb.Minimum;
2253 mouse_value = false;
2256 area = tb.ClientRectangle;
2258 /* Control Background */
2259 if ( tb.BackColor == DefaultControlBackColor ) {
2260 dc.FillRectangle( ResPool.GetSolidBrush( ColorControl ), clip_rectangle );
2262 dc.FillRectangle( ResPool.GetSolidBrush( tb.BackColor ), clip_rectangle );
2265 if ( tb.Orientation == Orientation.Vertical ) {
2266 DrawTrackBar_Vertical( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
2267 ticks, value_pos, mouse_value );
2270 DrawTrackBar_Horizontal( dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
2271 ticks, value_pos, mouse_value );
2274 // TODO: draw better focus rectangle
2276 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, area.Width - 1, 1 );
2277 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y + area.Height - 1, area.Width - 1, 1 );
2278 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X, area.Y, 1, area.Height - 1 );
2279 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControl, Color.Black ), area.X + area.Width - 1, area.Y, 1, area.Height - 1 );
2282 tb.ThumbPos = thumb_pos;
2283 tb.ThumbArea = thumb_area;
2285 #endregion // TrackBar
2288 // draws the ListViewItem of the given index
2289 protected override void DrawListViewItem( Graphics dc, ListView control, ListViewItem item ) {
2290 Rectangle rect_checkrect = item.CheckRectReal;
2291 Rectangle rect_iconrect = item.GetBounds( ItemBoundsPortion.Icon );
2292 Rectangle full_rect = item.GetBounds( ItemBoundsPortion.Entire );
2293 Rectangle text_rect = item.GetBounds( ItemBoundsPortion.Label );
2295 if ( control.CheckBoxes ) {
2296 if ( control.StateImageList == null ) {
2297 // Make sure we've got at least a line width of 1
2298 int check_wd = Math.Max( 3, rect_checkrect.Width / 6 );
2299 int scale = Math.Max( 1, rect_checkrect.Width / 12 );
2301 // set the checkbox background
2302 dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorWindow ),
2304 // define a rectangle inside the border area
2305 Rectangle rect = new Rectangle( rect_checkrect.X + 2,
2306 rect_checkrect.Y + 2,
2307 rect_checkrect.Width - 4,
2308 rect_checkrect.Height - 4 );
2309 Pen pen = new Pen( this.ColorWindowText, 2 );
2310 dc.DrawRectangle( pen, rect );
2312 // Need to draw a check-mark
2313 if ( item.Checked ) {
2315 // adjustments to get the check-mark at the right place
2316 rect.X ++; rect.Y ++;
2317 // following logic is taken from DrawFrameControl method
2318 for ( int i = 0; i < check_wd; i++ ) {
2319 dc.DrawLine( pen, rect.Left + check_wd / 2,
2320 rect.Top + check_wd + i,
2321 rect.Left + check_wd / 2 + 2 * scale,
2322 rect.Top + check_wd + 2 * scale + i );
2324 rect.Left + check_wd / 2 + 2 * scale,
2325 rect.Top + check_wd + 2 * scale + i,
2326 rect.Left + check_wd / 2 + 6 * scale,
2327 rect.Top + check_wd - 2 * scale + i );
2331 if ( item.Checked && control.StateImageList.Images.Count > 1 )
2332 control.StateImageList.Draw( dc,
2333 rect_checkrect.Location, 1 );
2334 else if ( ! item.Checked && control.StateImageList.Images.Count > 0 )
2335 control.StateImageList.Draw( dc,
2336 rect_checkrect.Location, 0 );
2340 // Item is drawn as a special case, as it is not just text
2341 if ( control.View == View.LargeIcon ) {
2342 if ( item.ImageIndex > -1 &&
2343 control.LargeImageList != null &&
2344 item.ImageIndex < control.LargeImageList.Images.Count ) {
2346 Point image_location = rect_iconrect.Location;
2347 Image image = control.LargeImageList.Images[ item.ImageIndex ];
2348 if ( image.Width < rect_iconrect.Width ) {
2349 int icon_rect_middle = rect_iconrect.Width / 2;
2350 int image_middle = image.Width / 2;
2351 image_location.X = image_location.X + icon_rect_middle - image_middle;
2353 control.LargeImageList.Draw( dc, image_location,
2357 if ( item.ImageIndex > -1 &&
2358 control.SmallImageList != null &&
2359 item.ImageIndex < control.SmallImageList.Images.Count )
2360 control.SmallImageList.Draw( dc, rect_iconrect.Location,
2364 // draw the item text
2365 // format for the item text
2366 StringFormat format = new StringFormat( );
2367 format.LineAlignment = StringAlignment.Center;
2368 if ( control.View == View.LargeIcon )
2369 format.Alignment = StringAlignment.Center;
2371 format.Alignment = StringAlignment.Near;
2373 if ( !control.LabelWrap )
2374 format.FormatFlags = StringFormatFlags.NoWrap;
2376 if ( item.Selected ) {
2377 if ( control.View == View.Details ) {
2378 if ( control.FullRowSelect ) {
2379 // fill the entire rect excluding the checkbox
2380 full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
2381 dc.FillRectangle( this.ResPool.GetSolidBrush
2382 ( this.ColorHighlight ), full_rect );
2384 Size text_size = Size.Ceiling( dc.MeasureString( item.Text,
2386 text_rect.Width = text_size.Width;
2387 dc.FillRectangle( this.ResPool.GetSolidBrush
2388 ( this.ColorHighlight ), text_rect );
2391 /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
2393 Point loc = text_rect.Location;
2394 loc.X += (text_rect.Width - text_size.Width) / 2;
2395 text_rect.Width = text_size.Width;*/
2396 dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorHighlight ),
2400 dc.FillRectangle( ResPool.GetSolidBrush( item.BackColor ), text_rect );
2402 if ( item.Text != null && item.Text.Length > 0 ) {
2404 if ( control.View != View.LargeIcon ) {
2405 if ( item.Selected )
2406 dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
2407 ( this.ColorHighlightText ), text_rect, format );
2409 dc.DrawString( item.Text, item.Font, this.ResPool.GetSolidBrush
2410 ( item.ForeColor ), text_rect, format );
2412 // ListView CalcTextSize says wrapping is done for two lines only !?!
2413 // text is centered for the complete text_rect but it should be centered per available row/line
2415 // calculate how much lines we get out of text_rect and current item.Font
2416 int nr_lines = text_rect.Height / item.Font.Height;
2417 int rest = text_rect.Height % item.Font.Height;
2418 int line_height = item.Font.Height + ( rest > 1 ? 2 : 0 );
2420 Rectangle[] text_rects = new Rectangle[ nr_lines ];
2422 for ( int i = 0; i < nr_lines; i++ ) {
2423 text_rects[ i ].X = text_rect.X;
2424 text_rects[ i ].Y = text_rect.Y + i * line_height;
2425 text_rects[ i ].Width = text_rect.Width;
2426 text_rects[ i ].Height = line_height;
2429 string[] lines = new string[ nr_lines ];
2431 string text = item.Text;
2434 int current_pos = 0;
2435 for ( int k = 1; k <= text.Length; k++ ) {
2436 lines[ line_nr ] = text.Substring( current_pos, k - current_pos );
2438 // FIXME: Graphics.MeasureString returns wrong results if there is a
2439 // space char in the string
2440 SizeF sizef = dc.MeasureString( lines[ line_nr ], item.Font, text_rect.Width, format );
2442 if ( (int)sizef.Width > text_rect.Width - 3 ) {
2443 lines[ line_nr ] = lines[ line_nr ].Remove( lines[ line_nr ].Length - 1, 1 );
2447 if ( line_nr == nr_lines )
2453 foreach ( Rectangle t_rect in text_rects ) {
2454 if ( item.Selected )
2455 dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
2456 ( this.ColorHighlightText ), t_rect, format );
2458 dc.DrawString( lines[ j ], item.Font, this.ResPool.GetSolidBrush
2459 ( item.ForeColor ), t_rect, format );
2465 if ( control.View == View.Details && control.Columns.Count > 0 ) {
2466 // draw subitems for details view
2467 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
2468 int count = ( control.Columns.Count < subItems.Count ?
2469 control.Columns.Count : subItems.Count );
2473 ListViewItem.ListViewSubItem subItem;
2474 Rectangle sub_item_rect = text_rect;
2476 // set the format for subitems
2477 format.FormatFlags = StringFormatFlags.NoWrap;
2478 format.Alignment = StringAlignment.Near;
2480 // 0th subitem is the item already drawn
2481 for ( int index = 1; index < count; index++ ) {
2482 subItem = subItems[ index ];
2483 col = control.Columns[ index ];
2484 sub_item_rect.X = col.Rect.Left;
2485 sub_item_rect.Width = col.Wd;
2486 sub_item_rect.X -= control.h_marker;
2488 SolidBrush sub_item_back_br = null;
2489 SolidBrush sub_item_fore_br = null;
2490 Font sub_item_font = null;
2492 if ( item.UseItemStyleForSubItems ) {
2493 sub_item_back_br = this.ResPool.GetSolidBrush
2495 sub_item_fore_br = this.ResPool.GetSolidBrush
2497 sub_item_font = item.Font;
2499 sub_item_back_br = this.ResPool.GetSolidBrush
2500 ( subItem.BackColor );
2501 sub_item_fore_br = this.ResPool.GetSolidBrush
2502 ( subItem.ForeColor );
2503 sub_item_font = subItem.Font;
2506 // In case of fullrowselect, background is filled
2507 // for the entire rect above
2508 if ( item.Selected && control.FullRowSelect ) {
2509 if ( subItem.Text != null && subItem.Text.Length > 0 )
2510 dc.DrawString( subItem.Text, sub_item_font,
2511 this.ResPool.GetSolidBrush
2512 ( this.ColorHighlightText ),
2513 sub_item_rect, format );
2515 dc.FillRectangle( sub_item_back_br, sub_item_rect );
2516 if ( subItem.Text != null && subItem.Text.Length > 0 )
2517 dc.DrawString( subItem.Text, sub_item_font,
2519 sub_item_rect, format );
2521 sub_item_rect.X += col.Wd;
2526 if ( item.Focused ) {
2527 if ( item.Selected )
2528 CPDrawFocusRectangle( dc, text_rect, ColorHighlightText, ColorHighlight );
2530 CPDrawFocusRectangle( dc, text_rect, control.ForeColor, control.BackColor );
2537 #region DateTimePicker
2538 public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
2539 // if not showing the numeric updown control then render border
2540 if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
2541 // draw the outer border
2542 Rectangle button_bounds = dtp.ClientRectangle;
2543 CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
2545 // deflate by the border width
2546 if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
2547 button_bounds.Inflate (-2,-2);
2548 ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
2549 Rectangle button_rect = new Rectangle(dtp.drop_down_arrow_rect.X, dtp.drop_down_arrow_rect.Y + 1,
2550 dtp.drop_down_arrow_rect.Width - 1, dtp.drop_down_arrow_rect.Height - 2);
2551 this.CPDrawComboButton (
2558 // render the date part
2559 if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
2560 // fill the background
2561 Rectangle date_area_rect = new Rectangle( dtp.date_area_rect.X + 1, dtp.date_area_rect.Y + 1,
2562 dtp.date_area_rect.Width - 2, dtp.date_area_rect.Height - 2);
2563 dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), date_area_rect);
2565 // fill the currently highlighted area
2566 if (dtp.hilight_date_area != Rectangle.Empty) {
2567 dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
2570 // draw the text part
2571 // TODO: if date format is CUstom then we need to draw the dates as separate parts
2572 StringFormat text_format = new StringFormat();
2573 text_format.LineAlignment = StringAlignment.Center;
2574 text_format.Alignment = StringAlignment.Near;
2575 dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
2576 text_format.Dispose ();
2579 #endregion // DateTimePicker
2581 #region MonthCalendar
2582 // draw the month calendar
2583 public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
2585 Rectangle client_rectangle = mc.ClientRectangle;
2586 Size month_size = mc.SingleMonthSize;
2587 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2588 Size calendar_spacing = (Size)((object)mc.calendar_spacing);
2589 Size date_cell_size = (Size)((object)mc.date_cell_size);
2591 // draw the singlecalendars
2594 // adjust for the position of the specific month
2595 for (int i=0; i < mc.CalendarDimensions.Height; i++)
2599 y_offset += month_size.Height + calendar_spacing.Height;
2601 // now adjust for x position
2602 for (int j=0; j < mc.CalendarDimensions.Width; j++)
2606 x_offset += month_size.Width + calendar_spacing.Width;
2613 Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
2614 if (month_rect.IntersectsWith (clip_rectangle)) {
2626 Rectangle bottom_rect = new Rectangle (
2628 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
2629 client_rectangle.Width,
2630 date_cell_size.Height + 2);
2631 // draw the today date if it's set
2632 if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
2634 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
2636 int today_offset = 5;
2637 if (mc.ShowTodayCircle)
2639 Rectangle today_circle_rect = new Rectangle (
2640 client_rectangle.X + 5,
2641 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
2642 date_cell_size.Width,
2643 date_cell_size.Height);
2644 DrawTodayCircle (dc, today_circle_rect);
2645 today_offset += date_cell_size.Width + 5;
2647 // draw today's date
2648 StringFormat text_format = new StringFormat();
2649 text_format.LineAlignment = StringAlignment.Center;
2650 text_format.Alignment = StringAlignment.Near;
2651 Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2652 Rectangle today_rect = new Rectangle (
2653 today_offset + client_rectangle.X,
2654 Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
2655 Math.Max(client_rectangle.Width - today_offset, 0),
2656 date_cell_size.Height);
2657 dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
2658 text_format.Dispose ();
2659 bold_font.Dispose ();
2663 // finally paint the borders of the calendars as required
2664 for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
2665 if (i == 0 && clip_rectangle.X == client_rectangle.X) {
2666 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
2667 } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
2668 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
2670 Rectangle rect = new Rectangle (
2671 client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
2673 calendar_spacing.Width,
2674 client_rectangle.Height);
2675 if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2676 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2680 for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
2681 if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
2682 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
2683 } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
2684 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
2686 Rectangle rect = new Rectangle (
2688 client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
2689 client_rectangle.Width,
2690 calendar_spacing.Height);
2691 if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2692 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2697 // draw the drop down border if need
2698 if (mc.owner != null) {
2699 Rectangle bounds = mc.ClientRectangle;
2700 if (clip_rectangle.Contains (mc.Location)) {
2701 // find out if top or left line to draw
2702 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2704 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
2706 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2707 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
2710 if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
2711 // find out if bottom or right line to draw
2712 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2713 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
2715 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2716 dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
2722 // darws a single part of the month calendar (with one month)
2723 private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
2725 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2726 Size title_size = (Size)((object)mc.title_size);
2727 Size date_cell_size = (Size)((object)mc.date_cell_size);
2728 DateTime current_month = (DateTime)((object)mc.current_month);
2730 // set up some standard string formating variables
2731 StringFormat text_format = new StringFormat();
2732 text_format.LineAlignment = StringAlignment.Center;
2733 text_format.Alignment = StringAlignment.Center;
2736 // draw the title back ground
2737 DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
2738 Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
2739 if (title_rect.IntersectsWith (clip_rectangle)) {
2740 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
2742 string title_text = this_month.ToString ("MMMM yyyy");
2743 dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
2745 // draw previous and next buttons if it's time
2746 if (row == 0 && col == 0)
2748 // draw previous button
2749 DrawMonthCalendarButton (
2755 (System.Drawing.Size)((object)mc.button_size),
2758 if (row == 0 && col == mc.CalendarDimensions.Width-1)
2761 DrawMonthCalendarButton (
2767 (System.Drawing.Size)((object)mc.button_size),
2772 // set the week offset and draw week nums if needed
2773 int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
2774 Rectangle day_name_rect = new Rectangle(
2776 rectangle.Y + title_size.Height,
2777 (7 + col_offset) * date_cell_size.Width,
2778 date_cell_size.Height);
2779 if (day_name_rect.IntersectsWith (clip_rectangle)) {
2780 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
2781 // draw the day names
2782 DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
2783 for (int i=0; i < 7; i++)
2785 int position = i - (int) first_day_of_week;
2788 position = 7 + position;
2791 Rectangle day_rect = new Rectangle(
2792 day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
2794 date_cell_size.Width,
2795 date_cell_size.Height);
2796 dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
2799 // draw the vertical divider
2800 int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
2802 ResPool.GetPen (mc.ForeColor),
2803 rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
2804 rectangle.Y + vert_divider_y,
2805 rectangle.Right - mc.divider_line_offset,
2806 rectangle.Y + vert_divider_y);
2810 // draw the actual date items in the grid (including the week numbers)
2811 Rectangle date_rect = new Rectangle (
2813 rectangle.Y + title_size.Height + date_cell_size.Height,
2814 date_cell_size.Width,
2815 date_cell_size.Height);
2816 int month_row_count = 0;
2817 bool draw_week_num_divider = false;
2818 DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
2819 for (int i=0; i < 6; i++)
2821 // establish if this row is in our clip_area
2822 Rectangle row_rect = new Rectangle (
2824 rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
2825 date_cell_size.Width * 7,
2826 date_cell_size.Height);
2827 if (mc.ShowWeekNumbers) {
2828 row_rect.Width += date_cell_size.Width;
2831 bool draw_row = row_rect.IntersectsWith (clip_rectangle);
2833 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
2835 // establish if this is a valid week to draw
2836 if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
2837 month_row_count = i;
2840 // draw the week number if required
2841 if (mc.ShowWeekNumbers && month_row_count == i) {
2842 if (!draw_week_num_divider) {
2843 draw_week_num_divider = draw_row;
2845 // get the week for this row
2846 int week = mc.GetWeekOfYear (current_date);
2852 ResPool.GetSolidBrush (mc.TitleBackColor),
2856 date_rect.Offset(date_cell_size.Width, 0);
2859 // only draw the days if we have to
2860 if(month_row_count == i) {
2861 for (int j=0; j < 7; j++)
2864 DrawMonthCalendarDate (
2875 current_date = current_date.AddDays(1);
2876 date_rect.Offset(date_cell_size.Width, 0);
2879 // shift the rectangle down one row
2880 int offset = (mc.ShowWeekNumbers) ? -8 : -7;
2881 date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
2885 // month_row_count is zero based, so add one
2888 // draw week numbers if required
2889 if (draw_week_num_divider) {
2892 ResPool.GetPen (mc.ForeColor),
2893 rectangle.X + date_cell_size.Width - 1,
2894 rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
2895 rectangle.X + date_cell_size.Width - 1,
2896 rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
2898 text_format.Dispose ();
2901 // draws the pervious or next button
2902 private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
2904 bool is_clicked = false;
2905 Rectangle button_rect;
2906 Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
2907 Point[] arrow_path = new Point[3];
2908 // prepare the button
2911 is_clicked = mc.is_previous_clicked;
2912 button_rect = new Rectangle (
2913 rectangle.X + 1 + x_offset,
2914 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2915 Math.Max(button_size.Width - 1, 0),
2916 Math.Max(button_size.Height - 1, 0));
2917 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2918 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2920 arrow_rect.Offset(1,1);
2922 arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
2923 arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
2924 arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
2928 is_clicked = mc.is_next_clicked;
2929 button_rect = new Rectangle (
2930 rectangle.Right - 1 - x_offset - button_size.Width,
2931 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2932 Math.Max(button_size.Width - 1, 0),
2933 Math.Max(button_size.Height - 1, 0));
2934 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2935 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2937 arrow_rect.Offset(1,1);
2939 arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
2940 arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
2941 arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
2944 // fill the background
2945 dc.FillRectangle (ResPool.GetSolidBrush(mc.TitleBackColor), button_rect);
2948 Color first_gradient_color = is_clicked ? pressed_gradient_first_color : gradient_first_color;
2949 Color second_gradient_color = is_clicked ? pressed_gradient_second_color : gradient_second_color;
2951 CL_Draw_Button (dc, button_rect, FlatStyle.Standard,
2952 false, true, is_clicked,
2953 first_gradient_color, second_gradient_color,
2957 SmoothingMode old_smooting_mode = dc.SmoothingMode;
2958 dc.SmoothingMode = SmoothingMode.AntiAlias;
2959 dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
2960 dc.SmoothingMode = old_smooting_mode;
2964 // draws one day in the calendar grid
2965 private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
2966 Color date_color = mc.ForeColor;
2967 Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
2969 // find out if we are the lead of the first calendar or the trail of the last calendar
2970 if (date.Year != month.Year || date.Month != month.Month) {
2971 DateTime check_date = month.AddMonths (-1);
2972 // check if it's the month before
2973 if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
2974 date_color = mc.TrailingForeColor;
2976 // check if it's the month after
2977 check_date = month.AddMonths (1);
2978 if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
2979 date_color = mc.TrailingForeColor;
2985 date_color = mc.ForeColor;
2989 if (date == mc.SelectionStart && date == mc.SelectionEnd) {
2990 // see if the date is in the start of selection
2991 date_color = mc.BackColor;
2992 // draw the left hand of the back ground
2993 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2994 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
2995 } else if (date == mc.SelectionStart) {
2996 // see if the date is in the start of selection
2997 date_color = mc.BackColor;
2998 // draw the left hand of the back ground
2999 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
3000 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
3001 // fill the other side as a straight rect
3002 if (date < mc.SelectionEnd)
3004 // use rectangle instead of rectangle to go all the way to edge of rect
3005 selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
3006 selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
3007 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
3009 } else if (date == mc.SelectionEnd) {
3010 // see if it is the end of selection
3011 date_color = mc.BackColor;
3012 // draw the left hand of the back ground
3013 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
3014 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
3015 // fill the other side as a straight rect
3016 if (date > mc.SelectionStart) {
3017 selection_rect.X = rectangle.X;
3018 selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
3019 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
3021 } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
3022 // now see if it's in the middle
3023 date_color = mc.BackColor;
3024 // draw the left hand of the back ground
3025 Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
3026 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
3029 // set up some standard string formating variables
3030 StringFormat text_format = new StringFormat();
3031 text_format.LineAlignment = StringAlignment.Center;
3032 text_format.Alignment = StringAlignment.Center;
3035 // establish if it's a bolded font
3037 if (mc.IsBoldedDate (date)) {
3038 font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
3043 // just draw the date now
3044 dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
3046 // today circle if needed
3047 if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
3048 DrawTodayCircle (dc, interior);
3051 // draw the selection grid
3052 if (mc.is_date_clicked && mc.clicked_date == date) {
3053 using (Pen pen = new Pen (Color.Black, 1) ) {
3054 pen.DashStyle = DashStyle.Dot;
3055 dc.DrawRectangle (pen, interior);
3058 text_format.Dispose ();
3061 private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
3062 Color circle_color = Color.FromArgb (248, 0, 0);
3063 // draw the left hand of the circle
3064 Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
3065 Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
3066 Point [] curve_points = new Point [3];
3067 curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
3068 curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
3069 curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
3071 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
3072 dc.SmoothingMode = SmoothingMode.AntiAlias;
3074 using (Pen pen = new Pen (circle_color, 2)) {
3075 dc.DrawArc (pen, lhs_circle_rect, 90, 180);
3076 dc.DrawArc (pen, rhs_circle_rect, 270, 180);
3077 dc.DrawCurve (pen, curve_points);
3078 dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
3081 dc.SmoothingMode = old_smoothing_mode;
3083 #endregion // MonthCalendar
3085 public override void CPDrawBorder3D( Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides ) {
3086 CPDrawBorder3D( graphics, rectangle, style, sides, ColorControl );
3089 protected override void CPDrawBorder3D( Graphics dc, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color ) {
3090 // currently we don't take care of Border3DStyle or Border3DSide
3092 Pen tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
3093 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 2, rectangle.Y + 1 );
3094 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 2 );
3095 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 3 );
3096 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Bottom - 3, rectangle.X + 2, rectangle.Bottom - 2 );
3098 tmp_pen = ResPool.GetPen( theme_back_color );
3099 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 2, rectangle.Right - 3, rectangle.Y + 2 );
3100 dc.DrawLine( tmp_pen, rectangle.X + 2, rectangle.Y + 3, rectangle.X + 2, rectangle.Bottom - 3 );
3102 tmp_pen = ResPool.GetPen( Color.White );
3103 dc.DrawLine( tmp_pen, rectangle.X + 3, rectangle.Bottom - 3, rectangle.Right - 3, rectangle.Bottom - 3 );
3104 dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 3, rectangle.Right - 3, rectangle.Bottom - 3 );
3107 new Point( rectangle.X + 3, rectangle.Y + 1 ),
3108 new Point( rectangle.Right - 4, rectangle.Y + 1 ),
3109 new Point( rectangle.Right - 2, rectangle.Y + 3 ),
3110 new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
3111 new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
3112 new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
3113 new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
3114 new Point( rectangle.X + 1, rectangle.Y + 3 ),
3115 new Point( rectangle.X + 3, rectangle.Y + 1 )
3118 dc.DrawLines( ResPool.GetPen( combobox_border_color ), points );
3120 Point[] points_top_outer = {
3121 new Point( rectangle.X + 1, rectangle.Y + 1 ),
3122 new Point( rectangle.X + 2, rectangle.Y ),
3123 new Point( rectangle.Right - 3, rectangle.Y ),
3124 new Point( rectangle.Right - 2 , rectangle.Y + 1 )
3127 Point[] points_bottom_outer = {
3128 new Point( rectangle.X + 1, rectangle.Bottom - 2 ),
3129 new Point( rectangle.X + 2, rectangle.Bottom - 1 ),
3130 new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
3131 new Point( rectangle.Right - 2, rectangle.Bottom - 2 )
3135 tmp_pen = ResPool.GetPen( button_outer_border_dark_color );
3136 dc.DrawLines( tmp_pen, points_top_outer );
3137 tmp_pen = ResPool.GetPen( button_outer_border_light_color );
3138 dc.DrawLines( tmp_pen, points_bottom_outer );
3140 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y + 2 ), new Point( rectangle.X, rectangle.Bottom - 3 ), button_outer_border_dark_color, button_outer_border_light_color ) ) {
3141 using (Pen lgbrpen = new Pen (lgbr)) {
3142 dc.DrawLine (lgbrpen, rectangle.X, rectangle.Y + 2, rectangle.X, rectangle.Bottom - 3 );
3143 dc.DrawLine (lgbrpen, rectangle.Right - 1, rectangle.Y + 2, rectangle.Right - 1, rectangle.Bottom - 3 );
3147 tmp_pen = ResPool.GetPen( button_edge_top_outer_color );
3148 dc.DrawLine( tmp_pen, rectangle.X, rectangle.Y + 1, rectangle.X + 1, rectangle.Y );
3149 dc.DrawLine( tmp_pen, rectangle.Right - 2, rectangle.Y, rectangle.Right - 1, rectangle.Y + 1 );
3151 tmp_pen = ResPool.GetPen( button_edge_bottom_outer_color );
3152 dc.DrawLine( tmp_pen, rectangle.X, rectangle.Bottom - 2, rectangle.X + 1, rectangle.Bottom - 1 );
3153 dc.DrawLine( tmp_pen, rectangle.Right - 1, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 1 );
3156 public override void CPDrawBorder( Graphics dc, Rectangle bounds, Color leftColor, int leftWidth,
3157 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
3158 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
3159 int bottomWidth, ButtonBorderStyle bottomStyle ) {
3160 dc.DrawRectangle( ResPool.GetPen( combobox_border_color ), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1 );
3163 // TODO: inactive...
3164 public override void CPDrawCheckBox( Graphics dc, Rectangle rectangle, ButtonState state ) {
3166 bool pushed = ( state & ButtonState.Pushed ) != 0;
3173 dc.FillRectangle( ResPool.GetSolidBrush( pushed ? checkbox_pressed_backcolor : Color.White ), rectangle );
3176 dc.DrawRectangle( ResPool.GetPen( scrollbar_border_color ), rectangle );
3178 Color inner_border_color = pushed ? checkbox_pressed_inner_boder_color : checkbox_inner_boder_color;
3180 Pen tmp_pen = ResPool.GetPen( inner_border_color );
3181 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 1, rectangle.Right - 1, rectangle.Y + 1 );
3182 dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 1, rectangle.Bottom - 1 );
3184 /* Make sure we've got at least a line width of 1 */
3185 lineWidth = Math.Max( 3, rectangle.Width / 6 );
3186 scale = Math.Max( 1, rectangle.Width / 12 );
3188 // define a rectangle inside the border area
3189 rect = new Rectangle( rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4 );
3190 if ( ( state & ButtonState.Inactive ) != 0 ) {
3191 tmp_pen = SystemPens.ControlDark;
3193 tmp_pen = SystemPens.ControlText;
3196 if ( ( state & ButtonState.Checked ) != 0 ) {
3197 /* Need to draw a check-mark */
3198 for ( int i=0; i < lineWidth; i++ ) {
3199 dc.DrawLine( tmp_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * scale, rect.Top + lineWidth + 2 * scale + i );
3200 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 );
3205 public override void CPDrawStringDisabled( Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
3206 StringFormat format ) {
3208 graphics.DrawString( s, font, ResPool.GetSolidBrush( ColorGrayText), layoutRectangle, format );
3212 public override void CPDrawButton (Graphics dc, Rectangle buttonRectangle, ButtonState state)
3214 bool is_enabled = true;
3215 FlatStyle flat_style = FlatStyle.Standard;
3216 bool is_pressed = false;
3218 if ((state & ButtonState.Pushed) != 0) {
3222 // if ((state & ButtonState.Checked)!=0) {
3223 // dfcs |= DrawFrameControlStates.Checked;
3226 if ((state & ButtonState.Flat) != 0) {
3227 flat_style = FlatStyle.Flat;
3230 if ((state & ButtonState.Inactive) != 0) {
3234 Color first_gradient_color = gradient_first_color;
3235 Color second_gradient_color = gradient_second_color;
3238 first_gradient_color = pressed_gradient_first_color;
3239 second_gradient_color = pressed_gradient_second_color;
3242 CL_Draw_Button (dc, buttonRectangle, flat_style,
3243 false, is_enabled, is_pressed,
3244 first_gradient_color, second_gradient_color,
3248 public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
3250 bool is_checked = false;
3251 bool is_inactive = false;
3253 if ((state & ButtonState.Checked) != 0) {
3257 if ((state & ButtonState.Inactive) != 0) {
3261 SmoothingMode old_smooting_mode = dc.SmoothingMode;
3262 dc.SmoothingMode = SmoothingMode.AntiAlias;
3264 dc.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
3266 dc.DrawArc (ResPool.GetPen (radio_button_border_circle_color), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
3268 CL_Draw_RadioButton_Dot (dc, rectangle, is_checked, is_inactive);
3270 dc.SmoothingMode = old_smooting_mode;
3273 private void CL_Draw_RadioButton_Dot (Graphics dc, Rectangle rectangle, bool is_checked, bool is_inactive)
3276 int lineWidth = Math.Max (1, Math.Min (rectangle.Width, rectangle.Height) / 4);
3278 SolidBrush buttonBrush;
3281 buttonBrush = SystemBrushes.ControlDark as SolidBrush;
3283 buttonBrush = ResPool.GetSolidBrush (radio_button_dot_color);
3285 dc.FillPie (buttonBrush, rectangle.X + lineWidth, rectangle.Y + lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height - lineWidth * 2, 0, 359);
3287 // the white shiny dott
3288 buttonBrush = ResPool.GetSolidBrush (ColorWindow);
3289 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);