' Rapid-Q by William Yu (c)1999-2000 . ' ================================================================================ ' Upload_il_tuo_script_su_Rapidq.it ' 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 Field Type R/W Default Support =============== =============== =============== =============== =============== Align INTEGER RW alNone W Align determines how the control aligns within its parent control. ClientHeight INTEGER RW W ClientWidth INTEGER RW W Color INTEGER RW WXG CopyMode INTEGER RW cmBlackness W Cursor INTEGER RW crDefault W Enabled INTEGER RW True WXG Font QFONT W W Height INTEGER RW WXG Hint STRING RW W Left INTEGER RW 0 WXG Parent QFORM/QPANEL/ W WXG QTABCONTROL Pixel 2D ARRAY of RW WXG INTEGER PopupMenu QPOPUPMENU W W ShowHint INTEGER RW False W Tag INTEGER RW WXG Top INTEGER RW 0 WXG Width INTEGER RW WXG Visible INTEGER RW True WXG QCanvas Methods Method Type Description Params Support =============== =============== =============== =============== =============== Circle SUB (x1%, y1%, Draw & Fill 6 WXG x2%, y2%, c%, Circle fill%) CopyRect SUB (D, Image, D and S are 3 W S) QRECTs, Image can be a QImage, QCanvas, or QBitmap 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 Draw SUB (x%, y%, Draw Bitmap on 3 WG BMP) Canvas 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 FillRect SUB (x1%, y1%, Draws & 5 WXG x2%, y2%, c%) Fills a rectangle Line SUB (x1%, y1%, Draws a line 5 WXG x2%, y2%, c%) Paint SUB (x%, y%, Fill Region 4 WXG c%, borderc%) Pset SUB (x%, y%, Pixel plot 3 WXG c%) Rectangle SUB (x1%, y1%, Draws a 5 WXG x2%, y2%, c%) rectangle Repaint SUB Force 0 W repainting Rotate SUB (xOrigin%, Rotates entire 3 W yOrigin%, canvas at Angle%) specified origin RoundRect SUB (x1%, y1%, Draws & 7 W x2%, y2%, x3%, Fills a rounded y3%, c%) rectangle StretchDraw SUB (Rect AS Draw image and 2 W QRECT, BMP) stretch to fit inside Rect TextHeight FUNCTION Returns the 1 W (Text$) AS WORD height, in pixels, of Text$ string TextWidth FUNCTION Returns the 1 W (Text$) AS WORD width, in pixels, of Text$ string TextRect SUB (Rect AS Write text, and 6 W QRECT, x%, y%, clip within S$, fc%, bc%) region Rect TextOut SUB (x%, y%, Writes text to 5 WXG S$, fc%, bc%) image QCanvas Events Event Type Occurs when... Params Support =============== =============== =============== =============== =============== OnClick VOID User clicked on 0 WXG canvas User double OnDblClick VOID clicked on 0 W canvas OnMouseDown SUB (Button%, Mouse button 4 WXG X%, Y%, Shift%) held down OnMouseMove SUB (X%, Y%, Mouse moves 3 WXG Shift%) OnMouseUp SUB (Button%, Mouse button is 4 WXG X%, Y%, Shift%) released Receives OnPaint VOID WM_PAINT 0 WXG message 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 ' =============================================================================== ' 2003 Holyguard.net - 2007_Abruzzoweb