typedef struct with HUG
Jun 27, 2014 16:48:10 GMT 1
Post by bigbass on Jun 27, 2014 16:48:10 GMT 1
Hey Peter
I would like to remove all the USEC stuff
because I need to test some other low level ideas and HUG would be a good place to
test out this idea first
I need some demo code to stress test this and see if it is working correctly or not
with the new syntax it compiles correctly but that's not enough to be sure
Using PROTO for the typedef and the struct
notice the typedef name needs to be placed in "()" an example (GdkEventKey)
this was a pain too to get to work because you can't DECLARE it
'---GdkEventKey* keypress;
LOCAL keypress TYPE GdkEventKey*
if this works we can get at all the low level stuff directly
Joe
This is a cut and paste into HUG
I would like to remove all the USEC stuff
because I need to test some other low level ideas and HUG would be a good place to
test out this idea first
I need some demo code to stress test this and see if it is working correctly or not
with the new syntax it compiles correctly but that's not enough to be sure
Using PROTO for the typedef and the struct
notice the typedef name needs to be placed in "()" an example (GdkEventKey)
this was a pain too to get to work because you can't DECLARE it
'---GdkEventKey* keypress;
LOCAL keypress TYPE GdkEventKey*
if this works we can get at all the low level stuff directly
Joe
This is a cut and paste into HUG
REM --------------------------------------------------------------------------------------------------
FUNCTION hug_key_press(NUMBER hug_widget, void *hug_data1, NUMBER hug_data2) : REM INCLUDE
REM should work for GTK 1.x and 2.x 3.x
'--- The big problem of typedef structs with pointers !
PROTO typedef,struct
typedef struct { int type; \
void *window; \
signed char send_event; \
unsigned int time; \
unsigned int state; \
unsigned int keyval;}(GdkEventKey)
'---GdkEventKey* keypress;
LOCAL keypress TYPE GdkEventKey*
keypress = (GdkEventKey*)hug_data1
hug_gui_properties.last_key_pressed = keypress->keyval
RETURN FALSE
END FUNCTION
REM --------------------------------------------------------------------------------------------------
SUB hug_mouse_event (NUMBER hug_widget, NUMBER hug_data, long hug_user) : REM INCLUDE
LOCAL gdk, x, y
IF hug_user = 30 THEN
hug_gui_properties.scroll = -1
hug_gui_properties.button = -1
hug_gui_properties.mousex = -1
hug_gui_properties.mousey = -1
ELSE
hug_gui_properties.canvasid = hug_widget
REM Works for GTK 2.x
'--- The big problem of typedef structs with pointers !
PROTO typedef,struct
typedef struct {int type; \
void *window; \
signed char send_event; \
unsigned int time; \
double x; \
double y; \
unsigned int state; \
int direction; }(GdkEventScroll)
LOCAL mousescroll TYPE GdkEventScroll*
mousescroll = (GdkEventScroll*)hug_data
IF (hug_user == 10) THEN hug_gui_properties.scroll = mousescroll->direction
ELSE hug_gui_properties.scroll = -1
'--- The big problem of typedef structs with pointers !
typedef struct {int type; \
void *window; \
signed char send_event; \
unsigned int time; \
double x; \
double y; \
double *axes; \
unsigned int state; \
unsigned int button; \
void *device;} (GdkEventButton)
LOCAL mousebutton TYPE GdkEventButton*
mousebutton = (GdkEventButton*)hug_data
IF (hug_user == 20) THEN hug_gui_properties.button = mousebutton->button
ELSE IF (hug_user == 40) THEN hug_gui_properties.button = -1
REM always get position
gdk = gdk_window_at_pointer(ADDRESS(x), ADDRESS(y))
gdk_window_get_pointer(gdk, ADDRESS(hug_gui_properties.mousex), ADDRESS(hug_gui_properties.mousey), 0)
END IF
END SUB
REM --------------------------------------------------------------------------------------------------