rc 檔案樣本@GTK+ 2.0 中文教程連載

來源:互聯網
上載者:User
rc 檔案樣本
# pixmap_path "<dir 1>:<dir 2>:<dir 3>:..."
#
pixmap_path "/usr/include/X11R6/pixmaps:/home/imain/pixmaps"
#
# style <name> [= <name>]
# {
# <option>
# }
#
# widget <widget_set> style <style_name>
# widget_class <widget_class_set> style <style_name>

# 這裡列出所有狀態。注意有些狀態不能用在一定的構件上。
#
# NORMAL -構件的一般狀態,如滑鼠不位於構件上方,鍵未按下時構件所處的狀態。
#
# PRELIGHT - 當滑鼠移到構件上方,在此狀態下定義的顏色生效。
#
#
# ACTIVE -當處於構件上的滑鼠鍵被按下或點擊時,該構件被啟用,相應的屬性值將生效。
#
#
# INSENSITIVE -當構件被設定為不敏感 (insensitive) 時,它不能被啟用,相應屬性值起作用。
#
#
# SELECTED -選中一個對象時,取相應的屬性值。
#
# 給定了這些狀態,我們就能使用以下指令設定在這些狀態下構件的屬性。
#
# fg - 設定構件的前景色彩。
# fg - 設定構件的背景色。
# bg_pixmap - 設定構件的背景為一幅象素圖。
# font - 設定給定構件所用的字型。
#

# 本例設定一種名為"button"的風格。這個名稱實際不重要,因為在本檔案的後面這個風格都分
# 配給了實際的構件。

style "window"
{
#此處設定視窗背景為指定的像素圖。
#bg_pixmap[<STATE>] = "<pixmap filename>"
bg_pixmap[NORMAL] = "warning.xpm"
}

style "scale"
{
#設定"NORMAL"狀態下前景色彩(字型顏色)為紅色。

fg[NORMAL] = { 1.0, 0, 0 }

#設定此構件的背景像素圖為其父構件的背景像素圖。
bg_pixmap[NORMAL] = "<parent>"
}

style "button"
{
# 顯示一個按鈕的所有可能狀態,唯一未用的狀態是SELECTED。

fg[PRELIGHT] = { 0, 1.0, 1.0 }
bg[PRELIGHT] = { 0, 0, 1.0 }
bg[ACTIVE] = { 1.0, 0, 0 }
fg[ACTIVE] = { 0, 1.0, 0 }
bg[NORMAL] = { 1.0, 1.0, 0 }
fg[NORMAL] = { .99, 0, .99 }
bg[INSENSITIVE] = { 1.0, 1.0, 1.0 }
fg[INSENSITIVE] = { 1.0, 0, 1.0 }
}

# 在本例中,我們繼承"button"風格的屬性,然後重設PRELIGHT狀態下的字型和背景色以建立一個新的"main_button"風格。

style "main_button" = "button"
{
font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
bg[PRELIGHT] = { 0.75, 0, 0 }
}

style "toggle_button" = "button"
{
fg[NORMAL] = { 1.0, 0, 0 }
fg[ACTIVE] = { 1.0, 0, 0 }

# 這裡設定toggle_button的背景像素圖為其父構件的像素圖(在應用程式中已定義)。
bg_pixmap[NORMAL] = "<parent>"
}

style "text"
{
bg_pixmap[NORMAL] = "marble.xpm"
fg[NORMAL] = { 1.0, 1.0, 1.0 }
}

style "ruler"
{
font = "-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*"
}

# pixmap_path "~/.pixmaps"

# 下面設定使用以上所定義風格的構件類型。
# 構件類型是在類的組織中列出的,但是恰有可能在本文檔中列出供使用者參考。

widget_class "GtkWindow" style "window"
widget_class "GtkDialog" style "window"
widget_class "GtkFileSelection" style "window"
widget_class "*Gtk*Scale" style "scale"
widget_class "*GtkCheckButton*" style "toggle_button"
widget_class "*GtkRadioButton*" style "toggle_button"
widget_class "*GtkButton*" style "button"
widget_class "*Ruler" style "ruler"
widget_class "*GtkText" style "text"

# 設定作為“main windows”的子構件的所有按鈕構件為main_button風格。
# 這些(專門命名的構件)都必須附有文檔說明讓使用者更好地使用它們。
widget "main window.*GtkButton*" style "main_button"
<<< Previous Home Next >>>
GTK rc 檔案的格式 Up 編寫你自己的構件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.