本文整理汇总了C++中QColor::pixel方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::pixel方法的具体用法?C++ QColor::pixel怎么用?C++ QColor::pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::pixel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: colorIndex
uint QGLContext::colorIndex( const QColor& c ) const
{
if ( isValid() ) {
if ( format().plane()
&& c.pixel() == overlayTransparentColor().pixel() )
return c.pixel(); // Special; don't look-up
if ( ((XVisualInfo*)vi)->visualid ==
XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual() ) )
return c.pixel(); // We're using QColor's cmap
CMapEntry *x = cmap_dict->find( (long)((XVisualInfo*)vi)->visualid );
if ( x && !x->alloc) { // It's a standard colormap
int rf = (int)(((float)c.red() * (x->scmap.red_max+1))/256.0);
int gf = (int)(((float)c.green() * (x->scmap.green_max+1))/256.0);
int bf = (int)(((float)c.blue() * (x->scmap.blue_max+1))/256.0);
uint p = x->scmap.base_pixel
+ ( rf * x->scmap.red_mult )
+ ( gf * x->scmap.green_mult )
+ ( bf * x->scmap.blue_mult );
return p;
}
else
return c.pixel(); // ### wrong; should really ask QColor to alloc
}
return 0;
}
示例2: colorIndex
uint QGLContext::colorIndex( const QColor& c ) const
{
int screen = ((XVisualInfo *)vi)->screen;
if ( isValid() ) {
if ( format().plane()
&& c.pixel( screen ) == overlayTransparentColor().pixel( screen ) )
return c.pixel( screen ); // Special; don't look-up
if ( ((XVisualInfo*)vi)->visualid ==
XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual( screen ) ) )
return c.pixel( screen ); // We're using QColor's cmap
XVisualInfo *info = (XVisualInfo *) vi;
CMapEntry *x = cmap_dict->find( (long) info->visualid + ( info->screen * 256 ) );
if ( x && !x->alloc) { // It's a standard colormap
int rf = (int)(((float)c.red() * (x->scmap.red_max+1))/256.0);
int gf = (int)(((float)c.green() * (x->scmap.green_max+1))/256.0);
int bf = (int)(((float)c.blue() * (x->scmap.blue_max+1))/256.0);
uint p = x->scmap.base_pixel
+ ( rf * x->scmap.red_mult )
+ ( gf * x->scmap.green_mult )
+ ( bf * x->scmap.blue_mult );
return p;
} else {
if (!qglcmap_dict) {
qglcmap_dict = new QIntDict< QMap<int, QRgb> >;
}
QMap<int, QRgb> *cmap;
if ((cmap = qglcmap_dict->find((long) info->visualid)) == 0) {
cmap = new QMap<int, QRgb>;
qglcmap_dict->insert((long) info->visualid, cmap);
}
// already in the map?
QRgb target = c.rgb();
QMap<int, QRgb>::Iterator it = cmap->begin();
for (; it != cmap->end(); ++it) {
if ((*it) == target)
return it.key();
}
// need to alloc color
unsigned long plane_mask[2];
unsigned long color_map_entry;
if (!XAllocColorCells (QPaintDevice::x11AppDisplay(), x->cmap, TRUE, plane_mask, 0,
&color_map_entry, 1))
return c.pixel(screen);
XColor col;
col.flags = DoRed | DoGreen | DoBlue;
col.pixel = color_map_entry;
col.red = (ushort)((qRed(c.rgb()) / 255.0) * 65535.0 + 0.5);
col.green = (ushort)((qGreen(c.rgb()) / 255.0) * 65535.0 + 0.5);
col.blue = (ushort)((qBlue(c.rgb()) / 255.0) * 65535.0 + 0.5);
XStoreColor(QPaintDevice::x11AppDisplay(), x->cmap, &col);
cmap->insert(color_map_entry, target);
return color_map_entry;
}
}
return 0;
}
示例3: reparent_good
// taken from qt/x11 (doing this sucks sucks sucks sucks sucks)
void reparent_good(QWidget *that, Qt::WindowFlags f, bool showIt)
{
extern void qPRCreate( const QWidget *, Window );
extern void qt_XDestroyWindow( const QWidget *destroyer, Display *display, Window window );
extern bool qt_dnd_enable( QWidget* w, bool on );
QWidget *parent = 0;
Display *dpy = that->x11Display();
QCursor oldcurs;
bool setcurs = that->windowState(Qt::WState_OwnCursor);
if ( setcurs ) {
oldcurs = that->cursor();
that->unsetCursor();
}
// dnd unregister (we will register again below)
bool accept_drops = that->acceptDrops();
that->setAcceptDrops( false );
// clear mouse tracking, re-enabled below
bool mouse_tracking = that->hasMouseTracking();
that->clearWState(Qt::WState_MouseTracking);
QWidget* oldtlw = that->window();
QWidget *oldparent = that->parentWidget();
WId old_winid = that->winid;
if ( that->windowFlags(Qt::WType_Desktop) )
old_winid = 0;
that->setWinId( 0 );
// hide and reparent our own window away. Otherwise we might get
// destroyed when emitting the child remove event below. See QWorkspace.
XUnmapWindow( that->x11Display(), old_winid );
XReparentWindow( that->x11Display(), old_winid,
RootWindow( that->x11Display(), that->x11Screen() ), 0, 0 );
if ( that->isTopLevel() ) {
// input contexts are associated with toplevel widgets, so we need
// destroy the context here. if we are reparenting back to toplevel,
// then we will have another context created, otherwise we will
// use our new toplevel's context
that->destroyInputContext();
}
if ( that->isTopLevel() || !parent ) // we are toplevel, or reparenting to toplevel
that->topData()->parentWinId = 0;
if ( parent != that->parentObj ) {
if ( that->parentObj ) // remove from parent
that->parentObj->removeChild( that );
if ( parent ) // insert into new parent
parent->insertChild( that );
}
bool enable = that->isEnabled(); // remember status
Qt::FocusPolicy fp = that->focusPolicy();
QSize s = that->size();
QPixmap *bgp = (QPixmap *)that->backgroundPixmap();
QColor bgc = that->bg_col; // save colors
QString capt= that->caption();
that->widget_flags = f;
that->clearWState( Qt::WState_Created | Qt::WState_Visible | Qt::WState_ForceHide );
that->create();
if ( that->isTopLevel() || (!parent || parent->isVisible() ) )
that->setWState( Qt::WState_ForceHide ); // new widgets do not show up in already visible parents
const QObjectList *chlist = that->children();
if ( chlist ) { // reparent children
QObjectListIt it( *chlist );
QObject *obj;
while ( (obj=it.current()) ) {
if ( obj->isWidgetType() ) {
QWidget *w = (QWidget *)obj;
if ( !w->isTopLevel() ) {
XReparentWindow( that->x11Display(), w->winId(), that->winId(),
w->geometry().x(), w->geometry().y() );
} else if ( w->isPopup()
|| w->windowFlags(Qt::WStyle_DialogBorder)
|| w->windowFlags(Qt::WType_Dialog)
|| w->windowFlags(Qt::WStyle_Tool) ) {
XSetTransientForHint( that->x11Display(), w->winId(), that->winId() );
}
}
++it;
}
}
qPRCreate( that, old_winid );
if ( bgp )
XSetWindowBackgroundPixmap( dpy, that->winid, bgp->handle() );
else
XSetWindowBackground( dpy, that->winid, bgc.pixel(that->x11Screen()) );
// all this just to do a stupid resize instead of setGeometry
//setGeometry( p.x(), p.y(), s.width(), s.height() );
that->resize(s.width(), s.height());
that->setEnabled( enable );
that->setFocusPolicy( fp );
if ( !capt.isNull() ) {
that->extra->topextra->caption = QString::null;
//.........这里部分代码省略.........