Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / Doc French / QCanvasEx.html

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Appendix A: QCanvasEx  
Documentation composant par D.Glodt (c)2000-2002 Appendix A: QCanvasEx

QCanvasEx Composant

QCanvasEx est un controle identique a Qcanvas avec extensions de fonctionnalités.

QCanvasEx Proprietés
Champs Type L/E Defaut




MixMode Long LE R2_COPYPEN_CAN
Combinaison couleur entre le pinceau,le crayon et l'écran.
Les differentes valeurs sont:
R2_BLACK_CAN=1
R2_NOTMERGEPEN_CAN=2
R2_MASKNOTPEN_CAN=3
R2_NOTCOPYPEN_CAN=4
R2_MASKPENNOT_CAN=5
R2_NOT_CAN=6
R2_XORPEN_CAN=7
R2_NOTMASKPEN_CAN=8
R2_MASKPEN_CAN=9
R2_NOTXORPEN_CAN=10
R2_NOP_CAN=11
R2_MERGENOTPEN_CAN=12
R2_COPYPEN_CAN=13
R2_MERGEPENNOT_CAN=14
R2_MERGEPEN_CAN=15
R2_WHITE_CAN=16
PenSize Long LE 1
Taille du crayon pour le dessin de ligne,rectangle et cercle LE
PenStyle Long LE PS_SOLID_CAN
Style du crayon , les autres valeurs sont:
PS_SOLID_CAN=0
PS_DASH_CAN=1
PS_DOT_CAN=2
PS_DASHDOT_CAN=3
PS_DASHDOTDOT_CAN=4
PS_NULL_CAN=5
PS_INSIDEFRAME_CAN=6

QCanvasEx Methodes

Methode Type Description Parametres




DrawIco SUB(left%,top%,width%,height%,handle%) Dessine un icone 3
Si les parametres width et height sont a 0,l'icone sera affiché avec ses dimensions par défaut.
CopyToClipboard SUB(rect as QRECT) Copie l'image dans le presse papier 1
PasteFromClipboard SUB(x%,y%) Colle l'image du presse papier 2
GetWidthClipboard FUNCTION as INTEGER Retourne la largeur image du presse papier 0
GetHeightClipboard FUNCTION as INTEGER Retourne la hauteur image du presse papier 0
CanPaste FUNCTON as BOOLEAN Retourne true si image présente dans le presse papier 0
Circle SUB(x1%,y1%,x2%,y2%,c%) Dessine un cercle vide 5
CircleFilled SUB(x1%,y1%,x2%,y2%,c%,Fill%) Dessine un cercle plein 6
Rectangle SUB(x1%,y1%,x2%,y2%,c%) Dessine un rectangle vide 5
RectangleFilled SUB(x1%,y1%,x2%,y2%,c%,Fill%) Dessine un rectangle plein 6
RoundRect SUB(x1%,y1%,x2%,y2%,x3%,y3%,c%) Dessine un rectangle vide avec coins arrondi 7
RoundRectFilled SUB(x1%,y1%,x2%,y2%,x3%,y3%,c%,Fill%) Dessine un rectangle plein avec coins arrondi 8
Line SUB(x1%,y1%,x2%,y2%,c%) Dessine une ligne 5
FillSurface SUB(x%,y%,c%) Rempli la surface pointé par la couleur du pixel x,y 3
TextOut SUB(x%,y%,s$,fc%,bc%) Affiche du texte 5
InvertColor SUB(x%,y%,width%,height%) Inverse les couleurs 4
Mirror SUB(x%,y%,width%,height%) Effectue un miroir x 4
Flip SUB(x%,y%,width%,height%) Effectue un miroir y 4

QCanvasEx Evenements

Evenement Type Déclenchement Parametres




QCanvasEx Exemple 1

 $typecheck on
 $INCLUDE "Rapidq.inc"
 $INCLUDE "Object\QCanvasEx.inc"
 declare sub OuvrirClick
 declare sub FermerClick
 declare sub QuitterClick
 declare sub Copier
 declare sub Coller
 declare sub Present
 const title="Viewer picture"
 dim bitmap as QBITMAP
 dim source as QRECT
 CREATE Form AS QFORM
   Caption =title
   Width = 600
   Height = 600
   Center
   CREATE Menu AS QMAINMENU
     CREATE item1 AS QMENUITEM
       Caption="&Fichier"
       CREATE item2 AS QMENUITEM
         Caption="&Ouvrir"
         OnClick=OuvrirClick
       END CREATE
       CREATE item4 AS QMENUITEM
         Caption="&Fermer"
         OnClick=FermerClick
       END CREATE
       CREATE item5 AS QMENUITEM
         Caption="-"
       END CREATE
       CREATE item6 AS QMENUITEM
         Caption="&Quitter"
         OnClick=QuitterClick
       END CREATE
     END CREATE
     CREATE item11 as QMENUITEM
       Caption="&Edition"
       OnClick=Present
       CREATE item12 as QMENUITEM
         Caption="&Copier"
         OnClick=Copier
       END CREATE
       CREATE item13 as QMENUITEM
         Caption="&Coller"
         OnClick=Coller
         Enabled=false
        END CREATE
      END CREATE
    END CREATE
    CREATE ScrollBox1 AS QSCROLLBOX
      AutoScroll = 1
      Align=5
      Color = &HFFFFFF
      CREATE image AS QCanvasEx
        width=1000
        height=1000
      END CREATE
    END CREATE
  END CREATE
  bitmap.PixelFormat=6
  Form.ShowModal
  
  sub OuvrirClick
    dim file as QOPENDIALOG
    
    file.Filter="Fichiers bitmap(*.bmp)|*.bmp"
    file.InitialDir=CurDir$
    if file.Execute then
      bitmap.Bmp=file.FileName
      image.draw(0,0,bitmap.bmp)
      Form.Caption=title+"-"+file.FileName
    end if
  end sub
  
  sub FermerClick
     image.repaint
     Form.Caption=title
  end sub
  
  sub QuitterClick
    Form.Close
  end sub
  
  sub Copier
    source.left=0
    source.top=0 
    source.right=bitmap.width 
    source.bottom=bitmap.height 
    image.copyToClipboard(source)
  end sub
  
  sub coller
    image.pasteFromClipboard(20,20)
    form.caption=str$(image.GetWidthClipboard)+"*"+str$(image.GetHeightClipboard)
  end sub
  
  Sub Present
    if image.canpaste then
      item13.enabled=true
    else
      item13.enabled=false
    end if
  End Sub
QCanvasEx Exemple 2
$typecheck on
$INCLUDE "Rapidq.inc" 
$Include "Object\QCanvasEx.inc"
$INCLUDE "OBJECT\QCOLORDIALOG.INC"

declare sub selectdrawing(sender as qmenuitem)
declare sub selectSize(sender as qmenuitem)
declare sub move(x as integer,y as integer)
declare sub start(bt as integer,x as integer,y as integer)
declare sub stop
declare sub ResetMenuDrawing
declare sub ResetMenuSize
declare sub SelectPenColor
declare sub SelectBackColor
declare sub New
declare sub Quit

dim TypeDraw as integer
TypeDraw=1
dim flag as integer
dim orx as integer
dim ory as integer
dim ox as integer
dim oy as integer
dim pencolor as long
dim backcolor as long
dim Dial as QColorDialog

CREATE Form AS QFORM
  Caption="Paint"
  Width=690
  Height=503
  Center
  CREATE MainMenu AS QMAINMENU
    CREATE MenuFile AS QMENUITEM
      Caption="&File"
      CREATE MenuNew AS QMENUITEM
        Caption="&New"
        OnClick=New
      END CREATE
      CREATE separator AS QMENUITEM
        Caption="-"
      END CREATE
      CREATE MenuExit AS QMENUITEM
        Caption="&Exit"
        OnClick=Quit
      END CREATE
    END CREATE
    CREATE MenuTool AS QMENUITEM
      Caption="&Tools"
      CREATE MenuPenColor AS QMENUITEM
        Caption="&Pen color"
        OnClick=SelectPenColor
      END CREATE
      CREATE MenuPenSize AS QMENUITEM
        Caption="&Pen size"
        CREATE MenuSize1 AS QMENUITEM
          Caption="&Size 1"
          Tag=1
          Checked=true
          OnClick=SelectSize
        END CREATE
        CREATE MenuSize2 AS QMENUITEM
          Caption="&Size 2"
          Tag=2
          OnClick=SelectSize
        END CREATE
        CREATE MenuSize4 AS QMENUITEM
          Caption="&Size 4"
          Tag=3
          OnClick=SelectSize
        END CREATE
        CREATE MenuSize8 AS QMENUITEM
          Caption="&Size 8"
          Tag=4
          OnClick=SelectSize
        END CREATE
      END CREATE
      CREATE MenuBackcolor AS QMENUITEM
        Caption="&Back color"
        OnClick=SelectBackColor
      END CREATE
    END CREATE
    CREATE MenuDrawing AS QMENUITEM
      caption="&Drawing"
      CREATE MenuDraw AS QMENUITEM
        Caption="&Draw"
        tag=1
        Checked=true
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuLine AS QMENUITEM
        Caption="&Line"
        tag=2
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuRect AS QMENUITEM
        Caption="&Rectangle"
        tag=3
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuRectFilled AS QMENUITEM
        Caption="&Rectangle filled"
        tag=4
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuCircle AS QMENUITEM
        Caption="&Circle"
        tag=5
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuCircleFilled AS QMENUITEM
        Caption="&Circle filled"
        tag=6
        OnClick=SelectDrawing
      END CREATE
      CREATE MenuFill AS QMENUITEM
        Caption="&Fill"
        tag=7
        OnClick=SelectDrawing
      END CREATE
    END CREATE
  END CREATE
  CREATE ScrollBox1 AS QSCROLLBOX
    Align=alClient
    color=&hffffff
    CREATE image AS QCanvasEx
      Align=alClient
      OnMouseMove=move
      OnMouseDown=start
      OnMouseUp=stop
    END CREATE
  END CREATE
END CREATE

Form.ShowModal

sub New
  image.repaint
end sub

sub Quit
  Form.close
  Application.terminate
end sub

sub SelectDrawing(sender as qmenuitem)
  TypeDraw=sender.tag
  ResetMenuDrawing
  sender.checked=true
end sub

sub SelectSize(sender as qmenuitem)
  Select case sender.tag
  case 1
    image.pensize=1
  case 2
    image.pensize=2
  case 3
    image.pensize=4
  case 4
    image.pensize=8
  end select
  ResetMenuSize
  sender.checked=true
end sub

sub Start(bt as integer,x as integer,y as integer)  
  flag=true
  orx=x
  ory=y
  ox=x
  oy=y
  select case typeDraw
  case 1
    image.line(x,y,x,y,PenColor)
  case 2
    image.mixmode=R2_NOTXORPEN_CAN
    image.line(x,y,x,y,PenColor)
  case 3
    image.mixmode=R2_NOTXORPEN_CAN
    image.rectangle(x,y,x,y,PenColor)
  case 4
    image.mixmode=R2_NOTXORPEN_CAN
    image.rectangleFilled(x,y,x,y,PenColor,backcolor)
  case 5
    image.mixmode=R2_NOTXORPEN_CAN
    image.circle(x,y,x,y,PenColor)
  case 6
    image.mixmode=R2_NOTXORPEN_CAN
    image.circleFilled(x,y,x,y,PenColor,backcolor)
  case 7
    image.fillSurface(x,y,pencolor)
  end select
end sub 

sub Move(x as integer,y as integer)
  if flag then
    select case typeDraw
    case 1
      image.line(ox,oy,x,y,PenColor)
    case 2
      image.line(orx,ory,ox,oy,PenColor)
      image.line(orx,ory,x,y,PenColor)
    case 3
      image.rectangle(orx,ory,ox,oy,PenColor)
      image.rectangle(orx,ory,x,y,PenColor)
    case 4
      image.rectangleFilled(orx,ory,ox,oy,PenColor,backcolor)
      image.rectangleFilled(orx,ory,x,y,PenColor,backcolor)
    case 5
      image.circle(orx,ory,ox,oy,PenColor)
      image.circle(orx,ory,x,y,PenColor)
    case 6
      image.circleFilled(orx,ory,ox,oy,PenColor,backcolor)
      image.circleFilled(orx,ory,x,y,PenColor,backcolor)
    end select
    ox=x
    oy=y
  end if
end sub 
    
sub Stop
 if  flag then
   image.mixmode=R2_COPYPEN_CAN
   flag=0
 end if
 select case typeDraw
 case 2
   image.line(orx,ory,ox,oy,PenColor)
 case 3
   image.rectangle(orx,ory,ox,oy,PenColor)
 case 4
   image.rectangleFilled(orx,ory,ox,oy,PenColor,backcolor)
 case 5
   image.circle(orx,ory,ox,oy,PenColor)
 case 6
   image.circleFilled(orx,ory,ox,oy,PenColor,backcolor)
 end select
end sub 

sub ResetMenuDrawing
  MenuDraw.checked=false
  MenuLine.checked=false
  MenuRect.checked=false
  MenuRectFilled.checked=false
  MenuCircle.checked=false
  MenuCircleFilled.checked=false
  MenuFill.checked=false
end sub  

sub ResetMenuSize
  MenuSize1.checked=false
  MenuSize2.checked=false
  MenuSize4.checked=false
  MenuSize8.checked=false
end sub  
  
sub SelectPenColor
  Dial.caption="Select pen color"
  if Dial.Execute then
    PenColor=Dial.Color
  end if
end sub

sub SelectBackColor
  Dial.caption="Select backcolor"
  if Dial.Execute then
    BackColor=Dial.Color
  end if
end sub  



掌柜推荐
 
 
¥1,420.00 ·
 
 
¥950.00 ·
 
 
¥288.00 ·
 
 
¥738.00 ·
 
 
¥397.00 ·
 
 
¥750.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-09-26 18:31:08