コード例 #1
0
ファイル: area_unix.go プロジェクト: UIKit0/ui
// shared code for doing a key event
func doKeyEvent(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer, up bool) {
	var ke KeyEvent

	e := (*C.GdkEventKey)(unsafe.Pointer(event))
	s := (*sysData)(unsafe.Pointer(data))
	keyval := e.keyval
	// get modifiers now in case a modifier was pressed
	state := translateModifiers(e.state, e.window)
	ke.Modifiers = makeModifiers(state)
	if extkey, ok := extkeys[keyval]; ok {
		ke.ExtKey = extkey
	} else if mod, ok := modonlykeys[keyval]; ok {
		ke.Modifier = mod
		// don't include the modifier in ke.Modifiers
		ke.Modifiers &^= mod
	} else if xke, ok := fromScancode(uintptr(e.hardware_keycode) - 8); ok {
		// see events_notdarwin.go for details of the above map lookup
		// one of these will be nonzero
		ke.Key = xke.Key
		ke.ExtKey = xke.ExtKey
	} else { // no match
		return
	}
	ke.Up = up
	repaint := s.handler.Key(ke)
	if repaint {
		C.gtk_widget_queue_draw(widget)
	}
}
コード例 #2
0
ファイル: sysdata_unix.go プロジェクト: kingpro/ui
func (s *sysData) repaintAll() {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		c := gtkAreaGetControl(s.widget)
		C.gtk_widget_queue_draw(c)
		ret <- struct{}{}
	}
	<-ret
}
コード例 #3
0
ファイル: sysdata_unix.go プロジェクト: kingpro/ui
func (s *sysData) setAreaSize(width int, height int) {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		c := gtkAreaGetControl(s.widget)
		gtk_widget_set_size_request(c, width, height)
		s.areawidth = width // for sysData.preferredSize()
		s.areaheight = height
		C.gtk_widget_queue_draw(c)
		ret <- struct{}{}
	}
	<-ret
}
コード例 #4
0
ファイル: area_unix.go プロジェクト: UIKit0/ui
// shared code for finishing up and sending a mouse event
func finishMouseEvent(widget *C.GtkWidget, data C.gpointer, me MouseEvent, mb uint, x C.gdouble, y C.gdouble, state C.guint, gdkwindow *C.GdkWindow) {
	var areawidth, areaheight C.gint

	// on GTK+, mouse buttons 4-7 are for scrolling; if we got here, that's a mistake
	if mb >= 4 && mb <= 7 {
		return
	}
	s := (*sysData)(unsafe.Pointer(data))
	state = translateModifiers(state, gdkwindow)
	me.Modifiers = makeModifiers(state)
	// the mb != # checks exclude the Up/Down button from Held
	if mb != 1 && (state&C.GDK_BUTTON1_MASK) != 0 {
		me.Held = append(me.Held, 1)
	}
	if mb != 2 && (state&C.GDK_BUTTON2_MASK) != 0 {
		me.Held = append(me.Held, 2)
	}
	if mb != 3 && (state&C.GDK_BUTTON3_MASK) != 0 {
		me.Held = append(me.Held, 3)
	}
	// don't check GDK_BUTTON4_MASK or GDK_BUTTON5_MASK because those are for the scrolling buttons mentioned above; there doesn't seem to be a way to detect higher buttons... (TODO)
	me.Pos = image.Pt(int(x), int(y))
	C.gtk_widget_get_size_request(widget, &areawidth, &areaheight)
	if !me.Pos.In(image.Rect(0, 0, int(areawidth), int(areaheight))) { // outside the actual Area; no event
		return
	}
	// and finally, if the button ID >= 8, continue counting from 4, as above and as in the MouseEvent spec
	if me.Down >= 8 {
		me.Down -= 4
	}
	if me.Up >= 8 {
		me.Up -= 4
	}
	repaint := s.handler.Mouse(me)
	if repaint {
		C.gtk_widget_queue_draw(widget)
	}
}
コード例 #5
0
ファイル: gtk.go プロジェクト: evmar/smash
func (w *Window) Dirty() {
	C.gtk_widget_queue_draw(w.gtkWin)
}
コード例 #6
0
ファイル: area_unix.go プロジェクト: NotBadPad/ui
func (a *area) RepaintAll() {
	C.gtk_widget_queue_draw(a._widget)
}
コード例 #7
0
ファイル: widget.go プロジェクト: yamnikov-oleg/gotk3
// QueueDraw is a wrapper around gtk_widget_queue_draw().
func (v *Widget) QueueDraw() {
	C.gtk_widget_queue_draw(v.native())
}