Mostly completed writing Area on Windows. Now to fix compiler errors.
This commit is contained in:
parent
bccfde2c34
commit
fada6849c4
|
@ -5,7 +5,7 @@
|
||||||
#include "winapi_windows.h"
|
#include "winapi_windows.h"
|
||||||
#include "_cgo_epxort.h"
|
#include "_cgo_epxort.h"
|
||||||
|
|
||||||
LPWSTR areaWindowClass = L"gouiarea";
|
#define areaWindowClass L"gouiarea"
|
||||||
|
|
||||||
static void getScrollPos(HWND hwnd, int *xpos, int *ypos)
|
static void getScrollPos(HWND hwnd, int *xpos, int *ypos)
|
||||||
{
|
{
|
||||||
|
@ -441,3 +441,19 @@ DWORD makeAreaWindowClass(char **errmsg)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWND newArea(void *data)
|
||||||
|
{
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
|
hwnd = CreateWindowExW(
|
||||||
|
0,
|
||||||
|
areaWindowClass, L"",
|
||||||
|
WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
100, 100,
|
||||||
|
msgwin, NULL, hInstance, data);
|
||||||
|
if (hwnd == NULL)
|
||||||
|
xpanic("container creation failed", GetLastError());
|
||||||
|
return hwnd;
|
||||||
|
}
|
||||||
|
|
|
@ -12,10 +12,43 @@ import (
|
||||||
// #include "winapi_windows.h"
|
// #include "winapi_windows.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
const (
|
type area struct {
|
||||||
areastyle = _WS_HSCROLL | _WS_VSCROLL | controlstyle
|
*areabase
|
||||||
areaxstyle = 0 | controlxstyle
|
|
||||||
)
|
_hwnd C.HWND
|
||||||
|
|
||||||
|
clickCounter *clickCounter
|
||||||
|
}
|
||||||
|
|
||||||
|
func registerAreaWndClass() (err error) {
|
||||||
|
var errmsg *C.char
|
||||||
|
|
||||||
|
err := C.makeWindowWindowClass(&errmsg)
|
||||||
|
if err != 0 || errmsg != nil {
|
||||||
|
return fmt.Errorf("%s: %v", C.GoString(errmsg), syscall.Errno(err))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newArea(ab *areabase) Area {
|
||||||
|
a := &area{
|
||||||
|
areabase: ab,
|
||||||
|
clickCounter: new(clickCounter),
|
||||||
|
}
|
||||||
|
a._hwnd = C.newArea(unsafe.Pointer(a))
|
||||||
|
a.SetSize(width, height)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *area) SetSize(width, height int) {
|
||||||
|
a.width = width
|
||||||
|
a.height = height
|
||||||
|
C.SendMessageW(a._hwnd, C.msgAreaSizeChanged, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *area) RepaintAll() {
|
||||||
|
C.SendMessageW(a._hwnd, C.msgAreaRepaintAll, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
//export doPaint
|
//export doPaint
|
||||||
func doPaint(xrect *C.RECT, hscroll C.int, vscroll C.int, data unsafe.Pointer, dx *C.intptr_t, dy *C.intptr_t) unsafe.Pointer {
|
func doPaint(xrect *C.RECT, hscroll C.int, vscroll C.int, data unsafe.Pointer, dx *C.intptr_t, dy *C.intptr_t) unsafe.Pointer {
|
||||||
|
@ -241,7 +274,11 @@ var modonlykeys = map[C.WPARAM]Modifiers{
|
||||||
C.VK_RWIN: Super,
|
C.VK_RWIN: Super,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO storeAreaHWND
|
//export storeAreaHWND
|
||||||
|
func storeAreaHWND(data unsafe.Pointer, hwnd C.HWND) {
|
||||||
|
a := (*area)(data)
|
||||||
|
a._hwnd = hwnd
|
||||||
|
}
|
||||||
|
|
||||||
//export areaResetClickCounter
|
//export areaResetClickCounter
|
||||||
func areaResetClickCounter(data unsafe.Pointer) {
|
func areaResetClickCounter(data unsafe.Pointer) {
|
||||||
|
@ -249,12 +286,27 @@ func areaResetClickCounter(data unsafe.Pointer) {
|
||||||
a.clickCounter.reset()
|
a.clickCounter.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerAreaWndClass() (err error) {
|
func (a *area) hwnd() C.HWND {
|
||||||
var errmsg *C.char
|
return a._hwnd
|
||||||
|
}
|
||||||
err := C.makeWindowWindowClass(&errmsg)
|
|
||||||
if err != 0 || errmsg != nil {
|
func (a *area) setParent(p *controlParent) {
|
||||||
return fmt.Errorf("%s: %v", C.GoString(errmsg), syscall.Errno(err))
|
basesetParent(a, p)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
func (a *area) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
||||||
|
return baseallocate(a, x, y, width, height, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *area) preferredSize(d *sizing) (width, height int) {
|
||||||
|
// the preferred size of an Area is its size
|
||||||
|
return a.width, a.height
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *area) commitResize(a *allocation, d *sizing) {
|
||||||
|
basecommitResize(a, a, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *area) getAuxResizeInfo(d *sizing) {
|
||||||
|
basegetAuxResizeInfo(a, d)
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,8 @@ extern DWORD makeContainerWindowClass(char **);
|
||||||
extern HWND newContainer(void *);
|
extern HWND newContainer(void *);
|
||||||
|
|
||||||
/* area_window.c */
|
/* area_window.c */
|
||||||
extern LPWSTR areaWindowClass;
|
|
||||||
extern void repaintArea(HWND);
|
extern void repaintArea(HWND);
|
||||||
extern DWORD makeAreaWindowClass(char **);
|
extern DWORD makeAreaWindowClass(char **);
|
||||||
|
extern HWND newArea(void *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue