DDgui Programmers Reference Guide by Nicholas J. Kingsley - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

User-Defined Routines

 

DDGui allows a limited amount of customisation, enabling the look of a window to be changed.  These are set by using no id parameter in DDgui_set command :

 

DDgui_set("","COL_BRIGHT",RGB(255,0,0))

 

This sets the background colour of the window, and the top part of things like buttons

 

img33.png

 

DDgui_set("","COL_NORM",RGB(255,0,0))

 

This sets the title colour of the window and the main part of, say, a button when there is no mouse pointer over it

 

img34.png

 

DDgui_set("","COL_HOVER_BRIGHT",RGB(255,0,0))

 

This sets the top part of, say, a button graphic when the mouse is over it

 

img35.png

DDgui_set("","COL_HOVER_NORM",RGB(255,0,0))

 

This sets the colour of the main body of, say, a button, when a mouse pointer is over it

 

img36.png

 

FUNCTION DDgui_backrect: x%,y%,dx%,dy%, col%

 

This function allows you to overwrite the colour of the border of the window, the title bar and the main area of widgets like buttons.

For example, using the following :

 

FUNCTION DDgui_backrect: x%,y%,dx%,dy%, col%

DRAWRECT x%,y%,dx%,dy%,RGB(0,255,0)

ENDFUNCTION

 

produces :

 

img37.png

FUNCTION DDgui_backgnd%: col1%, col2%, x%, y%, dx%, dy%

 

This allows you to override the background colour of windows and widgets

 

This example :

 

FUNCTION DDgui_backgnd%: col1%, col2%, x%, y%, dx%, dy%

DRAWRECT x%,y%,dx%,dy%,RGB(0,255,0)

ENDFUNCTION

 

Would produce a green background :

img38.png

DDgui_userdefined(id$, user_type$, width%, height%)

DDgui_draw_user%: BYREF id$, width%, height%, ytop%

DDgui_handle_user%:BYREF id$,mx%,my%,b1%,b2%

 

These three need to be used together, and allow user-defined widgets to be created and processed.

 

DDgui_userdefined creates a user-defined widget.  id$ gives the widget an ID, user_type$ defines a type for the widget, and width% and height% is the width and height of the widget.

 

DDgui_draw_user draws your user-defined widget.  As the routine will let your widget have focus, you perform all drawing from 0,0 coordinates.

 

id$ is the ID of the widget, width% and height% are the width and height of the widget and

ytop% is the vertical position of the widget (which is usually 0)

 

DDgui_handle_user handles all mouse input for your widget.  id$ is the ID of the widget, mx% and my% are the mouse X and Y coordinates, relative to the top-left corner of the widget. 

 

It should be noted that these coordinates can be negative or can be updated outside the window area.

 

b1% and b2% will be TRUE if the left or right mouse button within the widget area.

 

Code for user-defined widget could look like :

 

DDgui_userdefined("test","moo",100,100)

 

FUNCTION DDgui_draw_user%: BYREF id$, width%, height%, ytop%

DDgui_backgnd(RGB(0,0,0), RGB(255,0,255), 0,0,width, height)

ENDFUNCTION

 

FUNCTION DDgui_handle_user%:BYREF id$,mx%,my%,b1%,b2%

DEBUG id$+" "+mx%+" "+my%+" "+b1%+"\n"

IF b1%

DEBUG "Button pressed\n"

KEYWAIT

ENDIF

ENDFUNCTION

 

which produces :

img39.png

With the text “Button pressed” displayed in the Output area in the editor (see GLBasic User Guide for more information) when the user presses the left mouse button within the purple area.

 

In addition, there are several GLOBAL variables than can be used to adjust how DDGui works :

 

DDGUI_AUTO_INPUT_DLG

 

If set to TRUE, then a keyboard window will be created at the bottom of the screen when the user clicks on a text box.  This value is set to TRUE for smartphones and some other platforms.

 

DDGUI_IN_INPUT_DLG

 

Prevents keyboard window being continually if text entry area is repeatedly clicked.

 

gDDguiCaretColour%

 

This sets the default colour of the caret.  The default value is 0 (black)

 

gDDguiMinControlDimension%

 

This sets the minimum height of the caption bar as well as the height of each line in a listbox.  The default value is 16