本文整理汇总了C++中wxDC::GetHPS方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetHPS方法的具体用法?C++ wxDC::GetHPS怎么用?C++ wxDC::GetHPS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetHPS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDrawItem
// draw the item
bool wxOwnerDrawn::OnDrawItem(
wxDC& rDC
, const wxRect& rRect
, wxODAction eAction
, wxODStatus eStatus
)
{
//
// We do nothing on focus change
//
if (eAction == wxODFocusChanged )
return TRUE;
//
// Select the font and draw the text
// ---------------------------------
//
CHARBUNDLE vCbnd;
HPS hPS= rDC.GetHPS();
wxColour vColBack;
wxColour vColText;
COLORREF vRef;
RECTL vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height};
memset(&vCbnd, 0, sizeof(CHARBUNDLE));
//
// Use default font if no font set
//
if (m_font.Ok())
{
m_font.RealizeResource();
}
else
{
::GpiSetCharSet(hPS, LCID_DEFAULT);
}
//
// Based on the status of the menu item, pick the right colors
//
if (eStatus & wxODSelected)
{
wxColour vCol2(wxT("WHITE"));
vColBack.Set( (unsigned char)0
,(unsigned char)0
,(unsigned char)160
); // no dark blue in color table
vColText = vCol2;
}
else if (eStatus & wxODDisabled)
{
vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENU // Light gray
,0L
);
vColBack.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENUDISABLEDTEXT // dark gray
,0L
);
vColText.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
}
else
{
//
// Fall back to default colors if none explicitly specified
//
vRef = ::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_MENU // we are using gray for all our window backgrounds in wxWidgets
,0L
);
vColBack.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
vRef = ::WinQuerySysColor( HWND_DESKTOP
,SYSCLR_WINDOWTEXT // Black
,0L
);
vColText.Set( GetRValue(vRef)
,GetGValue(vRef)
,GetBValue(vRef)
);
}
rDC.SetTextBackground(vColBack);
rDC.SetTextForeground(vColText);
rDC.SetBackgroundMode(wxTRANSPARENT);
vCbnd.lColor = vColText.GetPixel();
vCbnd.lBackColor = vColBack.GetPixel();
::GpiSetAttrs( hPS
//.........这里部分代码省略.........
示例2: OnDrawItem
bool wxCheckListBoxItem::OnDrawItem (
wxDC& rDc
, const wxRect& rRect
, wxODAction eAct
, wxODStatus eStat
)
{
wxRect vRect = rRect;
::WinQueryWindowRect( m_pParent->GetHWND()
,&rDc.m_vRclPaint
);
if (IsChecked())
eStat = (wxOwnerDrawn::wxODStatus)(eStat | wxOwnerDrawn::wxODChecked);
//
// Unfortunately PM doesn't quite get the text position exact. We need to alter
// it down and to the right, just a little bit. The coords in rRect are OS/2
// coords not wxWidgets coords.
//
vRect.x += 5;
vRect.y -= 3;
if (wxOwnerDrawn::OnDrawItem( rDc
,vRect
,eAct
,eStat))
{
size_t nCheckWidth = GetDefaultMarginWidth();
size_t nCheckHeight = m_pParent->GetItemHeight();
int nParentHeight;
int nX = rRect.GetX();
int nY = rRect.GetY();
int nOldY = nY;
wxColour vColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
wxPen vPenBack;
wxPen vPenGray;
wxPen vPenPrev;
m_pParent->GetSize( NULL
,&nParentHeight
);
nY = nParentHeight - nY - nCheckHeight;
vPenBack = wxPen(vColour, 1, wxSOLID);
vPenGray = wxPen(wxColour(127, 127, 127), 1, wxSOLID);
//
// Erase the 1-pixel border
//
rDc.SetPen(vPenBack);
rDc.DrawRectangle( nX
,nY
,nCheckWidth
,nCheckHeight
);
//
// Now we draw the smaller rectangle
//
nY++;
nCheckWidth -= 2;
nCheckHeight -= 2;
//
// Draw hollow gray rectangle
//
rDc.SetPen(vPenGray);
rDc.DrawRectangle( nX
,nY
,nCheckWidth
,nCheckHeight
);
nX++;
if (IsChecked())
{
//
// Draw the check by loading the sys standard bitmap and drawing it
//
HBITMAP hChkBmp = ::WinGetSysBitmap( HWND_DESKTOP
,SBMP_MENUCHECK
);
POINTL vPoint = {nX, nOldY + 3};
::WinDrawBitmap( rDc.GetHPS()
,hChkBmp
,NULL
,&vPoint
,NULL
,NULL
,DBM_NORMAL
);
}
return TRUE;
}
return FALSE;
} // end of wxCheckListBoxItem::OnDrawItem