WideStudio Logo
WideStudio
Programming Guide
WideStudio Index
Table of contents


The drawing area



How to draw pictures on the drawing area

It is possible to draw pictures freely by drawing area. It has the methods to draw various pictures, which can be used on the event procedure with exposure event WSEV_EXPOSE. The following program shows a basic method to draw pictures by drawing area.

(*----------------------------------------------------------*)
(*Function for the event procedure                          *)
(*----------------------------------------------------------*)
open Swig
open Mpfc
open Mpfclib
let drawep obj =

  obj->setForeColor("#ff0000");  (* A *)
  obj->drawLine(0,0,100,100);    (* B *)

  ()
let _ = Callback.register "drawep" drawep

It is the sample to set the color to the drawing area which is used to the other methods for drawing pictures (A). At (B),draws the line from (0,0) to (100,100).

The drawing area class has the following methods.


  • The rectangle and the filled rectangle

  • The circle,filled circle,arc,chord,oval.

  • The polygon,filled polygon.

  • The string.

  • The image of JPG,BMP.


  • How to draw images(JPG,BMP) on the drawing area

    It is possible to draw images of JPG,BMP by the method: drawImage(), drawStretchedImage(). The method: drawImage() draws the image as is, and the method: drawStretchedImage() draws the image as specified size.

    (*----------------------------------------------------------*)
    (*Function for the event procedure                          *)
    (*----------------------------------------------------------*)
    open Swig
    open Mpfc
    open Mpfclib
    let drawep obj =
      let w = obj -> getProperty("width") in
      let h = obj -> getProperty("height") in
      obj -> drawStretchedImage(0,0,(w->getLong()),(h->getLong()),"001.jpg"); (* A *)
    
      ()
    let _ = Callback.register "drawep" drawep
    

    At (A), draws the image by size as same as the drawing area.

    Document Release 3.80 for WideStudio ver 3.80, Jan 2005


    WideStudio documents index | Table of contents

    Copyright(C) WideStudio Development Team, 1999-2005 Last modified: Jan 05, 2005