Wide Studio Programmer's Guide

Wide Studio Home
Up to


The drawing area



How to draw pictures on the drawing area

It it possible to draw pictures freely by the 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 the drawing area.
#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSCvdrawingArea.h>
#include <WSCvslider.h>

void drawep(WSCbase* object){
  //drawing_a is same as newvdra_000...
  //You can get it extern WSCvdrawingArea* newvdra000; also.
  WSCvdrawingArea* drawing_a =
         (WSCvdrawingArea*)object->cast("WSCvdrawingArea"); //(A)
  if (drawing_a == NULL){ //(B)
    return;
  }

  drawing_a->setForeColor("#ff0000"); //(C)
  drawing_a->drawLine(0,0,100,100);  //(D)

}
static WSCfunctionRegister  op("drawep",(void*)drawep);
At first access to the method of the drawing area, include the headder WSCdrawingArea.h of the WSCdrawingArea class and get the native class pointer of the WSCdrawingArea class at (A). It is impossible to access the native method of WSCdrawingArea class with the pointer of WSCbase class. If the pointer drawing_a is NULL at (B), the instance is not WSCdrawingArea, so exit the event procedure. Next, it is the sample to set the color to the drawing area which is used to the other methods for drawing pictures (C). At (D),draws the line from (0,0) to (100,100).
The drawing area class has the folloing 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.
    #include <WScom.h>
    #include <WSCfunctionList.h>
    #include <WSCbase.h>
    //----------------------------------------------------------
    //Function for the event procedure
    //----------------------------------------------------------
    #include <WSCvdrawingArea.h>
    #include <WSCvslider.h>
    
    void drawep(WSCbase* object){
      //drawing_a is same as newvdra_000...
      //You can get it extern WSCvdrawingArea* newvdra000; also.
      WSCvdrawingArea* drawing_a =
             (WSCvdrawingArea*)object->cast("WSCvdrawingArea");
      if (drawing_a == NULL){
        return;
      }
      WSCushort w = drawing_a->getProperty(WSNwidth);
      WSCushort h = drawing_a->getProperty(WSNheight);
      drawing_a->drawStretchedImage(0,0,w,h,"001.jpg");  //(A)
    
    }
    static WSCfunctionRegister  op("drawep",(void*)drawep);
    
    At (A), draws the image by size as same as the drawing area.
    Document Release 1.3

    For Use with Wide Studio Release 1.3, Summer 2001


    Wide Stuido Home | Up to

    Copyright(C) T. Hirabayashi, 2000-2001 Last modified: August 20, 2001