Guidance
指路人
g.yi.org
software / RapidQ / RQ Doc / html / qcanvas.html

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

  
Appendix A: QCANVAS
Rapid-Q Documentation by William Yu (c)1999-2000 Appendix A: QCANVAS


QCANVAS Component

QCanvas is an empty image for painting on. Instead of loading your images, you must draw them on the QCanvas.

QCanvas Properties
FieldTypeR/WDefaultSupport





AlignINTEGERRWalNoneW
Align determines how the control aligns within its parent control.
ClientHeightINTEGERRWW
ClientWidthINTEGERRWW
ColorINTEGERRWWXG
CopyModeINTEGERRWcmBlacknessW
CursorINTEGERRWcrDefaultW
EnabledINTEGERRWTrueWXG
FontQFONTWW
HeightINTEGERRWWXG
HintSTRINGRWW
LeftINTEGERRW0WXG
ParentQFORM/QPANEL/QTABCONTROLWWXG
Pixel2D ARRAY of INTEGERRWWXG
PopupMenuQPOPUPMENUWW
ShowHintINTEGERRWFalseW
TagINTEGERRWWXG
TopINTEGERRW0WXG
WidthINTEGERRWWXG
VisibleINTEGERRWTrueWXG


QCanvas Methods
MethodTypeDescriptionParamsSupport





CircleSUB (x1%, y1%, x2%, y2%, c%, fill%)Draw & Fill Circle6WXG
CopyRectSUB (D, Image, S)D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap3W
Example (copies QIMAGE to canvas at 10,10):
DIM Destination AS QRECT
DIM Source AS QRECT
DIM Image AS QIMAGE
Image.BMP = "whatever.bmp"

SUB CanvasPaint (Sender AS QCANVAS)
WITH Destination
.Top = 10
.Left = 10
.Right = .Left+Image.Width
.Bottom = .Top+Image.Height
END WITH
WITH Source
.Top = 0
.Left = 0
.Right = Image.Width
.Bottom = Image.Height
END WITH
Sender.CopyRect(Destination, Image, Source)
END SUB

DIM Canvas AS QCANVAS
Canvas.OnPaint = CanvasPaint
DrawSUB (x%, y%, BMP)Draw Bitmap on Canvas3WG
Details:
BMP can be any BMP property from QBitmap, QImage, QImageList, etc. any component with a BMP property is fine.
Examples:
DIM Image1 AS QIMAGE
Image1.BMP = "whatever.bmp"
DIM Image2 AS QBITMAP
Image2.BMP = "whatever.bmp"

SUB CanvasPaint (Sender AS QCANVAS)
Sender.Draw(0, 0, Image1.BMP)
Sender.Draw(50, 50, Image2.BMP)
END SUB

DIM Canvas AS QCANVAS
Canvas.OnPaint = CanvasPaint
FillRectSUB (x1%, y1%, x2%, y2%, c%)Draws & Fills a rectangle5WXG
LineSUB (x1%, y1%, x2%, y2%, c%)Draws a line5WXG
PaintSUB (x%, y%, c%, borderc%)Fill Region4WXG
PsetSUB (x%, y%, c%)Pixel plot3WXG
RectangleSUB (x1%, y1%, x2%, y2%, c%)Draws a rectangle5WXG
RepaintSUBForce repainting0W
RotateSUB (xOrigin%, yOrigin%, Angle%)Rotates entire canvas at specified origin3W
RoundRectSUB (x1%, y1%, x2%, y2%, x3%, y3%, c%)Draws & Fills a rounded rectangle7W
StretchDrawSUB (Rect AS QRECT, BMP)Draw image and stretch to fit inside Rect2W
TextHeightFUNCTION (Text$) AS WORDReturns the height, in pixels, of Text$ string1W
TextWidthFUNCTION (Text$) AS WORDReturns the width, in pixels, of Text$ string1W
TextRectSUB (Rect AS QRECT, x%, y%, S$, fc%, bc%)Write text, and clip within region Rect6W
TextOutSUB (x%, y%, S$, fc%, bc%)Writes text to image5WXG

QCanvas Events
EventTypeOccurs when...ParamsSupport





OnClickVOIDUser clicked on canvas0WXG
OnDblClickVOIDUser double clicked on canvas0W
OnMouseDownSUB (Button%, X%, Y%, Shift%)Mouse button held down4WXG
OnMouseMoveSUB (X%, Y%, Shift%)Mouse moves3WXG
OnMouseUpSUB (Button%, X%, Y%, Shift%)Mouse button is released4WXG
OnPaintVOIDReceives WM_PAINT message0WXG


QCanvas Examples
'  Pixel by pixel credit scroller for Rapid-Q by William Yu

DIM Canvas AS QCanvas
DIM Form AS QForm
DIM Timer1 AS QTimer
DIM Font AS QFont
DIM Y AS INTEGER
    Y = -20

SUB Resize
  Canvas.Height = Form.ClientHeight
  Canvas.Width = Form.ClientWidth
END SUB

SUB Paint
  Canvas.Textout (65,Y-30,"Beware the power of Rapid-Q!", &H00FF00, 0)
  Canvas.Textout (30,Y,"Credit Scroller written in Rapid-Q by William Yu", &HFFFFFF, 0)
END SUB

SUB TimerOver
  Timer1.Interval = 1  '' Can't go any lower!
  Y = Y + 1            '' Pixel by pixel!
  Paint
END SUB

Form.Width = 400
Form.Height = 200
Form.Center
Form.Color = 0

Font.Name = "Arial"
Font.Size = 12
Font.Color = &H00FF00
Canvas.Parent = Form
Canvas.Font = Font
Canvas.Color = 0
Canvas.OnPaint = Paint

Timer1.Interval = 1
Timer1.OnTimer = TimerOver

Form.Onresize = Resize
Form.ShowModal

Prev Component Contents Next Component
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-4-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2015-12-25 19:42:30