高手你好,由于工作需要,做一个阵面监测的程序,
我在窗口上画的矩形没有任何显示,为什么?程序如下
int MyDetectWin::MyDraw(int left,int top,int width,int height) { ZafRegionStruct drawRegion ; //BeginDraw(); ZafDisplay *display = Display(); display->SetCoordinateType(ZAF_PIXEL); BeginDraw(); drawRegion.left = 10; drawRegion.top = 10; drawRegion.right = drawRegion.left + 100; drawRegion.bottom = drawRegion.top + 100;
display->SetBackground(ZAF_CLR_RED); display->Rectangle(drawRegion,1,true); //display->DestroyColor(color); ZafPrompt *lable=new ZafPrompt(drawRegion.left,drawRegion.top,40, ZAF_ITEXT("prompt"));//prompt在界面上可以看到,说明执行了。 lable->SetCoordinateType(ZAF_PIXEL); Add(lable); EndDraw(); return 1; }
但是用鼠标消息画的矩形却有显示:
ZafEventType MyDetectWin::Event(const ZafEventStruct &event) { ZafEventType ccode = LogicalEvent(event); char buf[50]; ZafDisplay *replay = Display(); switch (ccode) { case L_BEGIN_SELECT: { ccode = ZafWindow::Event(event);
//WindowManager()->SetMouseEventRoute(this);//这一句会导致任何鼠标事件都发给她处理,破坏了 origin = event.position; //原来的路由方式. replay->SetCoordinateType(ZAF_PIXEL); origin_PIXEL = origin.Position(ZAF_PIXEL); sprintf(buf,"%d",origin_PIXEL.column); rowstring->SetText(ZAF_ITEXT(buf)); sprintf(buf,"%d",origin_PIXEL.line); linestring->SetText(ZAF_ITEXT(buf)); BeginDraw(); ZafRegionStruct redrawRegion ; redrawRegion.left = origin_PIXEL.column; redrawRegion.top = origin_PIXEL.line; redrawRegion.right = redrawRegion.left + CELLWIDTH; redrawRegion.bottom = redrawRegion.top + CELLHEIGHT; replay->SetBackground(ZAF_CLR_RED); replay->Rectangle(redrawRegion,1,true); EndDraw(); } break; default: ccode = ZafWindow::Event(event); }
return (ccode); }
怎么办?
我需要画几十个矩形呢!!对了MyDetectWin是加在notebook上的。
MyTabBook::MyTabBook(int left ,int top,int width,int height) :ZafNotebook(left, top, width, height) { SetCoordinateType(ZAF_PIXEL);
ZafWindow *page1 = new MyDetectWin(left,top,width,height); page1->Add(new ZafTitle("Array Detect"));
Add(page1);
tableft = left; tabtop = top; tabwidth = width; tabheight = height; }
我感觉是画了,但是又被重画刷新了,怎么改? |
用户73924 2006-11-27 16:59
聊聊gui和os接口多少的问题,移植过ucgui到nucleus上,感觉确实很少的东西需要porting,一般一个delay,一个task id,就差不多了。
不过说到gui,uc给我的感觉是能力有限,而且为了专注于代码空间,而影响了效率,这个可以从ucgui的datasheet上看出来,他的测试都是在什么什么条件下的代码量,而不是多少次运算。感觉这点不是很好。对稍复杂的图形应用,不太合适。特别是多窗口,多任务条件下。
看过几天的minigui,不过只是浮在表面,没做实际工作。它的gui好像采用的是client / sever 模式,而且还有一些posix函数支持。这样的gui与os接口估计不是简单的那几个函数的东西可以解决了。