[go-nuts] GUI canvas widget

95 views
Skip to first unread message

laurent

unread,
Dec 15, 2010, 4:05:13 AM12/15/10
to golang-nuts
Hi,
I would to integrate the package draw2d in a Window application, I
started to work on exp/draw and x11 implementation. It simply work but
with some limitation. I think exp/draw/x11 is not ready to be use for
a real windowing application. For example on OS X it starts X11, on
Win32 it doesn't work. I saw some GUI port:
- WALK "Windows Application Library Kit:
- SDL
- GotX
- GTK
- GLUT
...

I don't want to be too platform dependent, this is why exp/draw
interest me, but it's partial.
http://code.google.com/p/draw2d/source/browse/trunk/draw2d/src/cmd/testX11draw.go

What Windowing system may I choose?
Is exp/draw the right choice?
Is there any plan to upgrade exp/draw(mac port, windows port)?


Laurent Le Goff

Nigel Tao

unread,
Dec 15, 2010, 4:58:04 AM12/15/10
to laurent, golang-nuts
On 15 December 2010 20:05, laurent <legoff....@gmail.com> wrote:
> Is there any plan to upgrade exp/draw(mac port, windows port)?

I'm happy to review Mac and Windows backends for exp/draw, but since
my everyday computers all run Linux, I'm not going to be writing those
backends.

laurent

unread,
Dec 15, 2010, 7:05:48 AM12/15/10
to golang-nuts
I think it means I have to implement it.
I think first implement it in windows:
- it seems that this project may help me to find the right way to do
it https://github.com/lxn/walk/

but if I download the latest build of go in windows, I can't use it
cause of this:
http://codereview.appspot.com/1696051/

I feel that I bore people when I speak of GUI on windows with Go.

what should I do next to port exp/draw on win32?

Laurent

On 15 déc, 10:58, Nigel Tao <nigel.tao.gn...@gmail.com> wrote:

Alexander Neumann

unread,
Dec 15, 2010, 7:41:38 AM12/15/10
to golang-nuts


On 15 Dez., 13:05, laurent <legoff.laur...@gmail.com> wrote:
> I think it means I have to implement it.
> I think first implement it in windows:
>   - it seems that this project may help me to find the right way to do
> ithttps://github.com/lxn/walk/
>
> but if I download the latest build of go in windows, I can't use it
> cause of this:http://codereview.appspot.com/1696051/

We are currently investigating how to move forward with the Walk
project. We would of course prefer to use pure Go code with officially
supported callbacks, but right now this does work only via the
(outdated) CL you linked to.

We hope the new cgo will enable something similar, once Windows
support is there.

Atm, your best bet would be to use the crutches branch of Walk, but it
is way behind master. Btw, the instructions for the crutches branch
are also out of date (will fix soon). Thanks to Mateusz Czapliński, a
helper dll is no longer required.

Cheers
Alex

laurent

unread,
Dec 15, 2010, 9:17:32 AM12/15/10
to golang-nuts
Compilation failed when compile crutches.

8c -I. -I/c/dev/programs/go/src/pkg/runtime -I/c/dev/programs/go/src/
pkg/runtime/windows -I/c/dev/programs/go/src/pkg/runtime/386 -I/c/dev/
programs/go/src/pkg/runtime/windows/386 -wF -D__WINDOWS__ queue.c
queue.c:124 function args not checked: runtime.get_proc_addr
queue.c:124 incompatible types: "IND VOID" and "INT" for op "AS"
queue.c:125 function args not checked: runtime.get_proc_addr
queue.c:125 incompatible types: "IND VOID" and "INT" for op "AS"
queue.c:126 function args not checked: runtime.get_proc_addr
queue.c:126 incompatible types: "IND VOID" and "INT" for op "AS"
queue.c:127 function args not checked: runtime.get_proc_addr
queue.c:127 incompatible types: "IND VOID" and "INT" for op "AS"
queue.c:128 function args not checked: runtime.get_proc_addr
queue.c:128 incompatible types: "IND VOID" and "INT" for op "AS"
queue.c:129 function args not checked: runtime.get_proc_addr
queue.c:129 incompatible types: "IND VOID" and "INT" for op "AS"

laurent

unread,
Dec 15, 2010, 10:53:35 AM12/15/10
to golang-nuts
it seems that runtime api change I finally successfully compile
crutches, and examples now works just fine, please see the patch below
(apply the patch crutches folder):

diff --git a/crutches/crutch.c b/crutches/crutch.c
index 7d6b8b0..f6aa4bc 100644
--- a/crutches/crutch.c
+++ b/crutches/crutch.c
@@ -5,7 +5,7 @@
#include "crutch.h"

uintptr crutches·stdcall_return(uintptr retval, void*
addr_of_caller_first_arg, uint32 no_of_caller_args);
-
+void *user32;
void *DefDlgProcW;
void *GetClassInfoExW;
void *LoadCursorW;
@@ -18,13 +18,14 @@ void
·initcrutch(void) {
// TODO: make sure that 'runtime·osinit()' was already called,
// or use their approach with 'get_proc_addr2()'
- DefDlgProcW = runtime·get_proc_addr("user32.dll", "DefDlgProcW");
- GetClassInfoExW = runtime·get_proc_addr("user32.dll",
"GetClassInfoExW");
- LoadCursorW = runtime·get_proc_addr("user32.dll", "LoadCursorW");
- LoadIconW = runtime·get_proc_addr("user32.dll", "LoadIconW");
- PostMessageW = runtime·get_proc_addr("user32.dll",
"PostMessageW");
- RegisterClassExW = runtime·get_proc_addr("user32.dll",
"RegisterClassExW");
- RegisterWindowMessageW = runtime·get_proc_addr("user32.dll",
"RegisterWindowMessageW");
+ user32 = runtime·stdcall(runtime·LoadLibraryEx, 3, "user32.dll",
0, 0);
+ DefDlgProcW = runtime·stdcall(runtime·GetProcAddress, 2, user32,
"DefDlgProcW");
+ GetClassInfoExW = runtime·stdcall(runtime·GetProcAddress, 2,
user32, "GetClassInfoExW");
+ LoadCursorW = runtime·stdcall(runtime·GetProcAddress, 2, user32,
"LoadCursorW");
+ LoadIconW = runtime·stdcall(runtime·GetProcAddress, 2, user32,
"LoadIconW");
+ PostMessageW = runtime·stdcall(runtime·GetProcAddress, 2, user32,
"PostMessageW");
+ RegisterClassExW = runtime·stdcall(runtime·GetProcAddress, 2,
user32, "RegisterClassExW");
+ RegisterWindowMessageW = runtime·stdcall(runtime·GetProcAddress,
2, user32, "RegisterWindowMessageW");
}

enum {
diff --git a/crutches/crutch.h b/crutches/crutch.h
diff --git a/crutches/queue.c b/crutches/queue.c
index b12fe64..808b96f 100644
--- a/crutches/queue.c
+++ b/crutches/queue.c
@@ -11,7 +11,7 @@ void*
crutches·wildcall(void* fn, int32 count, ...) {
return crutches·wildcall_raw(fn, count, (uintptr*)(&count+1));
}
-
+static void* kernel32;
static void* InitializeCriticalSectionAndSpinCount;
static void* EnterCriticalSection;
static void* LeaveCriticalSection;
@@ -121,12 +121,13 @@ void
·initqueue(void) {
// TODO: make sure that 'runtime·osinit()' was already called,
// or use their approach with 'get_proc_addr2()'
- InitializeCriticalSectionAndSpinCount =
runtime·get_proc_addr("kernel32.dll",
"InitializeCriticalSectionAndSpinCount");
- EnterCriticalSection = runtime·get_proc_addr("kernel32.dll",
"EnterCriticalSection");
- LeaveCriticalSection = runtime·get_proc_addr("kernel32.dll",
"LeaveCriticalSection");
- CreateEvent = runtime·get_proc_addr("kernel32.dll",
"CreateEventA");
- WaitForSingleObject = runtime·get_proc_addr("kernel32.dll",
"WaitForSingleObject");
- SetEvent = runtime·get_proc_addr("kernel32.dll", "SetEvent");
+ kernel32 = runtime·stdcall(runtime·LoadLibraryEx, 3,
"kernel32.dll", 0, 0);
+ InitializeCriticalSectionAndSpinCount =
runtime·stdcall(runtime·GetProcAddress, 2, kernel32,
"InitializeCriticalSectionAndSpinCount");
+ EnterCriticalSection = runtime·stdcall(runtime·GetProcAddress, 2,
kernel32, "EnterCriticalSection");
+ LeaveCriticalSection = runtime·stdcall(runtime·GetProcAddress, 2,
kernel32, "LeaveCriticalSection");
+ CreateEvent = runtime·stdcall(runtime·GetProcAddress, 2,
kernel32, "CreateEventA");
+ WaitForSingleObject = runtime·stdcall(runtime·GetProcAddress, 2,
kernel32, "WaitForSingleObject");
+ SetEvent = runtime·stdcall(runtime·GetProcAddress, 2, kernel32,
"SetEvent");

crutches·newqueue(&crutches·queue, qqdata, qqmaxsize);
}




thanks for help
cheers

laurent
Reply all
Reply to author
Forward
0 new messages