示例#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
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
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
// QueueDraw is a wrapper around gtk_widget_queue_draw().
func (v *Widget) QueueDraw() {
	C.gtk_widget_queue_draw(v.native())
}