zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

syscall_windows.go (5508B)


      1 // Copyright 2015 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package win32
      6 
      7 import (
      8 	"syscall"
      9 )
     10 
     11 type _COLORREF uint32
     12 
     13 func _RGB(r, g, b byte) _COLORREF {
     14 	return _COLORREF(r) | _COLORREF(g)<<8 | _COLORREF(b)<<16
     15 }
     16 
     17 type _POINT struct {
     18 	X int32
     19 	Y int32
     20 }
     21 
     22 type _RECT struct {
     23 	Left   int32
     24 	Top    int32
     25 	Right  int32
     26 	Bottom int32
     27 }
     28 
     29 type _MSG struct {
     30 	HWND    syscall.Handle
     31 	Message uint32
     32 	Wparam  uintptr
     33 	Lparam  uintptr
     34 	Time    uint32
     35 	Pt      _POINT
     36 }
     37 
     38 type _WNDCLASS struct {
     39 	Style         uint32
     40 	LpfnWndProc   uintptr
     41 	CbClsExtra    int32
     42 	CbWndExtra    int32
     43 	HInstance     syscall.Handle
     44 	HIcon         syscall.Handle
     45 	HCursor       syscall.Handle
     46 	HbrBackground syscall.Handle
     47 	LpszMenuName  *uint16
     48 	LpszClassName *uint16
     49 }
     50 
     51 type _WINDOWPOS struct {
     52 	HWND            syscall.Handle
     53 	HWNDInsertAfter syscall.Handle
     54 	X               int32
     55 	Y               int32
     56 	Cx              int32
     57 	Cy              int32
     58 	Flags           uint32
     59 }
     60 
     61 const (
     62 	_WM_SETFOCUS         = 7
     63 	_WM_KILLFOCUS        = 8
     64 	_WM_PAINT            = 15
     65 	_WM_CLOSE            = 16
     66 	_WM_WINDOWPOSCHANGED = 71
     67 	_WM_KEYDOWN          = 256
     68 	_WM_KEYUP            = 257
     69 	_WM_SYSKEYDOWN       = 260
     70 	_WM_SYSKEYUP         = 261
     71 	_WM_MOUSEMOVE        = 512
     72 	_WM_MOUSEWHEEL       = 522
     73 	_WM_LBUTTONDOWN      = 513
     74 	_WM_LBUTTONUP        = 514
     75 	_WM_RBUTTONDOWN      = 516
     76 	_WM_RBUTTONUP        = 517
     77 	_WM_MBUTTONDOWN      = 519
     78 	_WM_MBUTTONUP        = 520
     79 	_WM_USER             = 0x0400
     80 )
     81 
     82 const (
     83 	_WS_OVERLAPPED       = 0x00000000
     84 	_WS_CAPTION          = 0x00C00000
     85 	_WS_SYSMENU          = 0x00080000
     86 	_WS_THICKFRAME       = 0x00040000
     87 	_WS_MINIMIZEBOX      = 0x00020000
     88 	_WS_MAXIMIZEBOX      = 0x00010000
     89 	_WS_OVERLAPPEDWINDOW = _WS_OVERLAPPED | _WS_CAPTION | _WS_SYSMENU | _WS_THICKFRAME | _WS_MINIMIZEBOX | _WS_MAXIMIZEBOX
     90 )
     91 
     92 const (
     93 	_VK_SHIFT   = 16
     94 	_VK_CONTROL = 17
     95 	_VK_MENU    = 18
     96 	_VK_LWIN    = 0x5B
     97 	_VK_RWIN    = 0x5C
     98 )
     99 
    100 const (
    101 	_MK_LBUTTON = 0x0001
    102 	_MK_MBUTTON = 0x0010
    103 	_MK_RBUTTON = 0x0002
    104 )
    105 
    106 const (
    107 	_COLOR_BTNFACE = 15
    108 )
    109 
    110 const (
    111 	_IDI_APPLICATION = 32512
    112 	_IDC_ARROW       = 32512
    113 )
    114 
    115 const (
    116 	_CW_USEDEFAULT = 0x80000000 - 0x100000000
    117 
    118 	_SW_SHOWDEFAULT = 10
    119 
    120 	_HWND_MESSAGE = syscall.Handle(^uintptr(2)) // -3
    121 
    122 	_SWP_NOSIZE = 0x0001
    123 )
    124 
    125 const (
    126 	_BI_RGB         = 0
    127 	_DIB_RGB_COLORS = 0
    128 
    129 	_AC_SRC_OVER  = 0x00
    130 	_AC_SRC_ALPHA = 0x01
    131 
    132 	_SRCCOPY = 0x00cc0020
    133 
    134 	_WHEEL_DELTA = 120
    135 )
    136 
    137 func _GET_X_LPARAM(lp uintptr) int32 {
    138 	return int32(_LOWORD(lp))
    139 }
    140 
    141 func _GET_Y_LPARAM(lp uintptr) int32 {
    142 	return int32(_HIWORD(lp))
    143 }
    144 
    145 func _GET_WHEEL_DELTA_WPARAM(lp uintptr) int16 {
    146 	return int16(_HIWORD(lp))
    147 }
    148 
    149 func _LOWORD(l uintptr) uint16 {
    150 	return uint16(uint32(l))
    151 }
    152 
    153 func _HIWORD(l uintptr) uint16 {
    154 	return uint16(uint32(l >> 16))
    155 }
    156 
    157 // notes to self
    158 // UINT = uint32
    159 // callbacks = uintptr
    160 // strings = *uint16
    161 
    162 //sys	GetDC(hwnd syscall.Handle) (dc syscall.Handle, err error) = user32.GetDC
    163 //sys	ReleaseDC(hwnd syscall.Handle, dc syscall.Handle) (err error) = user32.ReleaseDC
    164 //sys	sendMessage(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult uintptr) = user32.SendMessageW
    165 
    166 //sys	_CreateWindowEx(exstyle uint32, className *uint16, windowText *uint16, style uint32, x int32, y int32, width int32, height int32, parent syscall.Handle, menu syscall.Handle, hInstance syscall.Handle, lpParam uintptr) (hwnd syscall.Handle, err error) = user32.CreateWindowExW
    167 //sys	_DefWindowProc(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult uintptr) = user32.DefWindowProcW
    168 //sys	_DestroyWindow(hwnd syscall.Handle) (err error) = user32.DestroyWindow
    169 //sys	_DispatchMessage(msg *_MSG) (ret int32) = user32.DispatchMessageW
    170 //sys	_GetClientRect(hwnd syscall.Handle, rect *_RECT) (err error) = user32.GetClientRect
    171 //sys	_GetWindowRect(hwnd syscall.Handle, rect *_RECT) (err error) = user32.GetWindowRect
    172 //sys   _GetKeyboardLayout(threadID uint32) (locale syscall.Handle) = user32.GetKeyboardLayout
    173 //sys   _GetKeyboardState(lpKeyState *byte) (err error) = user32.GetKeyboardState
    174 //sys	_GetKeyState(virtkey int32) (keystatus int16) = user32.GetKeyState
    175 //sys	_GetMessage(msg *_MSG, hwnd syscall.Handle, msgfiltermin uint32, msgfiltermax uint32) (ret int32, err error) [failretval==-1] = user32.GetMessageW
    176 //sys	_LoadCursor(hInstance syscall.Handle, cursorName uintptr) (cursor syscall.Handle, err error) = user32.LoadCursorW
    177 //sys	_LoadIcon(hInstance syscall.Handle, iconName uintptr) (icon syscall.Handle, err error) = user32.LoadIconW
    178 //sys	_MoveWindow(hwnd syscall.Handle, x int32, y int32, w int32, h int32, repaint bool) (err error) = user32.MoveWindow
    179 //sys	_PostMessage(hwnd syscall.Handle, uMsg uint32, wParam uintptr, lParam uintptr) (lResult bool) = user32.PostMessageW
    180 //sys   _PostQuitMessage(exitCode int32) = user32.PostQuitMessage
    181 //sys	_RegisterClass(wc *_WNDCLASS) (atom uint16, err error) = user32.RegisterClassW
    182 //sys	_ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) = user32.ShowWindow
    183 //sys	_ScreenToClient(hwnd syscall.Handle, lpPoint *_POINT) (ok bool) = user32.ScreenToClient
    184 //sys   _ToUnicodeEx(wVirtKey uint32, wScanCode uint32, lpKeyState *byte, pwszBuff *uint16, cchBuff int32, wFlags uint32, dwhkl syscall.Handle) (ret int32) = user32.ToUnicodeEx
    185 //sys	_TranslateMessage(msg *_MSG) (done bool) = user32.TranslateMessage
    186 //sys	_UnregisterClass(lpClassName *uint16, hInstance syscall.Handle) (done bool) = user32.UnregisterClassW