当前位置: 首页>>代码示例>>Golang>>正文


Golang GtkWidget.ModifyFG方法代码示例

本文整理汇总了Golang中github.com/agl/go-gtk/gtk.GtkWidget.ModifyFG方法的典型用法代码示例。如果您正苦于以下问题:Golang GtkWidget.ModifyFG方法的具体用法?Golang GtkWidget.ModifyFG怎么用?Golang GtkWidget.ModifyFG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/agl/go-gtk/gtk.GtkWidget的用法示例。


在下文中一共展示了GtkWidget.ModifyFG方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: configureWidget

func configureWidget(w *gtk.GtkWidget, b widgetBase) {
	width := -1
	if b.width != 0 {
		width = b.width
	}

	height := -1
	if b.height != 0 {
		height = b.height
	}

	if width != -1 || height != -1 {
		w.SetSizeRequest(width, height)
	}

	w.SetSensitive(!b.insensitive)

	if color := b.Foreground(); color != 0 {
		w.ModifyFG(gtk.GTK_STATE_NORMAL, toColor(color))
	}
	if color := b.Background(); color != 0 {
		w.ModifyBG(gtk.GTK_STATE_NORMAL, toColor(color))
	}
	if len(b.font) != 0 {
		w.ModifyFontEasy(b.font)
	}
}
开发者ID:shpedoikal,项目名称:pond,代码行数:27,代码来源:gtk.go

示例2: configureWidget

func configureWidget(w *gtk.GtkWidget, b widgetBase) {
	width := -1
	if b.width != 0 {
		width = b.width
	}

	height := -1
	if b.height != 0 {
		height = b.height
	}

	if width != -1 || height != -1 {
		w.SetSizeRequest(width, height)
	}

	w.SetSensitive(!b.insensitive)

	if color := b.Foreground(); color != 0 {
		w.ModifyFG(gtk.GTK_STATE_NORMAL, toColor(color))
	}
	if color := b.Background(); color != 0 {
		w.ModifyBG(gtk.GTK_STATE_NORMAL, toColor(color))
	}
	if len(b.font) != 0 {
		w.ModifyFontEasy(b.font)
	}
	if b.hExpand {
		w.SetHExpand(true)
	}
	if b.vExpand {
		w.SetVExpand(true)
	}
	if b.margin > 0 {
		w.SetMargin(b.margin)
	}
	if b.marginTop > 0 {
		w.SetMarginTop(b.marginTop)
	}
	if b.marginBottom > 0 {
		w.SetMarginBottom(b.marginBottom)
	}
	if b.marginLeft > 0 {
		w.SetMarginLeft(b.marginLeft)
	}
	if b.vAlign != AlignNone {
		w.SetVAlign(alignToGTK(b.vAlign))
	}
	if b.hAlign != AlignNone {
		w.SetHAlign(alignToGTK(b.hAlign))
	}
}
开发者ID:nico,项目名称:pond,代码行数:51,代码来源:gtk.go

示例3: handle


//.........这里部分代码省略.........
		ui.window.ShowAll()
	case SetChild:
		bin := gtk.GtkBin{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
		for _, child := range bin.GetChildren() {
			child.Destroy()
		}
		bin.Add(ui.newWidget(action.child))
		ui.window.ShowAll()
	case SetBoxContents:
		box := gtk.GtkBox{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
		for _, child := range box.GetChildren() {
			child.Destroy()
		}
		child := action.child
		widget := ui.newWidget(child)
		box.PackStart(widget, child.Expand(), child.Fill(), child.Padding())
		ui.window.ShowAll()
	case SetBackground:
		widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
		widget.ModifyBG(gtk.GTK_STATE_NORMAL, toColor(action.color))
	case Sensitive:
		widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
		widget.SetSensitive(action.sensitive)
	case StartSpinner:
		widget := gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
		widget.Start()
	case StopSpinner:
		widget := gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
		widget.Stop()
	case SetText:
		widget := gtk.GtkLabel{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
		widget.SetText(action.text)
	case SetEntry:
		widget := ui.getWidget(action.name).(gtk.TextInputLike)
		widget.SetText(action.text)
	case SetTextView:
		widget := gtk.GtkTextView{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
		buffer := gtk.TextBuffer(gtk.TextTagTable())
		buffer.SetText(action.text)
		widget.SetBuffer(buffer)
	case SetImage:
		widget := gtk.GtkImage{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
		widget.SetFromPixbuf(action.image.Image())
	case SetFocus:
		widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
		widget.GrabFocus()
	case Destroy:
		widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
		widget.Destroy()
		delete(ui.widgets, action.name)
	case FileOpen:
		fileAction := gtk.GTK_FILE_CHOOSER_ACTION_OPEN
		but := gtk.GTK_STOCK_OPEN
		if action.save {
			fileAction = gtk.GTK_FILE_CHOOSER_ACTION_SAVE
			but = gtk.GTK_STOCK_SAVE
		}
		dialog := gtk.FileChooserDialog(action.title, ui.window, fileAction, gtk.GTK_STOCK_CANCEL, int(gtk.GTK_RESPONSE_CANCEL), but, int(gtk.GTK_RESPONSE_ACCEPT))
		switch gtk.GtkResponseType(dialog.Run()) {
		case gtk.GTK_RESPONSE_ACCEPT:
			ui.events <- OpenResult{
				ok:   true,
				path: dialog.GetFilename(),
				arg:  action.arg,
			}
		default:
			ui.events <- OpenResult{arg: action.arg}
		}
		dialog.Destroy()
	case SetForeground:
		widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
		widget.ModifyFG(gtk.GTK_STATE_NORMAL, toColor(action.foreground))
	case SetProgress:
		widget := gtk.GtkProgressBar{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
		widget.SetFraction(action.fraction)
		widget.SetText(action.s)
	case SetTitle:
		ui.window.SetTitle(action.title)
	case InsertRow:
		grid := gtk.GtkGrid{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
		x := 0
		for _, elem := range action.row {
			if elem.widget != nil {
				grid.Attach(ui.newWidget(elem.widget), x, action.pos, elem.width, elem.height)
			}
			x += elem.width
		}
		ui.window.ShowAll()
	case GridSet:
		grid := gtk.GtkGrid{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
		grid.Attach(ui.newWidget(action.widget), action.col, action.row, 1, 1)
		ui.window.ShowAll()

	case UIError:
	case UIState:
		// for testing.
	default:
		panic("unknown action")
	}
}
开发者ID:nico,项目名称:pond,代码行数:101,代码来源:gtk.go


注:本文中的github.com/agl/go-gtk/gtk.GtkWidget.ModifyFG方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。