コード例 #1
0
ファイル: group_unix.go プロジェクト: sjn1978/ui
func newGroup(text string, control Control) Group {
	ctext := togstr(text)
	defer freegstr(ctext)
	widget := C.gtk_frame_new(ctext)
	g := &group{
		controlSingleWidget: newControlSingleWidget(widget),
		gcontainer:          (*C.GtkContainer)(unsafe.Pointer(widget)),
		frame:               (*C.GtkFrame)(unsafe.Pointer(widget)),
		child:               control,
	}

	// with GTK+, groupboxes by default have frames and slightly x-offset regular text
	// they should have no frame and fully left-justified, bold text
	var yalign C.gfloat

	// preserve default y-alignment
	C.gtk_frame_get_label_align(g.frame, nil, &yalign)
	C.gtk_frame_set_label_align(g.frame, 0, yalign)
	C.gtk_frame_set_shadow_type(g.frame, C.GTK_SHADOW_NONE)
	label := (*C.GtkLabel)(unsafe.Pointer(C.gtk_frame_get_label_widget(g.frame)))
	// this is the boldness level used by GtkPrintUnixDialog
	// (it technically uses "bold" but see pango's pango-enum-types.c for the name conversion; GType is weird)
	bold := C.pango_attr_weight_new(C.PANGO_WEIGHT_BOLD)
	boldlist := C.pango_attr_list_new()
	C.pango_attr_list_insert(boldlist, bold)
	C.gtk_label_set_attributes(label, boldlist)
	C.pango_attr_list_unref(boldlist) // thanks baedert in irc.gimp.net/#gtk+

	g.container = newContainer()
	g.child.setParent(g.container.parent())
	g.container.resize = g.child.resize
	C.gtk_container_add(g.gcontainer, g.container.widget)

	return g
}
コード例 #2
0
ファイル: frame.go プロジェクト: napsy/go-gtk3
func (self *Frame) GetLabelAlign() (xalign, yalign float32) {
	var cax C.gfloat
	var cay C.gfloat
	C.gtk_frame_get_label_align(self.object, &cax, &cay)
	return float32(cax), float32(cay)
}