Exemple #1
0
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
}
Exemple #2
0
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
}