mail-archives/gtk-sharp-list/2005-August/006289.html

225 строки
8.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [good] Re: [Gtk-sharp-list] simple button style change ...
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5Bgood%5D%20Re%3A%20%5BGtk-sharp-list%5D%20simple%20button%20style%20change%20...&In-Reply-To=20050804140849.GA21619%40localhost">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="006287.html">
<LINK REL="Next" HREF="006296.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[good] Re: [Gtk-sharp-list] simple button style change ...</H1>
<B>Anset</B>
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5Bgood%5D%20Re%3A%20%5BGtk-sharp-list%5D%20simple%20button%20style%20change%20...&In-Reply-To=20050804140849.GA21619%40localhost"
TITLE="[good] Re: [Gtk-sharp-list] simple button style change ...">Anset at anset.org
</A><BR>
<I>Thu Aug 4 10:28:59 EDT 2005</I>
<P><UL>
<LI>Previous message: <A HREF="006287.html">[good] Re: [Gtk-sharp-list] simple button style change ...
</A></li>
<LI>Next message: <A HREF="006296.html">[good] Re: [Gtk-sharp-list] simple button style change ...
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6289">[ date ]</a>
<a href="thread.html#6289">[ thread ]</a>
<a href="subject.html#6289">[ subject ]</a>
<a href="author.html#6289">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
Hi,
On both os you can find examples of resource files. do a search for
gtkrc files and you should find a few. On windows you will find them
under the directory where you installed GTK.
The best documentation is to be found on the gnome developer website.
look at the api documentation.
of course it is all C code, but you should get the point.
The only problem is that the RC class is not fully ported yet.
(depending on your version of gtk#, your success wil vary).
So if things do not seem to work for you, take a look at the custom
files on svn.myrealbox.org to see what has been &quot;ported&quot;.
Below are the examples you asked for. MAKE SURE TO GIVE YOUR WIDGET A
NAME! that is how the styles are matched.
Here is a part of a resource file:
############
# Defaults #
############
style &quot;Default_Style&quot;
{
font_name = &quot;Times new Roman 10&quot;
fg[NORMAL] = &quot;#000000&quot;
bg_pixmap[NORMAL] = &quot;ice.png&quot;
bg_pixmap[ACTIVE] = &quot;cork.png&quot;
bg_pixmap[PRELIGHT] = &quot;camouflage.png&quot;
bg_pixmap[INSENSITIVE] = &quot;purple_marble.png&quot;
engine &quot;pixmap&quot;
{
}
}
class &quot;GtkWidget&quot; style &quot;Default_Style&quot;
#widget &quot;*&quot; style &quot;Default_Style&quot;
#widget &quot;DDD_Main_Window&quot; style &quot;Default_Style&quot;
#widget &quot;DDD_Main_Window.*&quot; style &quot;Default_Style&quot;
##################
# Startup Dialog #
##################
style &quot;Startup_Dialog_Title_Style&quot;
{
font_name = &quot;Times new Roman Bold 12&quot;
fg[NORMAL] = &quot;#000000&quot;
}
widget &quot;*.Startup_Dialog_Title&quot; style &quot;Startup_Dialog_Title_Style&quot;
Here is an example parsing a string in your program:
Basically you just put the text you would put in the resource file in a
string and then parse it. It's a lot less clear, but this way you can
&quot;hide&quot; style settings.
Gtk.Rc.ParseString( &quot;pixmap_path \&quot;images\&quot;\n&quot;+
&quot;style \&quot;Startup_Dialog_Style\&quot; {\n&quot;+
&quot;bg_pixmap[NORMAL] = \&quot;startup.png\&quot;\&quot;\n&quot;+
&quot;}\n&quot;+
&quot;widget \&quot;*Startup_Dialog\&quot; style \&quot;Startup_Dialog_Style\&quot;&quot;);
ted leslie wrote:
&gt;<i> do you have any examples of this,
</I>&gt;<i> i see some for GTKmm but thats not quite the same.
</I>&gt;<i>
</I>&gt;<i> any code snipets, file?
</I>&gt;<i>
</I>&gt;<i> -tl
</I>&gt;<i>
</I>&gt;<i> On Thu, Aug 04, 2005 at 03:37:56PM +0200, Anset wrote:
</I>&gt;<i>
</I>&gt;&gt;<i>Hi,
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>The only way I found that works is using a resource file, or building a
</I>&gt;&gt;<i>resource string and then parse it using the RC class.
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>Afaik, rcstyle in gtk# is broken.
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>Anset
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>ted leslie wrote:
</I>&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>i am just trying to get the color of a button to change, i think i
</I>&gt;&gt;&gt;<i>exhausted
</I>&gt;&gt;&gt;<i>ever color type in the widget below, but none take effect,
</I>&gt;&gt;&gt;<i>Relief takes effect when i change it from one type to another, but nothing
</I>&gt;&gt;&gt;<i>else,
</I>&gt;&gt;&gt;<i>What am i doing wrong,
</I>&gt;&gt;&gt;<i>I use the GTKmm pages for documentation because i havnt found much
</I>&gt;&gt;&gt;<i>on GTK# anywhere, is there some ..
</I>&gt;&gt;&gt;<i>No one seems to do this on any of the GTK# applications in the mono site
</I>&gt;&gt;&gt;<i>so i am baffed..
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> Gtk.RcStyle rc_style;
</I>&gt;&gt;&gt;<i> rc_style= new Gtk.RcStyle();
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> Gdk.Color color;
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> color.Red = 65535;
</I>&gt;&gt;&gt;<i> color.Green = 0;
</I>&gt;&gt;&gt;<i> color.Blue = 0;
</I>&gt;&gt;&gt;<i> color.Pixel = 65535; // whats this?
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> btn3.Style=null;
</I>&gt;&gt;&gt;<i> btn3.ModifyStyle(rc_style);
</I>&gt;&gt;&gt;<i> btn3.Relief=Gtk.ReliefStyle.Half; // this works and we see impact!!!
</I>&gt;&gt;&gt;<i>btn3.ModifyBg(Gtk.StateType.Selected, color);
</I>&gt;&gt;&gt;<i>btn3.ModifyFg(Gtk.StateType.Selected, color);
</I>&gt;&gt;&gt;<i>btn3.ModifyBase(Gtk.StateType.Selected, color);
</I>&gt;&gt;&gt;<i>Console.WriteLine(btn3.Style.BaseColors[1]);
</I>&gt;&gt;&gt;<i>Console.WriteLine(btn3.Style.Foregrounds[0]);
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>btn3.Style.DarkColors[0]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.DarkColors[1]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.DarkColors[2]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.DarkColors[3]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.DarkColors[4]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.LightColors[0]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.LightColors[1]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.LightColors[2]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.LightColors[3]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.LightColors[4]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.BaseColors[1]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.BaseColors[0]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.BaseColors[2]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.BaseColors[3]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.BaseColors[4]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.Foregrounds[0]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.Foregrounds[1]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.Foregrounds[2]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.Foregrounds[3]=color;
</I>&gt;&gt;&gt;<i>btn3.Style.Foregrounds[4]=color;
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>..... assign widget into another container ....
</I>&gt;&gt;&gt;<i>_______________________________________________
</I>&gt;&gt;&gt;<i>Gtk-sharp-list maillist - <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">Gtk-sharp-list at lists.ximian.com</A>
</I>&gt;&gt;&gt;<i><A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I></PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="006287.html">[good] Re: [Gtk-sharp-list] simple button style change ...
</A></li>
<LI>Next message: <A HREF="006296.html">[good] Re: [Gtk-sharp-list] simple button style change ...
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6289">[ date ]</a>
<a href="thread.html#6289">[ thread ]</a>
<a href="subject.html#6289">[ subject ]</a>
<a href="author.html#6289">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">More information about the Gtk-sharp-list
mailing list</a><br>
</body></html>