[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit.cs,1.5,1.6 |
Date: |
Sat, 14 Jun 2003 07:06:21 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp
In directory subversions:/tmp/cvs-serv30059/System.Drawing.Xsharp
Modified Files:
DrawingToolkit.cs
Log Message:
Add some of the infrastructure for RESOURCE_MANAGER - currently disabled.
Index: DrawingToolkit.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing.Xsharp/DrawingToolkit.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** DrawingToolkit.cs 13 Jun 2003 12:30:31 -0000 1.5
--- DrawingToolkit.cs 14 Jun 2003 11:06:19 -0000 1.6
***************
*** 35,38 ****
--- 35,42 ----
internal Application app;
internal Widget placeholder;
+ private int background;
+ private int foreground;
+ private int textBackground;
+ private int textForeground;
// Constructor.
***************
*** 44,47 ****
--- 48,120 ----
// Get the placeholder widget for the screen.
placeholder =
app.Display.DefaultScreenOfDisplay.Placeholder;
+
+ // Track changes to RESOURCE_MANAGER on the
root window.
+
app.Display.DefaultScreenOfDisplay.RootWindow.ResourcesChanged
+ += new EventHandler(ResourcesChanged);
+
+ // And then load the initial state.
+ LoadResources();
+ }
+
+ // Parse an X resource color.
+ private static int ParseColor(String name)
+ {
+ if(name == null || name[0] != '#')
+ {
+ return -1;
+ }
+ long value = 0;
+ int posn = 1;
+ char ch;
+ while(posn < name.Length)
+ {
+ ch = name[posn++];
+ if(ch >= '0' && ch <= '9')
+ {
+ value = value * 16 + (long)(ch
- '0');
+ }
+ else if(ch >= 'A' && ch <= 'F')
+ {
+ value = value * 16 + (long)(ch
- 'A' + 10);
+ }
+ else if(ch >= 'a' && ch <= 'f')
+ {
+ value = value * 16 + (long)(ch
- 'a' + 10);
+ }
+ }
+ int red, green, blue;
+ if(name.Length <= 7)
+ {
+ red = ((int)(value >> 16)) & 0xFF;
+ green = ((int)(value >> 8)) & 0xFF;
+ blue = ((int)value) & 0xFF;
+ }
+ else
+ {
+ red = ((int)(value >> 40)) & 0xFF;
+ green = ((int)(value >> 24)) & 0xFF;
+ blue = ((int)(value >> 8)) & 0xFF;
+ }
+ return ((red << 16) | (green << 8) | blue);
+ }
+
+ // Load the resources that are relevant to system colors.
+ private void LoadResources()
+ {
+ RootWindow root;
+ root =
app.Display.DefaultScreenOfDisplay.RootWindow;
+ background =
ParseColor(root.GetResource("*background"));
+ foreground =
ParseColor(root.GetResource("*foreground"));
+ textBackground = ParseColor
+
(root.GetResource("*XmText.background"));
+ textForeground = ParseColor
+
(root.GetResource("*XmText.foreground"));
+ }
+
+ // Track a change in resources on the X display server.
+ private void ResourcesChanged(Object sender, EventArgs e)
+ {
+ LoadResources();
+ // TODO: raise a repaint on all windows
}
***************
*** 71,78 ****
--- 144,201 ----
}
+ // Get lighter or darker versions of a color.
+ private static int Light(int color)
+ {
+ // TODO
+ return -1;
+ }
+ private static int LightLight(int color)
+ {
+ // TODO
+ return -1;
+ }
+ private static int Dark(int color)
+ {
+ // TODO
+ return -1;
+ }
+ private static int DarkDark(int color)
+ {
+ // TODO
+ return -1;
+ }
+
// Resolve a system color to an RGB value. Returns -1 if the
// system does not support the color and a default should be used.
public int ResolveSystemColor(KnownColor color)
{
+ #if false
+ switch(color)
+ {
+ case KnownColor.Control:
+ return background;
+
+ case KnownColor.ControlLight:
+ return Light(background);
+
+ case KnownColor.ControlLightLight:
+ return LightLight(background);
+
+ case KnownColor.ControlDark:
+ return Dark(background);
+
+ case KnownColor.ControlDarkDark:
+ return DarkDark(background);
+
+ case KnownColor.ControlText:
+ return foreground;
+
+ case KnownColor.Window:
+ return textBackground;
+
+ case KnownColor.WindowText:
+ return textForeground;
+ }
+ #endif
return -1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing.Xsharp DrawingToolkit.cs,1.5,1.6,
Rhys Weatherley <address@hidden> <=