










|
Colour menu
 Changing colour with the use of a Toolbox Colour menu
You can download the application from here.
This is an amendment of the previous ‘Drawing’ application
- Insert an ‘Initial’ event handler
The Initial event handler is called only once - before Wimp polling starts. E.g.
DEF PROCDealWith_InitialEvent
Colour=11
ENDPROC
|
sets the initial value of the variable Colour.
- Amend the Drawing event-handler code
The following amendment
DEF PROCDealWith_WindowRedraw(object,xo%,yo%)
LOCAL radius : radius=400
SYS "Wimp_SetColour",Colour
CIRCLE FILL xo%,yo%,radius
ENDPROC
|
draws a filled circle using the desktop colour specified by the value of the variable Colour.
- Add a Colour menu template to the resource file
- Attach the Colour menu to the window
- Add a Colour menu event-handler and amend the code to
DEF PROCDealWith_ColourMenu(event,object,component)
CASE event OF
WHEN ColourMenu_Selection
PROCColourMenu_GetColour(object,Colour)
PROCRedrawWindow(FNToolbox_GetParent(object))
ENDCASE
ENDPROC
DEF PROCRedrawWindow(object)
LOCAL x,y,X,Y
PROCWindow_GetExtent(object,x,y,X,Y)
PROCWindow_ForceRedraw(object,x,y,X,Y)
ENDPROC
|
When a Colour menu selection is made the ColourMenu_GetColour method is used to retrieve the selection. The window is then redrawn by forcing a redraw (which causes the DealWith_WindowRedraw handler to be called).
N.B. The window is the ‘parent’ of the attached colour menu.
|