OSDN Git Service

Update Go library to r60.
[pf3gnuchains/gcc-fork.git] / libgo / go / exp / wingui / winapi.go
1 // Copyright 2011 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 main
6
7 import (
8         "unsafe"
9 )
10
11 type Wndclassex struct {
12         Size       uint32
13         Style      uint32
14         WndProc    uintptr
15         ClsExtra   int32
16         WndExtra   int32
17         Instance   uint32
18         Icon       uint32
19         Cursor     uint32
20         Background uint32
21         MenuName   *uint16
22         ClassName  *uint16
23         IconSm     uint32
24 }
25
26 type Point struct {
27         X int32
28         Y int32
29 }
30
31 type Msg struct {
32         Hwnd    uint32
33         Message uint32
34         Wparam  int32
35         Lparam  int32
36         Time    uint32
37         Pt      Point
38 }
39
40 const (
41         // Window styles
42         WS_OVERLAPPED   = 0
43         WS_POPUP        = 0x80000000
44         WS_CHILD        = 0x40000000
45         WS_MINIMIZE     = 0x20000000
46         WS_VISIBLE      = 0x10000000
47         WS_DISABLED     = 0x8000000
48         WS_CLIPSIBLINGS = 0x4000000
49         WS_CLIPCHILDREN = 0x2000000
50         WS_MAXIMIZE     = 0x1000000
51         WS_CAPTION      = WS_BORDER | WS_DLGFRAME
52         WS_BORDER       = 0x800000
53         WS_DLGFRAME     = 0x400000
54         WS_VSCROLL      = 0x200000
55         WS_HSCROLL      = 0x100000
56         WS_SYSMENU      = 0x80000
57         WS_THICKFRAME   = 0x40000
58         WS_GROUP        = 0x20000
59         WS_TABSTOP      = 0x10000
60         WS_MINIMIZEBOX  = 0x20000
61         WS_MAXIMIZEBOX  = 0x10000
62         WS_TILED        = WS_OVERLAPPED
63         WS_ICONIC       = WS_MINIMIZE
64         WS_SIZEBOX      = WS_THICKFRAME
65         // Common Window Styles
66         WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
67         WS_TILEDWINDOW      = WS_OVERLAPPEDWINDOW
68         WS_POPUPWINDOW      = WS_POPUP | WS_BORDER | WS_SYSMENU
69         WS_CHILDWINDOW      = WS_CHILD
70
71         WS_EX_CLIENTEDGE = 0x200
72
73         // Some windows messages
74         WM_CREATE  = 1
75         WM_DESTROY = 2
76         WM_CLOSE   = 16
77         WM_COMMAND = 273
78
79         // Some button control styles
80         BS_DEFPUSHBUTTON = 1
81
82         // Some color constants
83         COLOR_WINDOW  = 5
84         COLOR_BTNFACE = 15
85
86         // Default window position
87         CW_USEDEFAULT = 0x80000000 - 0x100000000
88
89         // Show window default style
90         SW_SHOWDEFAULT = 10
91 )
92
93 var (
94         // Some globally known cursors
95         IDC_ARROW = MakeIntResource(32512)
96         IDC_IBEAM = MakeIntResource(32513)
97         IDC_WAIT  = MakeIntResource(32514)
98         IDC_CROSS = MakeIntResource(32515)
99
100         // Some globally known icons
101         IDI_APPLICATION = MakeIntResource(32512)
102         IDI_HAND        = MakeIntResource(32513)
103         IDI_QUESTION    = MakeIntResource(32514)
104         IDI_EXCLAMATION = MakeIntResource(32515)
105         IDI_ASTERISK    = MakeIntResource(32516)
106         IDI_WINLOGO     = MakeIntResource(32517)
107         IDI_WARNING     = IDI_EXCLAMATION
108         IDI_ERROR       = IDI_HAND
109         IDI_INFORMATION = IDI_ASTERISK
110 )
111
112 //sys   GetModuleHandle(modname *uint16) (handle uint32, errno int) = GetModuleHandleW
113 //sys   RegisterClassEx(wndclass *Wndclassex) (atom uint16, errno int) = user32.RegisterClassExW
114 //sys   CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent uint32, menu uint32, instance uint32, param uintptr) (hwnd uint32, errno int) = user32.CreateWindowExW
115 //sys   DefWindowProc(hwnd uint32, msg uint32, wparam int32, lparam int32) (lresult int32) = user32.DefWindowProcW
116 //sys   DestroyWindow(hwnd uint32) (errno int) = user32.DestroyWindow
117 //sys   PostQuitMessage(exitcode int32) = user32.PostQuitMessage
118 //sys   ShowWindow(hwnd uint32, cmdshow int32) (wasvisible bool) = user32.ShowWindow
119 //sys   UpdateWindow(hwnd uint32) (errno int) = user32.UpdateWindow
120 //sys   GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, errno int) [failretval==-1] = user32.GetMessageW
121 //sys   TranslateMessage(msg *Msg) (done bool) = user32.TranslateMessage
122 //sys   DispatchMessage(msg *Msg) (ret int32) = user32.DispatchMessageW
123 //sys   LoadIcon(instance uint32, iconname *uint16) (icon uint32, errno int) = user32.LoadIconW
124 //sys   LoadCursor(instance uint32, cursorname *uint16) (cursor uint32, errno int) = user32.LoadCursorW
125 //sys   SetCursor(cursor uint32) (precursor uint32, errno int) = user32.SetCursor
126 //sys   SendMessage(hwnd uint32, msg uint32, wparam int32, lparam int32) (lresult int32) = user32.SendMessageW
127 //sys   PostMessage(hwnd uint32, msg uint32, wparam int32, lparam int32) (errno int) = user32.PostMessageW
128
129 func MakeIntResource(id uint16) *uint16 {
130         return (*uint16)(unsafe.Pointer(uintptr(id)))
131 }