Beispiel #1
0
func handleKeyPress(ctx *glib.CallbackContext) {
	arg := ctx.Args(0)
	kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))

	kpe := kh.GTKKeyPressEvent{int(kev.Keyval), 0}
	if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 {
		kpe.Modifier = gdk.CONTROL_MASK
	}

	_, keyh = keyh.Handle(kpe, &microemacs)
}
Beispiel #2
0
func OnMenuOther(ctx *glib.CallbackContext) {
	v := reflect.ValueOf(ctx.Target())
	if v.Kind() == reflect.Ptr {
		fmt.Printf("Item %s(%p) was selected", v.Elem(), v.Interface())
		fmt.Println()
		if w, ok := v.Elem().Interface().(gtk.IWidget); ok {
			v := reflect.ValueOf(ctx.Target())
			v2 := v.Elem()
			fmt.Println(v.Kind(), v2.Kind())
			fmt.Println("Menu item ", w.GetName(), " was selected")
		}
	}
}
Beispiel #3
0
func (mw *MapWidget) movement(ctx *glib.CallbackContext) {
	if mw.gdkwin == nil {
		mw.gdkwin = mw.dArea.GetWindow()
	}
	arg := ctx.Args(0)
	mev := *(**gdk.EventMotion)(unsafe.Pointer(&arg))
	var mt gdk.ModifierType
	if mev.IsHint != 0 {
		mw.gdkwin.GetPointer(&(mw.mx2), &(mw.my2), &mt)
	} else {
		mw.mx2, mw.my2 = int(mev.X), int(mev.Y)
	}

	x := (mw.offX + mw.mx2) / zoom
	z := (mw.offZ + mw.my2) / zoom

	bio := mcmap.Biome(mcmap.BioUncalculated)
	if _bio, ok := mw.regWrap.GetBiomeAt(x, z); ok {
		bio = _bio
	}
	mw.guicbs.updateInfo(x, z, bio, mw.bioLookup.Name(bio))

	if mw.panning {
		if (mw.mx1 != -1) && (mw.my1 != -1) {
			mw.offX += mw.mx1 - mw.mx2
			mw.offZ += mw.my1 - mw.my2

			mw.updateGUI()
		}
	}

	if mw.continueTool {
		mw.regWrap.UseTool(x, z)

		mw.updateGUI()
	}

	mw.mx1, mw.my1 = mw.mx2, mw.my2
}
Beispiel #4
0
func (mw *MapWidget) buttonChanged(ctx *glib.CallbackContext) {
	arg := ctx.Args(0)
	bev := *(**gdk.EventButton)(unsafe.Pointer(&arg))

	switch gdk.EventType(bev.Type) {
	case gdk.BUTTON_RELEASE:
		if mw.panning {
			mw.panning = false

			mw.updateChunkBounds()

			gdk.ThreadsLeave()
			mw.regWrap.UpdateTiles()
			gdk.ThreadsEnter()
		}

		mw.continueTool = false
	case gdk.BUTTON_PRESS:
		switch bev.Button {
		case 1:
			if !mw.regWrap.RegionLoaded() {
				return
			}
			x := (mw.offX + int(bev.X)) / zoom
			z := (mw.offZ + int(bev.Y)) / zoom
			mw.regWrap.UseTool(x, z)

			mw.updateGUI()

			if !mw.regWrap.ToolSingleClick() {
				mw.continueTool = true
			}
		case 2:
			mw.panning = true
		}
	}
}