// Peter Dennis Bartok, pbartok@novell.com
//
-
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
internal static CPColor Empty;
}
- // Implements a pool of system resources
+ // Implements a pool of system resources
internal class SystemResPool
{
private Hashtable pens = new Hashtable ();
public Pen GetPen (Color color)
{
- int hash = color.ToArgb ();
+ int hash = color.ToArgb ();
lock (pens) {
Pen res = pens [hash] as Pen;
public HatchBrush GetHatchBrush (HatchStyle hatchStyle, Color foreColor, Color backColor)
{
- string hash = hatchStyle.ToString () + foreColor.ToString () + backColor.ToString ();
+ string hash = hatchStyle.ToString () + foreColor.ToString () + backColor.ToString ();
lock (hatchbrushes) {
if (hatchbrushes.Contains (hash))
- return (HatchBrush) hatchbrushes[hash];
+ return (HatchBrush) hatchbrushes[hash];
HatchBrush brush = new HatchBrush (hatchStyle, foreColor, backColor);
hatchbrushes.Add (hash, brush);
}
internal abstract class Theme
- {
+ {
protected Array syscolors;
- protected Font default_font;
+ private readonly Font default_font;
+ protected Font window_border_font;
protected Color defaultWindowBackColor;
- protected Color defaultWindowForeColor;
- protected bool always_draw_hotkeys = true;
+ protected Color defaultWindowForeColor;
internal SystemResPool ResPool = new SystemResPool ();
- private Type system_colors = Type.GetType("System.Drawing.SystemColors, System.Drawing");
+ private MethodInfo update;
- private void SetSystemColors(string name, Color value) {
- if (system_colors != null) {
- MethodInfo update;
+ protected Theme ()
+ {
+#if NET_2_0
+ default_font = SystemFonts.DefaultFont;
+#else
+ default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+#endif
+ }
- system_colors.GetField(name, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
- update = system_colors.GetMethod("UpdateColors", BindingFlags.Static | BindingFlags.NonPublic);
- if (update != null) {
- update.Invoke(null, null);
- }
+ private void SetSystemColors (KnownColor kc, Color value)
+ {
+ if (update == null) {
+ Type known_colors = Type.GetType ("System.Drawing.KnownColors, " + Consts.AssemblySystem_Drawing);
+ if (known_colors != null)
+ update = known_colors.GetMethod ("Update", BindingFlags.Static | BindingFlags.Public);
}
+ if (update != null)
+ update.Invoke (null, new object [2] { (int)kc, value.ToArgb () });
}
-
/* OS Feature support */
public abstract Version Version {
get;
}
- /* Default properties */
+ /* Default properties */
public virtual Color ColorScrollBar {
- get { return SystemColors.ScrollBar;}
- set { SetSystemColors("scroll_bar", value); }
+ get { return SystemColors.ScrollBar; }
+ set { SetSystemColors (KnownColor.ScrollBar, value); }
}
public virtual Color ColorDesktop {
get { return SystemColors.Desktop;}
- set { SetSystemColors("desktop", value); }
+ set { SetSystemColors (KnownColor.Desktop, value); }
}
public virtual Color ColorActiveCaption {
get { return SystemColors.ActiveCaption;}
- set { SetSystemColors("active_caption", value); }
+ set { SetSystemColors (KnownColor.ActiveCaption, value); }
}
public virtual Color ColorInactiveCaption {
get { return SystemColors.InactiveCaption;}
- set { SetSystemColors("inactive_caption", value); }
+ set { SetSystemColors (KnownColor.InactiveCaption, value); }
}
public virtual Color ColorMenu {
get { return SystemColors.Menu;}
- set { SetSystemColors("menu", value); }
+ set { SetSystemColors (KnownColor.Menu, value); }
}
public virtual Color ColorWindow {
get { return SystemColors.Window;}
- set { SetSystemColors("window", value); }
+ set { SetSystemColors (KnownColor.Window, value); }
}
public virtual Color ColorWindowFrame {
get { return SystemColors.WindowFrame;}
- set { SetSystemColors("window_frame", value); }
+ set { SetSystemColors (KnownColor.WindowFrame, value); }
}
public virtual Color ColorMenuText {
get { return SystemColors.MenuText;}
- set { SetSystemColors("menu_text", value); }
+ set { SetSystemColors (KnownColor.MenuText, value); }
}
public virtual Color ColorWindowText {
get { return SystemColors.WindowText;}
- set { SetSystemColors("window_text", value); }
+ set { SetSystemColors (KnownColor.WindowText, value); }
}
public virtual Color ColorActiveCaptionText {
get { return SystemColors.ActiveCaptionText;}
- set { SetSystemColors("active_caption_text", value); }
+ set { SetSystemColors (KnownColor.ActiveCaptionText, value); }
}
public virtual Color ColorActiveBorder {
get { return SystemColors.ActiveBorder;}
- set { SetSystemColors("active_border", value); }
+ set { SetSystemColors (KnownColor.ActiveBorder, value); }
}
public virtual Color ColorInactiveBorder{
get { return SystemColors.InactiveBorder;}
- set { SetSystemColors("inactive_border", value); }
+ set { SetSystemColors (KnownColor.InactiveBorder, value); }
}
public virtual Color ColorAppWorkspace {
get { return SystemColors.AppWorkspace;}
- set { SetSystemColors("app_workspace", value); }
+ set { SetSystemColors (KnownColor.AppWorkspace, value); }
}
public virtual Color ColorHighlight {
get { return SystemColors.Highlight;}
- set { SetSystemColors("highlight", value); }
+ set { SetSystemColors (KnownColor.Highlight, value); }
}
public virtual Color ColorHighlightText {
get { return SystemColors.HighlightText;}
- set { SetSystemColors("highlight_text", value); }
+ set { SetSystemColors (KnownColor.HighlightText, value); }
}
public virtual Color ColorControl {
get { return SystemColors.Control;}
- set { SetSystemColors("control", value); }
+ set { SetSystemColors (KnownColor.Control, value); }
}
public virtual Color ColorControlDark {
get { return SystemColors.ControlDark;}
- set { SetSystemColors("control_dark", value); }
+ set { SetSystemColors (KnownColor.ControlDark, value); }
}
public virtual Color ColorGrayText {
get { return SystemColors.GrayText;}
- set { SetSystemColors("gray_text", value); }
+ set { SetSystemColors (KnownColor.GrayText, value); }
}
public virtual Color ColorControlText {
get { return SystemColors.ControlText;}
- set { SetSystemColors("control_text", value); }
+ set { SetSystemColors (KnownColor.ControlText, value); }
}
public virtual Color ColorInactiveCaptionText {
get { return SystemColors.InactiveCaptionText;}
- set { SetSystemColors("inactive_caption_text", value); }
+ set { SetSystemColors (KnownColor.InactiveCaptionText, value); }
}
public virtual Color ColorControlLight {
get { return SystemColors.ControlLight;}
- set { SetSystemColors("control_light", value); }
+ set { SetSystemColors (KnownColor.ControlLight, value); }
}
public virtual Color ColorControlDarkDark {
get { return SystemColors.ControlDarkDark;}
- set { SetSystemColors("control_dark_dark", value); }
+ set { SetSystemColors (KnownColor.ControlDarkDark, value); }
}
public virtual Color ColorControlLightLight {
get { return SystemColors.ControlLightLight;}
- set { SetSystemColors("control_light_light", value); }
+ set { SetSystemColors (KnownColor.ControlLightLight, value); }
}
public virtual Color ColorInfoText {
get { return SystemColors.InfoText;}
- set { SetSystemColors("info_text", value); }
+ set { SetSystemColors (KnownColor.InfoText, value); }
}
public virtual Color ColorInfo {
get { return SystemColors.Info;}
- set { SetSystemColors("info", value); }
+ set { SetSystemColors (KnownColor.Info, value); }
}
public virtual Color ColorHotTrack {
get { return SystemColors.HotTrack;}
- set { SetSystemColors("hot_track", value);}
+ set { SetSystemColors (KnownColor.HotTrack, value);}
}
public virtual Color DefaultControlBackColor {
}
public virtual Color DefaultWindowBackColor {
- get { return defaultWindowBackColor; }
+ get { return defaultWindowBackColor; }
}
public virtual Color DefaultWindowForeColor {
}
}
+ public virtual Size BorderSizableSize {
+ get {
+ return new Size (3, 3);
+ }
+ }
+
public virtual Size Border3DSize {
get {
- return new Size(2, 2);
+ return XplatUI.Border3DSize;
}
}
- public virtual Size BorderSize {
+ public virtual Size BorderStaticSize {
get {
return new Size(1, 1);
}
}
+ public virtual Size BorderSize {
+ get {
+ return XplatUI.BorderSize;
+ }
+ }
+
public virtual Size CaptionButtonSize {
get {
- return new Size(18, 18);
+ return XplatUI.CaptionButtonSize;
}
}
public virtual Size FixedFrameBorderSize {
get {
- return new Size(3, 3);
+ return XplatUI.FixedFrameBorderSize;
}
}
}
}
+ public virtual bool MenuAccessKeysUnderlined {
+ get {
+ return XplatUI.MenuAccessKeysUnderlined;
+ }
+ }
+
public virtual Size MenuButtonSize {
get {
return new Size(18, 18);
return 16;
}
}
-
+
+ public virtual Font WindowBorderFont {
+ get {
+ return window_border_font;
+ }
+ }
+
+ public int Clamp (int value, int lower, int upper)
+ {
+ if (value < lower) return lower;
+ else if (value > upper) return upper;
+ else return value;
+ }
+
[MonoTODO("Figure out where to point for My Network Places")]
public virtual string Places(UIIcon index) {
switch (index) {
#endregion // OwnerDraw Support
#region Button
+ public abstract void CalculateButtonTextAndImageLayout (Button b, out Rectangle textRectangle, out Rectangle imageRectangle);
+ public abstract void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
+ public abstract void DrawFlatButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
+ public abstract void DrawPopupButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
#endregion // Button
#region ButtonBase
#endregion // CheckBox
#region CheckedListBox
- // Drawing
+ // Drawing
public abstract void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e);
#endregion // CheckedListBox
#region ComboBox
// Drawing
public abstract void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e);
+ public abstract void DrawFlatStyleComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
#endregion // ComboBox
#region Control
+ public abstract Font GetLinkFont (Control control);
#endregion // Control
#region Datagrid
public abstract int DataGridMinimumColumnCheckBoxWidth { get; }
// Default colours
- public abstract Color DataGridAlternatingBackColor { get; }
- public abstract Color DataGridBackColor { get; }
+ public abstract Color DataGridAlternatingBackColor { get; }
+ public abstract Color DataGridBackColor { get; }
public abstract Color DataGridBackgroundColor { get; }
public abstract Color DataGridCaptionBackColor { get; }
- public abstract Color DataGridCaptionForeColor { get; }
+ public abstract Color DataGridCaptionForeColor { get; }
public abstract Color DataGridGridLineColor { get; }
public abstract Color DataGridHeaderBackColor { get; }
public abstract Color DataGridHeaderForeColor { get; }
#region ListBox
// Drawing
- public abstract void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e);
- #endregion // ListBox
+ public abstract void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e);
+ #endregion // ListBox
#region ListView
// Drawing
public abstract int ListViewEmptyColumnWidth { get; }
public abstract int ListViewHorizontalSpacing { get; }
public abstract Size ListViewDefaultSize { get; }
+ public abstract int ListViewGroupHeight { get; }
+ public abstract int ListViewTileWidthFactor { get; }
+ public abstract int ListViewTileHeightFactor { get; }
#endregion // ListView
#region Menus
public abstract int CalcMenuBarSize (Graphics dc, Menu menu, int width);
public abstract void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect);
public abstract void DrawMenuItem (MenuItem item, DrawItemEventArgs e);
- public abstract void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect);
+ public abstract void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect);
#endregion // Menus
#region MonthCalendar
#endregion // StatusBar
#region TabControl
- public abstract Size TabControlDefaultItemSize { get; }
- public abstract Point TabControlDefaultPadding { get; }
- public abstract int TabControlMinimumTabWidth { get; }
-
- public abstract Rectangle GetTabControlLeftScrollRect (TabControl tab);
- public abstract Rectangle GetTabControlRightScrollRect (TabControl tab);
- public abstract Rectangle GetTabControlDisplayRectangle (TabControl tab);
+ public abstract Size TabControlDefaultItemSize {get; }
+ public abstract Point TabControlDefaultPadding {get; }
+ public abstract int TabControlMinimumTabWidth {get; }
+ public abstract Rectangle TabControlSelectedDelta { get; }
+ public abstract int TabControlSelectedSpacing { get; }
+ public abstract int TabPanelOffsetX { get; }
+ public abstract int TabPanelOffsetY { get; }
+ public abstract int TabControlColSpacing { get; }
+ public abstract Point TabControlImagePadding { get; }
+ public abstract int TabControlScrollerWidth { get; }
+
+ public abstract Rectangle TabControlGetLeftScrollRect (TabControl tab);
+ public abstract Rectangle TabControlGetRightScrollRect (TabControl tab);
+ public abstract Rectangle TabControlGetDisplayRectangle (TabControl tab);
+ public abstract Rectangle TabControlGetPanelRect (TabControl tab);
public abstract Size TabControlGetSpacing (TabControl tab);
public abstract void DrawTabControl (Graphics dc, Rectangle area, TabControl tab);
#endregion
public abstract int ToolBarDropDownArrowWidth { get; } // width for the dropdown arrow on the ToolBarButton
public abstract int ToolBarDropDownArrowHeight { get; } // height for the dropdown arrow on the ToolBarButton
public abstract Size ToolBarDefaultSize{get;}
- public abstract bool ToolBarInvalidateEntireButton { get; }
#endregion // ToolBar
#region ToolTip
public abstract void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control);
public abstract Size ToolTipSize(ToolTip.ToolTipWindow tt, string text);
- #endregion // ToolTip
+ #endregion // ToolTip
+ #region BalloonWindow
+#if NET_2_0
+ public abstract void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon);
+ public abstract void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control);
+ public abstract Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control);
+#endif
+ #endregion // BalloonWindow
#region TrackBar
// Drawing
// Sizing
public abstract Size TrackBarDefaultSize{get; } // Default size for the TrackBar control
+
+ public abstract int TrackBarValueFromMousePosition (int x, int y, TrackBar tb);
#endregion // TrackBar
#region VScrollBar
int bottomWidth, ButtonBorderStyle bottomStyle);
public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides);
+ public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color);
public abstract void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state);
public abstract void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
public abstract void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state);