MyWindow :: MyWindow( ): XFrameWindow( 100 , "Handling events!", XFrameWindow::defaultStyle)
{
    //at first we define a color which is used to paint the background
    //we chose white as background color
    XColor color(COL_WHITE);
    SetBackgroundColor( &color );

    //Set the position of this window
    //left-lower corner is 100,100, width is 300, height is 200
    XRect rect(100,100,300,230);
    SetSize(&rect);

    //now we create some control windows so events can be posted
    //at first a combobox
    XComboBox * combo = new XComboBox( this, XRect( 20, 100, 200, 90), IDC_LISTNAME, CB_DROPDOWNLIST | WIN_VISIBLE);
    //insert some rows
    combo->InsertItem( "Line 1");
    combo->InsertItem( "Line 2");
    combo->InsertItem( "Line 3");
    combo->InsertItem( "Line 4");
    combo->InsertItem( "Line 5");

    //create a simple entry field
    XEntryField * entry = new XEntryField( this, XRect( 20, 60, 100, 20), IDE_ENTRYNAME, ES_MARGIN | EN_LEFT | WIN_VISIBLE);

    //make this window the active window
    Activate();
}
Esempio n. 2
0
XU32 XDomTD::Handle(XU32 nOpera, XU32 pData1, XU32 pData2)
{
	switch(nOpera)
	{
		case XDO_GET_RECT:
		 if(IsVisiable()&&m_nWidth>0)
		 {
			XRect*pr=(XRect*)pData1;
			*pr=XRect(m_nPosX,m_nPosY,
					  m_nPosX+m_nWidth,m_nPosY+m_nHeight);
			//rt.InflateRect(2,2);
			
			return XTRUE;
		 }break;

	case XDO_PAINT:return XDomNode::Handle(nOpera,pData1,pData2);
	case XDO_LAYEROUT_TABPRE:
		 return LayeroutPre((DRAWCONTEXT*)pData1,(CELLDATA*)pData2);
	case XDO_LAYEROUT_TAB:
		 LayeroutCell((DRAWCONTEXT*)pData1,(CELLDATA*)pData2);
		 return XTRUE;
	case XDO_LAYEROUT_TABS:
		 LayeroutCells((DRAWCONTEXT*)pData1,(CELLDATA*)pData2);
		 return XTRUE;
	case XDO_PAINT_TABLE:
		 if(!IsVisiable()) return 0;
		 return Paint((DRAWCONTEXT*)pData1,pData2);
	}
	return XDomBlock::Handle(nOpera,pData1,pData2);
}
Esempio n. 3
0
XBOOL XHScrollBar::OnPaint(XGraphics &g)
{
	XRect rect;
	GetClientRect(rect);
	XColor c(XWindow::m_nColors[XCW_BUTTON]);
	XColor cc(c);
	cc.Bright(24);
	g.SetBackColor(cc);
	g.FillRectangle(rect);
	
	XRect r=rect;
	int pp;
	CalcRect(r,pp);
	if(m_nStatus==XS_UPPAGE&&r.left>rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(0,0,r.left,rect.bottom));
	}
	if(m_nStatus==XS_DOWNPAGE&&r.right<rect.right-rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(r.right,0,rect.right-rect.bottom,rect.bottom));
	}


	XColor hc(c);
	hc.Bright(10);
	XRect rl(0,0,rect.bottom,rect.bottom);
	XRect rr(rect.right-rect.bottom,0,rect.right,rect.bottom);
	g.DrawButton(rl,m_nStatus==XS_UPLINE?hc:c,XBS_BFRAME|XBS_WFRAME);
	g.DrawButton(rr,m_nStatus==XS_DOWNLINE?hc:c,XBS_BFRAME|XBS_WFRAME);

	cc=c;cc.Dark(60);
	g.DrawDirect(rl,XK_LEFT,cc);
	g.DrawDirect(rr,XK_RIGHT,cc);


	g.DrawButton(r,m_nStatus==XS_HAND?hc:c,XBS_BFRAME|XBS_WFRAME|XBS_VHAND);

	return XTRUE;
	//*/
}
Esempio n. 4
0
void XHScrollBar::CalcRect(XRect &rect, int &pp)
{
	GetClientRect(rect);
	int w=rect.Width()-(rect.bottom<<1);
	int mw=rect.Height()<<1;
	pp=m_nRange==0?1000:XMIN(1000,(w-mw)*1000/m_nRange);
	int bx=m_nPos*pp/1000+rect.bottom-1;
	int ex=rect.right-((m_nRange-m_nPos)*pp/1000+rect.bottom)+1;
	rect=XRect(bx,0,ex,rect.bottom);
}
MyWindow :: MyWindow( ): XFrameWindow( 100 , "Hello world!", XFrameWindow::defaultStyle)
{
        //at first we define a color which is used to paint the background
        //we chose white as background color
        XColor color(COL_WHITE);
        SetBackgroundColor( &color );

        //create a text
        //the owner of the text is this window, show the text "Hello World"
        XStaticText * text = new XStaticText(this, "Hello world!", XRect( 100, 100, 150, 20), TX_CENTER, 300);

        //Set the position of this window
        //left-lower corner is 100,100, width is 300, height is 200
        XRect rect(100,100,300,200);
        SetSize(&rect);

        //make this window the active window
        Activate();
}
MyWindow :: MyWindow( ): XFrameWindow( 100 , "Handling events!", XFrameWindow::defaultStyle)
{
    //at first we define a color which is used to paint the background
    //we chose white as background color
    XColor color(COL_WHITE);
    SetBackgroundColor( &color );

    //create a static text
    XStaticText * text = new XStaticText(this, "Hello world!", XRect( 20, 100, 200, 20), WIN_VISIBLE| TX_LEFT, 300);

    //now create our mouse-handler for this window
    MyMouseHandler * handler = new MyMouseHandler(this);

    //Set the position of this window
    //left-lower corner is 100,100, width is 300, height is 200
    XRect rect(100,100,300,230);
    SetSize(&rect);

    //make this window the active window
    Activate();
}
Esempio n. 7
0
void XCtrlManagerBase::drawUp()
{
	if (m_isAutoDraw == 0 ||
		m_ctrlObjInfos.size() <= 0) return;
	int index;
	//描绘上层
	XControlBasic *p = NULL;
	for (int i = (int)(m_ctrlObjInfos.size()) - 1; i >= 0; --i)
	{
		index = m_ctrlDrawOrderMap[i];
		if (m_ctrlObjInfos[index].pObject == NULL) continue;
		p = m_ctrlObjInfos[index].pObject;
		if (m_ctrlObjInfos[index].needDraw) p->drawUp();
		if (p->isFocus() && m_ctrlObjInfos[i].needDraw && m_withWireframe && p->getWithWireframe())//如果处于激活状态,则这里画一个边框,标记为可以接受鼠标和键盘事件
			XRender::drawRectAntiColor(XRect(p->getBox(0) - XVec2::one, p->getBox(2) + XVec2::one), 0.5f, XRender::LS_DASHES);
	}
	//下面描绘特殊物体
	for (auto it = m_specialCtrls.begin(); it != m_specialCtrls.end(); ++it)
	{
		(*it)->drawUp();
	}
}
Esempio n. 8
0
XU32 XDomTable::Paint(DRAWCONTEXT *pDraw)
{
   	//XString8 str=FindAttrib(XEAB::ID,"");
	//if(str=="last")
	//	int a=0;


   if(m_nWidth<=0) return 0;
   if(m_nPosX>=pDraw->paint.right||
	  m_nPosX+m_nWidth<=pDraw->paint.left||
	  m_nPosY>=pDraw->paint.bottom||
	  m_nPosY+m_nHeight<=pDraw->paint.top) return 0;

  XU32 ss=PrePaint(pDraw);

  XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight);

  int bd=FindAttrib(XEAB::BORDER,0);
  XU8 nType=FindAttrib(XEAB::FRAME,XEnumFrame::BOX);
  XU8 bCollapse=pDraw->bCollapse;
  pDraw->bCollapse=FindAttrib(XEAB::BORDER_COLLAPSE,0);
  int nr=pDraw->SPACING;
  pDraw->SPACING=XMAX(FindAttrib(XEAB::CELLSPACING,1),0);
  XU8 d=pDraw->TABBORDER;
  pDraw->TABBORDER=bd;

  XRect ar=XRect(rect.left,rect.top,rect.right,rect.bottom);
  
  PaintBack(pDraw,ar,XTRUE);
  
  XU32 s=HandleChild(XDO_PAINT_TABLE,(XU32)pDraw,0);
  pDraw->bCollapse=bCollapse;
  pDraw->TABBORDER=d;
  if(nType==XEF::VOID_X) bd=0;

  if(bd>0)
  {
	  XGraphics*pg=pDraw->pDraw;
	  //pDraw->Save();
	  XColor cc(pDraw->DCBACK);
	  XColor dc(cc);
	  dc.Dark(60);
	  cc.Dark(30);
	  
	  int bx=m_nPosX,by=m_nPosY;
	  int ex=m_nPosX+m_nWidth-1,ey=m_nPosY+m_nHeight-1;
	  for(int i=0;i<bd;i++)
	  {
		pg->SetColor(cc);
		switch(nType)
		{
		case XEF::BOX:
		case XEF::ABOVE:
		case XEF::BORDER:
		case XEF::HSIDES:
			 pg->DrawLine(bx,by,ex,by);
			 break;
		}
		switch(nType)
		{
		case XEF::BORDER:
		case XEF::BOX:
		case XEF::VSIDES:
		case XEF::LHS:
			 pg->DrawLine(bx,by,bx,ey);
			 break;
		}
		pg->SetColor(dc);
		switch(nType)
		{
		case XEF::BORDER:
		case XEF::BOX:
		case XEF::VSIDES:
		case XEF::RHS:
			 pg->DrawLine(ex,by,ex,ey);
			 break;
		}
		switch(nType)
		{
		case XEF::BORDER:
		case XEF::BOX:
		case XEF::HSIDES:
		case XEF::BELOW:
			 pg->DrawLine(bx,ey,ex,ey);
			 break;
		}
		cc.Bright(3);
		dc.Bright(3);
		bx++;
		by++;
		ex--;
		ey--;
	  }

	  //cc.Dark(20);
	  /*pDraw->pDraw->DrawFrame(
		  XRect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight),
		  cc,bd,XTRUE);*/
//	  pDraw->Restore();
  }
  pDraw->SPACING=nr;
  PaintBorder(pDraw,ar);
  EndPaint(pDraw);
  //if(bSave) 
	//  pDraw->Restore();

  return s;
}
Esempio n. 9
0
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
XU32 XDomTable::Handle(XU32 nOpera, XU32 pData1, XU32 pData2)
{
	XVar*p=(XVar*)pData1;
	switch(nOpera)
	{
	case XDO_GET_RECT:
		 *((XRect*)pData1)=XRect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight);
		 return XTRUE;
	case XDO_HITTEST:
		{
		  XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight);
		  if(!rect.PtInRect(pData1,pData2)) return 0;
		}break;
/*	case XDO_SET_ATTR:
	case XDO_ADD_ATTR:
		 switch(p->nID)
		 {
		 case XEnumAttribs::COLUMNS:
			  p->ToInt();
			  break;
		 case XEnumAttribs::ALIGN:
			  if(p->nType==VSTRING) 
				  *p=XEnumAlign().Index(p->strData);
			  break;
		 }
		 break;*/
	case XDO_UPDATE_TABLECHILD:
//		 m_bNoChild=0;
		 break;
	case XDO_UPDATE_TABLE:
		 //m_nWin=0;
		 //XDomNode::Handle(XDO_
		 m_nWidth=0;//m_nFixWidth=0;
		 break;
	case XDO_SET_FINAL:
		 //if(m_bFinal)
		 if(m_pParent!=XNULL)
		   m_pParent->Handle(XDO_UPDATE_TABLECHILD,0,0);
		 m_bFinal=1;
		 //m_nWin=0;
		 m_nWidth=0;//m_nFixWidth=0;
		 //m_bFinal=1;
		 break;
	case XDO_GET_STYLE:
		 return XDomNode::Handle(nOpera,pData1,pData2)|DOM_TABLE|DOM_PAINT;
	case XDO_LAYEROUT_CELL:
		 LayeroutCell((DRAWCONTEXT*)pData1,(CELLDATA*)pData2);
		 return XTRUE;
	case XDO_LAYEROUT_CELLS:
		 LayeroutCells((DRAWCONTEXT*)pData1,(CELLDATA*)pData2);
		 return XTRUE;
	case XDO_PAINT:
		 return Paint((DRAWCONTEXT*)pData1);
		 
		//{
			//XRect 
		//}
		 //return XDomNode::Handle(XDO_PAINT_TABLE,pData1,pData2);
		 //break;
	}
	return XDomNode::Handle(nOpera,pData1,pData2);
}
Esempio n. 10
0
MyWindow :: MyWindow( ): XFrameWindow( 100 , "Hello world!", FRM_BORDER|FRM_TASKLIST|FRM_TITLEBAR|FRM_SYSMENU|WIN_VISIBLE, XRect(100,100,156,57))
{
   toolBar = new XToolBar(this, TB_TOP, 0, 34);

   XRect rec(0,0,32,24);
   XPushButton * back = new XPushButton( toolBar, rec, (USHORT) IDP_BACK, BU_BITMAP | WIN_VISIBLE);
   XPushButton * play = new XPushButton( toolBar, rec, (USHORT) IDP_PLAY, BU_BITMAP);
   XPushButton * halt = new XPushButton( toolBar, rec, (USHORT) IDP_STOP, BU_BITMAP);
   XPushButton * sel = new XPushButton( toolBar, rec, (USHORT) IDP_OPEN, BU_BITMAP);

   //disable buttons
   play->Enable(FALSE);
   halt->Enable(FALSE);
   back->Enable(FALSE);

   //add the pushbuttons to the toolbar, the toolbar will use the size of the first button
   toolBar->AddWindow( play );
   toolBar->AddWindow( halt );
   toolBar->AddWindow( back );
   toolBar->AddWindow( sel, TRUE );

   sound = new XSound(this);

   //make this window the active window
   Activate();
}
Esempio n. 11
0
 MyMLE( MyAppWindow * w ): XMultiLineEdit( w, XRect(), MY_MLE, MLE_HORZSCROLL | MLE_VERTSCROLL | WIN_VISIBLE) { owner = w; }