Пример #1
1
void COutlook2Ctrl::AnimateToFolder(int f)
{
	m_iSelectedFolder = f;
 	pLastHilink = NULL;
	m_csCaption = GetFolder(f)->csName;

	if (m_iSize > 4)
	{

		CRect rc;
		GetClientRect(rc);

		CDC dc;
		CClientDC cdc(this);
		dc.CreateCompatibleDC(&cdc);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(&cdc, rc.Width(), rc.Height());
		CBitmap * ob = (CBitmap *) dc.SelectObject(&bmp);

		DrawCaption(&dc, rc);
		CRect rcBdr(rc);
		rc.InflateRect(-1,-1);
		DrawButtons(&dc, rc);
		int iBottomInner = rc.bottom;
		dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
		rcInnerRect = rc;
		dc.FillSolidRect(rc, m_crBackground);
		if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
		{
			COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
			DrawItems(&dc, o, rc);
		}

		for (int t = iBottomInner - 10; t > 0; t -= (iBottomInner/8))
		{
			cdc.BitBlt(0,t,rc.Width(), iBottomInner - t, &dc, 0,0, SRCCOPY);
			Sleep(30);
		}
		dc.SelectObject(ob);
	}

	Invalidate();
}
Пример #2
0
//*****************************************************************************
//
// Animate Buttons.
//
//*****************************************************************************
void
AnimateButtons(bool bInit)
{
    if(bInit) {
        g_sButtons.i32X = 0;
        g_sButtons.i32Y = 0;
        g_sButtons.bEnabled = true;
        g_sButtons.bActive = false;
        g_sButtons.ui32Delay = 0;
    } else if(g_sButtons.bEnabled == false) {
        //
        // Just return if the buttons are not on screen.
        //
        return;
    }

    if(g_sButtons.ui32Delay == 0) {
        g_sButtons.ui32Delay = 6;

        GrContextForegroundSet(&g_sContext, ClrBlack);
        GrContextBackgroundSet(&g_sContext, ClrGray);

        if((bInit == false) || (g_sButtons.bActive == true)) {
            //
            // Update the buttons.
            //
            DrawButtons(g_sButtons.i32X - g_sButtons.i32Y, true);

            if(g_sButtons.i32X < 3) {
                g_sButtons.i32X++;
            } else {
                g_sButtons.i32Y++;
            }
        }

        if(g_sButtons.bActive == false) {
            //
            // Update the buttons.
            //
            DrawButtons(g_sButtons.i32X - g_sButtons.i32Y, false);

            if(g_sButtons.i32Y >= 3) {
                g_sButtons.bActive = true;
                g_sButtons.ui32Delay = 6;
            }
        } else if((g_i32ScreenIdx == SCREEN_SUMMARY) ||
                  (g_i32ScreenIdx == SCREEN_DETAILS)) {
            ButtonsDisable();
        }
    }
}
Пример #3
0
/** Handle a mouse button release event. */
int HandleDialogButtonRelease(const XButtonEvent *event) {

   DialogType *dp;
   int x, y;
   int cancelPressed, okPressed;

   Assert(event);

   dp = FindDialogByWindow(event->window);
   if(dp) {
      cancelPressed = 0;
      okPressed = 0;
      y = event->y;
      if(y >= dp->buttony && y < dp->buttony + dp->buttonHeight) {
         x = event->x;
         if(x >= dp->okx && x < dp->okx + dp->buttonWidth) {
            okPressed = 1;
         } else if(x >= dp->cancelx && x < dp->cancelx + dp->buttonWidth) {
            cancelPressed = 1;
         }
      }

      if(okPressed) {
         (dp->action)(dp->client);
      }

      if(cancelPressed || okPressed) {
         DestroyConfirmDialog(dp);
      } else {
         dp->buttonState = DBS_NORMAL;
         DrawButtons(dp);
      }

      return 1;
   } else {

      for(dp = dialogList; dp; dp = dp->next) {
         if(dp->buttonState != DBS_NORMAL) {
            dp->buttonState = DBS_NORMAL;
            DrawButtons(dp);
         }
      }

      return 0;

   }

}
Пример #4
0
void COutlook2Ctrl::OnPaint()
{
	ClearRects();
	CPaintDC pdc(this);

	CRect rc;
	GetClientRect(rc);
	if (m_iSize <= 4)
	{
		pdc.FillSolidRect(rc, GetSysColor(COLOR_3DFACE));
		return;
	}
	COMemDC dc(&pdc);
	DrawCaption(&dc, rc);
	CRect rcBdr(rc);
	rc.InflateRect(-1,-1);
	DrawButtons(&dc, rc);
	dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
	rcInnerRect = rc;
	dc.FillSolidRect(rc, m_crBackground);
	if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
	{
		COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
		DrawItems(&dc, o, rc);
	}
}
Пример #5
0
/** Render the dialog to the pixmap. */
void DrawDialog(void)
{

    int yoffset;
    int x;

    Assert(dialog);

    /* Clear the dialog. */
    JXSetForeground(display, rootGC, colors[COLOR_MENU_BG]);
    JXFillRectangle(display, dialog->pmap, rootGC, 0, 0,
                    dialog->width, dialog->height);

    /* Draw the message. */
    yoffset = 4;
    for(x = 0; x < dialog->lineCount; x++) {
        RenderString(dialog->pmap, FONT_MENU, COLOR_MENU_FG,
                     4, yoffset, dialog->width, dialog->message[x]);
        yoffset += dialog->lineHeight;
    }

    /* Draw the buttons. */
    DrawButtons();

}
Пример #6
0
/** Handle a mouse button release event. */
char HandleDialogButtonRelease(const XButtonEvent *event)
{

    Assert(event);

    if(dialog && event->window == dialog->node->window) {
        char cancelPressed = 0;
        char okPressed = 0;
        const int y = event->y;
        if(y >= dialog->buttony && y < dialog->buttony + dialog->buttonHeight) {
            const int x = event->x;
            if(x >= dialog->okx && x < dialog->okx + dialog->buttonWidth) {
                okPressed = 1;
            } else if(x >= dialog->cancelx
                      && x < dialog->cancelx + dialog->buttonWidth) {
                cancelPressed = 1;
            }
        }

        if(okPressed) {
            RunDialogAction();
        }

        if(cancelPressed || okPressed) {
            DestroyConfirmDialog();
        } else {
            dialog->buttonState = DBS_NORMAL;
            DrawButtons();
            ExposeConfirmDialog();
        }

        return 1;
    } else {

        if(dialog) {
            if(dialog->buttonState != DBS_NORMAL) {
                dialog->buttonState = DBS_NORMAL;
                DrawButtons();
                ExposeConfirmDialog();
            }
        }

        return 0;

    }

}
void clAuiSimpleTabArt::DrawButton(wxDC& dc,
                                   wxWindow* WXUNUSED(wnd),
                                   const wxRect& in_rect,
                                   int bitmap_id,
                                   int button_state,
                                   int orientation,
                                   wxRect* out_rect)
{
	wxBitmap bmp;
	wxRect rect;

	switch (bitmap_id) {
	case wxAUI_BUTTON_CLOSE:
		if (button_state & wxAUI_BUTTON_STATE_DISABLED)
			bmp = m_disabled_close_bmp;
		else
			bmp = m_active_close_bmp;
		break;
	case wxAUI_BUTTON_LEFT:
		if (button_state & wxAUI_BUTTON_STATE_DISABLED)
			bmp = m_disabled_left_bmp;
		else
			bmp = m_active_left_bmp;
		break;
	case wxAUI_BUTTON_RIGHT:
		if (button_state & wxAUI_BUTTON_STATE_DISABLED)
			bmp = m_disabled_right_bmp;
		else
			bmp = m_active_right_bmp;
		break;
	case wxAUI_BUTTON_WINDOWLIST:
		if (button_state & wxAUI_BUTTON_STATE_DISABLED)
			bmp = m_disabled_windowlist_bmp;
		else
			bmp = m_active_windowlist_bmp;
		break;
	}

	if (!bmp.IsOk())
		return;

	rect = in_rect;

	if (orientation == wxLEFT) {
		rect.SetX(in_rect.x);
		rect.SetY(((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2));
		rect.SetWidth(bmp.GetWidth());
		rect.SetHeight(bmp.GetHeight());
	} else {
		rect = wxRect(in_rect.x + in_rect.width - bmp.GetWidth(),
		              ((in_rect.y + in_rect.height)/2) - (bmp.GetHeight()/2),
		              bmp.GetWidth(), bmp.GetHeight());
	}


	DrawButtons(dc, rect, bmp, *wxWHITE, button_state);

	*out_rect = rect;
}
Пример #8
0
/** Draw a confirm dialog. */
void DrawConfirmDialog(DialogType *dp) {

   Assert(dp);

   DrawMessage(dp);
   DrawButtons(dp);

}
Пример #9
0
ULONG Toolbar_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
  struct Toolbar_Data *data = (struct Toolbar_Data *)INST_DATA(cl, obj);

  DoSuperMethodA(cl, obj, (Msg)msg);

  if (msg->flags & MADF_DRAWUPDATE)
  {
    if(data->UpdateFlag)
      DrawButton(data->Update, data, obj, data->UpdateFlag == UPDATE_DOWN, NOT_THREE_D);

    if(data->RedrawFlag)
    {
      DrawButtons(data, obj, FALSE);
      data->RedrawFlag = FALSE;
    }
  }
  else if (msg->flags & MADF_DRAWOBJECT)
  {
    DrawButtons(data, obj, TRUE);
  }

  return(0);
}
Пример #10
0
/** Handle a mouse button release event. */
int HandleDialogButtonPress(const XButtonEvent *event) {

   DialogType *dp;
   int cancelPressed;
   int okPressed;
   int x, y;

   Assert(event);

   /* Find the dialog on which the press occured (if any). */
   dp = FindDialogByWindow(event->window);
   if(dp) {

      /* Determine which button was pressed (if any). */
      cancelPressed = 0;
      okPressed = 0;
      y = event->y;
      if(y >= dp->buttony && y < dp->buttony + dp->buttonHeight) {
         x = event->x;
         if(x >= dp->okx && x < dp->okx + dp->buttonWidth) {
            okPressed = 1;
         } else if(x >= dp->cancelx && x < dp->cancelx + dp->buttonWidth) {
            cancelPressed = 1;
         }
      }

      dp->buttonState = DBS_NORMAL;
      if(cancelPressed) {
         dp->buttonState = DBS_CANCEL;
      }

      if(okPressed) {
         dp->buttonState = DBS_OK;
      }

      /* Draw the buttons. */
      DrawButtons(dp);

      return 1;

   } else {

      /* This event doesn't affect us. */
      return 0;

   }

}
Пример #11
0
LRESULT CPopupFrame::OnNcMouseLeave(WPARAM wParam, LPARAM lParam)
{
	m_nBtnHover = -1;
	
	RECT rect = { 0 };
	GetWindowRect(&rect);
	RECT arrRect[3] = { 0 };
	CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, /*m_bLayoutRTL*/false);
	
	CWindowDC dc(this);
	CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect);
	DrawButtons(&dc, arrRect, 0);

	m_bMouseTracking = FALSE;

	return 0;
}
Пример #12
0
/** Handle a mouse button release event. */
char HandleDialogButtonPress(const XButtonEvent *event)
{

    Assert(event);

    /* Find the dialog on which the press occured (if any). */
    if(dialog && event->window == dialog->node->window) {

        /* Determine which button was pressed (if any). */
        char cancelPressed = 0;
        char okPressed = 0;
        const int y = event->y;
        if(y >= dialog->buttony && y < dialog->buttony + dialog->buttonHeight) {
            const int x = event->x;
            if(x >= dialog->okx && x < dialog->okx + dialog->buttonWidth) {
                okPressed = 1;
            } else if(x >= dialog->cancelx
                      && x < dialog->cancelx + dialog->buttonWidth) {
                cancelPressed = 1;
            }
        }

        dialog->buttonState = DBS_NORMAL;
        if(cancelPressed) {
            dialog->buttonState = DBS_CANCEL;
        }

        if(okPressed) {
            dialog->buttonState = DBS_OK;
        }

        /* Draw the buttons. */
        DrawButtons();
        ExposeConfirmDialog();

        return 1;

    } else {

        /* This event doesn't affect us. */
        return 0;

    }

}
Пример #13
0
void CCaptionPainter::PaintSolidCaption(CRect& capRect, COLORREF theColor)
{
	ASSERT(m_pParentDlg);
	CWnd& wnd = (CWnd&)*m_pParentDlg;

	// Get caption DC and rectangle
	CWindowDC dcWin(&wnd);					// window DC
	CDC dcMem;									// memory DC
	dcMem.CreateCompatibleDC(&dcWin);		// ...create it

	CBitmap bm;
	CBitmap* pOldBitmap;

	int cxCap = capRect.Width();
	int cyCap = capRect.Height();

	bm.CreateCompatibleBitmap(&dcWin, cxCap, cyCap); // create one
	pOldBitmap = dcMem.SelectObject(&bm);	// select bitmap into memory DC


	if (!m_bActive) 
	{
		// Inactive caption
		PaintRect(dcMem, 0, 0, cxCap, cyCap, GetSysColor(COLOR_INACTIVECAPTION));
	}
	else
	{
		PaintRect(dcMem, 0, 0, cxCap, cyCap, theColor);
	}

	// draw icon and buttons
	int cxIcon  = DrawIcon( &dcMem );
	int cxButns = DrawButtons( &dcMem, capRect.Size() );

	CRect rc(CPoint(0,0), capRect.Size()); // text rectangle
	rc.left  += cxIcon+2;						// start after icon
	rc.right -= cxButns;							// don't draw past buttons
	// draw text
	DrawWindowText(&dcMem, rc);
	
	// blast bits to screen
	dcWin.BitBlt(capRect.left, capRect.top,
					capRect.Width(),capRect.Height(),&dcMem,0,0,SRCCOPY);
	dcMem.SelectObject(pOldBitmap); // restore DC
}
Пример #14
0
void CDxMonthPicker::OnPaint(CDCHandle dc)
{
    CRect rcClient;
    GetRect(rcClient);

    // draw background
    dc.FillSolidRect(rcClient, m_clrControlBack);

    // draw all month items in the collection
    m_monthPicker->Draw(dc);

    // draw today/none buttons
    DrawButtons(dc);

    // draw border
    //COLORREF m_clrStaticBorder = RGB(255,255,0);
    //dc.Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), m_clrStaticBorder, m_clrStaticBorder);
}
Пример #15
0
void CPopupFrame::OnNcPaint() 
{
	CFrameWnd::OnNcPaint();

	if ((GetStyle() & WS_CAPTION) == WS_CAPTION)
	{	
		// get DC and window rectangle
		CWindowDC dc(this);
		RECT rect;
		GetWindowRect(&rect);
		int cxWidth = rect.right - rect.left;
		int cyHeight = rect.bottom - rect.top;

		// draw buttons
		RECT arrRect[3] = { 0 };
		CalcBtnRects(cxWidth, cyHeight, arrRect);
		DrawButtons(&dc, arrRect, -1);   // draw all buttons
	}
}
Пример #16
0
void CPopupFrame::OnCaptureChanged(CWnd* pWnd)
{
	if (m_nBtnPressed != -1)
	{
		ATLASSERT(m_nBtnPressed == m_nBtnWasPressed);   // must be
		m_nBtnPressed = -1;
		RECT rect = { 0 };
		GetWindowRect(&rect);
		RECT arrRect[3] = { 0 };
		CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect);
		CWindowDC dc(this);
		DrawButtons(&dc, arrRect, m_nBtnWasPressed);
		m_nBtnWasPressed = -1;
	}
	else
	{
		Default();
	}
}
Пример #17
0
void CPopupFrame::OnMouseMove(UINT nHitTest, CPoint point) 
{
	ClientToScreen(&point);
	RECT rect = { 0 };
	GetWindowRect(&rect);
	point.x -= rect.left;
	point.y -= rect.top;
	RECT arrRect[3] = { 0 };
	CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, /*m_bLayoutRTL*/false);
	int nOldBtnPressed = m_nBtnPressed;
	m_nBtnPressed = ::PtInRect(&arrRect[m_nBtnWasPressed], point) ? m_nBtnWasPressed : -1;
	if (m_nBtnHover != -1 || nOldBtnPressed != m_nBtnPressed)
	{
		m_nBtnHover = 0;

		CWindowDC dc(this);
		CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect);
		DrawButtons(&dc, arrRect, (m_nBtnPressed != -1) ? m_nBtnPressed : nOldBtnPressed);
	}
}
Пример #18
0
void CMiniMap::DrawFrame()
{
	// outline
	glLineWidth(1.0f);
	glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
	glBegin(GL_LINE_LOOP);
		glVertex2f(float(xpos - 2 + 0.5f) * globalRendering->pixelX,         float(ypos - 2 + 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos - 2 + 0.5f) * globalRendering->pixelX,         float(ypos + height + 2 - 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos + width + 2 - 0.5f) * globalRendering->pixelX, float(ypos + height + 2 - 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos + width + 2 - 0.5f) * globalRendering->pixelX, float(ypos - 2 + 0.5f) * globalRendering->pixelY);
	glEnd();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glBegin(GL_LINE_LOOP);
		glVertex2f(float(xpos - 1 + 0.5f) * globalRendering->pixelX,         float(ypos - 1 + 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos - 1 + 0.5f) * globalRendering->pixelX,         float(ypos + height + 1 - 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos + width + 1 - 0.5f) * globalRendering->pixelX, float(ypos + height + 1 - 0.5f) * globalRendering->pixelY);
		glVertex2f(float(xpos + width + 1 - 0.5f) * globalRendering->pixelX, float(ypos - 1 + 0.5f) * globalRendering->pixelY);
	glEnd();

	DrawButtons();
}
Пример #19
0
LRESULT CDreamSkinTab::OnPaint()
{
	PAINTSTRUCT ps;
	HDC hPaintDC = ::BeginPaint(m_hWnd, &ps);

	::SetBkMode(hPaintDC, TRANSPARENT);

	RECT rcWindow, rcClient;
	::GetClientRect(m_hWnd, &rcWindow);
	rcClient = GetClientByWindow(rcWindow);

	DrawBackground(hPaintDC, rcWindow, rcClient);

	DrawBorder(hPaintDC, rcWindow, rcClient);

	DrawButtons(hPaintDC, rcWindow, rcClient);

	::EndPaint(m_hWnd, &ps);

	return 0;
}
Пример #20
0
/* Set the silkscreen to contain the toolbar buttons */
void HanderaSetSilkScreen( void )
{
    UInt16          defaultSize;
    PenBtnListType* defaultButtons;
    UInt16          numNewButtons;
    UInt16          newSize;
    PenBtnListType* newButtons;

    /* currently only handeraSilkScreen supported */
    if ( GetDIAHardware() != DIA_HARDWARE_HANDERA )
        return;

    currentSilkStatus = ( GetDIAState() == DIA_STATE_MAX ? 
                                         HANDERA_SILK_UP : HANDERA_SILK_DOWN );

    /* if we already have defaultButtonsHandle stored in memory, there
       is no point in doing everything again, since its already done */
    if ( defaultButtonsHandle[ currentSilkStatus ] != NULL )
        return;

    defaultSize = SilkGetButtonListSize( (Boolean) currentSilkStatus );

    defaultButtonsHandle[ currentSilkStatus ] = MemHandleNew( defaultSize );
    defaultButtons = MemHandleLock( defaultButtonsHandle[ currentSilkStatus ] );
    SilkGetButtonList( defaultButtons, (Boolean) currentSilkStatus );

    numNewButtons = defaultButtons->numButtons + TOTAL_ICONS;
    newSize = sizeof( PenBtnListType ) +
        ( sizeof( PenBtnInfoType ) * ( numNewButtons - 1 ) );
    newButtons = SafeMemPtrNew( newSize );
    MemMove( newButtons, defaultButtons, defaultSize );

    GetButtons();
    DrawButtons();
    SetButtons( newButtons );
    SilkSetButtonList( newButtons, (Boolean) currentSilkStatus );

    MemPtrUnlock( defaultButtons );
    SafeMemPtrFree( newButtons );
}
Пример #21
0
void CPopupFrame::OnNcLButtonDown(UINT nHitTest, CPoint point) 
{
	RECT rect = { 0 };
	GetWindowRect(&rect);
	point.x -= rect.left;
	point.y -= rect.top;

	RECT arrRect[3] = { 0 };
	CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, /*m_bLayoutRTL*/false);

	if (::PtInRect(&arrRect[0], point) && m_bControlBox)
	{
		m_nBtnWasPressed = m_nBtnPressed = 0;
	}
//	else if(::PtInRect(&arrRect[1], point))
//	{
//		m_nBtnWasPressed = m_nBtnPressed = 1;
//	}
//	else if(::PtInRect(&arrRect[2], point))
//	{
//		m_nBtnWasPressed = m_nBtnPressed = 2;
//	}
	else
	{
		CFrameWnd::OnNcLButtonDown(nHitTest, point);
	}

	// draw the button state if it was pressed
	if (m_nBtnPressed != -1)
	{
		SetActiveWindow();

		SetCapture();
		CWindowDC dc(this);
		CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect);
		DrawButtons(&dc, arrRect, m_nBtnPressed);
	}
}
Пример #22
0
void CPopupFrame::OnNcMouseMove(UINT nHitTest, CPoint point)
{
	if (m_hThemeDLL == NULL)
		return;

	RECT rect = { 0 };
	GetWindowRect(&rect);
	point.x -= rect.left;
	point.y -= rect.top;

	RECT arrRect[3] = { 0 };
	CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect, /*m_bLayoutRTL*/false);

	int nOldBtnHover = m_nBtnHover;

	if (::PtInRect(&arrRect[0], point))
	{
		m_nBtnHover = 0;
	}
	else
	{
		m_nBtnHover = -1;
	}

	if (nOldBtnHover != m_nBtnHover)
	{
		CWindowDC dc(this);
		CalcBtnRects(rect.right - rect.left, rect.bottom - rect.top, arrRect);
		DrawButtons(&dc, arrRect, 0);
	}

	if (m_nBtnHover != -1 && !m_bMouseTracking)
	{
		if (StartTrackMouseHover())
			m_bMouseTracking = TRUE;
	}
}
Пример #23
0
void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
                                wxWindow* wnd,
                                const wxAuiNotebookPage& page,
                                const wxRect& in_rect,
                                int close_button_state,
                                wxRect* out_tab_rect,
                                wxRect* out_button_rect,
                                int* x_extent)
{
    wxCoord normal_textx, normal_texty;
    wxCoord selected_textx, selected_texty;
    wxCoord textx, texty;

    // if the caption is empty, measure some temporary text
    wxString caption = page.caption;
    if (caption.empty())
        caption = wxT("Xj");

    dc.SetFont(m_selectedFont);
    dc.GetTextExtent(caption, &selected_textx, &selected_texty);

    dc.SetFont(m_normalFont);
    dc.GetTextExtent(caption, &normal_textx, &normal_texty);

    // figure out the size of the tab
    wxSize tab_size = GetTabSize(dc,
                                 wnd,
                                 page.caption,
                                 page.bitmap,
                                 page.active,
                                 close_button_state,
                                 x_extent);

    wxCoord tab_height = tab_size.y;
    wxCoord tab_width = tab_size.x;
    wxCoord tab_x = in_rect.x;
    wxCoord tab_y = in_rect.y + in_rect.height - tab_height;

    caption = page.caption;

    // select pen, brush and font for the tab to be drawn

    if (page.active)
    {
        dc.SetPen(m_selectedBkPen);
        dc.SetBrush(m_selectedBkBrush);
        dc.SetFont(m_selectedFont);
        textx = selected_textx;
        texty = selected_texty;
    }
    else
    {
        dc.SetPen(m_normalBkPen);
        dc.SetBrush(m_normalBkBrush);
        dc.SetFont(m_normalFont);
        textx = normal_textx;
        texty = normal_texty;
    }


    // -- draw line --

    wxPoint points[7];
    points[0].x = tab_x;
    points[0].y = tab_y + tab_height - 1;
    points[1].x = tab_x + tab_height - 3;
    points[1].y = tab_y + 2;
    points[2].x = tab_x + tab_height + 3;
    points[2].y = tab_y;
    points[3].x = tab_x + tab_width - 2;
    points[3].y = tab_y;
    points[4].x = tab_x + tab_width;
    points[4].y = tab_y + 2;
    points[5].x = tab_x + tab_width;
    points[5].y = tab_y + tab_height - 1;
    points[6] = points[0];

    dc.SetClippingRegion(in_rect);

    dc.DrawPolygon(WXSIZEOF(points) - 1, points);

    dc.SetPen(*wxGREY_PEN);

    //dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points);
    dc.DrawLines(WXSIZEOF(points), points);


    int text_offset;

    int close_button_width = 0;
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        close_button_width = m_activeCloseBmp.GetWidth();
        text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2);
    }
    else
    {
        text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2);
    }

    // set minimum text offset
    if (text_offset < tab_x + tab_height)
        text_offset = tab_x + tab_height;

    // chop text if necessary
    wxString draw_text = wxAuiChopText(dc,
                          caption,
                          tab_width - (text_offset-tab_x) - close_button_width);

    // draw tab text
    dc.DrawText(draw_text,
                 text_offset,
                 (tab_y + tab_height)/2 - (texty/2) + 1);


    // draw focus rectangle
    if (page.active && (wnd->FindFocus() == wnd))
    {
        wxRect focusRect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1),
            selected_textx, selected_texty);

        focusRect.Inflate(2, 2);

        wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0);
    }

    // draw close button if necessary
    if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
    {
        wxBitmap bmp;
        if (page.active)
            bmp = m_activeCloseBmp;
        else
            bmp = m_disabledCloseBmp;

        wxRect rect(tab_x + tab_width - close_button_width - 1,
                    tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1,
                    close_button_width,
                    tab_height - 1);
        DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state);

        *out_button_rect = rect;
    }


    *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height);

    dc.DestroyClippingRegion();
}
Пример #24
0
BOOL CPopupFrame::OnNcActivate(BOOL bActive) 
{
	BOOL b = CFrameWnd::OnNcActivate(bActive);

    if (m_nFlags & WF_STAYACTIVE)
        bActive = TRUE;
    if (!IsWindowEnabled())
        bActive = FALSE;

	m_bActive = bActive; 

	if ((GetStyle() & WS_CAPTION) == WS_CAPTION)
	{	
		// get DC and window rectangle
		CWindowDC dc(this);
		RECT rect;
		GetWindowRect(&rect);
		int cxWidth = rect.right - rect.left;
		int cyHeight = rect.bottom - rect.top;

		// draw buttons
		RECT arrRect[3] = { 0 };
		CalcBtnRects(cxWidth, cyHeight, arrRect);
		DrawButtons(&dc, arrRect, -1);   // draw all buttons
	}

	return b;

//    // Mimic MFC kludge to stay active if WF_STAYACTIVE bit is on. Yuk!
//    if (m_nFlags & WF_STAYACTIVE)
//        bActive = TRUE;
//    if (!IsWindowEnabled())
//        bActive = FALSE;
//    if (bActive == m_bActive)
//        return TRUE;
//
//    // If this is a MDI app, manually activate/paint active MDI child
//    // window, because Windows won't do it if parent frame is invisible.
//    // Must do this BEFORE calling Default, or it will not work.
//    //
//    CFrameWnd* pActiveFrame = GetActiveFrame();
//    if (pActiveFrame != this) {
//        pActiveFrame->SendMessage(WM_NCACTIVATE, bActive);
//        pActiveFrame->SendMessage(WM_NCPAINT);
//    }
//
//    // Turn WS_VISIBLE off before calling DefWindowProc,
//    // so DefWindowProc won't paint and thereby cause flicker.
//    // 
//    DWORD dwStyle = GetStyle();
//    if (dwStyle & WS_VISIBLE)
//        ::SetWindowLong(m_hWnd, GWL_STYLE, (dwStyle & ~ WS_VISIBLE));
//
//    MSG& msg = AfxGetThreadState()->m_lastSentMsg;
//    msg.wParam = bActive;
//    Default();
//    if (dwStyle & WS_VISIBLE)
//        ::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
//
//    // At this point, nothing has happened (since WS_VISIBLE was off).
//    // Now it's time to paint.
//    //
//    m_bActive = bActive;                  // update state
//    SendMessage(WM_NCPAINT);    // paint non-client area (frame too)
//
//    return TRUE; 
}
Пример #25
0
//////////////////
// Paint custom caption.
// This is the function that actually does the shading. It creates a
// bitmap that's used to paint the caption. It looks horrible, but it's
// just a lot of bit-twiddling GDI stuff.
//
void CCaptionPainter::PaintGradiantCaption(CRect& capRect)
{
	ASSERT(m_pParentDlg);
	CWnd& wnd = (CWnd&)*m_pParentDlg;

	// Get caption DC and rectangle
	CWindowDC dcWin(&wnd);					// window DC
	CDC dcMem;									// memory DC
	dcMem.CreateCompatibleDC(&dcWin);		// ...create it

	CBitmap bm;
	CBitmap* pOldBitmap;
	int cxCap = capRect.Width();
	int cyCap = capRect.Height();

	bm.CreateCompatibleBitmap(&dcWin, cxCap, cyCap); // create one
	pOldBitmap = dcMem.SelectObject(&bm);	// select bitmap into memory DC


	if (!m_bActive) 
	{
		// Inactive caption: don't do shading, just fill w/bg color
		PaintRect(dcMem, 0, 0, cxCap, cyCap, GetSysColor(COLOR_INACTIVECAPTION));

	} 
	else 
	{
		// Active caption: do shading
		//
		COLORREF clrBG = GetSysColor(COLOR_ACTIVECAPTION); // background color
		int r = GetRValue(clrBG);				// red..
		int g = GetGValue(clrBG);				// ..green
		int b = GetBValue(clrBG);				// ..blue color vals
		int x = 5*cxCap/6;						// start 5/6 of the way right
		int w = x;									// width of area to shade
		int xDelta= max(w/NCOLORSHADES,1);	// width of one shade band

		// Paint far right 1/6 of caption the background color
		PaintRect(dcMem, x, 0, cxCap-x, cyCap, clrBG);

		// Compute new color brush for each band from x to x + xDelta.
		// Excel uses a linear algorithm from black to normal, i.e.
		//
		//		color = CaptionColor * r
		//
		// where r is the ratio x/w, which ranges from 0 (x=0, left)
		// to 1 (x=w, right). This results in a mostly black title bar,
		// since we humans don't distinguish dark colors as well as light
		// ones. So instead, I use the formula
		//
		//		color = CaptionColor * [1-(1-r)^2]
		//
		// which still equals black when r=0 and CaptionColor when r=1,
		// but spends more time near CaptionColor. For example, when r=.5,
		// the multiplier is [1-(1-.5)^2] = .75, closer to 1 than .5.
		// I leave the algebra to the reader to verify that the above formula
		// is equivalent to
		//
		//		color = CaptionColor - (CaptionColor*(w-x)*(w-x))/(w*w)
		//
		// The computation looks horrendous, but it's only done once each
		// time the caption changes size; thereafter BitBlt'ed to the screen.
		//
		while (x > xDelta) 						// paint bands right to left
		{
			x -= xDelta;							// next band
			int wmx2 = (w-x)*(w-x);				// w minus x squared
			int w2  = w*w;							// w squared
			PaintRect(dcMem, x, 0, xDelta, cyCap,	
				RGB(r-(r*wmx2)/w2, g-(g*wmx2)/w2, b-(b*wmx2)/w2));
		}

		PaintRect(dcMem,0,0,x,cyCap,COLOR_BLACK);  // whatever's left ==> black
	}

	// draw icon and buttons
	int cxIcon  = DrawIcon( &dcMem );
	int cxButns = DrawButtons( &dcMem, capRect.Size() );

	CRect rc(CPoint(0,0), capRect.Size()); // text rectangle
	rc.left  += cxIcon+2;						// start after icon
	rc.right -= cxButns;							// don't draw past buttons
	// draw text
	DrawWindowText(&dcMem, rc);
	
	// blast bits to screen
	dcWin.BitBlt(capRect.left, capRect.top,
					capRect.Width(),capRect.Height(),&dcMem,0,0,SRCCOPY);
	dcMem.SelectObject(pOldBitmap); // restore DC
}
Пример #26
0
void CMiniMap::DrawForReal()
{
	SCOPED_TIMER("Draw minimap");

	setSurfaceCircleFunc(DrawSurfaceCircle);
	setSurfaceSquareFunc(DrawSurfaceSquare);
	cursorIcons.Enable(false);

	//glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDepthFunc(GL_LEQUAL);

	if (minimized) {
		if (!slaveDrawMode) {
			DrawMinimizedButton();
		}
		cursorIcons.Enable(true);
		setSurfaceCircleFunc(NULL);
		setSurfaceSquareFunc(NULL);
		return;
	}

	glViewport(xpos, ypos, width, height);
	glLoadIdentity();
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0, 1.0, 0.0, 1.0, -1.0e6, +1.0e6);
	glMatrixMode(GL_MODELVIEW);

	glColor4f(0.6f, 0.6f, 0.6f, 1.0f);

	// draw the map
	glDisable(GL_BLEND);
	readmap->DrawMinimap();
	glEnable(GL_BLEND);

	// move some of the transform to the GPU
	glTranslatef(0.0f, +1.0f, 0.0f);
	glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0);

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.0f);

	// draw the units
	std::list<CUnit*>::iterator ui;
	for (ui = uh->activeUnits.begin(); ui != uh->activeUnits.end(); ui++) {
		DrawUnit(*ui);
	}

	// highlight the selected unit
	CUnit* unit = GetSelectUnit(GetMapPosition(mouse->lastx, mouse->lasty));
	if (unit != NULL) {
		DrawUnitHighlight(unit);
	}

	glDisable(GL_ALPHA_TEST);
	glDisable(GL_TEXTURE_2D);

	left.clear();

	// add restraints for camera sides
	GetFrustumSide(cam2->bottom);
	GetFrustumSide(cam2->top);
	GetFrustumSide(cam2->rightside);
	GetFrustumSide(cam2->leftside);

	if (!minimap->maximized) {
		// draw the camera lines
		std::vector<fline>::iterator fli,fli2;
		for(fli=left.begin();fli!=left.end();fli++){
			for(fli2=left.begin();fli2!=left.end();fli2++){
				if(fli==fli2)
					continue;
				float colz=0;
				if(fli->dir-fli2->dir==0)
					continue;
				colz=-(fli->base-fli2->base)/(fli->dir-fli2->dir);
				if(fli2->left*(fli->dir-fli2->dir)>0){
					if(colz>fli->minz && colz<400096)
						fli->minz=colz;
				} else {
					if(colz<fli->maxz && colz>-10000)
						fli->maxz=colz;
				}
			}
		}
		glColor4f(1,1,1,0.5f);
		glBegin(GL_LINES);
		for(fli = left.begin(); fli != left.end(); fli++) {
			if(fli->minz < fli->maxz) {
				DrawInMap2D(fli->base + (fli->dir * fli->minz), fli->minz);
				DrawInMap2D(fli->base + (fli->dir * fli->maxz), fli->maxz);
			}
		}
		glEnd();
	}

	glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates

	// draw the projectiles
	if (drawProjectiles && ph->ps.size()>0) {
		CVertexArray* lines=GetVertexArray();
		CVertexArray* points=GetVertexArray();
		lines->Initialize();
		lines->EnlargeArrays(ph->ps.size()*2,0,VA_SIZE_C);
		points->Initialize();
		points->EnlargeArrays(ph->ps.size(),0,VA_SIZE_C);

		static unsigned char red[4]    = {255,0,0,255};
		static unsigned char redA[4]   = {255,0,0,128};
		static unsigned char yellow[4] = {255,255,0,255};
		static unsigned char green[4]  = {0,255,0,25};
		static unsigned char white[4]  = {255,255,255,25};

		Projectile_List::iterator psi;
		for(psi = ph->ps.begin(); psi != ph->ps.end(); ++psi) {
			CProjectile* p = *psi;

			if ((p->owner && (p->owner->allyteam == gu->myAllyTeam)) ||
				gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) {

				if (dynamic_cast<CGeoThermSmokeProjectile*>(p)) {
				} else if (dynamic_cast<CGfxProjectile*>(p)) {//Nano-piece
					points->AddVertexQC(p->pos,green);
				} else if (dynamic_cast<CBeamLaserProjectile*>(p)) {
					CBeamLaserProjectile& beam = *(CBeamLaserProjectile*)p;
					unsigned char color[4] = {beam.kocolstart[0],beam.kocolstart[1],beam.kocolstart[2],255};
					lines->AddVertexQC(beam.startPos,color);
					lines->AddVertexQC(beam.endPos,color);
				} else if (dynamic_cast<CLargeBeamLaserProjectile*>(p)) {
					CLargeBeamLaserProjectile& beam = *(CLargeBeamLaserProjectile*)p;
					unsigned char color[4] = {beam.kocolstart[0],beam.kocolstart[1],beam.kocolstart[2],255};
					lines->AddVertexQC(beam.startPos,color);
					lines->AddVertexQC(beam.endPos,color);
				} else if (dynamic_cast<CLightingProjectile*>(p)) {
					CLightingProjectile& beam = *(CLightingProjectile*)p;
					unsigned char color[4] = {(unsigned char)beam.color[0]*255,(unsigned char)beam.color[1]*255,(unsigned char)beam.color[2]*255,255};
					lines->AddVertexQC(beam.pos,color);
					lines->AddVertexQC(beam.endPos,color);
				} else if (dynamic_cast<CPieceProjectile*>(p)) {
					points->AddVertexQC(p->pos,red);
				} else if (dynamic_cast<CWreckProjectile*>(p)) {
					points->AddVertexQC(p->pos,redA);
				} else if (dynamic_cast<CWeaponProjectile*>(p)) {
					points->AddVertexQC(p->pos,yellow);
				} else {
					points->AddVertexQC(p->pos,white);
				}
			}
		}
		lines->DrawArrayC(GL_LINES);
		points->DrawArrayC(GL_POINTS);
	}

	// draw the queued commands
	//
	// NOTE: this needlessly adds to the CursorIcons list, but at least
	//       they are not drawn  (because the input receivers are drawn
	//       after the command queues)
	LuaUnsyncedCtrl::DrawUnitCommandQueues();
	if ((drawCommands > 0) && guihandler->GetQueueKeystate()) {
		selectedUnits.DrawCommands();
	}
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// draw the selection shape, and some ranges
	if (drawCommands > 0) {
		guihandler->DrawMapStuff(!!drawCommands);
	}

	// draw unit ranges
	const float radarSquare = (SQUARE_SIZE * RADAR_SIZE);
	CUnitSet& selUnits = selectedUnits.selectedUnits;
	for(CUnitSet::iterator si = selUnits.begin(); si != selUnits.end(); ++si) {
		CUnit* unit = *si;
		if (unit->radarRadius && !unit->beingBuilt && unit->activated) {
			glColor3fv(cmdColors.rangeRadar);
			DrawCircle(unit->pos, (unit->radarRadius * radarSquare));
		}
		if (unit->sonarRadius && !unit->beingBuilt && unit->activated) {
			glColor3fv(cmdColors.rangeSonar);
			DrawCircle(unit->pos, (unit->sonarRadius * radarSquare));
		}
		if (unit->jammerRadius && !unit->beingBuilt && unit->activated) {
			glColor3fv(cmdColors.rangeJammer);
			DrawCircle(unit->pos, (unit->jammerRadius * radarSquare));
		}
		// change if someone someday create a non stockpiled interceptor
		const CWeapon* w = unit->stockpileWeapon;
		if((w != NULL) && w->weaponDef->interceptor) {
			if (w->numStockpiled) {
				glColor3fv(cmdColors.rangeInterceptorOn);
			} else {
				glColor3fv(cmdColors.rangeInterceptorOff);
			}
			DrawCircle(unit->pos, w->weaponDef->coverageRange);
		}
	}

	glRotatef(+90.0f, +1.0f, 0.0f, 0.0f); // revert to the 2d xform

	// selection box
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	CMouseHandler::ButtonPress& bp = mouse->buttons[SDL_BUTTON_LEFT];
	if (selecting && fullProxy && (bp.movement > 4)) {
		const float3 oldPos = GetMapPosition(bp.x, bp.y);
		const float3 newPos = GetMapPosition(mouse->lastx, mouse->lasty);
		glColor4fv(cmdColors.mouseBox);
		glBlendFunc((GLenum)cmdColors.MouseBoxBlendSrc(),
		            (GLenum)cmdColors.MouseBoxBlendDst());
		glLineWidth(cmdColors.MouseBoxLineWidth());
		glBegin(GL_LINE_LOOP);
			DrawInMap2D(oldPos.x, oldPos.z);
			DrawInMap2D(newPos.x, oldPos.z);
			DrawInMap2D(newPos.x, newPos.z);
			DrawInMap2D(oldPos.x, newPos.z);
		glEnd();
		glLineWidth(1.0f);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}

	DrawNotes();

	// allow the LUA scripts to draw into the minimap
	eventHandler.DrawInMiniMap();

	// reset the modelview
	glLoadIdentity();

	if (!slaveDrawMode) {
		DrawButtons();

		// outline
		glLineWidth(1.51f);
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		glViewport(xpos - 1, ypos - 1, width + 2, height + 2);
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
		glRectf(0.0f, 0.0f, 1.0f, 1.0f);
		glViewport(xpos - 2, ypos - 2, width + 4, height + 4);
		glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
		glRectf(0.0f, 0.0f, 1.0f, 1.0f);
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glLineWidth(1.0f);
	}

	glViewport(gu->viewPosX, 0, gu->viewSizeX, gu->viewSizeY);

	cursorIcons.Enable(true);
	setSurfaceCircleFunc(NULL);
	setSurfaceSquareFunc(NULL);
}
Пример #27
0
void CGuiHandler::Draw()
{
	DrawButtons();
}
Пример #28
0
void Radar360Class::Display(VirtualDisplay *activeDisplay)
{
	float				scaledCosYaw, scaledSinYaw;
	char				string[24];
	Falcon4EntityClassType*	classPtr;
	int tmpColor = activeDisplay->Color();


	// Prepare our rotation from world space into heading north space including feet->screen scaleing
	scaledCosYaw = (float)cos( platform->Yaw() ) * invRangeFT;
	scaledSinYaw = (float)sin( platform->Yaw() ) * invRangeFT;


	// For now we have to do this silly thing to placate the SMS display routine --
	// we really should get ride of the display/privateDisplay dicotemy.
	display = activeDisplay;
//	display->SetColor( 0x0000FF00 );


	// Quit now if we're turned off
	if (!isEmitting) {
		return;
		display->TextCenter( 0.0f, 0.0f, "RADAR OFF" );
	}


	// Label our buttons
	DrawButtons();

	// Draw range circles
	display->Circle ( 0.0f, 0.0f, 0.5f );
	display->Circle ( 0.0f, 0.0f, 0.99f );

	// Draw the radar lock sector
	if (!AWACSMode) // JB 011213
	{
		display->Line( 0.0f, 0.0f,  SIN_RADAR_CONE_ANGLE, COS_RADAR_CONE_ANGLE );
		display->Line( 0.0f, 0.0f, -SIN_RADAR_CONE_ANGLE, COS_RADAR_CONE_ANGLE );
	}

	// Note if we're in auto target mode
	if (lockCmd == AUTO)
	{
		display->TextRight( 0.90f, -0.90f, "AUTO" );
	}


	// Mark where the locked target will be (if we have one)
	if (lockedTarget)
	{
		float		dx, dy;		// World space deltas		(x north)
		float		x, y;		// Screen space coordinates (x left/right)

		dx = (lockedTarget->BaseData()->XPos() - platform->XPos());
		dy = (lockedTarget->BaseData()->YPos() - platform->YPos());
		x = dy*scaledCosYaw - dx*scaledSinYaw;
		y = dy*scaledSinYaw + dx*scaledCosYaw;
		display->Circle ( x, y, BLIP_SIZE*2.0f );
	}


	// Now draw the radar cursors
	DrawCursor();
	DrawBullseyeData();


	// Now fill in the target blips
	if (mode == AA) {
		DisplayAATargets( scaledSinYaw, scaledCosYaw );
	} else {
		DisplayAGTargets( scaledSinYaw, scaledCosYaw );
	}


	// Put the display color back to green
	display->SetColor( tmpColor );

	// Target ID (NCTR)
	if (lockedTarget)
	{
		classPtr = (Falcon4EntityClassType*)lockedTarget->BaseData()->EntityType();
		if (lockedTarget->BaseData()->IsSim() && !((SimBaseClass*)lockedTarget->BaseData())->IsExploding())
		{
			if (classPtr->dataType == DTYPE_VEHICLE) {
				sprintf (string, "%s", ((VehicleClassDataType*)(classPtr->dataPtr))->Name);
			} else if (classPtr->dataType == DTYPE_FEATURE) {
				sprintf (string, "%s", "BLDG");
			} else {
				sprintf (string, "%s", "---");
			}
		} else {
			sprintf (string, "%s", "---");
		}
		ShiAssert( strlen(string) < sizeof(string) );
		display->TextCenter(0.0F, 0.75F, string);
	}
}