Iyonix Select Acorn RISCOS 4 Home About Toolbox Examples Maillist Downloads
AppBasic

Toolbar


bar/gif
General
Hello world 1
Hello world 2
Min app
Bin
Window
Slot machine
Drawing
Colour menu
Drawing
Clock

Colour menu

colmenu/gif
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

  1. Insert an ‘Initial’ event handler
    initial/gif
    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.
  2. 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.
  3. 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.