Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Sunshow Pro V3.0 - <b>drawoutbutton()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
DrawOutButton()

Draw a 3-D button in OUT position in graphic mode


Syntax

DrawOutButton(<nRow>, <nColumn>, <nFontPoints>, ;
   <nForegroundIndex>, <nBackgroundIndex>, ;
   <nLightColorIndex>, <nShadowColorIndex>, ;
   <nBoxColorIndex>, <cMessage>)


Arguments

<nRow>
Top left row origin of beveled button to draw.

<nColumn>
Top left column origin of beveled button to draw.

<nFontPoints>
Font height in pixels (8, 14, or 16).

<nForegroundIndex>
The foreground color index (The color of the button text), usually black 
(index 0).

<nBackgroundIndex>
The background color index (The face of the button and background text 
color), usually white (index 7).

<nLightColorIndex>
The beveled edge highlight color, usually bright white (index 15).

<nShadowColorIndex>
The beveled edge shadow color, usually dark grey (index 8).

<nBoxColorIndex>
The color of the box edges, usually black (index 0).

<cMessage>
Button legend or text string.


Returns

0
Success.

-1
DrawOutButton() can not draw in this graphic mode.

-2
Font size to small.

-3
An EGA card is required to use an 8 x 14 font.

-4
A VGA card is required to use an 8 x 16 font.

-5
Row to large, it should be less than (vertical resolution / font points).

-6
Column to large, it should be less than 40 or 80 when the horizontal 
resolution is 320 or 640.

-7
Unknown character found in picture.

-8
Can not allocate memory for line buffer.

-99
Parameters are invalid.


Remarks

DrawOutButton() draws a 3-D beveled button in the OUT position at (<nRow>, 
<nColumn>), with specified colors. DrawOutButton() works similar to SunSay() 
in that it writes graphic mode string or message at row and column 
coordinates within a beveled button. DrawOutButton(), however, requires no 
picture clause. In order for this function to have correct button colors 
when superimposed on top of or next to an image, the default palette must be 
used. 


Example

nStatus = FindVideoMode(640,480,16)
nStatus = ClearWin(1,8,0,0,59,79)
nStatus = DrawOutButton(56,4,8,0,7,15,8,0,"Button1")
nStatus = DrawInButton(56,13,8,0,7,15,8,0,"Button2")
nStatus = DrawOutButton(56,22,8,0,7,15,8,0,"Button3")
nStatus = DrawOutButton(56,31,8,0,7,15,8,0,"Button4")
nStatus = Sleep(10)
nStatus = TextMode()

Refer to the example below for complete, working code of the use of 3D 
button functions with the live graphic mode mouse functions.

nStatus = CheckMouse()
IF nStatus > 0
    nStatus = FindVideoMode(640,480,16)
    nStatus = ClearWin(1,8,0,0,59,79)
    nStatus = DrawOutButton(56,4,8,0,7,15,8,0,"Button1")
    nStatus = DrawOutButton(56,13,8,0,7,15,8,0,"Button2")
    nStatus = DrawOutButton(56,22,8,0,7,15,8,0,"Button3")
    nStatus = DrawOutButton(56,31,8,0,7,15,8,0,"Button4")
    nStatus = OpenLiveMouse(320,240)
    nButtons =  0  
    nMouseX = 0
    nMouseY = 0
    nFontWidth = 8
    nFontHeight = 8
    nCurrentButton = 0
    nOldButton = 0

*   loop until right mouse button is pressed  
    
    DO WHILE nButtons < 2
        nButtons = GetMousePosition(@nMouseX, @nMouseY)
        IF nButtons > 0 
            nMouseRow = int(nMouseY / nFontHeight)
            nMouseColumn = int(nMouseX / nFontWidth)
            IF nMouseRow = 56 .and. nMouseColumn >= 4 ;
               .and. nMouseColumn <= 10
                nOldButton = nCurrentButton
                nCurrentButton = 1
            ELSEIF nMouseRow = 56 .and. nMouseColumn >= ;
                13 .and. nMouseColumn <= 19
                nOldButton = nCurrentButton
                nCurrentButton = 2
            ELSEIF nMouseRow = 56 .and. nMouseColumn >= ;
                22 .and. nMouseColumn <= 28
                nOldButton = nCurrentButton
                nCurrentButton = 3
            ELSEIF nMouseRow = 56 .and. nMouseColumn >= ;
                31 .and. nMouseColumn <= 37
                nOldButton = nCurrentButton
                nCurrentButton = 4
            ENDIF
            IF nOldButton <> nCurrentButton
                nStatus = HideMouse()
                DO CASE
                    CASE nOldButton = 1
                        nStatus = DrawOutButton(56, 4, ;
                           8, 0, 7, 15, 8, 0, "Button1")
                    CASE nOldButton = 2
                        nStatus = DrawOutButton(56, 13, ;
                           8, 0, 7, 15, 8, 0, "Button2")
                    CASE nOldButton = 3
                        nStatus = DrawOutButton(56, 22, ;
                           8, 0, 7, 15, 8, 0, "Button3")
                    CASE nOldButton = 4
                        nStatus = DrawOutButton(56, 31, ;
                           8, 0, 7, 15, 8, 0, "Button4")
                ENDCASE
                DO CASE
                    CASE nCurrentButton = 1
                        nStatus = DrawInButton(56, 4, ;
                           8, 0, 7, 15, 8, 0, "Button1")
                    CASE nCurrentButton = 2
                        nStatus = DrawInButton(56, 13, ;
                           8, 0, 7, 15, 8, 0, "Button2")
                    CASE nCurrentButton = 3
                        nStatus = DrawInButton(56, 22, ;
                           8, 0, 7, 15, 8, 0, "Button3")
                    CASE nCurrentButton = 4
                        nStatus = DrawInButton(56, 31, ;
                           8, 0, 7, 15, 8, 0, "Button4")
                ENDCASE
                nStatus = ShowMouse()
                nOldButton = nCurrentButton
            ENDIF
       ENDIF
    ENDDO
    nStatus = CloseLiveMouse()
    TextMode()
ELSE
    ? "No mouse driver detected"
ENDIF

For other examples of how to use the DrawOutButton() function, see 
SUNMOUSE.PRG, an example program distributed with Sunshow Pro.



See Also: DrawInButton() DrawBeveledBox()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson