Documentation component by D.Glodt (c)2000-2001, appended by John Kelly Appendix A: QDrawFocus

QDrawFocus Component

QDrawFocus is a focus to use as selection in graphic components and forms, or anything you can get a Device Context from..
 

QDrawFocus Properties
Field Type R/W Défault





Left SHORT R
Position x of focus when it is visible
Top SHORT R
Position y of focus when it is visible 
Width SHORT R
Width of focus when it is visible
Height SHORT R
Height of focus when it is visible
Move BOOLEAN R FALSE
At true if focus has moved.
Visible BOOLEAN RW FALSE
At true if focus is visible
Inside BOOLEAN R FALSE
At true if cursor is inside the focus
NoResize BOOLEAN RW FALSE
No resize when the value is true
ShowCursor BOOLEAN RW TRUE
Change the cursor state following the actions on focus

QDrawFocus Methods
Method Type Description Params





Remove SUB(handle&) Remove the focus 1
Start SUB(handle&,x%,y%) Start the drawing of focus 3
Draw SUB(handle&,x%,y%,flagDraw%) Draw the focus 4
Stop SUB(handle&,flagRemove%) Stop the drawing of focus 2

QDrawFocus Events
Event Type Occurs when... Params





QDrawFocus Examples
'==============================================================================================
' the Start method gives the starting point of focus
' the Draw method draws the focus , moves it or the resize if this one is already visible and if flagDraw is at true,
' if flagDraw is at false only the state of the cursor changes
' the Stop method gives the cursor at its state of origin after action on the focus and removes the focus if the flagRemove is true.
'===============================================================================================

$TYPECHECK ON
$Include <Rapidq.inc>
$include <QDrawFocus.inc>
declare sub StartFocusForm(button as short,x as short,y as short)
declare sub StopFocusForm(x as short,y as short)
declare sub DrawFocusForm(x as short,y as short)
declare sub StartFocus(button as short,x as short,y as short)
declare sub StopFocus(x as short,y as short)
declare sub DrawFocus(x as short,y as short)
declare sub paint
declare sub resize

dim focus as QDrawFocus
dim focus2 as QDrawFocus
dim flag as byte

CREATE Form AS QFORM
    Caption = "Form1"
    Width = 640
    Height = 480
    Center
    OnMouseDown=StartFocusForm
    OnMouseUp=StopFocusForm
    OnMouseMove=DrawFocusForm
    OnResize=resize

CREATE Button AS QBUTTON
    left = 10
    top = 10
END CREATE

CREATE Canvas1 AS QCANVAS
    Left = 200
    Top = 0
    Width = 400
    Height = 400
    OnPaint=paint
    OnMouseDown=StartFocus
    OnMouseUp=StopFocus
    OnMouseMove=DrawFocus
END CREATE
END CREATE

DEFINT FormDC = GetDC(Form.handle)
Form.ShowModal


Sub StartFocusForm(button as short,x as short,y as short)
    focus.start(FormDC,x,y)
    flag=true
End Sub

Sub DrawFocusForm(x as short,y as short)
    focus.draw(FormDC,x,y,flag)
End Sub

Sub StopFocusForm(x as short,y as short)
    focus.stop(FormDC,false)
    IF focus.Left < Button.Left AND _
    focus.Top < Button.Top AND _
    focus.Width > Button.Width AND _
    focus.Height > Button.Height THEN Showmessage "Button selected"
    flag=false
End Sub


Sub StartFocus(button as short,x as short,y as short)
    focus2.start(Canvas1.handle,x,y)
    flag=true
End Sub

Sub DrawFocus(x as short,y as short)
    focus2.draw(Canvas1.handle,x,y,flag)
End Sub

Sub StopFocus(x as short,y as short)
    focus2.stop(Canvas1.handle,false)
    flag=false
End Sub

Sub paint
    if focus2.visible then
        focus2.visible=false
        Canvas1.fillrect(0,0,400,400,&HFFFFFF)
        focus2.start(Canvas1.handle,focus2.left,focus2.top)
        focus2.draw(Canvas1.handle,focus2.left+focus2.width,focus2.top+focus2.height,true)
    else
        Canvas1.fillrect(0,0,400,400,&HFFFFFF)
    end if
end sub

sub resize
    canvas1.repaint
end sub