예제 #1
0
파일: gdd_window.c 프로젝트: Mars-Wu/djyos
//----默认的窗口非客户区绘制消息处理函数------------------------------------------
//描述: 该函数为内部函数,在DefWindowPorc的MSG_NCPAINT中被调用.
//参数:pMsg: 消息指针.
//返回:无.
//------------------------------------------------------------------------------
static void DefWindowProc_NCPAINT(MSG *pMsg)
{
    HWND hwnd=pMsg->hwnd;
    HDC hdc;
    RECT rc;

    if(HWND_Lock(hwnd))
    {
        hdc =GetWindowDC(hwnd);
        if(NULL!=hdc)
        {
            _GetWindowRect(hwnd,&rc);
            _ScreenToWindow(hwnd,(POINT*)&rc,2);

            if(hwnd->Style&WS_BORDER)
            {
                SetDrawColor(hdc,WINDOW_BORDER_COLOR);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);
            }

            if(hwnd->Style&WS_DLGFRAME)
            {
                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR1);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR2);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR3);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

            }

            if(hwnd->Style&WS_CAPTION)
            {
                rc.bottom =rc.top+hwnd->CaptionSize;

                GradientFillRect(hdc,&rc,RGB(180,180,200),RGB(0,0,180),GFILL_U_D);

                SetTextColor(hdc,WINDOW_CAPTION_TEXT_COLOR);
                InflateRect(&rc,-1,-1);
                DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER);
            }

            ReleaseDC(hwnd,hdc);
        }

        HWND_Unlock(hwnd);
    }


}
예제 #2
0
void  OGL2DBase::AxesDrawSetup()
{
    SetDrawColor(plot2Dbase.defaultPenSet->GetColor(plot2Dbase.plotAnnotation.axesDataPen));
    SetLine(plot2Dbase.plotAnnotation.axesLineWidth);
    SetLineSolid();
    SetGridHigh();
}
예제 #3
0
void  OGL2DBase::MajorGridDrawSetup()
{
    SetDrawColor(plot2Dbase.defaultPenSet->GetColor(plot2Dbase.plotAnnotation.gridLineDataPen));
    SetLine(plot2Dbase.plotAnnotation.majorGridWidth);
    SetLineType(plot2Dbase.plotAnnotation.majorGridLineType);
    if (plot2Dbase.plotAnnotation.gridOverData)
        SetGridHigh();
}
예제 #4
0
gkAuxRenderer::gkAuxRenderer( void )
{
	m_vecLineVertexBuffer.clear();
	m_vecSolidVertexBuffer.clear();
	m_vecOverHudLineVertexBuffer.clear();
	m_vecOverHudSolidVertexBuffer.clear();
	SetDrawColor(ColorF(1, 1, 1, 1));
}
예제 #5
0
void ESoundEnvironment::Construct(LPVOID data)
{
	ClassID					= OBJCLASS_SOUND_ENV;
    
	add_box					(Fidentity);
	SetDrawColor			(0x205050FF, 0xFF202020);
    m_EnvInner				= "";
    m_EnvOuter				= "";
}
예제 #6
0
void cGraphicsSDL2::DrawFillCircle(int &x, int &y, 
                                   uint32_t &radius, 
                                   sColor *color /*= nullptr*/) {
    SetDrawColor(color);
    int tmpX = 0;
    int tmpY = 0;
    for (int i = 0; i < 360; i++) {
        tmpX = x + (sin(i) * radius);
        tmpY = y + (cos(i) * radius);
        SDL_RenderDrawPoint(m_Renderer, tmpX, tmpY);
    }
}
예제 #7
0
		void Base::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString & text )
		{
			
		//	std::cout << "tryinta render sum txt '" << Gwen::Utility::UnicodeToString(text) <<"'\n";
			float fSize = pFont->size * Scale();

			SetDrawColor(Gwen::Color(0,0,0,255));
			for ( float i = 0; i < text.length(); i++ )
			{
				wchar_t chr = text[i];

				if ( chr == ' ' ) { continue; }

				Gwen::Rect r( pos.x + i * fSize * 0.4, pos.y, fSize * 0.4 - 1, fSize );

				/*
					This isn't important, it's just me messing around changing the
					shape of the rect based on the letter.. just for fun.
				*/
				if ( chr == 'l' || chr == 'i' || chr == '!' || chr == 't' )
				{
					r.w = 1;
				}
				else if ( chr >= 'a' && chr <= 'z' )
				{
					r.y += fSize * 0.5f;
					r.h -= fSize * 0.4f;
				}
				else if ( chr == '.' || chr == ',' )
				{
					r.x += 2;
					r.y += r.h - 2;
					r.w = 2;
					r.h = 2;
				}
				else if ( chr == '\'' || chr == '`'  || chr == '"' )
				{
					r.x += 3;
					r.w = 2;
					r.h = 2;
				}

				if ( chr == 'o' || chr == 'O' || chr == '0' )
				{ DrawLinedRect( r ); }
				else
				{
				//	std::cout << "drawing ur flld rct: " <<r.x<<','<<r.y<<','<<r.w<<','<<r.h<<"\n";
					DrawFilledRect( r );
				}
			}
		}
예제 #8
0
//-----------------------------------------------------------------------
void gkAuxRenderer::AuxRender3DLine( const Vec3& from, const Vec3& to, ColorF& color, bool ignoreZ)
{
	SetDrawColor(color);
	GK_HELPER_LINEVERTEX vertexFrom(from, m_curColor);
	GK_HELPER_LINEVERTEX vertexTo(to, m_curColor);
	if (ignoreZ)
	{
		m_vecOverHudLineVertexBuffer.push_back(vertexFrom);
		m_vecOverHudLineVertexBuffer.push_back(vertexTo);
	}
	else
	{
		m_vecLineVertexBuffer.push_back(vertexFrom);
		m_vecLineVertexBuffer.push_back(vertexTo);
	}

}
예제 #9
0
void cGraphicsSDL2::DrawCircle(int &x, int &y, 
                               uint32_t &radius, 
                               uint32_t width /* = 1 */,
                               sColor *color /*= nullptr*/) {
    SetDrawColor(color);
    if (width == 0) {
        width = 1;
    }
    radius += 1;
    for (uint32_t i = 1; i <= width; i++) {
        radius -= i;
        int tmpX = 0;
        int tmpY = 0;
        for (double i = 0.0; i < 360.0; i += 0.4) {
            tmpX = x + (cos(i) * radius);
            tmpY = y + (sin(i) * radius);
            SDL_RenderDrawPoint(m_Renderer, tmpX, tmpY);
        }
    }
}
예제 #10
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                cfg_idx =0;
                bBorder=TRUE;
                bBKGND=TRUE;
                bColor=TRUE;

                GetClientRect(hwnd,&rc0);
                CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);

                i=RectH(&rc0)-(3*30);
                CreateWindow(CHECKBOX,"绘制边框",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+0*32,128,24,hwnd,ID_BORDER,NULL);
                CreateWindow(CHECKBOX,"绘制背景",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+1*32,128,24,hwnd,ID_BKGND,NULL);
                CreateWindow(CHECKBOX,"改变颜色",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+2*32,128,24,hwnd,ID_COLOR,NULL);

                GDD_CreateTimer(hwnd,1,3000,TMR_START);
                GDD_CreateTimer(hwnd,2,1000,TMR_START);

                break;
                ////
        case    MSG_TIMER:
                {
                    switch(pMsg->Param1)
                    {
                        case    1:
                                cfg_idx++;
                                if(DrawText_Cfg_Tbl[cfg_idx].text==NULL)
                                {
                                    cfg_idx=0;
                                }
                                InvalidateWindow(hwnd);
                                break;
                                /////
                        case    2:
                                if(bColor!=FALSE)
                                {
                                    color_idx++;
                                    if(color_idx>=8)
                                    {
                                        color_idx=0;
                                    }
                                    InvalidateWindow(hwnd);
                                }
                                break;
                                /////
                    }
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    if(id==ID_CLOSE)
                    {
                    	if(event==BTN_UP)
                    	{
                    		PostMessage(hwnd,MSG_CLOSE,0,0);
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_BORDER)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bBorder =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bBorder =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_BKGND)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bBKGND =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bBKGND =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                    if(id==ID_COLOR)
                    {
                    	if(event==CBN_SELECTED)
                    	{
                    		bColor =TRUE;
                    	}
                    	if(event==CBN_UNSELECTED)
                    	{
                    		bColor =FALSE;
                    	}
                    	InvalidateWindow(hwnd);
                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(200,200,200));
                    FillRect(hdc,&rc0);


                    SetRect(&rc,4,10,RectW(&rc0)-4*2,60);
                    SetTextColor(hdc,DrawText_Color_Tbl[color_idx].text_color);
                    SetDrawColor(hdc,DrawText_Color_Tbl[color_idx].bd_color);
                    SetFillColor(hdc,DrawText_Color_Tbl[color_idx].bk_color);

                    i=DrawText_Cfg_Tbl[cfg_idx].flag;
                    if(bBorder)
                    {
                        i |= DT_BORDER;
                    }
                    if(bBKGND)
                    {
                        i |= DT_BKGND;
                    }

                    DrawText(hdc,DrawText_Cfg_Tbl[cfg_idx].text,-1,&rc,i);
                   // DrawText(hdc,"DrawText\r\n**绘制字符串**",-1,&rc,DT_BORDER|DT_BKGND|DT_VCENTER|DT_CENTER);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
예제 #11
0
//-----------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------
void CCanvas::SetDrawColor( Color col )
{
	SetDrawColor( col.r / 255.0f, col.g / 255.0f, col.b / 255.0f, col.a / 255.0f );
}
예제 #12
0
//-----------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------
void CCanvas::SetDrawColor( int r, int g, int b, int a )
{
	SetDrawColor( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
}
예제 #13
0
//-----------------------------------------------------------------------
void gkAuxRenderer::AuxRender3DBoxSolid( const Vec3& center, Vec3& size, ColorF& color /*= ColorF(1.0,1.0,1.0,1.0)*/, bool ignoreZ /*= false*/ )
{
	SetDrawColor( color );

	GK_HELPER_LINEVERTEX point[8];
	point[0].m_vPosition = center + Vec3(-size.x, size.y, -size.z) * 0.5f;
	point[1].m_vPosition  = center + Vec3(-size.x, -size.y, -size.z) * 0.5f;
	point[2].m_vPosition  = center + Vec3(size.x, size.y, -size.z) * 0.5f;
	point[3].m_vPosition  = center + Vec3(size.x, -size.y, -size.z) * 0.5f;
	point[4].m_vPosition  = center + Vec3(-size.x, size.y, size.z) * 0.5f;
	point[5].m_vPosition = center + Vec3(-size.x, -size.y, size.z) * 0.5f;
	point[6].m_vPosition = center + Vec3(size.x, size.y, size.z) * 0.5f;
	point[7].m_vPosition = center + Vec3(size.x, -size.y, size.z) * 0.5f;

	point[0].m_dwDiffuse = m_curColor;
	point[1].m_dwDiffuse = m_curColor;
	point[2].m_dwDiffuse = m_curColor;
	point[3].m_dwDiffuse = m_curColor;
	point[4].m_dwDiffuse = m_curColor;
	point[5].m_dwDiffuse = m_curColor;
	point[6].m_dwDiffuse = m_curColor;
	point[7].m_dwDiffuse = m_curColor;

	if (ignoreZ)
	{
	// 填12个面
	// face#1
		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);

		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);

		// face#2
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[6]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);

		m_vecOverHudSolidVertexBuffer.push_back(point[6]);
		m_vecOverHudSolidVertexBuffer.push_back(point[7]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);

		// face#3
		m_vecOverHudSolidVertexBuffer.push_back(point[6]);
		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[7]);

		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[5]);
		m_vecOverHudSolidVertexBuffer.push_back(point[7]);

		// face#4
		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[5]);

		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);
		m_vecOverHudSolidVertexBuffer.push_back(point[5]);

		// face#5
		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[6]);
		m_vecOverHudSolidVertexBuffer.push_back(point[0]);

		m_vecOverHudSolidVertexBuffer.push_back(point[6]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[0]);

		// face#6
		m_vecOverHudSolidVertexBuffer.push_back(point[5]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);
		m_vecOverHudSolidVertexBuffer.push_back(point[7]);

		m_vecOverHudSolidVertexBuffer.push_back(point[7]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);
	}
	else
	{
		// 填12个面
		// face#1
		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[1]);

		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[3]);
		m_vecSolidVertexBuffer.push_back(point[1]);

		// face#2
		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[6]);
		m_vecSolidVertexBuffer.push_back(point[3]);

		m_vecSolidVertexBuffer.push_back(point[6]);
		m_vecSolidVertexBuffer.push_back(point[7]);
		m_vecSolidVertexBuffer.push_back(point[3]);

		// face#3
		m_vecSolidVertexBuffer.push_back(point[6]);
		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[7]);

		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[5]);
		m_vecSolidVertexBuffer.push_back(point[7]);

		// face#4
		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[5]);

		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[1]);
		m_vecSolidVertexBuffer.push_back(point[5]);

		// face#5
		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[6]);
		m_vecSolidVertexBuffer.push_back(point[0]);

		m_vecSolidVertexBuffer.push_back(point[6]);
		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[0]);

		// face#6
		m_vecSolidVertexBuffer.push_back(point[5]);
		m_vecSolidVertexBuffer.push_back(point[1]);
		m_vecSolidVertexBuffer.push_back(point[7]);

		m_vecSolidVertexBuffer.push_back(point[7]);
		m_vecSolidVertexBuffer.push_back(point[1]);
		m_vecSolidVertexBuffer.push_back(point[3]);
	}



}
예제 #14
0
//-----------------------------------------------------------------------
void gkAuxRenderer::AuxRenderPyramid( const Vec3& center, const Vec3& dir, const float radius, ColorF& color /*= ColorF(1.0,1.0,1.0,1.0)*/ , bool ignoreZ)
{
	SetDrawColor(color);

	// sturcture

	//      0
	//     /|\
	//    / | \
	//   / 4|  \
    //  /__ |_-`3
	// 1    2


	Vec3 crosser = Vec3(0.5f,0.5f,0.5f);
	Vec3 right = dir % crosser; // -1
	right.normalize();
	Vec3 down = dir % right; // -2
	down.normalize();

	GK_HELPER_LINEVERTEX point[5];
	point[0].m_vPosition  = center + dir * radius * 1.5f;
	point[1].m_vPosition = center + right * radius * 0.5f;
	point[2].m_vPosition = center + down * radius * 0.5f;
	point[3].m_vPosition = center - right * radius * 0.5f;
	point[4].m_vPosition = center - down * radius * 0.5f;

	point[0].m_dwDiffuse = m_curColor;
	point[1].m_dwDiffuse = m_curColor;
	point[2].m_dwDiffuse = m_curColor;
	point[3].m_dwDiffuse = m_curColor;
	point[4].m_dwDiffuse = m_curColor;


	if (ignoreZ)
	{
		// 填6个面
		// face#1
		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);

		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);

		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);
		m_vecOverHudSolidVertexBuffer.push_back(point[4]);

		m_vecOverHudSolidVertexBuffer.push_back(point[0]);
		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);

		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
		m_vecOverHudSolidVertexBuffer.push_back(point[1]);

		m_vecOverHudSolidVertexBuffer.push_back(point[4]);
		m_vecOverHudSolidVertexBuffer.push_back(point[3]);
		m_vecOverHudSolidVertexBuffer.push_back(point[2]);
	}
	else
	{
		// 填6个面
		// face#1
		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[1]);
		m_vecSolidVertexBuffer.push_back(point[2]);

		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[3]);

		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[3]);
		m_vecSolidVertexBuffer.push_back(point[4]);

		m_vecSolidVertexBuffer.push_back(point[0]);
		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[1]);

		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[2]);
		m_vecSolidVertexBuffer.push_back(point[1]);

		m_vecSolidVertexBuffer.push_back(point[4]);
		m_vecSolidVertexBuffer.push_back(point[3]);
		m_vecSolidVertexBuffer.push_back(point[2]);
	}

}
예제 #15
0
void  OGL3DBase::DrawOneAxes( const double&         axMin,
                              const double&         axMax,
                              const SC_DoubleArray& majorIncs,
                              const SC_DoubleArray& minorIncs,
                              const PC_AxesFormat&  format,
                                    Point2D&        stPoint,
                                    Point2D&        majTicEndPoint,
                                    Point2D&        minTicEndPoint,
                                    Point2D&        gridEndPoint,
                                    Point2D&        offsetEndPoint,
                                    double&         stComponent,
                                    double&         majTicComponent,
                                    double&         minTicComponent,
                                    double&         gridComponent,
                                    double&         offsetComponent,
                              const double&         zValue,
                                    Plane3D         axPlane,
                                    bool            axisIsLog)
{

    Point2D* endPoint;
    double*  endComponent;

    PC_3DAxesFormat&  axesFormat = plot3Dbase.axesFormat;
    DC_PenSet&        penSet   = *plot3Dbase.defaultPenSet;          //  default PenSet used for plot

    if (format.axesLinePos == PC_AxesFormat::alpBoth)
    {
        SetDrawColor(penSet.GetColor(axesFormat.axesLinePen));
        SetLine(axesFormat.axesLineWidth);
        SetLineSolid();

        HardCopyBlockStart(6);

        stComponent = axMin;
        Point2D axSt = stPoint;
        stComponent = axMax;
        Point2D axEnd = stPoint;
        DrawLine(axSt, axEnd, zValue, axPlane);

        //  needed at axes end to make offsets look clean
        endPoint = &offsetEndPoint;
        endComponent = &offsetComponent;

        stComponent = axMin;
        *endComponent = stComponent;
        DrawLine(stPoint, *endPoint, zValue, axPlane);

        stComponent = axMax;
        *endComponent = stComponent;
        DrawLine(stPoint, *endPoint, zValue, axPlane);

        HardCopyBlockEnd();
    }


    if ((format.axesMajorInc == PC_Axes::aitGrid) ||
        ((format.axesMajorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
    {
        SetDrawColor(penSet.GetColor(axesFormat.majorPen));
        if (format.axesMajorInc == PC_Axes::aitTic)
        {
            SetLine(axesFormat.majorTicWidth);
            endPoint = &majTicEndPoint;
            endComponent = &majTicComponent;
        }
        else
        {
            SetLine(axesFormat.majorGridWidth);
            SetLineType(axesFormat.majorGridLineType);
            endPoint = &gridEndPoint;
            endComponent = &gridComponent;
        }
        HardCopyBlockStart(majorIncs.Size() * 2);
        for (int i = 0; i < majorIncs.Size(); i++)
        {
            stComponent = majorIncs[i];
            if (Limit::WithinOneLimit(axMin, axMax, stComponent))
            {
                *endComponent = stComponent;
                DrawLine(stPoint, *endPoint, zValue, axPlane);
            }
        }
        HardCopyBlockEnd();
    }



    if ((format.axesMinorInc == PC_Axes::aitGrid) ||
        ((format.axesMinorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth)))
    {
        SetDrawColor(penSet.GetColor(axesFormat.minorPen));
        if (format.axesMinorInc == PC_Axes::aitTic)
        {
            SetLine(axesFormat.minorTicWidth);
            endPoint = &minTicEndPoint;
            endComponent = &minTicComponent;
        }
        else
        {
            SetLine(axesFormat.minorGridWidth);
            SetLineType(axesFormat.minorGridLineType);

            endPoint = &gridEndPoint;
            endComponent = &gridComponent;
        }


        HardCopyBlockStart((majorIncs.Size() + 1) * minorIncs.Size()  * 2);

        if (!axisIsLog)
        {
            double multVal = 1.0;
            if (axMin > axMax )
                multVal = -1.0;

            for (int i = -1; i < majorIncs.Size(); i++)
                for (int j = 0; j < minorIncs.Size(); j++)
                {
                    if (i < 0)
                        stComponent = majorIncs[0] - (minorIncs[j] * multVal);
                    else
                        stComponent = majorIncs[i] + (minorIncs[j] * multVal);

                    if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                    {
                        *endComponent = stComponent;
                        DrawLine(stPoint, *endPoint, zValue, axPlane);
                    }
                }
        }
        else
        {
            //
            static const double logIncVals[] = {0.30103, 0.47712, 0.60206, 0.69897,
                                                0.77815, 0.84510, 0.90309, 0.95424};
            if (axMin < axMax)
            {
                for (int i = -1; i < majorIncs.Size(); i++)
                    for (int j = 0; j < 8; j++)
                    {
                        if (i < 0)
                            stComponent = majorIncs[0] - 1.0 + logIncVals[j];
                        else
                            stComponent = majorIncs[i] + logIncVals[j];

                        if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                        {
                            *endComponent = stComponent;
                            DrawLine(stPoint, *endPoint, zValue, axPlane);
                        }
                    }
            }
            else
            {
                for (int i = -1; i < majorIncs.Size(); i++)
                    for (int j = 0; j < 8; j++)
                    {
                        if (i < 0)
                            stComponent = majorIncs[0] + logIncVals[j];
                        else
                            stComponent = majorIncs[i] - 1.0 + logIncVals[j];

                        if (Limit::WithinOneLimit(axMin, axMax, stComponent))
                        {
                            *endComponent = stComponent;
                            DrawLine(stPoint, *endPoint, zValue, axPlane);
                        }
                    }
            }

        }
        HardCopyBlockEnd();

    }
}
예제 #16
0
void OGL3DBase::DrawAxesLabels(const SC_DoubleArray& xMajorIncs,
                                const SC_DoubleArray& xtranMajorIncs,
                                const SC_DoubleArray& yMajorIncs,
                                const SC_DoubleArray& ytranMajorIncs,
                                const SC_DoubleArray& zMajorIncs,
                                const SC_DoubleArray& ztranMajorIncs,
                                const SC_RealFormat&     xFormat,
                                const SC_RealFormat&     yFormat,
                                const SC_RealFormat&     zFormat)
{
    PC_3DAxesLabel&      axesLabel  = plot3Dbase.axesLabel;
    if (!(axesLabel.plotIncrementLabel || axesLabel.plotAxesLabel))
        return;

    PC_3DAxesFormat&     axesFormat = plot3Dbase.axesFormat;


    if (axesLabel.autoPositionLabels)
    {
        axesLabel.xyLabIsVert = (fabs(currView.elevation) < 45.0);
        axesLabel.xLabYPosIsMax = (fabs(currView.azimuth) >= 90.0);
        axesLabel.yLabXPosIsMax = (currView.azimuth < 0.0);
        axesLabel.zLabYPosIsMax = !axesLabel.yLabXPosIsMax;
        axesLabel.zLabXPosIsMax = axesLabel.xLabYPosIsMax;

        if (fabs(currView.azimuth) >= 135.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZr;
        else if (currView.azimuth < -45.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZn;
        else if (currView.azimuth < 45.0)
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZn;
        else
            axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZr;
    }


    SetDrawColor(plot3Dbase.defaultPenSet->GetColor(axesFormat.majorPen));
    double fontRatio = double(axesLabel.incrementFont.fontSize) / double(axesLabel.labelFont.fontSize);

    char labStr[80];
    Coord3D labLoc;
    int i;
    bool adjSt, adjEnd;

    Coord3D minLim, maxLim;
    GetTransformedLimits(minLim, maxLim);
    Coord3D offComp = GetPixelComponents(axesFormat.axesOffset);

    //  x axis first
    SetAlignmentAdjust(xtranMajorIncs, minLim.cX, maxLim.cX, adjSt, adjEnd);
    labLoc = Coord3D(0.0, minLim.cY - offComp.cY, minLim.cZ - offComp.cZ);
    if (axesLabel.xLabYPosIsMax)
        labLoc.cY = maxLim.cY + offComp.cY;

    double rotVal = 0.0;
    if ((!axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax)
        rotVal = 180.0;
    bool mirror = (axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax;
    Plane3D txtPlane = p3D_XY;
    if (axesLabel.xyLabIsVert)
        txtPlane = p3D_XZ;
    HorizontalTextAlignment halign = hta_Center;
    if (adjSt)
        if (axesLabel.xLabYPosIsMax)
            halign = hta_Right;
        else
            halign = hta_Left;

    bool xyExponents = (xFormat.format > ncf_Scientific) || (yFormat.format > ncf_Scientific);
    double xyIncOffset = -0.25;
    if (xyExponents)
        xyIncOffset = -0.40;

    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < xMajorIncs.Size(); i++)
        {
            labLoc.cX = xtranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cX, maxLim.cX, labLoc.cX))
            {
                xFormat.RealToString(xMajorIncs[i], labStr, 80);
                if (adjEnd && (i == (xMajorIncs.Size() - 1)))
                    if (axesLabel.xLabYPosIsMax)
                        halign = hta_Left;
                    else
                        halign = hta_Right;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr);
            }
            halign = hta_Center;
        }
    }

//  need to check both X&Y here
    double xyAxOffset = xyIncOffset - 1.15;

    if (axesLabel.plotAxesLabel)
    {
        if (!axesLabel.plotIncrementLabel)
            xyAxOffset = -.25;
        xyAxOffset *= fontRatio;

        double labWidth, xoverTop, yoverTop;
        GetLabelSpecs(axesLabel.labelFont, axesLabel.xaxesLabel, xoverTop, labWidth);
        GetLabelSpecs(axesLabel.labelFont, axesLabel.yaxesLabel, yoverTop, labWidth);

        if (xoverTop > yoverTop)
            xyAxOffset -= xoverTop;
        else
            xyAxOffset -= yoverTop;
    }


    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.xaxesLabel) > 0))
    {
        labLoc.cX = (minLim.cX + maxLim.cX) / 2.0;
        Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, xyAxOffset,
                            rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.xaxesLabel);
    }

    //  y axes
    SetAlignmentAdjust(ytranMajorIncs, minLim.cY, maxLim.cY, adjSt, adjEnd);
    labLoc = Coord3D(minLim.cX - offComp.cX, 0.0, minLim.cZ - offComp.cZ);

    if (axesLabel.yLabXPosIsMax)
        labLoc.cX = maxLim.cX + offComp.cX;

    rotVal = 0.0;
    if (axesLabel.xyLabIsVert)
        txtPlane = p3D_YZ;
    else
        if (axesLabel.yLabXPosIsMax)
            rotVal = 90.0;
        else
           rotVal = -90.0;

    mirror = (axesLabel.xyLabIsVert) && (!axesLabel.yLabXPosIsMax);
    halign = hta_Center;
    if (adjSt)
        if (axesLabel.yLabXPosIsMax)
            halign = hta_Left;
        else
            halign = hta_Right;

    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < yMajorIncs.Size(); i++)
        {
            labLoc.cY = ytranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cY, maxLim.cY, labLoc.cY))
            {
                yFormat.RealToString(yMajorIncs[i], labStr, 80);
                if (adjEnd && (i == (yMajorIncs.Size() - 1)))
                    if (axesLabel.yLabXPosIsMax)
                        halign = hta_Right;
                    else
                        halign = hta_Left;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr);
            }
            halign = hta_Center;
        }
    }

    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.yaxesLabel) > 0))
    {
        labLoc.cY = (minLim.cY + maxLim.cY) / 2.0;
        double fontOffset = -1.50;
        if (!axesLabel.plotIncrementLabel)
            fontOffset = -.25;

        Axes3DLabel(axesLabel.labelFont, labLoc,0.0, xyAxOffset,
                    rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.yaxesLabel);
    }

    //  zaxes
    bool doLeft = false;
    switch (axesLabel.zLabOrientation)
    {
        case PC_3DAxesLabel::zloXZn : {
            txtPlane = p3D_XZ;
            mirror = false;
            doLeft = axesLabel.zLabXPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloXZr : {
            txtPlane = p3D_XZ;
            mirror = true;
            doLeft = !axesLabel.zLabXPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloYZn : {
            txtPlane = p3D_YZ;
            mirror = false;
            doLeft = axesLabel.zLabYPosIsMax;
            break;
        }
        case PC_3DAxesLabel::zloYZr : {
            txtPlane = p3D_YZ;
            mirror = true;
            doLeft = !axesLabel.zLabYPosIsMax;
            break;
        }
    }

    double offsetMult = 1.0;
    if (doLeft)
        halign = hta_Left;
    else
    {
        halign = hta_Right;
        offsetMult = -1.0;
    }

    if (axesLabel.zLabYPosIsMax)
        labLoc.cY = maxLim.cY + offComp.cY;
    else
        labLoc.cY = minLim.cY - offComp.cY;

    if (axesLabel.zLabXPosIsMax)
        labLoc.cX = maxLim.cX  + offComp.cX;
    else
        labLoc.cX = minLim.cX  - offComp.cX;


    double zAxOffset = 0.0;
    if (axesLabel.plotIncrementLabel)
    {
        for (i = 0; i < zMajorIncs.Size(); i++)
        {
            labLoc.cZ = ztranMajorIncs[i];
            if (Limit::WithinOneLimit(minLim.cZ, maxLim.cZ, labLoc.cZ))
            {
                zFormat.RealToString(zMajorIncs[i], labStr, 80);
                double labLen, overTop;
                GetLabelSpecs(axesLabel.incrementFont, labStr, overTop, labLen);
                if (labLen > zAxOffset)
                    zAxOffset = labLen;

                Axes3DLabel(axesLabel.incrementFont, labLoc,
                                    0.5 * offsetMult, 0.0, 0.0, halign, vta_Center, txtPlane, mirror, labStr);
            }
        }
    }

    if (axesLabel.plotAxesLabel && (StringLength(axesLabel.zaxesLabel) > 0))
    {
        labLoc.cZ = (minLim.cZ + maxLim.cZ) / 2.0;
        double fontOffset = - (zAxOffset + 0.75) * fontRatio * offsetMult;

        VerticalTextAlignment valign = vta_Bottom;
        if (fontOffset < 0.0)
            valign = vta_Top;

        Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, fontOffset,
                             90.0, hta_Center, valign, txtPlane, mirror, axesLabel.zaxesLabel);
    }
}
예제 #17
0
void cGraphicsSDL2::DrawRect(sRect &rect, sColor *color /*= nullptr*/) {
    SetDrawColor(color);
    SDL_RenderDrawRect(m_Renderer, (SDL_Rect*)&rect);
}
예제 #18
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i,x,y;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                cfg_idx =0;
                bBorder=TRUE;
                bBKGND=TRUE;
                bColor=TRUE;

                for(i=0;i<8;i++)
                {
                    timer_count[i] =0;
                    timer_run[i]    =FALSE;
                }
                GetClientRect(hwnd,&rc0);
                CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);

                y=20;
                x=128+8;
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_START_1,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_START_2,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_START_3,NULL);
                CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_START_4,NULL);

                y=20;
                x=128+8+64;
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_CLR_1,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_CLR_2,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_CLR_3,NULL);
                CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_CLR_4,NULL);

                GDD_CreateTimer(hwnd,0,timer_interval[0],0);
                GDD_CreateTimer(hwnd,1,timer_interval[1],0);
                GDD_CreateTimer(hwnd,2,timer_interval[2],0);
                GDD_CreateTimer(hwnd,3,timer_interval[3],0);
                GDD_CreateTimer(hwnd,7,500,TMR_START);

                break;
                ////
        case    MSG_TIMER:
                {
                    i =pMsg->Param1&0xFF;
                    timer_count[i]++;
                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {
                        case BTN_DOWN:  //按钮按下
                            if(id>=ID_START_1 && id<=ID_START_4)
                            {
                                i =id&0xF;
                                timer_run[i] =TRUE;
                                GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],TMR_START);
                            }

                            if(id>=ID_CLR_1 && id<=ID_CLR_4)
                            {
                                i =id&0xF;
                                timer_count[i] =0;
                                InvalidateWindow(hwnd);
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id>=ID_START_1 && id<=ID_START_4)
                            {
                                i =id&0xF;
                                timer_run[i] =FALSE;
                                GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],0);
                            }
                            break;
                            ////



                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {
                    char wbuf[32];

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(100,100,100));
                    FillRect(hdc,&rc0);

                    SetRect(&rc,4,20,128,24);
                    for(i=0;i<4;i++)
                    {
                        SetTextColor(hdc,DrawText_Color_Tbl[i].text_color);
                        SetDrawColor(hdc,DrawText_Color_Tbl[i].bd_color);
                        SetFillColor(hdc,DrawText_Color_Tbl[i].bk_color);
                        sprintf(wbuf," 定时器%d: %d",i+1,timer_count[i]);

                        if(timer_run[i]!=FALSE)
                        {
                            DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);
                        }
                        else
                        {
                            if(timer_count[7]&0x01)
                            {
                                DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                            }
                            else
                            {
                                DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BKGND);
                            }
                        }

                        OffsetRect(&rc,0,28);

                    }

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
예제 #19
0
		void Base::DrawMissingImage( Gwen::Rect pTargetRect )
		{
			SetDrawColor( Colors::Red );
			DrawFilledRect( pTargetRect );
		}
예제 #20
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 i;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:

                x1_inc =2;
                y1_inc =1;

                x2_inc =2;
                y2_inc =1;

                bMoveMainWin=FALSE;

                GetClientRect(hwnd,&rc0);
                hwnd_BTN1 =CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL);
                hwnd_BTN2 =CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,4,4,60,24,hwnd,ID_CLOSE,NULL);


                CreateWindow(BUTTON,"移动主窗口",WS_CHILD|BS_HOLD|WS_BORDER|WS_VISIBLE,4,RectH(&rc0)-28,100,24,hwnd,ID_MOVE_1,NULL);


                GDD_CreateTimer(hwnd,0,200,TMR_START);
                GDD_CreateTimer(hwnd,1,150,TMR_START);
                GDD_CreateTimer(hwnd,2,100,TMR_START);

                break;
                ////

        case    MSG_TIMER:
                {

                    switch(pMsg->Param1)
                    {
                    case 0:
                        {
                            static int x_inc=2;
                            static int y_inc=1;

                            if(bMoveMainWin==FALSE)
                            {
                                break;
                            }

                            GetWindowRect(hwnd,&rc);

                            if(rc.left > 320)
                            {
                                x_inc =-3;
                            }

                            if(rc.left <- 200)
                            {
                                x_inc =3;
                            }

                            if(rc.top > 200)
                            {
                                y_inc =-2;
                            }

                            if(rc.top < -100)
                            {
                                y_inc =2;
                            }

                            rc.left+=x_inc;
                            rc.top+=y_inc;

                            ScreenToClient(GetParent(hwnd),(POINT*)&rc,2);
                            MoveWindow(hwnd,rc.left,rc.top);
                        }
                        break;
                        /////

                    case 1:
                    {

                        GetClientRect(hwnd,&rc0);
                        ClientToScreen(hwnd,(POINT*)&rc0,2);

                        GetWindowRect(hwnd_BTN1,&rc);
                        /*
                        GetWindowRect(hwnd_BTN2,&rc0);
                        if(IsIntersectRect(&rc,&rc0))
                        {
                            x1_inc *=-1;
                            y1_inc *=-1;

                            x2_inc *=-1;
                            y2_inc *=-1;
                        }
                         */

                        if((rc.right) >= (rc0.right))
                        {
                            x1_inc =-3;
                        }

                        if(rc.left <= rc0.left)
                        {
                            x1_inc =3;
                        }

                        if((rc.bottom) >= (rc0.bottom))
                        {
                            y1_inc =-2;
                        }

                        if(rc.top <= rc0.top)
                        {
                            y1_inc =2;
                        }

                        rc.left +=x1_inc;
                        rc.top +=y1_inc;

                        ScreenToClient(hwnd,(POINT*)&rc,2);
                        MoveWindow(hwnd_BTN1,rc.left,rc.top);
                    }

                    case 2:
                    {

                        GetClientRect(hwnd,&rc0);
                        ClientToScreen(hwnd,(POINT*)&rc0,2);

                        GetWindowRect(hwnd_BTN2,&rc);
                        /*
                        GetWindowRect(hwnd_BTN1,&rc0);
                        if(IsIntersectRect(&rc,&rc0))
                        {
                            x1_inc *=-1;
                            y1_inc *=-1;

                            x2_inc *=-1;
                            y2_inc *=-1;
                        }
                        */

                        if((rc.right) >= (rc0.right))
                        {
                            x2_inc =-2;
                        }

                        if(rc.left <= rc0.left)
                        {
                            x2_inc =2;
                        }

                        if((rc.bottom) >= (rc0.bottom))
                        {
                            y2_inc =-1;
                        }

                        if(rc.top <= rc0.top)
                        {
                            y2_inc =1;
                        }

                        rc.left +=x2_inc;
                        rc.top +=y2_inc;

                        ScreenToClient(hwnd,(POINT*)&rc,2);
                        MoveWindow(hwnd_BTN2,rc.left,rc.top);
                    }

                    break;
                    ////

                    default:

                        break;

                    }

                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {

                        case BTN_DOWN:  //按钮按下
                            if(id==ID_MOVE_1)
                            {
                                bMoveMainWin=TRUE;
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id==ID_MOVE_1)
                            {
                                bMoveMainWin=FALSE;
                            }
                            break;
                            ////

                        default:
                            break;

                    }


                }
                break;
                ////

        case    MSG_PAINT:
                {
                    char wbuf[32];

                    hdc =BeginPaint(hwnd);

                    GetClientRect(hwnd,&rc0);


                    SetTextColor(hdc,RGB(0,240,0));
                    SetFillColor(hdc,RGB(40,40,40));
                    SetDrawColor(hdc,RGB(0,240,0));


                    GetWindowRect(hwnd,&rc);
                    sprintf(wbuf,"当前主窗口位置: %d,%d",rc.left,rc.top);
                    DrawText(hdc,wbuf,-1,&rc0,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}
void NsRendererOGL3::Draw(const NsQuad3D & quad)
{
	SetDrawColor(0.4f, 0.12f, 1.f);
	SetWorldMatrix(quad.GetWorldTransform());
		
	if(quad.bUseASCIIShader && !quad.shaderID < 1)
	{
		GLuint fontID = NsOGLResourceManager::Instance()->GetResourceID("/Textures/ASCII/ascii.png");
	
		glUseProgram(quad.shaderID);
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

		glActiveTexture(GL_TEXTURE0);
		glBindTexture (GL_TEXTURE_2D, quad.textureID);
		GLint iTextureUniform = glGetUniformLocation(quad.shaderID, "colorMap");
		glUniform1i(iTextureUniform, 0);

		glActiveTexture(GL_TEXTURE1);
		glBindTexture (GL_TEXTURE_2D, fontID);
		GLint iASCIIUniform = glGetUniformLocation(quad.shaderID, "asciiMap");
		glUniform1i(iASCIIUniform, 1);
	
		glBegin (GL_QUADS);
		{
			glTexCoord2f (0.0, 0.0);
			glVertex3f (0.0, 0.0, 0.0);

			glTexCoord2f (1.0, 0.0);
			glVertex3f (quad.fWidth, 0.0, 0.0);

			glTexCoord2f (1.0, 1.0);
			glVertex3f (quad.fWidth, quad.fHeight, 0.0);

			glTexCoord2f (0.0, 1.0);
			glVertex3f (0.0, quad.fHeight, 0.0);
		}
		glEnd ();

		glUseProgram(0);
		glDisable(GL_TEXTURE_2D);

	}
	else
	{
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

		glActiveTexture(GL_TEXTURE0);
		glBindTexture (GL_TEXTURE_2D, quad.textureID);

		glBegin (GL_QUADS);
		{
			glTexCoord2f (0.0, 0.0);
			glVertex3f (0.0, 0.0, 0.0);

			glTexCoord2f (1.0, 0.0);
			glVertex3f (quad.fWidth, 0.0, 0.0);

			glTexCoord2f (1.0, 1.0);
			glVertex3f (quad.fWidth, quad.fHeight, 0.0);

			glTexCoord2f (0.0, 1.0);
			glVertex3f (0.0, quad.fHeight, 0.0);
		}
		glEnd ();
		glDisable(GL_TEXTURE_2D);
	}
}
예제 #22
0
void  OGL2DBase::MinorTicDrawSetup()
{
    SetDrawColor(plot2Dbase.defaultPenSet->GetColor(plot2Dbase.plotAnnotation.axesDataPen));
    SetLine(plot2Dbase.plotAnnotation.minorTicWidth);
}
예제 #23
0
void PD_2DXYPS::DrawPlotAxes()
{

    if (!plotAnnotation.DoAnno())
    {
        SetClipPlanes();
        return;
    }

    SetIncrFont();

    ClearClipPlanes();

    SetAxesLocals();
    SetLineSolid();

    xAxis.SetMajorIncs();
    xAxis.SetMinorIncs();
    yAxis.SetMajorIncs();
    yAxis.SetMinorIncs();

    SC_DoubleArray xMajorIncs, xMinorIncs, yMajorIncs, yMinorIncs;
    xAxis.GetAxesMajorIncs(xMajorIncs);
    xAxis.GetAxesMinorIncs(xMinorIncs);
    yAxis.GetAxesMajorIncs(yMajorIncs);
    yAxis.GetAxesMinorIncs(yMinorIncs);

    Point2D axesOffComp, labelOffComp;
    bool dummy;
    GetAxesOffsets(axesOffComp, labelOffComp, dummy);

    Point2D majorTicLength = GetPixelComponents(plotAnnotation.majorTicLength);
    Point2D minorTicLength = GetPixelComponents(plotAnnotation.minorTicLength);
    Point2D majorTicOffset = GetPixelComponents(plotAnnotation.majorTicOffset);
    Point2D minorTicOffset = GetPixelComponents(plotAnnotation.minorTicOffset);

    // set Z val
    SetAnnoLow();

    if (plotAnnotation.drawAxesLines)
    {
        AxesDrawSetup();
        HardCopyBlockStart(24);         // 4 axes + 2 caps per axes * 2

        // x axis
        if (plotAnnotation.DoXAxis())
        {
            DrawXAxes(convYaxisMin, -axesOffComp.pY);
            if (plotAnnotation.framePlot)
                DrawXAxes(convYaxisMax, axesOffComp.pY);
        }

        // y axis
        if (plotAnnotation.DoYAxis())
        {
            DrawYAxes(convXaxisMin, -axesOffComp.pX);
            if (plotAnnotation.framePlot)
                DrawYAxes(convXaxisMax, axesOffComp.pX);
        }

        if (plotAnnotation.axesOffset > 0)
        {
            // slight kluge -- tic routines require untransformed X&Ys
            double xmin, xmax, ymin, ymax;
            xAxis.GetAxisLimits(xmin, xmax);
            yAxis.GetAxisLimits(ymin, ymax);

            // draw caps on axes

            if (plotAnnotation.DoXAxis())
            {
                DrawXTic(xmin, convYaxisMin, -axesOffComp.pY, axesOffComp.pY, 0.0);
                DrawXTic(xmax, convYaxisMin, -axesOffComp.pY, axesOffComp.pY, 0.0);

                if (plotAnnotation.framePlot)
                {
                    DrawXTic(xmin, convYaxisMax, axesOffComp.pY, -axesOffComp.pY, 0.0);
                    DrawXTic(xmax, convYaxisMax, axesOffComp.pY, -axesOffComp.pY, 0.0);
                }
            }

            if (plotAnnotation.DoYAxis())
            {
                DrawYTic(convXaxisMin, ymin, -axesOffComp.pX, axesOffComp.pX, 0.0);
                DrawYTic(convXaxisMin, ymax, -axesOffComp.pX, axesOffComp.pX, 0.0);

                if (plotAnnotation.framePlot)
                {
                    DrawYTic(convXaxisMax, ymin, axesOffComp.pX, -axesOffComp.pX, 0.0);
                    DrawYTic(convXaxisMax, ymax, axesOffComp.pX, -axesOffComp.pX, 0.0);
                }
            }
        }
        HardCopyBlockEnd();
        SetAnnoLow();
    }

    double axmaxOffset = 0.0;

    if (plotAnnotation.DoXAxis() && (xAxis.axisMajorIncs != PC_Axes::aitNone))
        if (xAxis.axisMajorIncs == PC_Axes::aitGrid)
        {
            MajorGridDrawSetup();
            HardCopyBlockStart(xMajorIncs.Size() * 2);

            if (plotAnnotation.framePlot)
                axmaxOffset = axesOffComp.pY;

            for (int i = 0; i < xMajorIncs.Size(); i++)
                DrawXGrid(xMajorIncs[i], -axesOffComp.pY, axmaxOffset, majorTicOffset.pY);

            HardCopyBlockEnd();
            SetAnnoLow();
        }
        else
        {
            MajorTicDrawSetup();
            HardCopyBlockStart(xMajorIncs.Size() * 4);
            int i;
            for (i = 0; i < xMajorIncs.Size(); i++)
            {
                DrawXTic(xMajorIncs[i], convYaxisMin, -axesOffComp.pY, majorTicLength.pY, majorTicOffset.pY);
                if (plotAnnotation.framePlot)
                    DrawXTic(xMajorIncs[i], convYaxisMax, axesOffComp.pY, -majorTicLength.pY, -majorTicOffset.pY);
            }
            HardCopyBlockEnd();
        }

    if (plotAnnotation.DoYAxis() && (yAxis.axisMajorIncs != PC_Axes::aitNone))
        if (yAxis.axisMajorIncs == PC_Axes::aitGrid)
        {
            MajorGridDrawSetup();

            if (plotAnnotation.framePlot)
                axmaxOffset = axesOffComp.pX;
            HardCopyBlockStart(yMajorIncs.Size() * 2);

            for (int i = 0; i < yMajorIncs.Size(); i++)
            {

                DrawYGrid(yMajorIncs[i], -axesOffComp.pX, axmaxOffset, majorTicOffset.pX);
            }

            HardCopyBlockEnd();
            SetAnnoLow();
        }
        else
        {
            MajorTicDrawSetup();
            HardCopyBlockStart(yMajorIncs.Size() * 4);
            for (int i = 0; i < yMajorIncs.Size(); i++)
            {
                DrawYTic(convXaxisMin, yMajorIncs[i], -axesOffComp.pX, majorTicLength.pX, majorTicOffset.pX);
                if (plotAnnotation.framePlot)
                    DrawYTic(convXaxisMax, yMajorIncs[i],  axesOffComp.pX, -majorTicLength.pX, -majorTicOffset.pX);
            }
            HardCopyBlockEnd();
        }


    if (plotAnnotation.DoXAxis() && (xAxis.axisMinorIncs != PC_Axes::aitNone))
        if (xAxis.axisMinorIncs == PC_Axes::aitGrid)
        {
            MinorGridDrawSetup();

            if (plotAnnotation.framePlot)
                axmaxOffset = axesOffComp.pY;

            HardCopyBlockStart((xMajorIncs.Size() + 1) * xMinorIncs.Size() * 2);

            for (int i = -1; i < xMajorIncs.Size(); i++)
                for (int j = 0; j < xMinorIncs.Size(); j++)
                    DrawXGrid(GetMinorIncVal(xMajorIncs, xMinorIncs, i, j, doLogX, convXaxisMax < convXaxisMin),
                                            -axesOffComp.pY, axmaxOffset, minorTicOffset.pX);

            HardCopyBlockEnd();
            SetAnnoLow();
        }
        else
        {
            MinorTicDrawSetup();
            HardCopyBlockStart((xMajorIncs.Size() + 1) * xMinorIncs.Size() * 4);
            for (int i = -1; i < xMajorIncs.Size(); i++)
                for (int j = 0; j < xMinorIncs.Size(); j++)
                {
                    double incVal = GetMinorIncVal(xMajorIncs, xMinorIncs, i, j, doLogX, convXaxisMax < convXaxisMin);
                    DrawXTic(incVal, convYaxisMin, -axesOffComp.pY, minorTicLength.pY, minorTicOffset.pY);
                    if (plotAnnotation.framePlot)
                        DrawXTic(incVal, convYaxisMax, axesOffComp.pY, -minorTicLength.pY, -minorTicOffset.pY);
                }
            HardCopyBlockEnd();
        }


    if (plotAnnotation.DoYAxis() && (yAxis.axisMinorIncs != PC_Axes::aitNone))
        if (yAxis.axisMinorIncs == PC_Axes::aitGrid)
        {
            MinorGridDrawSetup();

            if (plotAnnotation.framePlot)
                axmaxOffset = axesOffComp.pX;
            HardCopyBlockStart((yMajorIncs.Size() + 1) * yMinorIncs.Size() * 2);

            for (int i = -1; i < yMajorIncs.Size(); i++)
                for (int j = 0; j < yMinorIncs.Size(); j++)
                    DrawYGrid(GetMinorIncVal(yMajorIncs, yMinorIncs, i, j, doLogY, convYaxisMax < convYaxisMin),
                                    -axesOffComp.pX, axmaxOffset, minorTicOffset.pX);

            HardCopyBlockEnd();
            SetAnnoLow();
        }
        else
        {
            MinorTicDrawSetup();
            HardCopyBlockStart((yMajorIncs.Size() + 1) * yMinorIncs.Size() * 4);
            for (int i = -1; i < yMajorIncs.Size(); i++)
                for (int j = 0; j < yMinorIncs.Size(); j++)
                {
                    double incVal = GetMinorIncVal(yMajorIncs, yMinorIncs, i, j, doLogY, convYaxisMax < convYaxisMin);
                    DrawYTic(convXaxisMin, incVal,  -axesOffComp.pX, minorTicLength.pX, minorTicOffset.pX);
                    if (plotAnnotation.framePlot)
                        DrawYTic(convXaxisMax, incVal,  axesOffComp.pX, -minorTicLength.pX, -minorTicOffset.pX);
                }
            HardCopyBlockEnd();
        }

    double maxHeight = 0.0;
    double xaxYpos = convYaxisMin - axesOffComp.pY - labelOffComp.pY - majorTicOffset.pY;
    double maxWidth = 0.0;
    double yaxXpos = convXaxisMin - axesOffComp.pX - labelOffComp.pX - majorTicOffset.pX;

    if (plotAnnotation.labelIncrements)
    {
        SetDrawColor(defaultPenSet->GetColor(plotAnnotation.axesDataPen));

        char labStr[80];
        ExtendedLabelData labInfo;

        if (plotAnnotation.DoXAxis())
        {
            // need to go through all labels once to calc over top on exponents if horiz
            double exponentShift = 0.0;
            for (int i = 0; i < xMajorIncs.Size(); i++)
            {
                double xTran = TransformX(xMajorIncs[i]);
                if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran))
                {
                    xAxis.axisIncFormat.RealToString(xMajorIncs[i], labStr, 80);

                    if (xAxis.incrFont.fontRotation == PSC_Font::fr_Horiz)
                    {
                        if (GetExtendedStringSizeInfo(xAxis.incrFont, labStr, labInfo))
                        {
                            if (labInfo.aboveTop > exponentShift)
                                exponentShift = labInfo.aboveTop;
                            double totHeight = labInfo.height + labInfo.aboveTop;
                            if ((fabs(totHeight) > fabs(maxHeight)))
                                maxHeight = totHeight;
                        }
                    }
                    else
                    {
                        double w, h;
                        if (GetStringSizeInfo(xAxis.incrFont, labStr, w, h))
                        {
                            if (fabs(w) > fabs(maxHeight))
                                maxHeight = w;
                        }
                    }
                }
            }

            //set alignment for printing
            HorizontalTextAlignment halign;
            VerticalTextAlignment valign;
            if (xAxis.incrFont.fontRotation == PSC_Font::fr_Horiz)
            {
                halign = hta_Center;
                valign = vta_Top;
            }
            else
            {
                valign = vta_Center;
                if (xAxis.incrFont.fontRotation == PSC_Font::fr_VertLeft)
                    halign = hta_Right;
                else
                    halign = hta_Left;
            }

            // now print label
            double xincLabYPos = xaxYpos - exponentShift;
            for (int i = 0; i < xMajorIncs.Size(); i++)
            {
                double xTran = TransformX(xMajorIncs[i]);
                if (Limit::WithinOneLimit(convXaxisMin, convXaxisMax, xTran))
                {
                    xAxis.axisIncFormat.RealToString(xMajorIncs[i], labStr, 80);

                    PrintString(xAxis.incrFont, labStr, halign, valign,
                                xTran, xincLabYPos);
                }
            }
        }

        if (plotAnnotation.DoYAxis())
        {
            // need to go through all labels once to calc over top on exponents if not horiz
            double exponentShift = 0.0;
            for (int i = 0; i < yMajorIncs.Size(); i++)
            {
                double yTran = TransformY(yMajorIncs[i]);
                if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran))
                {
                    yAxis.axisIncFormat.RealToString(yMajorIncs[i], labStr, 80);

                    if (yAxis.incrFont.fontRotation != PSC_Font::fr_Horiz)
                    {
                        if (GetExtendedStringSizeInfo(yAxis.incrFont, labStr, labInfo))
                        {
                            if (labInfo.aboveTop > exponentShift)
                                exponentShift = labInfo.aboveTop;
                            double totHeight = labInfo.height + labInfo.aboveTop;
                            if ((fabs(totHeight) > fabs(maxWidth)))
                                maxWidth = totHeight;
                        }
                    }
                    else
                    {
                        double w, h;
                        if ((GetStringSizeInfo(yAxis.incrFont, labStr, w, h))
                            && (fabs(w) > fabs(maxWidth)))
                                maxWidth = w;
                    }
                }
            }

            //set alignment for printing
            HorizontalTextAlignment halign;
            VerticalTextAlignment valign;
            if (yAxis.incrFont.fontRotation == PSC_Font::fr_Horiz)
            {
                halign = hta_Right;
                valign = vta_Center;
            }
            else
            {
                halign = hta_Center;
                if (yAxis.incrFont.fontRotation == PSC_Font::fr_VertLeft)
                    valign = vta_Bottom;
                else
                    valign = vta_Top;
            }

            for (int i = 0; i < yMajorIncs.Size(); i++)
            {
                double yTran = TransformY(yMajorIncs[i]);
                if (Limit::WithinOneLimit(convYaxisMin, convYaxisMax, yTran))
                {
                    yAxis.axisIncFormat.RealToString(yMajorIncs[i], labStr, 80);
                    PrintString(yAxis.incrFont, labStr, halign, valign,
                                yaxXpos, yTran);
                }
            }
        }
    }

    plotAnnotation.xaxesLabelPos.pX = (convXaxisMin + convXaxisMax) / 2.0;
    plotAnnotation.xaxesLabelPos.pY = xaxYpos - maxHeight - labelOffComp.pY;
    plotAnnotation.yaxesLabelPos.pX = yaxXpos - maxWidth - labelOffComp.pX * 2.0;
    plotAnnotation.yaxesLabelPos.pY = (convYaxisMin + convYaxisMax) / 2.0;

    if (plotAnnotation.labelAxes)
    {
        if (plotAnnotation.DoXAxis() && IsNotNull(plotAnnotation.xaxesLabel))
        {
            PrintString(plotAnnotation.labelFont, plotAnnotation.xaxesLabel,
                hta_Center, vta_Top,
                plotAnnotation.xaxesLabelPos.pX, plotAnnotation.xaxesLabelPos.pY);
        }

        if (plotAnnotation.DoYAxis() && IsNotNull(plotAnnotation.yaxesLabel))
        {
            PSC_Font yLabFont(plotAnnotation.labelFont);
            yLabFont.fontRotation = PSC_Font::fr_VertLeft;

            PrintString(yLabFont, plotAnnotation.yaxesLabel, hta_Center, vta_Bottom,
                plotAnnotation.yaxesLabelPos.pX, plotAnnotation.yaxesLabelPos.pY);
        }
    }

    SetClipPlanes();
}
예제 #24
0
파일: gdd_checkbox.c 프로젝트: djyos/djyos
//----CheckBox绘制函数----------------------------------------------------------
//功能:这是CheckBox控件的MSG_PAINT消息响应函数
//参数:pMsg,消息指针
//返回:固定true
//-----------------------------------------------------------------------------
static  bool_t CheckBox_Paint(struct WindowMsg *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc;
    RECT rc0;

    hwnd=pMsg->hwnd;
    hdc =BeginPaint(hwnd);
    if(NULL!=hdc)
    {
        GetClientRect(hwnd,&rc0);

        SetTextColor(hdc,RGB(1,1,1));
        SetDrawColor(hdc,RGB(40,40,40));
        SetFillColor(hdc,RGB(200,200,200));

        FillRect(hdc,&rc0);

        if(hwnd->Style&CBS_SELECTED)
        {
            CopyRect(&rc,&rc0);
            rc.right =rc.left+RectH(&rc0);

            InflateRect(&rc,-2,-2);
            SetDrawColor(hdc,RGB(70,70,70));
            DrawRect(hdc,&rc);

            InflateRect(&rc,-1,-1);
            SetDrawColor(hdc,RGB(110,110,110));
            DrawRect(hdc,&rc);

            InflateRect(&rc,-1,-1);
            SetFillColor(hdc,RGB(240,240,240));
            FillRect(hdc,&rc);

            InflateRect(&rc,-4,-4);
            SetDrawColor(hdc,RGB(150,150,240));
            DrawRect(hdc,&rc);
            InflateRect(&rc,-1,-1);
            SetDrawColor(hdc,RGB(100,100,220));
            DrawRect(hdc,&rc);

            InflateRect(&rc,-1,-1);
            SetFillColor(hdc,RGB(50,50,200));
            FillRect(hdc,&rc);
        }
        else
        {
            CopyRect(&rc,&rc0);
            rc.right =rc.left+RectH(&rc0);

            InflateRect(&rc,-2,-2);
            SetDrawColor(hdc,RGB(100,100,100));
            DrawRect(hdc,&rc);

            InflateRect(&rc,-1,-1);
            SetDrawColor(hdc,RGB(160,160,160));
            DrawRect(hdc,&rc);

            InflateRect(&rc,-1,-1);
            SetFillColor(hdc,RGB(220,220,220));
            FillRect(hdc,&rc);

        }

        CopyRect(&rc,&rc0);
        InflateRectEx(&rc,-RectH(&rc),0,0,0);

        DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER);
        EndPaint(hwnd,hdc);
    }

    return true;

}
예제 #25
0
static  u32 win_proc(MSG *pMsg)
{
    HWND hwnd;
    HDC hdc;
    RECT rc,rc0;
    u32 x,y;

    hwnd =pMsg->hwnd;

    switch(pMsg->Code)
    {
        case    MSG_CREATE:
                timer_500ms_count=0;
                memset(ZigBeeTextBuf,0,sizeof(ZigBeeTextBuf));
                memset(ZigBeeTimeBuf,0,sizeof(ZigBeeTimeBuf));
                zigbee_ShowString("Zigbee Text");
                hwndZigBee =hwnd;
                GetClientRect(hwnd,&rc0);
                SetFocusWindow(hwnd);
                CreateWindow(BUTTON,"关闭",WS_BORDER|WS_DLGFRAME|WS_CHILD|BS_SIMPLE|WS_VISIBLE,RectW(&rc0)-60,RectH(&rc0)-60,56,56,hwnd,ID_CLOSE,NULL);

                SetRect(&rcZigBeeString,4,4,RectW(&rc0)-4*2,60);

                x=4;
                y=RectH(&rc0)-70;
                SetRect(&rcGroupBox_LED,x,y,100,66);
                SetRect(&rcGroupBox_CTR,x+100+4,y,100,66);

                x=rcGroupBox_LED.left+12;
                y=rcGroupBox_LED.top+18;
                CreateWindow(BUTTON,"LED1",WS_BORDER|WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+0*24,72,20,hwnd,ID_LED1,NULL);
                CreateWindow(BUTTON,"LED2",WS_BORDER|WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+1*24,72,20,hwnd,ID_LED2,NULL);

                x=rcGroupBox_CTR.left+12;
                y=rcGroupBox_CTR.top+18;
                CreateWindow(BUTTON,"组网",WS_BORDER|WS_CHILD|WS_VISIBLE,x,y+0*24,72,20,hwnd,ID_NET_ON,NULL);
                CreateWindow(BUTTON,"断开",WS_BORDER|WS_CHILD|WS_VISIBLE,x,y+1*24,72,20,hwnd,ID_NET_OFF,NULL);

                CreateWindow(BUTTON,"发送",WS_BORDER|WS_CHILD|BS_SIMPLE|WS_VISIBLE,RectW(&rc0)-60,rcGroupBox_CTR.top-(24+2),56,24,hwnd,ID_SEND,NULL);

                GDD_CreateTimer(hwnd,0,500,TMR_START);

                break;
                ////
        case MSG_KEY_DOWN:
         		break;
         		//////

        case MSG_KEY_UP:
        {
        		u16 key_val;
                hdc =BeginPaint(hwnd);
        		key_val =LO16(pMsg->Param1);
        		sprintf(ZigBeeTextBuf,"KeyVal:%04XH",key_val);
                DrawText(hdc,ZigBeeTextBuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);
                EndPaint(hwnd,hdc);
//        		InvalidateWindow(hwnd);
        }
         		break;
         		//////

        case    MSG_TIMER:
                {
                    timer_500ms_count++;

                    sprintf(ZigBeeTimeBuf,"TIME:%06d",timer_500ms_count);

                    /*
                    i=SendMessage(GetDesktopWindow(),MSG_GET_POS,timer_500ms_count,0);
                    printf("i=%08XH.\r\n",i);
                    */
                    InvalidateWindow(hwnd);
                }
                break;

        case    MSG_NOTIFY:
                {
                    u16 event,id;

                    event =HI16(pMsg->Param1);
                    id =LO16(pMsg->Param1);

                    switch(event)
                    {
                        case BTN_DOWN:  //按钮按下
                            if(id==ID_LED1)
                            {
                                zigbee_LED1_ON();
                            }

                            if(id==ID_LED2)
                            {
                                zigbee_LED2_ON();
                            }

                            if(id==ID_NET_ON)
                            {
                                zigbee_NET_ON();
                            }

                            if(id==ID_NET_OFF)
                            {
                                zigbee_NET_OFF();
                            }

                            if(id==ID_SEND)
                            {
                                zigbee_send_string(ZigBeeTextBuf);
                            }
                            break;
                            ////

                        case BTN_UP:    //按钮弹起
                            if(id==ID_CLOSE)
                            {
                                PostMessage(hwnd,MSG_CLOSE,0,0);
                            }

                            if(id==ID_LED1)
                            {
                                zigbee_LED1_OFF();
                            }

                            if(id==ID_LED2)
                            {
                                zigbee_LED2_OFF();
                            }


                            break;
                            ////



                    }

                }
                break;
                ////

        case    MSG_PAINT:
                {

                    hdc =BeginPaint(hwnd);
                    GetClientRect(hwnd,&rc0);
                    SetFillColor(hdc,RGB(150,150,150));
                    FillRect(hdc,&rc0);

                    SetTextColor(hdc,RGB(0,0,128));
                    SetDrawColor(hdc,RGB(100,100,100));
                    DrawGroupBox(hdc,&rcZigBeeString,"信息接收区");

                    ////
                    SetRect(&rc,
                            rcGroupBox_LED.left,
                            rcGroupBox_LED.top-(24+2),
                            RectW(&rcGroupBox_LED),
                            24);

                    if(zigbee_is_ok())
                    {
                        SetTextColor(hdc,RGB(0,255,0));
                        SetDrawColor(hdc,RGB(0,200,0));
                        SetFillColor(hdc,RGB(0,128,0));
                        DrawText(hdc,"连接成功",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                    }
                    else
                    {
                        SetTextColor(hdc,RGB(255,0,0));
                        SetDrawColor(hdc,RGB(200,0,0));
                        SetFillColor(hdc,RGB(100,0,0));
                        if(timer_500ms_count&0x01)
                        {
                            DrawText(hdc,"未连接",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                        }
                        else
                        {
                            DrawText(hdc," ",-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);
                        }

                    }

                    ////
                    SetRect(&rc,
                            rcGroupBox_CTR.left,
                            rcGroupBox_CTR.top-(24+2),
                            RectW(&rcGroupBox_CTR),
                            24);
                    SetTextColor(hdc,RGB(0,255,255));
                    SetDrawColor(hdc,RGB(0,200,200));
                    SetFillColor(hdc,RGB(0,80,80));
                    DrawText(hdc,ZigBeeTimeBuf,-1,&rc,DT_CENTER|DT_VCENTER|DT_BORDER|DT_BKGND);

                    ////
                    SetTextColor(hdc,RGB(0,255,0));
                    SetDrawColor(hdc,RGB(0,200,0));
                    SetFillColor(hdc,RGB(0,80,0));

                    CopyRect(&rc,&rcZigBeeString);
                    InflateRectEx(&rc,-4,-20,-4,-4);
                    DrawText(hdc,ZigBeeTextBuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND);

                    SetTextColor(hdc,RGB(0,0,128));
                    SetDrawColor(hdc,RGB(80,80,80));
                    DrawGroupBox(hdc,&rcGroupBox_LED,"LED控制");
                    DrawGroupBox(hdc,&rcGroupBox_CTR,"网络控制");

                    EndPaint(hwnd,hdc);

                }
                break;
                ////

        default:
                return  DefWindowProc(pMsg);


    }
    return  0;
}