本文整理汇总了C++中wxColour类的典型用法代码示例。如果您正苦于以下问题:C++ wxColour类的具体用法?C++ wxColour怎么用?C++ wxColour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxColour类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBackgroundColour
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;
}
示例2: selector
void colorPatternArea::OnMouse(wxMouseEvent &event) {
if (mID < kNumPatterns && event.LeftDClick()) {
patternSelectDlg selector(this);
if (selector.ShowModal() == wxOK) {
}
}
if (mID >= ID_BITMAP_SLT && mID < ID_BITMAP_SLT + kNumPatterns) //exclude color areas in the left panel
{
if ( mID >= ID_BITMAP_SLT && (event.Entering() || mID == dynamic_cast<patternSelectDlg*>(mParent)->getSltId()) ) {
//"distance" of two colors
if ( pow((float)(mCurrentColor.Red()-defaultColor.Red()),2.0f) + pow((float)(mCurrentColor.Green()-defaultColor.Green()),2.0f) + pow((float)(mCurrentColor.Blue()-defaultColor.Blue()),2.0f) < 500)
SetBackgroundColour(wxColour(68,68,68));
else
SetBackgroundColour(defaultColor);
}
if ( event.Leaving() && mID >= ID_BITMAP_SLT && mPatID != dynamic_cast<patternSelectDlg*>(mParent)->getSltPatId() )
SetBackgroundColour(mCurrentColor);
if (event.LeftDown() && mID >= ID_BITMAP_SLT) {
dynamic_cast<patternSelectDlg*>(mParent)->setSltId(mID);
}
}
}
示例3: SetDefaultFgColour
void LexerConf::SetDefaultFgColour(const wxColour& colour)
{
StyleProperty& style = GetProperty(0);
if(!style.IsNull()) {
style.SetFgColour(colour.GetAsString(wxC2S_HTML_SYNTAX));
}
}
示例4: RGB_2_HSL
wxColor DrawingUtils::DarkColour(const wxColour& color, float percent)
{
if(percent == 0) {
return color;
}
float h, s, l, r, g, b;
RGB_2_HSL(color.Red(), color.Green(), color.Blue(), &h, &s, &l);
// reduce the Lum value
l -= (float)((percent * 5.0)/100.0);
if (l < 0) l = 0.0;
HSL_2_RGB(h, s, l, &r, &g, &b);
return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b);
}
示例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: 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)
);
}
}
示例7: wxDoChangeForegroundColour
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);
}
}
示例8: GetColourFromUser
wxColour GetColourFromUser(wxWindow* parent, const wxColour& colInit)
{
#ifdef __WXMSW__
const wxString caption = _("Choose color");
#else
const wxString caption = _("Choose color (only first 16 will be saved)");
#endif
const wxString palette = _T("Default");
wxColourData data;
data = sett().GetCustomColors(palette);
data.SetChooseFull(true);
if (colInit.Ok()) {
data.SetColour((wxColour&)colInit); // const_cast
}
wxColour colRet;
wxColourDialog dialog(parent, &data);
if (!caption.empty())
dialog.SetTitle(caption);
if (dialog.ShowModal() == wxID_OK) {
colRet = dialog.GetColourData().GetColour();
}
//else: leave it invalid
sett().SaveCustomColors(dialog.GetColourData(), palette);
return colRet;
}
示例9: SetLineNumbersFgColour
void LexerConf::SetLineNumbersFgColour(const wxColour& colour)
{
StyleProperty& style = GetProperty(LINE_NUMBERS_ATTR_ID);
if(!style.IsNull()) {
style.SetFgColour(colour.GetAsString(wxC2S_HTML_SYNTAX));
}
}
示例10: ChannelBlend
void PixelBufferClass::Get2ColorBlend(int layer, int coloridx1, int coloridx2, double ratio, wxColour &color)
{
wxColour c1,c2;
palette[layer].GetColor(coloridx1,c1);
palette[layer].GetColor(coloridx2,c2);
color.Set(ChannelBlend(c1.Red(),c2.Red(),ratio), ChannelBlend(c1.Green(),c2.Green(),ratio), ChannelBlend(c1.Blue(),c2.Blue(),ratio));
}
示例11: wxColourPickerWidget
bool wxColourPickerCtrl::Create( wxWindow *parent, wxWindowID id,
const wxColour &col,
const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator,
const wxString &name )
{
if (!wxPickerBase::CreateBase(parent, id, col.GetAsString(), pos, size,
style, validator, name))
return false;
// we are not interested to the ID of our picker as we connect
// to its "changed" event dynamically...
m_picker = new wxColourPickerWidget(this, wxID_ANY, col,
wxDefaultPosition, wxDefaultSize,
GetPickerStyle(style));
// complete sizer creation
wxPickerBase::PostCreation();
m_picker->Connect(wxEVT_COMMAND_COLOURPICKER_CHANGED,
wxColourPickerEventHandler(wxColourPickerCtrl::OnColourChange),
NULL, this);
return true;
}
示例12: wxPenRefData
wxPen::wxPen(const wxColour& col, int width, int style)
{
m_refData = new wxPenRefData();
M_PENDATA.setWidth(width);
M_PENDATA.setStyle(ConvertPenStyle((wxPenStyle)style));
M_PENDATA.setColor(col.GetHandle());
}
示例13: ChannelBlend
void RgbEffects::Get2ColorBlend(int coloridx1, int coloridx2, double ratio, wxColour &color)
{
wxColour c1,c2;
palette.GetColor(coloridx1,c1);
palette.GetColor(coloridx2,c2);
color.Set(ChannelBlend(c1.Red(),c2.Red(),ratio), ChannelBlend(c1.Green(),c2.Green(),ratio), ChannelBlend(c1.Blue(),c2.Blue(),ratio));
}
示例14: blend50
wxColour blend50(const wxColour& c1, const wxColour& c2)
{
unsigned char r,g,b,a;
r = c1.Red()/2 + c2.Red()/2;
g = c1.Green()/2 + c2.Green()/2;
b = c1.Blue()/2 + c2.Blue()/2;
a = c1.Alpha()/2 + c2.Alpha()/2;
return a << 24 | b << 16 | g << 8 | r;
}
示例15: wxColour
wxColour Drawing::darkColour(const wxColour& colour, float percent)
{
if(percent == 0)
{
return colour;
}
// Convert to HSL
hsl_t hsl = Misc::rgbToHsl(rgba_t(colour.Red(), colour.Green(), colour.Blue()));
// Decrease luminance
hsl.l -= (float)((percent * 5.0)/100.0);
if (hsl.l < 0) hsl.l = 0;
rgba_t rgb = Misc::hslToRgb(hsl);
return wxColour(rgb.r, rgb.g, rgb.b);
}