WideStudio/MWT Logo
WideStudio/MWT
Programming Guide
WideStudio/MWT Index
Table of contents


绘图区域



在绘图区域中绘图

通过绘图区域(WSCvdrawingArea 类),可以自由地绘画图形。 绘图区域中,可以通过各种绘画用方法进行绘画。 以下的范例程序中,显示了在绘图区域中使用的基本绘画方法。

#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);

首先,为了访问制图区域中的各函数,须如(A)显示的那样,取得绘图领域(WSCvdrawingArea)的pointer。仍然使用WSCbase Class的pointer的话,不能访问制图区域的函数。

因为事项过程可能错误连接其他的Class,所以在(B)判断是否为绘图领域。如果pointer的取得结果不是 NULL,则为绘图领域。

在(C)指定绘画时的颜色。在(D)指定从坐标(0,0)到坐标(100,100)划线。

在制图区域,除了划线函数以外,还有下面的函数。


  • 矩形绘画

  • 圆,圆弧,椭圆的绘画

  • 多角形的绘画

  • 图片的绘画


  • 在制图区域追加图片

    想显示图片时,采用drawImage 函数,或drawStretchedImage 函数。drawStretchedImage函数,不像drawImage 函数那样将图片不变动直接表示,而是可以进行尺寸扩大或缩小后显示图片。

    #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);
    

    在A处,按照制图区域的尺寸显示图片。

    Document Release 3.90 for WideStudio/MWT ver 3.90, Jul 2005


    WideStudio/MWT documents index | Table of contents

    Copyright(C) WideStudio/MWT Development Team, 1999-2005 Last modified: Jul 31, 2005