Hi Axel,
  Thank you very much! I write a small applications to test, it looks that your advise works, but I still met some problems, so I still need some help.
At first, I will show my source code:
.hs file:
module Main where

import Graphics.UI.Gtk
import Graphics.UI.Gtk.Glade

deleteEvent :: Event -> IO Bool
deleteEvent _ = do return False

destroyEvent :: IO()
destroyEvent = do mainQuit

main :: IO()
main = do
    initGUI

    windowXml <- xmlNew "myStyle.glade"
    let window = case windowXml of
        (Just window) -> window
        Nothing       -> error "Can't read glade file!"
   
    winMain  <- xmlGetWidget window castToWindow "winMain"
    btnStyle <- xmlGetWidget window castToButton "btnStyle"
   
    widgetSetName winMain "winMain"
    widgetSetName btnStyle "btnStyle"

    onDelete  winMain deleteEvent
    onDestroy winMain destroyEvent

    widgetShowAll winMain
    mainGUI

then this is my .gtkrc-2.0 file:
style "mySize" {
    GtkButton::default_outside_border = { 10, 10, 10, 10 }
}
widget "btnStyle" style "mySize"

Why I say it works, because if I write with something wrong, when I run the application, I will get some error message about the gtkrc file. But when I corrected the resource file, I cannot find an effect. I think may my resource file still have some questions or my code made mistake about the function widgetSetName. So could you point out what's wrong in my two files above?

Deng Chao

2007/9/26, Axel Simon <A.Simon@kent.ac.uk>:
Deng,

On Sep 26, 2007, at 11:10, ˳ wrote:

>
>
> 2007/9/25, ˳ <knifewolf@gmail.com>: Hi Axel
>
> Thank you very much!
> When I search in the API document, I find these methods:
> styleGetForeground :: Style -> StateType -> IO Color
>
> styleGetBackground :: Style -> StateType -> IO Color


> I guess they can be used to modify UI elements background/
> foreground colors or something like that. These methods is useful
> for me. And if you can implement a method to modify the UI elements
> background to transparent. I think that will be better.
>

In principle you can use the Gtk API to create styles of widgets and
apply them. However, if you merely want some widgets in your
application to have a different appearance, you should modify the
style for that widget using a resource file. See:

http://library.gnome.org/devel/gtk/unstable/gtk-Resource-Files.html

It suffices to merely have a .gtkrc file in your home directory into
which you give certain widgets a different background colour, say.
Widgets in resource files are referenced by name. You can set the
name of a widget using widgetSetName.

A sample .gtkrc-2.0 file:

style "working_font" {
   font_name = "Courier 14"
}
widget_class "*" style "working_font"

Let us know how you get on.

Axel.


> Thank you!
>
> Deng Chao
>
> 2007/9/24, Axel Simon <A.Simon@kent.ac.uk >:
> Hi Deng,
>
> On Sep 24, 2007, at 15:17, ˳ wrote:
>
> > Hi, I'm a newbie for Haskell, I'm learning how to use Gtk2Hs, who
> can
> > show me a small sample for StyleClass? Thanks.
>
> I assume you mean the paint methods in Style that allow you to use
> the current theme engine to draw certain standard UI elements. We
> haven't implemented these functions yet as nobody has requested them.
> Can you explain in what context you need these function? Maybe we can
> suggest a work around. If there is no work around, we might implement
> the style_paint* functions.
>
> Cheers,
>
> Axel.
>
> > --
> > Deng Chao
> >
> ----------------------------------------------------------------------
> > ---
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Gtk2hs-users mailing list
> > Gtk2hs-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users
>
>
>
>
> --
> Deng Chao
>
>
>
> --
> Deng Chao




--
Deng Chao