コード例 #1
0
ファイル: control_unix.go プロジェクト: NotBadPad/ui
func newScroller(widget *C.GtkWidget, native bool, bordered bool, overlay bool) *scroller {
	var o *C.GtkWidget

	scrollwidget := C.gtk_scrolled_window_new(nil, nil)
	if overlay {
		o = C.gtk_overlay_new()
	}
	s := &scroller{
		scrollwidget:     scrollwidget,
		scrollcontainer:  (*C.GtkContainer)(unsafe.Pointer(scrollwidget)),
		scrollwindow:     (*C.GtkScrolledWindow)(unsafe.Pointer(scrollwidget)),
		overlaywidget:    o,
		overlaycontainer: (*C.GtkContainer)(unsafe.Pointer(o)),
		overlay:          (*C.GtkOverlay)(unsafe.Pointer(o)),
	}
	// give the scrolled window a border (thanks to jlindgren in irc.gimp.net/#gtk+)
	if bordered {
		C.gtk_scrolled_window_set_shadow_type(s.scrollwindow, C.GTK_SHADOW_IN)
	}
	if native {
		C.gtk_container_add(s.scrollcontainer, widget)
	} else {
		C.gtk_scrolled_window_add_with_viewport(s.scrollwindow, widget)
	}
	s.addShowWhich = s.scrollwidget
	if overlay {
		C.gtk_container_add(s.overlaycontainer, s.scrollwidget)
		s.addShowWhich = s.overlaywidget
	}
	return s
}
コード例 #2
0
ファイル: gtkcalls_unix.go プロジェクト: UIKit0/ui
// this should allow us to resize the window arbitrarily
// thanks to Company in irc.gimp.net/#gtk+
func gtkNewWindowLayout() *C.GtkWidget {
	layout := C.gtk_layout_new(nil, nil)
	scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil))
	C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(scrollarea)), layout)
	// never show scrollbars; we're just doing this to allow arbitrary resizes
	C.gtk_scrolled_window_set_policy((*C.GtkScrolledWindow)(unsafe.Pointer(scrollarea)),
		C.GTK_POLICY_NEVER, C.GTK_POLICY_NEVER)
	return scrollarea
}
コード例 #3
0
ファイル: area_unix.go プロジェクト: UIKit0/ui
func gtkAreaNew() *C.GtkWidget {
	drawingarea := C.gtk_drawing_area_new()
	// the Area's size will be set later
	// we need to explicitly subscribe to mouse events with GtkDrawingArea
	C.gtk_widget_add_events(drawingarea,
		C.GDK_BUTTON_PRESS_MASK|C.GDK_BUTTON_RELEASE_MASK|C.GDK_POINTER_MOTION_MASK|C.GDK_BUTTON_MOTION_MASK|C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK)
	// and we need to allow focusing on a GtkDrawingArea to enable keyboard events
	C.gtk_widget_set_can_focus(drawingarea, C.TRUE)
	scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil))
	// need a viewport because GtkDrawingArea isn't natively scrollable
	C.gtk_scrolled_window_add_with_viewport((*C.GtkScrolledWindow)(unsafe.Pointer(scrollarea)), drawingarea)
	return scrollarea
}
コード例 #4
0
ファイル: listbox_unix.go プロジェクト: UIKit0/ui
func gListboxNew(multisel bool) *C.GtkWidget {
	store := C.gtkListStoreNew()
	widget := C.gtk_tree_view_new_with_model((*C.GtkTreeModel)(unsafe.Pointer(store)))
	tv := (*C.GtkTreeView)(unsafe.Pointer(widget))
	column := C.gtkTreeViewColumnNewWithAttributes(C.gtk_cell_renderer_text_new())
	C.gtk_tree_view_column_set_sizing(column, C.GTK_TREE_VIEW_COLUMN_AUTOSIZE)
	C.gtk_tree_view_column_set_resizable(column, C.FALSE) // not resizeable by the user; just autoresize
	C.gtk_tree_view_append_column(tv, column)
	C.gtk_tree_view_set_headers_visible(tv, C.FALSE)
	sel := C.GTK_SELECTION_SINGLE
	if multisel {
		sel = C.GTK_SELECTION_MULTIPLE
	}
	C.gtk_tree_selection_set_mode(C.gtk_tree_view_get_selection(tv), C.GtkSelectionMode(sel))
	scrollarea := C.gtk_scrolled_window_new((*C.GtkAdjustment)(nil), (*C.GtkAdjustment)(nil))
	// thanks to jlindgren in irc.gimp.net/#gtk+
	C.gtk_scrolled_window_set_shadow_type((*C.GtkScrolledWindow)(unsafe.Pointer(scrollarea)), C.GTK_SHADOW_IN)
	C.gtk_container_add((*C.GtkContainer)(unsafe.Pointer(scrollarea)), widget)
	return scrollarea
}
コード例 #5
0
ファイル: control_unix.go プロジェクト: sjn1978/ui
func newScroller(widget *C.GtkWidget, native bool, bordered bool, overlay bool) *scroller {
	s := new(scroller)
	s.controlSingleWidget = newControlSingleWidget(widget)
	s.scrollwidget = C.gtk_scrolled_window_new(nil, nil)
	s.scrollcontainer = (*C.GtkContainer)(unsafe.Pointer(s.scrollwidget))
	s.scrollwindow = (*C.GtkScrolledWindow)(unsafe.Pointer(s.scrollwidget))

	// any actual changing operations need to be done to the GtkScrolledWindow
	// that is, everything /except/ preferredSize() are done to the GtkScrolledWindow
	s.scroller = newControlSingleWidget(s.scrollwidget)
	s.fsetParent = s.scroller.fsetParent
	s.fresize = s.scroller.fresize

	// in GTK+ 3.4 we still technically need to use the separate gtk_scrolled_window_add_with_viewpoint()/gtk_container_add() spiel for adding the widget to the scrolled window
	if native {
		C.gtk_container_add(s.scrollcontainer, s.widget)
	} else {
		C.gtk_scrolled_window_add_with_viewport(s.scrollwindow, s.widget)
	}

	// give the scrolled window a border (thanks to jlindgren in irc.gimp.net/#gtk+)
	if bordered {
		C.gtk_scrolled_window_set_shadow_type(s.scrollwindow, C.GTK_SHADOW_IN)
	}

	if overlay {
		// ok things get REALLY fun now
		// we now have to do all of the above again
		s.overlaywidget = C.gtk_overlay_new()
		s.overlaycontainer = (*C.GtkContainer)(unsafe.Pointer(s.overlaywidget))
		s.overlayoverlay = (*C.GtkOverlay)(unsafe.Pointer(s.overlaywidget))
		s.overlay = newControlSingleWidget(s.overlaywidget)
		s.fsetParent = s.overlay.fsetParent
		s.fresize = s.overlay.fresize
		C.gtk_container_add(s.overlaycontainer, s.scrollwidget)
	}

	return s
}
コード例 #6
0
ファイル: linux_gtk.go プロジェクト: axet/desktop
func gtk_scrolled_window_new() GtkWidget {
	return GtkWidget(C.gtk_scrolled_window_new(Arg(0), Arg(0)))
}