Пример #1
0
void CInformationPanel::Draw(HDC hdc,const RECT &PaintRect)
{
	HDC hdcDst;
	RECT rc;
//	TCHAR szText[256];

	GetClientRect(&rc);
	if (rc.right>m_Offscreen.GetWidth()
			|| m_FontHeight+m_Style.LineSpacing>m_Offscreen.GetHeight())
		m_Offscreen.Create(rc.right,m_FontHeight+m_Style.LineSpacing);
	hdcDst=m_Offscreen.GetDC();
	if (hdcDst==NULL)
		hdcDst=hdc;

	HFONT hfontOld=DrawUtil::SelectObject(hdcDst,m_Font);
	COLORREF crOldTextColor=::SetTextColor(hdcDst,m_Theme.Style.Fore.Fill.GetSolidColor());
	int OldBkMode=::SetBkMode(hdcDst,TRANSPARENT);

	for (int i=0;i<ITEM_PROGRAMINFO;i++) {
		if (GetDrawItemRect(i,&rc,PaintRect))
			m_ItemList[i]->Draw(hdc,rc);
	}

	GetItemRect(ITEM_PROGRAMINFO-1,&rc);
	if (PaintRect.bottom>rc.bottom) {
		rc.left=PaintRect.left;
		rc.top=max(PaintRect.top,rc.bottom);
		rc.right=PaintRect.right;
		rc.bottom=PaintRect.bottom;
		::FillRect(hdc,&rc,m_BackBrush.GetHandle());
	}

	if (IsItemVisible(ITEM_PROGRAMINFO)) {
		if (m_Theme.ProgramInfoStyle.Back.Border.Type!=TVTest::Theme::BORDER_NONE) {
			GetItemRect(ITEM_PROGRAMINFO,&rc);
			TVTest::Theme::Draw(hdc,rc,m_Theme.ProgramInfoStyle.Back.Border);
		}

		GetButtonRect(BUTTON_PROGRAMINFOPREV,&rc);
		DrawProgramInfoPrevNextButton(
			hdc,rc,false,IsButtonEnabled(BUTTON_PROGRAMINFOPREV),
			m_HotButton==BUTTON_PROGRAMINFOPREV);
		GetButtonRect(BUTTON_PROGRAMINFONEXT,&rc);
		DrawProgramInfoPrevNextButton(
			hdc,rc,true,IsButtonEnabled(BUTTON_PROGRAMINFONEXT),
			m_HotButton==BUTTON_PROGRAMINFONEXT);
	}

	::SetBkMode(hdcDst,OldBkMode);
	::SetTextColor(hdcDst,crOldTextColor);
	::SelectObject(hdcDst,hfontOld);
}
Пример #2
0
void CInformationPanel::RedrawButton(int Button)
{
	RECT rc;

	if (GetButtonRect(Button,&rc))
		Invalidate(&rc);
}
Пример #3
0
void CEditWithButton_Base::OnNcMouseMove(UINT nHitTest, CPoint point)
{
	CRect rectWindow;
	GetWindowRect(rectWindow);
	CRect rectButton = GetButtonRect(rectWindow);

	bool OldState = m_IsButtonHot;
	m_IsButtonHot = rectButton.PtInRect(point) != FALSE;
	// If the button state has changed, redraw it to reflect the change
	if (OldState != m_IsButtonHot)
	{
		SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);

		// If the state has changed to hot, register to get the WM_NCMOUSELEAVE notification.
		if (m_IsButtonHot)
		{
			TRACKMOUSEEVENT tme;
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE | TME_NONCLIENT;
			tme.hwndTrack = m_hWnd;
			tme.dwHoverTime = HOVER_DEFAULT;
			_TrackMouseEvent(&tme);
		}
	}

	CEdit::OnNcMouseMove(nHitTest, point);
}
Пример #4
0
void CEditWithButton_Base::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_IsMouseActive)
	{
		ReleaseCapture();

		ClientToScreen(&point);

		CRect rectWindow;
		GetWindowRect(rectWindow);
		CRect rectButton = GetButtonRect(rectWindow);

		// Reset the button to a "normal" state.
		m_IsButtonHot = false;
		m_IsButtonPressed = false;
		m_IsMouseActive = false;

		// Redraw the button to reflect the changes.
		SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);

		// Run the on-click logic if appropriate.
		if (rectButton.PtInRect(point))
			OnLeftClick();
	}

	CEdit::OnLButtonUp(nFlags, point);
}
Пример #5
0
UINT CEnEdit::TrackPopupMenu(UINT nID, CMenu* pMenu, BOOL bBelow)
{
	if (ButtonHitTest(nID) == -1)
	{
		ASSERT(0);
		return 0;
	}

	ASSERT_VALID(pMenu);

	CRect rButton = GetButtonRect(nID);
	
	TPMPARAMS tpmp;
	tpmp.cbSize = sizeof(TPMPARAMS);
	tpmp.rcExclude = rButton;

	int nX = bBelow ? rButton.left : rButton.right;
	int nY = bBelow ? rButton.bottom : rButton.top;
	
	UINT nCmdID = ::TrackPopupMenuEx(pMenu->GetSafeHmenu(), 
									TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, 
									nX, nY, ::GetParent(*this), &tpmp);
	
	return nCmdID;
}
Пример #6
0
void CNavigatorButtonUI::DrawItem(HDC hDC, const RECT& rcItem, UINT uStyle)
{
    RECT rcButton = GetButtonRect(m_rcItem);

    if ((m_uButtonState & UISTATE_PUSHED) != 0) {
        CBlueRenderEngineUI::DoFillRect(hDC, m_pManager, rcButton, UICOLOR_NAVIGATOR_BUTTON_PUSHED);
    }
    else if (m_bSelected) {
        CBlueRenderEngineUI::DoFillRect(hDC, m_pManager, rcButton, UICOLOR_NAVIGATOR_BUTTON_SELECTED);
    }
    else if ((m_uButtonState & UISTATE_PUSHED) != 0) {
        CBlueRenderEngineUI::DoFillRect(hDC, m_pManager, rcButton, UICOLOR_NAVIGATOR_BUTTON_HOVER);
    }
    ::SelectObject(hDC, m_pManager->GetThemePen(m_bSelected ? UICOLOR_NAVIGATOR_BORDER_SELECTED : UICOLOR_NAVIGATOR_BORDER_NORMAL));
    POINT ptTemp = { 0 };
    ::MoveToEx(hDC, rcButton.left, rcButton.top, &ptTemp);
    ::LineTo(hDC, rcButton.left, rcButton.bottom);
    ::LineTo(hDC, rcButton.right, rcButton.bottom);

    UITYPE_COLOR iTextColor = UICOLOR_NAVIGATOR_TEXT_NORMAL;
    if ((m_uButtonState & UISTATE_PUSHED) != 0) iTextColor = UICOLOR_NAVIGATOR_TEXT_PUSHED;
    else if (m_bSelected) iTextColor = UICOLOR_NAVIGATOR_TEXT_SELECTED;

    RECT rcText = rcButton;
    ::OffsetRect(&rcText, 0, 1);
    ::InflateRect(&rcText, -8, 0);
    if ((m_uButtonState & UISTATE_PUSHED) != 0) {
        rcText.left++;
        rcText.top += 2;
    }
    int nLinks = 0;
    CBlueRenderEngineUI::DoPaintPrettyText(hDC, m_pManager, rcText, m_sText, iTextColor, UICOLOR__INVALID, NULL, nLinks, DT_SINGLELINE | DT_VCENTER);
}
Пример #7
0
  void OnResize(PixelSize size) override {
    SingleWindow::OnResize(size);

    const PixelRect rc = GetClientRect();
    if (test_window.IsDefined())
      test_window.Move(rc);

    if (close_button.IsDefined())
      close_button.Move(GetButtonRect(rc));
  }
Пример #8
0
  void Create(PixelSize size) {
    SingleWindow::Create(_T("Test"), size);

    WindowStyle style;
    style.Disable();

    const PixelRect rc = GetClientRect();
    close_button.Create(*this, _T("Close"), CLOSE, GetButtonRect(rc));
    test_window.Create(*this, rc, style);
  }
Пример #9
0
LRESULT CEditWithButton_Base::OnNcHitTest(CPoint point)
{
	CRect rectWindow;
	GetWindowRect(rectWindow);
	CRect rectButton = GetButtonRect(rectWindow);

	if (rectButton.PtInRect(point))
		return HTBORDER;

	return CEdit::OnNcHitTest(point);
}
LRESULT CWinHotkeyCtrl::OnLeftClick(WPARAM wParam, LPARAM lParam)
{
	CRect r;
	CPoint pt;
	CEditWithButton::GetWindowRect(r);
	CRect rectButton = GetButtonRect(r);
	pt = rectButton.BottomRight();
	pt.x = pt.x-(rectButton.Width());
	OnContextMenu(this, pt);

	return 0;
}
Пример #11
0
int CInformationPanel::CItem::ButtonHitTest(int x,int y) const
{
	const int ButtonCount=GetButtonCount();
	for (int i=0;i<ButtonCount;i++) {
		RECT rc;
		GetButtonRect(i,&rc);
		POINT pt={x,y};
		if (::PtInRect(&rc,pt))
			return i;
	}
	return -1;
}
Пример #12
0
void CEditWithButton_Base::OnNcPaint()
{
	// Allow default processing
	CEdit::OnNcPaint();

	CRect rectWindow;
	GetWindowRect(rectWindow);
	// Adjust coords to start at 0,0
	rectWindow.OffsetRect(-rectWindow.TopLeft());

	CRect rectButton = GetButtonRect(rectWindow);

	DrawButton(rectButton);
}
Пример #13
0
BOOL CSkinWin::DrawButton( CDC * pDC, int i, int state)
{
    if ( i == 0 )
    {
        if ( m_bmpCloseBtn.GetSafeHandle() )
        {
            CRect r = GetButtonRect(0);
            m_bmpCloseBtn.Draw( pDC, r.left, r.top, 
                CRect( state * r.Width(), 0, (state + 1 ) * r.Width(), m_bmpCloseBtn.Height() ), m_colTrans, m_bTrans );
        }
    }
    if ( i == 1 )
    {
       /* CRect r = GetButtonRect(1);
        if ( m_maxable && m_bmpMaxBtn.GetSafeHandle() )
            if ( m_winstate == 1&& m_bmpRestoreBtn.GetSafeHandle() )
                m_bmpRestoreBtn.Draw( pDC, r.left, r.top, 
                    CRect( state * r.Width(), 0, (state + 1 ) * r.Width(), m_bmpCloseBtn.Height() ), m_colTrans, m_bTrans );
            else
                m_bmpMaxBtn.Draw( pDC, r.left, r.top, 
                    CRect( state * r.Width(), 0, (state + 1 ) * r.Width(), m_bmpCloseBtn.Height() ) , m_colTrans, m_bTrans);
    }
    if ( i == 2 )
    {*///liub_modify
        if ( m_minable && m_bmpMinBtn.GetSafeHandle() )
        {
            CRect r = GetButtonRect(1);
           // CRect r = GetButtonRect(2);
            m_bmpMinBtn.Draw( pDC, r.left, r.top, 
                CRect( state * r.Width(), 0, (state + 1 ) * r.Width(), m_bmpCloseBtn.Height() ) , m_colTrans, m_bTrans);

        }
    }
    return TRUE;
    
}
Пример #14
0
int CInformationPanel::ButtonHitTest(int x,int y) const
{
	POINT pt={x,y};

	for (int i=0;i<NUM_BUTTONS;i++) {
		if (IsButtonEnabled(i)) {
			RECT rc;

			if (GetButtonRect(i,&rc) && ::PtInRect(&rc,pt))
				return i;
		}
	}

	return -1;
}
Пример #15
0
ClientGame::ButtonId ClientGame::GetButtonAtPoint(int x, int y) const
{
    for (int i = 0; i < ButtonId_NumButtons; ++i)
    {
        if (m_button[i].enabled)
        {
            int xButton, yButton, xButtonSize, yButtonSize;
            GetButtonRect((ButtonId)i, xButton, yButton, xButtonSize, yButtonSize);

            if (x >= xButton && x <= xButton + xButtonSize &&
                y >= yButton && y <= yButton + yButtonSize)
            {
                return (ButtonId)i;
            }
        }
    }
    return ButtonId_None;
}
Пример #16
0
void CEditWithButton_Base::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
    if (!(GetStyle() & (ES_READONLY | WS_DISABLED))) {
        CRect rectWindow;
        GetWindowRect(rectWindow);
        CRect rectButton = GetButtonRect(rectWindow);

        if (rectButton.PtInRect(point)) {
            SetCapture();

            m_IsButtonPressed = true;
            m_IsMouseActive = true;

            // Redraw the button to reflect the change
            SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
        }
    }

    CEdit::OnNcLButtonDown(nHitTest, point);
}
Пример #17
0
void CEditWithButton_Base::OnNcMouseLeave()
{
    CPoint point;
    GetCursorPos(&point);

    CRect rectWindow;
    GetWindowRect(rectWindow);
    CRect rectButton = GetButtonRect(rectWindow);

    // We may get this message either when the mouse actually leaves the client area
    // or when the user clicks the mouse on the button. So we must check whether or
    // not the cursor has actually left the button area. If so, then update the hot
    // state and prompt a redraw of the button.
    if (!rectButton.PtInRect(point)) {
        m_IsButtonHot = false;
        SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
    }

    CEdit::OnNcMouseLeave();
}
Пример #18
0
void CEditWithButton_Base::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_IsMouseActive)
	{
		ClientToScreen(&point);

		CRect rectWindow;
		GetWindowRect(rectWindow);
		CRect rectButton = GetButtonRect(rectWindow);

		bool OldState = m_IsButtonPressed;

		m_IsButtonPressed = rectButton.PtInRect(point) != FALSE;

		// If the button state has changed, redraw it to reflect the change
		if (OldState != m_IsButtonPressed)
			SetWindowPos(NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
	}

	CEdit::OnMouseMove(nFlags, point);
}
Пример #19
0
// ボタンが押された
void CEqualizer::OnButtonPush(int Button)
{
	switch (Button) {
	case BUTTON_ENABLE:
		// On/Off切り替え
		EnableEqualizer(!m_fEnable);
		::UpdateWindow(m_hwnd);
		break;

	case BUTTON_RESET:
		// リセット
		ResetSettings();
		ApplySettings();
		::InvalidateRect(m_hwnd,NULL,TRUE);
		::UpdateWindow(m_hwnd);
		break;

	case BUTTON_LOAD:
	case BUTTON_SAVE:
		// プリセットの読み込み/保存
		{
			HMENU hmenu=::CreatePopupMenu();

			for (int i=0;i<NUM_CUSTOM_PRESETS;i++) {
				TCHAR szText[16];
				::wsprintf(szText,TEXT("Preset %d"),i+1);
				::AppendMenu(hmenu,MFT_STRING | MFS_ENABLED,i+1,szText);
			}
			if (Button==BUTTON_LOAD) {
				for (int i=0;i<sizeof(m_PresetList)/sizeof(EqualizerPreset);i++) {
					UINT Flags=MFT_STRING | MFS_ENABLED;
					if (i==0)
						Flags|=MF_MENUBREAK;
					::AppendMenu(hmenu,Flags,NUM_CUSTOM_PRESETS+1+i,m_PresetList[i].pszName);
				}
			}
			RECT rc;
			POINT pt;
			GetButtonRect(Button,&rc);
			pt.x=rc.left;
			pt.y=rc.bottom;
			::ClientToScreen(m_hwnd,&pt);
			int Result=::TrackPopupMenu(hmenu,TPM_RIGHTBUTTON | TPM_RETURNCMD,pt.x,pt.y,0,m_hwnd,NULL);
			::DestroyMenu(hmenu);
			if (Result>0) {
				Result--;
				if (Button==BUTTON_LOAD) {
					if (Result<NUM_CUSTOM_PRESETS)
						m_CurSettings=m_CustomPresetList[Result];
					else
						m_CurSettings=m_PresetList[Result-NUM_CUSTOM_PRESETS].Setting;
					if (m_fEnable) {
						ApplySettings();
						::InvalidateRect(m_hwnd,NULL,TRUE);
					} else {
						EnableEqualizer(true);
					}
					::UpdateWindow(m_hwnd);
				} else {
					m_CustomPresetList[Result]=m_CurSettings;
				}
			}
		}
		break;
	}
}
Пример #20
0
void clRowEntry::Render(wxWindow* win, wxDC& dc, const clColours& c, int row_index, clSearchText* searcher)
{
    wxUnusedVar(searcher);
    wxRect rowRect = GetItemRect();
    bool zebraColouring = (m_tree->HasStyle(wxTR_ROW_LINES) || m_tree->HasStyle(wxDV_ROW_LINES));
    bool even_row = ((row_index % 2) == 0);

    // Define the clipping region
    bool hasHeader = (m_tree->GetHeader() && !m_tree->GetHeader()->empty());

    // Not cell related
    clColours colours = c;
    if(zebraColouring) {
        // Set Zebra colouring, only if no user colour was provided for the given line
        colours.SetItemBgColour(even_row ? c.GetAlternateColour() : c.GetBgColour());
    }

    // Override default item bg colour with the user's one
    if(GetBgColour().IsOk()) { colours.SetItemBgColour(GetBgColour()); }
    wxRect selectionRect = rowRect;
    wxPoint deviceOrigin = dc.GetDeviceOrigin();
    selectionRect.SetX(-deviceOrigin.x);
    if(IsSelected()) {
        DrawSimpleSelection(win, dc, selectionRect, colours);
    } else if(IsHovered()) {
        dc.SetPen(colours.GetHoverBgColour());
        dc.SetBrush(colours.GetHoverBgColour());
        dc.DrawRectangle(selectionRect);
    } else if(colours.GetItemBgColour().IsOk()) {
        dc.SetBrush(colours.GetItemBgColour());
        dc.SetPen(colours.GetItemBgColour());
        dc.DrawRectangle(selectionRect);
    }

    // Per cell drawings
    for(size_t i = 0; i < m_cells.size(); ++i) {
        bool last_cell = (i == (m_cells.size() - 1));
        colours = c; // reset the colours
        wxFont f = clScrolledPanel::GetDefaultFont();
        clCellValue& cell = GetColumn(i);
        if(cell.GetFont().IsOk()) { f = cell.GetFont(); }
        if(cell.GetTextColour().IsOk()) { colours.SetItemTextColour(cell.GetTextColour()); }
        if(cell.GetBgColour().IsOk()) { colours.SetItemBgColour(cell.GetBgColour()); }
        dc.SetFont(f);
        wxColour buttonColour = IsSelected() ? colours.GetSelbuttonColour() : colours.GetButtonColour();
        wxRect cellRect = GetCellRect(i);

        // We use a helper class to clip the drawings this ensures that if we exit the scope
        // the clipping region is restored properly
        clClipperHelper clipper(dc);
        if(hasHeader) { clipper.Clip(cellRect); }

        int textXOffset = cellRect.GetX();
        if((i == 0) && !IsListItem()) {
            // The expand button is only make sense for the first cell
            if(HasChildren()) {
                wxRect buttonRect = GetButtonRect();
                buttonRect.Deflate(1);
                textXOffset += buttonRect.GetWidth();
                if(m_tree->IsNativeTheme() && !IS_OSX) {
                    int flags = wxCONTROL_CURRENT;
                    if(IsExpanded()) { flags |= wxCONTROL_EXPANDED; }
                    int button_width = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
                    wxRect modButtonRect = buttonRect;
                    modButtonRect.SetWidth(button_width);
                    modButtonRect.SetHeight(button_width);
                    modButtonRect = modButtonRect.CenterIn(buttonRect);
                    wxRendererNative::Get().DrawTreeItemButton(win, dc, modButtonRect, flags);
                } else {
                    wxRect buttonRect = GetButtonRect();
                    if(textXOffset >= cellRect.GetWidth()) {
                        // if we cant draw the button (off screen etc)
                        SetRects(GetItemRect(), wxRect());
                        continue;
                    }
                    buttonRect.Deflate((buttonRect.GetWidth() / 3), (buttonRect.GetHeight() / 3));
                    wxRect tribtn = buttonRect;
                    dc.SetPen(wxPen(buttonColour, 2));
                    if(IsExpanded()) {
                        tribtn.SetHeight(tribtn.GetHeight() - tribtn.GetHeight() / 2);
                        tribtn = tribtn.CenterIn(buttonRect);
                        wxPoint middleLeft = wxPoint((tribtn.GetLeft() + tribtn.GetWidth() / 2), tribtn.GetBottom());
                        dc.DrawLine(tribtn.GetTopLeft(), middleLeft);
                        dc.DrawLine(tribtn.GetTopRight(), middleLeft);
                    } else {
                        tribtn.SetWidth(tribtn.GetWidth() - tribtn.GetWidth() / 2);
                        tribtn = tribtn.CenterIn(buttonRect);

                        wxPoint middleLeft = wxPoint(tribtn.GetRight(), (tribtn.GetY() + (tribtn.GetHeight() / 2)));
                        wxPoint p1 = tribtn.GetTopLeft();
                        wxPoint p2 = tribtn.GetBottomLeft();
                        dc.DrawLine(p1, middleLeft);
                        dc.DrawLine(middleLeft, p2);
                    }
                }

            } else {
                wxRect buttonRect(rowRect);
                buttonRect.SetWidth(rowRect.GetHeight());
                buttonRect.Deflate(1);
                textXOffset += buttonRect.GetWidth();
                if(textXOffset >= cellRect.GetWidth()) {
                    SetRects(GetItemRect(), wxRect());
                    continue;
                }
            }
        }
        int itemIndent = IsListItem() ? clHeaderItem::X_SPACER : (GetIndentsCount() * m_tree->GetIndent());
        int bitmapIndex = cell.GetBitmapIndex();
        if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) {
            bitmapIndex = cell.GetBitmapSelectedIndex();
        }

        // Draw checkbox
        if(cell.IsBool()) {
            // Render the checkbox
            textXOffset += X_SPACER;
            int checkboxSize = GetCheckBoxWidth(win);
            wxRect checkboxRect = wxRect(textXOffset, rowRect.GetY(), checkboxSize, checkboxSize);
            checkboxRect = checkboxRect.CenterIn(rowRect, wxVERTICAL);
            dc.SetPen(colours.GetItemTextColour());
            RenderCheckBox(win, dc, colours, checkboxRect, cell.GetValueBool());
            cell.SetCheckboxRect(checkboxRect);
            textXOffset += checkboxRect.GetWidth();
            textXOffset += X_SPACER;
        } else {
            cell.SetCheckboxRect(wxRect()); // clear the checkbox rect
        }

        // Draw the bitmap
        if(bitmapIndex != wxNOT_FOUND) {
            const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex);
            if(bmp.IsOk()) {
                textXOffset += IsListItem() ? 0 : X_SPACER;
                int bitmapY = rowRect.GetY() + ((rowRect.GetHeight() - bmp.GetScaledHeight()) / 2);
                // if((textXOffset + bmp.GetScaledWidth()) >= cellRect.GetWidth()) { continue; }
                dc.DrawBitmap(bmp, itemIndent + textXOffset, bitmapY, true);
                textXOffset += bmp.GetScaledWidth();
                textXOffset += X_SPACER;
            }
        }

        // Draw the text
        wxRect textRect(dc.GetTextExtent(cell.GetValueString()));
        textRect = textRect.CenterIn(rowRect, wxVERTICAL);
        int textY = textRect.GetY();
        int textX = (i == 0 ? itemIndent : clHeaderItem::X_SPACER) + textXOffset;
        RenderText(win, dc, colours, cell.GetValueString(), textX, textY, i);
        textXOffset += textRect.GetWidth();
        textXOffset += X_SPACER;

        if(cell.IsChoice()) {
            // draw the drop down arrow. Make it aligned to the right
            wxRect dropDownRect(cellRect.GetTopRight().x - rowRect.GetHeight(), rowRect.GetY(), rowRect.GetHeight(),
                                rowRect.GetHeight());
            dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL);
            DrawingUtils::DrawDropDownArrow(win, dc, dropDownRect, wxNullColour);
            // Keep the rect to test clicks
            cell.SetDropDownRect(dropDownRect);
            textXOffset += dropDownRect.GetWidth();
            textXOffset += X_SPACER;
            
            // Draw a separator line between the drop down arrow and the rest of the cell content
            dropDownRect.Deflate(3);
            dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL);
            dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE));
            dc.DrawLine(dropDownRect.GetTopLeft(), dropDownRect.GetBottomLeft());
            
        } else {
            cell.SetDropDownRect(wxRect());
        }

        if(!last_cell) {
            cellRect.SetHeight(rowRect.GetHeight());
            dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE));
            dc.DrawLine(cellRect.GetTopRight(), cellRect.GetBottomRight());
        }
    }
}
Пример #21
0
 virtual void Move(const PixelRect &rc) override {
   quit.Move(GetButtonRect(rc));
   logo.Move(rc);
 }
Пример #22
0
SRect CGM_Slider::GetLocalButtonRectInOwnerDialogCoord()
{
	SRect rect = GetButtonRect();
	rect.Offset( -GetOwnerDialog()->GetBoundingBox().GetTopLeftCorner() );
	return rect;
}
Пример #23
0
unsigned int GMsgBox::initialize (GMessage& msg)
{
	LCD_MODULE* lcd = ((LCD_MODULE **)msg.lparam)[0];
	id = ID_MB_DLG;
	rect = lcd->rect;
	flags = GO_FLG_BORDER|GO_FLG_ENABLED|GO_FLG_SHOW|GO_FLG_SELECTED;

	RECT_T button_rect;
	RECT_T title_rect;
	RECT_T message_rect;

	int bnum =0;
	for(int mask = 1; type && mask < MBF_LAST_BTN; mask <<=1)
		if(type & mask)
			bnum++;

	if(body.empty() && !init_size.as_int )
	{
		for(int i=0; i < lcd->chars_per_row/2; i++)
			body += '.';
		type |= MBF_CLR;
	}

	POINT_T bs = get_border_size();
	text_metrics_t msg_size;
    int x_offset, y_offset;
	while(1)
	{
		allocate_border();
		if(bnum)
			button_rect = GetButtonRect();
		title_rect = GetTitleRect();
		message_rect =client_rect;

		message_rect.y0 += title_rect.height()+1; 								// title to message spacing 1 dot
		message_rect.y1 -= (button_rect.height())?(button_rect.height()):1;		// message to buttons spacing 1 dot

		int width=0;
		int dec = message_rect.width();
		if(type & MBF_EDIT)
			dec -= 2*bs.x;

		if(init_size.as_int)
			msg_size.as_int = init_size.as_int;
		else
			msg_size = get_text_metrics(body.c_str(), dec, font);

		if(msg_size.height + font->vspacing < message_rect.height())
		{
			rect.y1 -= message_rect.height() - (msg_size.height + font->vspacing);
			continue;
		}
		else
		{
			if(message_rect.height() < msg_size.height)
			{
				flags |= GO_FLG_VSCROLL;
				x_offset = message_rect.height();
				if(client_rect.height() > msg_size.height)
					message_rect.y1 = message_rect.y0 + msg_size.height;
				else
					message_rect.y1 = message_rect.y0 + client_rect.height();// +client_rect.y1;
				x_offset = message_rect.height() - x_offset;
				if(button_rect)
				{
					button_rect.Offset(0, x_offset);
				}
			}
		}
		if(dec > msg_size.width + 3*font->hdistance)
		{
			message_rect.x1 -= dec - msg_size.width - 3*font->hdistance;
			text_metrics_t new_msg_size;
			new_msg_size = get_text_metrics(body.c_str(), message_rect.width(), font);
			while(new_msg_size.height != msg_size.height )
			{
				message_rect.x1 += 3*font->hdistance;
				new_msg_size = get_text_metrics(body.c_str(), message_rect.width(), font);
			}
		}
		width = message_rect.width();
		if( title_rect.width() > width)
			width = title_rect.width();
		if(button_rect.width() + bnum * bs.x > width)
			width = button_rect.width() + bnum * bs.x ;
		if(client_rect.width() > width)
		{
			rect.x1 -= client_rect.width() - width;
			continue;
		}
		break;
	}
	if(type & MBF_CLR)
		body.clear();

    x_offset = (lcd->rect.width() - rect.width())/2;
    y_offset = (lcd->rect.height() - rect.height())/2;

    rect.Offset(x_offset, y_offset);
    client_rect.Offset(x_offset, y_offset);
    button_rect.Offset(x_offset, y_offset);
    if(title_rect)
    {
    	title_rect.x0 = rect.x0;
    	title_rect.x1 = rect.x1;
    	title_rect.Offset(0, y_offset);
    	GFlags flg = GO_FLG_SHOW|GO_FLG_TRANSPARENT;
    	if(message_rect.height() >= client_rect.height())
    		flg |= GO_FLG_ENABLED;
    	title_box = new GTitle(	ID_MB_TITLE, title_rect, title, nullptr,
    							flg, SS_CENTER|SS_TOP);
    	addChild(title_box);
    }
    if(message_rect.width() < client_rect.width())
    	x_offset += (client_rect.width() - message_rect.width())/2;
    message_rect.Offset(x_offset, y_offset);

    if(type & MBF_EDIT)
    {
    	edit_box = new GEdit(ID_MB_TEXT_BOX, message_rect, body, nullptr,
    			((bnum)?0:GO_FLG_SELECTED)|
				 GO_FLG_BORDER|GO_FLG_VSCROLL|GO_FLG_TRANSPARENT|GO_FLG_DEFAULT,
				 GET_MBF_EDIT_FLAGS(type),
				font);
		if(addChild(edit_box))
		{
			edit_box->shift = GET_MBF_INPUT_TYPE(type);
			text_box = edit_box;
		}
    }
    else
    {
    	text_box = new GText(ID_MB_TEXT_BOX, message_rect, body, nullptr,
 				GO_FLG_VSCROLL|GO_FLG_TRANSPARENT|GO_FLG_SHOW,SS_DEFAULT,font);
		if(addChild( text_box ))
		{
			if(message_rect.height() < msg_size.height)
				text_box->flags |= GO_FLG_ENABLED;
		}
    }
	int bdistance = client_rect.width();

	if ( bnum )
	{
		if(bdistance > button_rect.width())
		{
			bdistance -= button_rect.width();
			bdistance /= bnum+1;
		}
		else
			bdistance = 0;
		int distance = 4*font->hdistance + 2*bs.x;
		button_rect.Inflate(0,2);
		button_rect.Offset(0,1);
		for(unsigned char mask =1, i=0; mask < MBF_LAST_BTN; mask <<=1, i++)
		{
			if(type & mask)
			{
				if(!default_button)
					default_button = mask;

				button_rect.x0 += bdistance;
				button_rect.x1 = button_rect.x0 + (strlen(MB_IDS[i]) * font->hspacing) + distance;
				addChild(new GButton(mask/*ret_codes[i]*/, button_rect, ret_codes[i], MB_IDS[i],
						GO_FLG_DEFAULT|GO_FLG_BORDER|GO_FLG_TRANSPARENT|
						((default_button&mask)?GO_FLG_SELECTED:0 )));
				button_rect.x0 += button_rect.width();
			}
		}
	}
	weak_gui_message_beep(GET_MBF_BEEP_TYPE(type));
	return GDialog::initialize(msg);
}
Пример #24
0
UINT CSkinWin::OnNcHitTest(CPoint point)
{
    CWnd *pWnd = CWnd::FromHandle(m_hWnd);
    CRect wr;
    pWnd->GetWindowRect(wr);
    
    point.x -= wr.left;
    point.y -= wr.top;

    if ( PtInRect( GetButtonRect(0), point ) )
	{
		if (m_sysmenu) {
			return HTCLOSE;
		}else{
			return HTCAPTION;
		}
        
	}
   // if ( PtInRect( GetButtonRect(2), point ) && m_minable )
       // return HTMINBUTTON;
   /* if ( PtInRect( GetButtonRect(1), point ) && m_maxable )
        return HTMAXBUTTON;*///liub_modify (纠正去除最大化按钮后最小化按钮的位置)
    if ( PtInRect( GetButtonRect(1), point ) && m_minable )
        return HTMINBUTTON;

    CRect r;
    int cx = GetSystemMetrics(SM_CXSMICON);
    int cy = GetSystemMetrics(SM_CYSMICON);
    if ( PtInRect( CRect(m_BorderLeftWidth, 5, m_BorderLeftWidth + cx, cy + 5), point ) )
        return HTSYSMENU;

    r = CRect( 0, 0, m_BorderLeftWidth, m_TitleHeight );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTTOPLEFT;
    r = CRect( wr.Width() - m_BorderLeftWidth, 0,  wr.Width(), m_TitleHeight  );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTTOPRIGHT;
    r = CRect( 0, wr.Height() - m_BorderBottomHeight, m_BorderLeftWidth, wr.Height() );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTBOTTOMLEFT;
    r = CRect( wr.Width()-m_BorderRightWidth, wr.Height() - m_BorderBottomHeight,  wr.Width(), wr.Height() );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTBOTTOMRIGHT;
    r = CRect( 0, m_TitleHeight,  m_BorderLeftWidth, wr.Height() - m_BorderBottomHeight  );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTLEFT;
    r = CRect( wr.Width()-m_BorderRightWidth, m_TitleHeight,  wr.Width(), wr.Height() - m_BorderBottomHeight  );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTRIGHT;
    r = CRect( m_BorderLeftWidth, wr.Height() - m_BorderBottomHeight,  wr.Width()-m_BorderRightWidth, wr.Height() );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTBOTTOM;
    r = CRect( m_BorderLeftWidth, 0,  wr.Width()-m_BorderRightWidth, m_BorderBottomHeight );
    if ( PtInRect( r, point ) && m_sizable && m_winstate != 1 )  //!IsZoomed(m_hWnd) )
        return HTTOP;
    //set to boder 5
    r = CRect( m_BorderLeftWidth, 5 , wr.Width()-m_BorderRightWidth, m_TitleHeight );
    if ( PtInRect( r, point ) )
	{
        /*
        if(m_pHookedWnd->IsKindOf( RUNTIME_CLASS( CTabDialog ))){
                return HTCLIENT;
        }*/
        return HTCAPTION;
    }



    return HTCLIENT;
}
Пример #25
0
 virtual void Show(const PixelRect &rc) override {
   quit.MoveAndShow(GetButtonRect(rc));
   logo.MoveAndShow(rc);
 }
Пример #26
0
void ClientGame::Render()
{

    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST );
    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST );
 
    glEnable(GL_LINE_SMOOTH);
    glEnable(GL_POLYGON_SMOOTH);

    if (m_gameState == GameState_MainMenu)
    {
        RenderMainMenu();
        return;
    }

    if (m_gameState == GameState_WaitingForServer)
    {
        return;
    }

    glClearColor( 0.97f * 0.9f, 0.96f * 0.9f, 0.89f * 0.9f, 0.0f );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glDisable(GL_TEXTURE_2D);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(m_mapX, m_mapX + m_xSize * m_mapScale, m_mapY + m_ySize * m_mapScale, m_mapY);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    const int outerBorder = 35;

    // Draw the background.
    glColor(0xFFFFFFFF);
    glBegin(GL_QUADS);
    glVertex2i(-outerBorder, -outerBorder);
    glVertex2i(m_xMapSize + outerBorder, -outerBorder);
    glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder);
    glVertex2i(-outerBorder, m_yMapSize + outerBorder);
    glEnd();

    // Outer thick border of the map
    glColor(0xFF7FD6F2);
    glLineWidth(2);
    glBegin(GL_LINE_LOOP);
    glVertex2i(-outerBorder, -outerBorder);
    glVertex2i(m_xMapSize + outerBorder, -outerBorder);
    glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder);
    glVertex2i(-outerBorder, m_yMapSize + outerBorder);
    glEnd();

    // Grid
    glColor(0xFF7FD6F2);
    glLineWidth(1);
    glBegin(GL_LINES);
    for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x)
    {
        glVertex2i(x * m_gridSpacing, 0);
        glVertex2i(x * m_gridSpacing, m_yMapSize);
    }
    glVertex2i(m_xMapSize, 0);
    glVertex2i(m_xMapSize, m_yMapSize);
    for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y)
    {
        glVertex2i(0, y * m_gridSpacing);
        glVertex2i(m_xMapSize, y * m_gridSpacing);
    }
    glVertex2i(0, m_yMapSize);
    glVertex2i(m_xMapSize, m_yMapSize);
    glEnd();

    // Buildings.
    glEnable(GL_TEXTURE_2D);
    glColor(0xFFFFFFFF);
    for (int i = 0; i < m_map.GetNumStops(); ++i)
    {
        const Stop& stop = m_map.GetStop(i);
        Vec2 position = stop.point;
                
        const Texture* texture = NULL;
        switch (stop.structureType)
        {
        case StructureType_Bank:
            texture = &m_buildingBankTexture;
            break;
        case StructureType_Tower:
            texture = &m_buildingTowerTexture;
            break;
        case StructureType_Police:
            texture = &m_buildingPoliceTexture;
            break;
        }
        if (texture != NULL)
        {
            Render_DrawSprite(*texture, static_cast<int>(position.x) - texture->xSize / 2, static_cast<int>(position.y) - texture->ySize / 2);
        }
    }
    for (int i = 0; i < m_state.GetNumEntities(); ++i)
    {
        const Entity* entity = m_state.GetEntity(i);
        switch (entity->GetTypeId())
        {
        case EntityTypeId_Building:
            {
                const BuildingEntity* building = static_cast<const BuildingEntity*>(entity);
                Vec2 position = m_map.GetStop(building->m_stop).point;
                if (building->m_raided)
                {
                    Render_DrawSprite(m_buildingRaidedHouseTexture, static_cast<int>(position.x) - m_buildingRaidedHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2);
                }
                else
                {
                    Render_DrawSprite(m_buildingHouseTexture, static_cast<int>(position.x) - m_buildingHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2);
                }
            }
            break;
        }
    }
    glDisable(GL_TEXTURE_2D);

    // Rails.
    glLineWidth(8.0f / m_mapScale);
    glBegin(GL_LINES);
    for (int i = 0; i < m_map.GetNumRails(); ++i)
    {
        const Rail& rail  = m_map.GetRail(i);
        const Stop& stop1 = m_map.GetStop(rail.stop1);
        const Stop& stop2 = m_map.GetStop(rail.stop2);
        assert(rail.line >= 0);
        unsigned long color = m_map.GetLineColor(rail.line);
        // Draw the rails partially transparent to make the buldings more readable.
        color = (color & 0x00FFFFFF) | 0x90000000;
        glColor( color );
        glVertex(stop1.point);
        glVertex(stop2.point);
    }
    glEnd();

    // Stops.
    for (int i = 0; i < m_map.GetNumStops(); ++i)
    {
        const Stop& stop = m_map.GetStop(i);

        float inflate = 0.0f;
        if (i == m_hoverStop)
        {
            inflate = 5.0f;
        }
        if (stop.line == -1)
        {
            glColor( 0xFF000000 );
            DrawCircle(stop.point, 8.0f + inflate);
            glColor( 0xFFFFFFFF );
            DrawCircle(stop.point, 6.0f + inflate);
        }
        else
        {
            glColor( m_map.GetLineColor(stop.line) );
            DrawCircle(stop.point, 8.0f + inflate);
        }
    }

    // Draw the legend of the grid.
    Font_BeginDrawing(m_font);
    glColor(0xFF7FD6F2);
    int fontHeight = Font_GetTextHeight(m_font);
    for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x)
    {
        char buffer[32];
        sprintf(buffer, "%d", x);
        int textWidth = Font_GetTextWidth(m_font, buffer);
        Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, -outerBorder + 5);
        Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, m_yMapSize + 5);
    }
    for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y)
    {
        char buffer[32];
        sprintf(buffer, "%c", 'A' + y);
        Font_DrawText(buffer, -outerBorder + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2);
        Font_DrawText(buffer, m_xMapSize + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2);
    }

    Font_EndDrawing();


    glEnable(GL_TEXTURE_2D);    

    // DL: How about blinking for showing selection?
    const float kBlinkDuration = 0.2f;
    const float kBlinkCycleDuration = 1.0f;
    float blinkT = fmodf(m_time, kBlinkCycleDuration);
    float blinkAlpha = 1.0f;
    if (blinkT < kBlinkDuration)
    {
        blinkAlpha = (cosf(2.0f*kPi*blinkT/kBlinkDuration)+1.0f)/2.0f;
    }
    unsigned long blinkColor = (static_cast<int>(blinkAlpha*255.0f) << 24) | 0xffffff;
    
    // Entities
    int index = 0;
    const AgentEntity* agent;
    while (m_state.GetNextEntityWithType(index, agent))
    {
        if (m_selectedAgent == agent->GetId() && m_pathLength == 0)
        {
            glColor(blinkColor);
        }
        else
        {
            glColor(0xFFFFFFFF);
        }

        Vec2 position = GetAgentPosition(agent);
        if (agent->m_state == AgentEntity::State_Hacking)
        {
            Render_DrawSprite(m_agentHackingTexture, static_cast<int>(position.x) - m_agentHackingTexture.xSize / 2, static_cast<int>(position.y) - m_agentHackingTexture.ySize / 2);
        }
        else if (agent->m_state == AgentEntity::State_Stakeout)
        {
            Render_DrawSprite(m_agentStakeoutTexture, static_cast<int>(position.x) - m_agentStakeoutTexture.xSize / 2, static_cast<int>(position.y) - m_agentStakeoutTexture.ySize / 2);
        }
        else if (agent->m_intel != -1)
        {
            Render_DrawSprite(m_agentIntelTexture, static_cast<int>(position.x) - m_agentIntelTexture.xSize / 2, static_cast<int>(position.y) - m_agentIntelTexture.ySize / 2);
        }
        else
        {
            Render_DrawSprite(m_agentTexture, static_cast<int>(position.x) - m_agentTexture.xSize / 2, static_cast<int>(position.y) - m_agentTexture.ySize / 2);
        }
    }

    m_mapParticles.Draw();

    // Draw the UI.

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, m_xSize, m_ySize, 0);

    glDisable(GL_TEXTURE_2D);
    glColor(0xB0DBEDF7);
    glBegin(GL_QUADS);
    glVertex2i(0, m_ySize - yStatusBarSize);
    glVertex2i(m_xSize, m_ySize - yStatusBarSize);
    glVertex2i(m_xSize, m_ySize);
    glVertex2i(0, m_ySize);
    glEnd();

    glColor(0xFF86DDEE);
    glLineWidth(1);
    glBegin(GL_LINE_LOOP);
    glVertex2i(0, m_ySize - yStatusBarSize);
    glVertex2i(m_xSize, m_ySize - yStatusBarSize);
    glVertex2i(m_xSize, m_ySize);
    glVertex2i(0, m_ySize);
    glEnd();

    glEnable(GL_TEXTURE_2D);    

    for (int i = 0; i < ButtonId_NumButtons; ++i)
    {
        if (m_button[i].enabled)
        {
            int xButton, yButton, xButtonSize, yButtonSize;
            GetButtonRect((ButtonId)i, xButton, yButton, xButtonSize, yButtonSize);

            if (m_button[i].toggled)
            {
                glColor(0xFFB0E8E1);
            }
            else
            {
                glColor(0xFFFFFFFF);
            }
            int buttonOffset = 0;
            int shadowOffset = 10;
            Render_DrawSprite( m_buttonShadowTexture, xButton + shadowOffset, yButton + shadowOffset );
            if (m_activeButton == i && m_activeButtonDown)
            {
                buttonOffset = 5;
            }
            Render_DrawSprite( m_buttonTexture[i], xButton + buttonOffset, yButton + buttonOffset );
        }
    }

    m_notificationLog.Draw();

    const int maxPlayers = 32;
    const PlayerEntity* player[maxPlayers] = { NULL };
    int numPlayers = m_state.GetEntitiesWithType(player, maxPlayers);

    // Show the players.

    const int playerBoxHeight = 150;

    glDisable(GL_TEXTURE_2D);
    glColor(0xB0DBEDF7);
    glLineWidth(1);
    glBegin(GL_QUADS);
    for (int i = 0; i < numPlayers; ++i)
    {
        int x = m_xSize - 300;
        int y = 10 + (playerBoxHeight + 15) * i;
        glVertex2i( x, y );   
        glVertex2i( m_xSize, y );   
        glVertex2i( m_xSize, y + playerBoxHeight );   
        glVertex2i( x, y + playerBoxHeight );   
    }
    glEnd();

    glColor(0xFF86DDEE);
    glBegin(GL_LINE_LOOP);
    for (int i = 0; i < numPlayers; ++i)
    {
        int x = m_xSize - 300;
        int y = 10 + (playerBoxHeight + 15) * i;
        glVertex2i( x, y );   
        glVertex2i( m_xSize, y );   
        glVertex2i( m_xSize, y + playerBoxHeight );   
        glVertex2i( x, y + playerBoxHeight );   
    }
    glEnd();

    glEnable(GL_TEXTURE_2D);
    glColor(0xFFFFFFFF);

    const int scaledAgentWidth = (m_agentTexture.xSize * fontHeight) / m_agentTexture.ySize;
    const int scaledHouseWidth = (m_buildingHouseTexture.xSize * fontHeight) / m_buildingHouseTexture.ySize;
    const int scaledIntelWidth = (m_intelTexture.xSize * fontHeight) / m_intelTexture.ySize;

    for (int i = 0; i < numPlayers; ++i)
    {
        Render_DrawSprite(m_playerPortraitTexture, m_xSize - 290, 20 + (playerBoxHeight + 15) * i);

        int offset = 0;
        if (player[i]->m_hackingBank)
        {
            Render_DrawSprite(m_playerBankHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerBankHackedTexture.ySize);
            offset += m_playerBankHackedTexture.xSize;
        }
        if (player[i]->m_hackingTower)
        {
            Render_DrawSprite(m_playerCellHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerCellHackedTexture.ySize);
            offset += m_playerCellHackedTexture.xSize;
        }
        if (player[i]->m_hackingPolice)
        {
            Render_DrawSprite(m_playerPoliceHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerPoliceHackedTexture.ySize);
            offset += m_playerPoliceHackedTexture.xSize;
        }
        
        Render_DrawSprite(m_agentTexture, m_xSize - 280, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledAgentWidth, fontHeight);
        Render_DrawSprite(m_buildingHouseTexture, m_xSize - 180, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledHouseWidth, fontHeight);
        Render_DrawSprite(m_intelTexture, m_xSize - 80, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledIntelWidth, fontHeight);
    }

    Font_BeginDrawing(m_font);
    glColor(0xFF000000);

    for (int i = 0; i < numPlayers; ++i)
    {
        Font_DrawText(player[i]->m_name,
            m_xSize - m_playerPortraitTexture.xSize - 60,
            20 + (playerBoxHeight + 15) * i);

        char buffer[32];
        sprintf(buffer, "x%d", player[i]->m_numAgents);

        Font_DrawText(buffer,
            m_xSize - 280 + scaledAgentWidth + 5,
            playerBoxHeight - 25 + (playerBoxHeight + 15) * i);


        sprintf(buffer, "x%d", player[i]->m_numSafeHouses);
        Font_DrawText(buffer,
            m_xSize - 180 + scaledHouseWidth + 5,
            playerBoxHeight - 25 + (playerBoxHeight + 15) * i);

        sprintf(buffer, "x%d", player[i]->m_numIntels);
        Font_DrawText(buffer,
            m_xSize - 80 + scaledHouseWidth + 5,
            playerBoxHeight - 25 + (playerBoxHeight + 15) * i);
    }

    glColor(0xFF000000);
    Font_EndDrawing();


    // Tool tip.

    const char* toolTip = NULL;
    if (m_hoverButton == ButtonId_Capture)
    {
        toolTip = "Search and capture any enemy agents\nat this location";
    }
    else if (m_hoverButton == ButtonId_Stakeout)
    {
        toolTip = "Put the agent into stakeout mode\nso any enemy agents passing through\nthe stop will be detected";
    }
    else if (m_hoverButton == ButtonId_Infiltrate)
    {
        toolTip = "Search and infiltrate enemy safe\nhouses at this location";
    }
    else if (m_hoverButton == ButtonId_Hack)
    {
        toolTip = "Hack the building to gather\ninformation";
    }
    else if (m_hoverButton == ButtonId_Intel)
    {
        toolTip = "Pickup/drop the intel";
    }
    if (toolTip != NULL)
    {
        int xTipSize = 510;
        int yTipSize = 120;
        int xTip = 10;
        int yTip = m_ySize - yStatusBarSize - yTipSize - 10;

        glDisable(GL_TEXTURE_2D);
        glColor(0xB0DBEDF7);
        glLineWidth(1);
        glBegin(GL_QUADS);
        glVertex2i( xTip, yTip );   
        glVertex2i( xTip + xTipSize, yTip );   
        glVertex2i( xTip + xTipSize, yTip + yTipSize );   
        glVertex2i( xTip, yTip + yTipSize );   
        glEnd();

        glColor(0xFF86DDEE);
        glBegin(GL_LINE_LOOP);
        glVertex2i( xTip, yTip );   
        glVertex2i( xTip + xTipSize, yTip );   
        glVertex2i( xTip + xTipSize, yTip + yTipSize );   
        glVertex2i( xTip, yTip + yTipSize );   
        glEnd();

        glColor(0xFF000000);
        Font_BeginDrawing(m_font);
        Font_DrawText(toolTip, xTip + 10, yTip + 10);
        Font_EndDrawing();
    }



    glEnable(GL_TEXTURE_2D);
    glColor(0xFFFFFFFF);
    for (int i = 0; i < numPlayers; ++i)
    {
        if (player[i]->m_eliminated)
        {
            Render_DrawSprite(m_playerEliminatedTexture,
                m_xSize - 250,
                20 + (playerBoxHeight + 15) * i);
        }
    }

    m_screenParticles.Draw();

    if (m_gameState == GameState_GameOver)
    {
        
        const int windowWidth = 200;
        const int widonwHeight = 100;
        

        glDisable(GL_TEXTURE_2D);
        glColor(0xB0DBEDF7);
        glLineWidth(1);
        glBegin(GL_QUADS);

        glVertex2i( (m_xSize - windowWidth) / 2, 
                    (m_ySize - widonwHeight) / 2 );   
        glVertex2i( (m_xSize + windowWidth) / 2, 
                    (m_ySize - widonwHeight) / 2 );   
        glVertex2i( (m_xSize + windowWidth) / 2, 
                    (m_ySize + widonwHeight) / 2 );   
        glVertex2i( (m_xSize - windowWidth) / 2, 
                    (m_ySize + widonwHeight) / 2 );   
        glEnd();


        glColor(0xFF86DDEE);
        glBegin(GL_LINE_LOOP);

        glVertex2i( (m_xSize - windowWidth) / 2, 
                    (m_ySize - widonwHeight) / 2 );   
        glVertex2i( (m_xSize + windowWidth) / 2, 
                    (m_ySize - widonwHeight) / 2 );   
        glVertex2i( (m_xSize + windowWidth) / 2, 
                    (m_ySize + widonwHeight) / 2 );   
        glVertex2i( (m_xSize - windowWidth) / 2, 
                    (m_ySize + widonwHeight) / 2 );   
        glEnd();

        glEnable(GL_TEXTURE_2D);

        Font_BeginDrawing(m_font);
        const char* text = m_isWinner ? "You WIN!" : "GAME OVER";
        glColor(0xff000000);

        int textWidth = Font_GetTextWidth(m_font, text);
        Font_DrawText(text, (m_xSize - textWidth)/2, (m_ySize - fontHeight)/2);

        Font_EndDrawing();
    }


}
void COXCoolComboBox::OnPaint() 
{
	if(!IsInCoolState())
	{
		Default();
		return;
	}

	// set up all the pens we are likely to need
    HPEN penDefault=(HPEN)GetStockObject(BLACK_PEN);
    static CPen penHilite(PS_SOLID,1,GetSysColor(COLOR_3DHIGHLIGHT));
    static CPen penShadow(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW));
    static CPen penFace3D(PS_SOLID,1,GetSysColor(COLOR_3DFACE));
    static CPen penDkShad3D(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));

    // store margins for future use
    int nLeftMargin=GetLeftMargin(); 
	int nRightMargin=GetRightMargin();
	int nTopMargin=GetTopMargin();
	int nBottomMargin=GetBtmMargin();
    CRect button_rect=GetButtonRect();

	const BOOL bSimpleCombo=((GetStyle()&0x000f)==CBS_SIMPLE);
    const BOOL bIsEnabled=IsWindowEnabled();
	const BOOL bIsHot=IsInHotState() & bIsEnabled;

    // paint background
    CPaintDC paintdc(this);
    CDC* dc=&paintdc;

    CRect rect, rectClient, rectInternal; // temp rect, client rect, internal rect respectively

    GetClientRect(rectClient);
	rectClient.right-=::GetSystemMetrics(SM_CXVSCROLL)-GetButtonWidth();

	if(bSimpleCombo)
	{
		ASSERT(::IsWindow(m_edit.GetSafeHwnd()));
		CRect rectEdit;
		m_edit.GetWindowRect(rectEdit);
		rectClient.bottom=rectClient.top+rectEdit.Height()+5;
	}

    // set up internal rectangle
    rectInternal=rectClient;
    rectInternal.left+=nLeftMargin;
    rectInternal.top+=nTopMargin;
    rectInternal.right-=nRightMargin;
    rectInternal.bottom-=nBottomMargin;

    rect=rectInternal;
	if(!button_rect.IsRectEmpty())
		rect.right=button_rect.left;
    if(!bIsEnabled)
        ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_3DFACE));
    else
        ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_WINDOW));

    // do default painting
    if(!::IsWindow(m_edit.GetSafeHwnd()))
    {
        DRAWITEMSTRUCT dis={ sizeof(&dis) };
        dis.CtlType=ODT_COMBOBOX;
        dis.CtlID=GetWindowLongPtr(m_hWnd, GWL_ID);
        dis.itemID=GetCurSel();
        dis.itemAction=ODA_DRAWENTIRE;
        dis.hwndItem=m_hWnd;
        dis.hDC=dc->m_hDC;
        dis.rcItem=CRect(nLeftMargin+1,nTopMargin+1, 
			button_rect.left-1,rectClient.bottom-nBottomMargin-1);
        dis.itemData=GetItemData(GetCurSel());
        dis.itemState=((::GetFocus()==GetSafeHwnd() && !IsDroppedDown()) ? 
			ODS_FOCUS : 0);

        DrawItem(&dis);
    }

    // now do our painting - first borderect...
    // but first exclude the 'real' client area from the DC
    dc->SelectClipRgn(NULL);   // from drawing background
    dc->ExcludeClipRect(&rectInternal);

    // draw border
	if(!bIsHot)
	{
		// now paint background 
	    if(bSimpleCombo)
			FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_WINDOW));
		else
			FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_3DFACE));

		// fill in small area to the left of edit window in appropriate colour, 
		// to make window look bigger
		rect=rectClient;
		rect.top+=nTopMargin;
		rect.left+=nLeftMargin-1;
		rect.right=rect.left+1;
		rect.bottom-=nBottomMargin;

		if(bIsEnabled)
			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_WINDOW));
		else
			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
	}
	else
	{
		// HOT case - difficult to describe, but reasonably obvious
		rect=rectClient;
		rect.left++;
		rect.right--;
		rect.top++;
		rect.bottom-=1+EXTRA_BOTTOM_MARGIN;            

		// paint background 
		FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));

		// and border
		rect=rectClient;
		SelectObject(dc->m_hDC,penShadow);
		dc->MoveTo(0,0);
		dc->LineTo(rect.right,0);
		dc->MoveTo(0,0);
		dc->LineTo(0,rect.bottom-1-EXTRA_BOTTOM_MARGIN);

		SelectObject(dc->m_hDC,penHilite);
		dc->LineTo(rect.right-1,rect.bottom-1-EXTRA_BOTTOM_MARGIN);
		dc->LineTo(rect.right-1,rect.top);

		// and paint extra margin
		if(EXTRA_BOTTOM_MARGIN)
		{
			rect=rectClient;
			rect.top=rect.bottom-EXTRA_BOTTOM_MARGIN;        

			FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
		}
	}

    // unselect the clip region
    SelectClipRgn(dc->m_hDC, NULL);

    // now draw highlight border, if disabled
    if(!bIsEnabled)
    {
        SelectObject(dc->m_hDC, GetStockObject(NULL_BRUSH));
        SelectObject(dc->m_hDC, penHilite);
        dc->Rectangle(rectInternal.left-1, rectInternal.top-1, 
			rectInternal.right+1, rectInternal.bottom+1);
    }

    // and now for the button
    BOOL pressed=IsDroppedDown();
    rect=button_rect;

    // do the background
    if(bIsHot)
    {
        rect.bottom--;
        rect.right++;
    }

    if(bIsHot || pressed || !bIsEnabled)
    {
        ::FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE));
    }
    else
    {
		if(bIsEnabled)
		{
			// cold and unpressed
			SelectObject(dc->m_hDC, penHilite);
			SelectObject(dc->m_hDC, GetSysColorBrush(COLOR_3DFACE));
			::Rectangle(dc->m_hDC, rect.left, rect.top, rect.right, rect.bottom);
		}
    }

    rect=button_rect; // set again

    if(bIsHot || pressed)
    {
        if(pressed)
        {
            SelectObject(dc->m_hDC, penShadow);
            dc->MoveTo(rect.left , rect.top);
            dc->LineTo(rect.right, rect.top);
            dc->MoveTo(rect.left , rect.top);
            dc->LineTo(rect.left , rect.bottom);
        }
        else
        {
            SelectObject(dc->m_hDC, penHilite);
            dc->MoveTo(rect.right,  rect.top);
            dc->LineTo(rect.left+1, rect.top);
            dc->LineTo(rect.left+1, rect.bottom);
            SelectObject(dc->m_hDC, penFace3D);
            dc->MoveTo(rect.left, rect.top);
            dc->LineTo(rect.left, rect.bottom);
            SelectObject(dc->m_hDC, penShadow);
            dc->MoveTo(rect.left , rect.bottom - 1);
            dc->LineTo(rect.right-1, rect.bottom - 1);
            dc->LineTo(rect.right-1, rect.top);
        }

        SelectObject(dc->m_hDC, penDefault);
    }

    // now draw shadowy arrow
    SelectObject(dc->m_hDC, penDkShad3D);
    SelectObject(dc->m_hDC, ::GetSysColorBrush(COLOR_3DDKSHADOW));

    POINT p[3];

    p[0].x=rect.left +((rect.right - rect.left) / 3);
    p[1].x=rect.left +(2 *(rect.right - rect.left) / 3) + 1;
    p[2].x=(p[0].x + p[1].x) / 2;

    if(((p[1].x - p[0].x) % 2))
        p[1].x--;

    p[0].y=(rect.top + rect.bottom / 2) -(p[1].x - p[0].x) / 4 - 1;
    p[1].y=p[0].y;
    p[2].y=p[0].y +(p[1].x - p[0].x) / 2;

    if(pressed)    // offset by a pixel
    {
        p[0].x++;
        p[0].y++;
        p[1].x++;
        p[1].y++;
        p[2].x++;
        p[2].y++;
    }

    Polygon(dc->m_hDC, p, 3);

}