本文整理汇总了C++中wxColour::IsOk方法的典型用法代码示例。如果您正苦于以下问题:C++ wxColour::IsOk方法的具体用法?C++ wxColour::IsOk怎么用?C++ wxColour::IsOk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxColour
的用法示例。
在下文中一共展示了wxColour::IsOk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoChangeFont
void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
{
m_canvas->SetTextFont(font);
if ( col.IsOk() )
m_canvas->SetColour(col);
m_canvas->Refresh();
m_textctrl->SetFont(font);
if ( col.IsOk() )
m_textctrl->SetForegroundColour(col);
m_textctrl->Refresh();
// update the state of the bold/italic/underlined menu items
wxMenuBar *mbar = GetMenuBar();
if ( mbar )
{
mbar->Check(Font_Light, font.GetWeight() == wxFONTWEIGHT_LIGHT);
mbar->Check(Font_Bold, font.GetWeight() == wxFONTWEIGHT_BOLD);
mbar->Check(Font_Italic, font.GetStyle() == wxFONTSTYLE_ITALIC);
#ifndef __WXMSW__
mbar->Check(Font_Slant, font.GetStyle() == wxFONTSTYLE_SLANT);
#endif
mbar->Check(Font_Underlined, font.GetUnderlined());
mbar->Check(Font_Strikethrough, font.GetStrikethrough());
}
}
示例2: DoMSWControlColor
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
{
HDC hdc = (HDC)pDC;
WXHBRUSH hbr = 0;
if ( !colBg.IsOk() )
{
if ( wxWindow *win = wxFindWinFromHandle(hWnd) )
hbr = win->MSWGetBgBrush(pDC);
// if the control doesn't have any bg colour, foreground colour will be
// ignored as the return value would be 0 -- so forcefully give it a
// non default background brush in this case
if ( !hbr && m_hasFgCol )
colBg = GetBackgroundColour();
}
// use the background colour override if a valid colour is given: this is
// used when the control is disabled to grey it out and also if colBg was
// set just above
if ( colBg.IsOk() )
{
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg);
hbr = (WXHBRUSH)brush->GetResourceHandle();
}
// always set the foreground colour if we changed the background, whether
// m_hasFgCol is true or not: if it true, we must do it, of course, but
// even if it isn't, we must set the default foreground explicitly as by
// default just the simple black is used
if ( hbr )
{
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
}
// finally also set the background colour for text drawing: without this,
// the text in an edit control is drawn using the default background even
// if we return a valid brush
if ( colBg.IsOk() || m_hasBgCol )
{
if ( !colBg.IsOk() )
colBg = GetBackgroundColour();
::SetBkColor(hdc, wxColourToRGB(colBg));
}
return hbr;
}
示例3: SetForegroundColour
void wxMenu::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col;
if (!col.IsOk())
return;
if (m_menuWidget)
wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col);
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
# pragma ivdep
# pragma swp
# pragma unroll
# pragma prefetch
# if 0
# pragma simd noassert
# endif
#endif /* VDM auto patch */
for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem* item = node->GetData();
if (item->GetButtonWidget())
{
// This crashes because it uses gadgets
// wxDoChangeForegroundColour(item->GetButtonWidget(), (wxColour&) col);
}
if (item->GetSubMenu())
item->GetSubMenu()->SetForegroundColour((wxColour&) col);
}
}
示例4: CallParseInnerWithBg
// Call ParseInner() preserving background colour and mode after any
// changes done by it.
void CallParseInnerWithBg(const wxHtmlTag& tag, const wxColour& colBg)
{
const wxColour oldbackclr = m_WParser->GetActualBackgroundColor();
const int oldbackmode = m_WParser->GetActualBackgroundMode();
if ( colBg.IsOk() )
{
m_WParser->SetActualBackgroundColor(colBg);
m_WParser->SetActualBackgroundMode(wxBRUSHSTYLE_SOLID);
m_WParser->GetContainer()->InsertCell(
new wxHtmlColourCell(colBg, wxHTML_CLR_BACKGROUND)
);
}
ParseInner(tag);
if ( oldbackmode != m_WParser->GetActualBackgroundMode() ||
oldbackclr != m_WParser->GetActualBackgroundColor() )
{
m_WParser->SetActualBackgroundMode(oldbackmode);
m_WParser->SetActualBackgroundColor(oldbackclr);
m_WParser->GetContainer()->InsertCell(
new wxHtmlColourCell(oldbackclr,
oldbackmode == wxBRUSHSTYLE_TRANSPARENT
? wxHTML_CLR_TRANSPARENT_BACKGROUND
: wxHTML_CLR_BACKGROUND)
);
}
}
示例5: IsSelected
bool
wxVListBox::DoDrawSolidBackground(const wxColour& col,
wxDC& dc,
const wxRect& rect,
size_t n) const
{
if ( !col.IsOk() )
return false;
// we need to render selected and current items differently
const bool isSelected = IsSelected(n),
isCurrent = IsCurrent(n);
if ( isSelected || isCurrent )
{
if ( isSelected )
{
dc.SetBrush(wxBrush(col, wxBRUSHSTYLE_SOLID));
}
else // !selected
{
dc.SetBrush(*wxTRANSPARENT_BRUSH);
}
dc.SetPen(*(isCurrent ? wxBLACK_PEN : wxTRANSPARENT_PEN));
dc.DrawRectangle(rect);
}
//else: do nothing for the normal items
return true;
}
示例6: getReadonlyColour
wxColour FRLayoutConfig::getReadonlyColour()
{
static wxColour colourReadOnly;
if (!colourReadOnly.IsOk())
{
// first try to compute a colour that is between "white" and "gray"
// (but use the actual system colours instead of hard-coded values)
wxColour clWnd(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
int r1 = clWnd.Red(), g1 = clWnd.Green(), b1 = clWnd.Blue();
wxColour clBtn = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
int r2 = clBtn.Red(), g2 = clBtn.Green(), b2 = clBtn.Blue();
int distance = abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2);
if (distance >= 72)
{
// start at 50 %, and use progressively lighter colours for larger
// distances between white and gray
int scale = (distance >= 192) ? distance / 64 : 2;
colourReadOnly.Set(r1 + (r2 - r1) / scale,
g1 + (g2 - g1) / scale, b1 + (b2 - b1) / scale);
}
else
{
// wxSYS_COLOUR_WINDOW and wxSYS_COLOUR_BTNFACE are too similar
// compute a darker shade of wxSYS_COLOUR_WINDOW
RgbHsvConversion rgbhsv(clWnd);
rgbhsv.setValue(std::max(0.0, rgbhsv.getValue() - 0.05));
colourReadOnly = rgbhsv.getColour();
}
}
return colourReadOnly;
}
示例7: MSWMakeOwnerDrawn
void
wxMSWOwnerDrawnButtonBase::MSWMakeOwnerDrawnIfNecessary(const wxColour& colFg)
{
// The only way to change the checkbox foreground colour when using
// themes is to owner draw it.
if ( wxUxThemeEngine::GetIfActive() )
MSWMakeOwnerDrawn(colFg.IsOk());
}
示例8:
RgbHsvConversion::RgbHsvConversion(const wxColour& colour)
{
redM = colour.Red() / 255.0;
greenM = colour.Green() / 255.0;
blueM = colour.Blue() / 255.0;
rgbValidM = colour.IsOk();
hueM = 0.0;
satM = 0.0;
valM = 0.0;
hsvValidM = false;
}
示例9: SetForegroundColour
bool wxCheckBox::SetForegroundColour(const wxColour& colour)
{
if ( !wxCheckBoxBase::SetForegroundColour(colour) )
return false;
// the only way to change the checkbox foreground colour under Windows XP
// is to owner draw it
if ( wxUxThemeEngine::GetIfActive() )
MSWMakeOwnerDrawn(colour.IsOk());
return true;
}
示例10: wxGetColourFromUser
wxColour wxGetColourFromUser(wxWindow *parent,
const wxColour& colInit,
const wxString& caption,
wxColourData *ptrData)
{
// contains serialized representation of wxColourData used the last time
// the dialog was shown: we want to reuse it the next time in order to show
// the same custom colours to the user (and we can't just have static
// wxColourData itself because it's a GUI object and so should be destroyed
// before GUI shutdown and doing it during static cleanup is too late)
static wxString s_strColourData;
wxColourData data;
if ( !ptrData )
{
ptrData = &data;
if ( !s_strColourData.empty() )
{
if ( !data.FromString(s_strColourData) )
{
wxFAIL_MSG( "bug in wxColourData::FromString()?" );
}
#ifdef __WXMSW__
// we don't get back the "choose full" flag value from the native
// dialog and so we can't preserve it between runs, so we decide to
// always use it as it seems better than not using it (user can
// just ignore the extra controls in the dialog but having to click
// a button each time to show them would be very annoying
data.SetChooseFull(true);
#endif // __WXMSW__
}
}
if ( colInit.IsOk() )
{
ptrData->SetColour(colInit);
}
wxColour colRet;
wxColourDialog dialog(parent, ptrData);
if (!caption.empty())
dialog.SetTitle(caption);
if ( dialog.ShowModal() == wxID_OK )
{
*ptrData = dialog.GetColourData();
colRet = ptrData->GetColour();
s_strColourData = ptrData->ToString();
}
//else: leave colRet invalid
return colRet;
}
示例11: SetTextForeground
void wxGCDCImpl::SetTextForeground( const wxColour &col )
{
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
// don't set m_textForegroundColour to an invalid colour as we'd crash
// later then (we use m_textForegroundColour.GetColor() without checking
// in a few places)
if ( col.IsOk() )
{
m_textForegroundColour = col;
m_graphicContext->SetFont( m_font, m_textForegroundColour );
}
}
示例12: DrawTab
virtual void DrawTab(wxDC &dc, wxWindow *wnd, const wxAuiNotebookPage &page, const wxRect &rect, int close_button_state, wxRect *out_tab_rect, wxRect *out_button_rect, int *x_extent)
{
wxColour const tint = m_pNotebook->GetTabColour(page.window);
if (tint.IsOk()) {
#if !defined(__WXGTK__) || !defined(wxHAS_NATIVE_TABART)
wxColour const baseOrig = m_baseColour;
wxColour const activeOrig = m_activeColour;
wxColour const base(
wxColour::AlphaBlend(tint.Red(), baseOrig.Red(), tint.Alpha() / 255.0f),
wxColour::AlphaBlend(tint.Green(), baseOrig.Green(), tint.Alpha() / 255.0f),
wxColour::AlphaBlend(tint.Blue(), baseOrig.Blue(), tint.Alpha() / 255.0f));
wxColour const active(
wxColour::AlphaBlend(tint.Red(), activeOrig.Red(), tint.Alpha() / 255.0f),
wxColour::AlphaBlend(tint.Green(), activeOrig.Green(), tint.Alpha() / 255.0f),
wxColour::AlphaBlend(tint.Blue(), activeOrig.Blue(), tint.Alpha() / 255.0f));
m_baseColour = base;
m_activeColour = active;
wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent);
m_baseColour = baseOrig;
m_activeColour = baseOrig;
#else
wxRect tab_rect;
if (!out_tab_rect) {
out_tab_rect = &tab_rect;
}
wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent);
wxMemoryDC *mdc = dynamic_cast<wxMemoryDC*>(&dc);
if (mdc) {
wxGraphicsContext *gc = wxGraphicsContext::Create(*mdc);
if (gc) {
gc->SetBrush(wxBrush(tint));
gc->DrawRectangle(out_tab_rect->x, out_tab_rect->y, out_tab_rect->width, out_tab_rect->height);
delete gc;
}
}
#endif
}
else {
wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent);
}
}
示例13: GetColourToUse
void wxMenuItem::GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const
{
#if wxUSE_UXTHEME
wxUxThemeEngine* theme = MenuDrawData::GetUxThemeEngine();
if ( theme )
{
wxUxThemeHandle hTheme(GetMenu()->GetWindow(), L"MENU");
if ( stat & wxODDisabled)
{
wxRGBToColour(colText, theme->GetThemeSysColor(hTheme, COLOR_GRAYTEXT));
}
else
{
colText = GetTextColour();
if ( !colText.IsOk() )
wxRGBToColour(colText, theme->GetThemeSysColor(hTheme, COLOR_MENUTEXT));
}
if ( stat & wxODSelected )
{
wxRGBToColour(colBack, theme->GetThemeSysColor(hTheme, COLOR_HIGHLIGHT));
}
else
{
colBack = GetBackgroundColour();
if ( !colBack.IsOk() )
wxRGBToColour(colBack, theme->GetThemeSysColor(hTheme, COLOR_MENU));
}
}
else
#endif // wxUSE_UXTHEME
{
wxOwnerDrawn::GetColourToUse(stat, colText, colBack);
}
}
示例14: SetForegroundColour
bool wxMenuBar::SetForegroundColour(const wxColour& col)
{
if (!wxWindowBase::SetForegroundColour(col))
return false;
if (!col.IsOk())
return false;
if (m_mainWidget)
wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
m_menus.Item(i)->GetData()->SetForegroundColour((wxColour&) col);
return true;
}
示例15: setPenColor
/*****************************************************
**
** DcPainter --- setPenColor
**
******************************************************/
void DcPainter::setPenColor( const wxColour &c )
{
if ( ! c.IsOk() )
{
wxLogError( wxT( "pen color not okay, using default pen" ));
setDefaultPen();
}
else
{
wxPen currentPen = dc->GetPen();
if ( currentPen.IsOk() )
{
dc->SetPen( wxPen( c, currentPen.GetWidth(), currentPen.GetStyle() ));
}
else dc->SetPen( wxPen( c, 1, wxSOLID ));
}
}