static const QScreen *parentScreen (const QScreen *current, const QScreen *lookingFor) { if (!current) return 0; switch (current->classId()) { case QScreen::ProxyClass: case QScreen::TransformedClass: { const QScreen *child = static_cast<const QProxyScreen *>(current)->screen(); if (child == lookingFor) return current; else return parentScreen(child, lookingFor); } // Not reached. case QScreen::MultiClass: { QList<QScreen *> screens = current->subScreens(); foreach (QScreen *screen, screens) { if (screen == lookingFor) return current; const QScreen *parent = parentScreen(screen, lookingFor); if (parent) return parent; } } break; default: break; } return 0; }
void PWidget::draw(PPortingAbstract *disp) const { passert(parScreen, "no parent screen yet"); #ifdef DRAWING_MODE_CHANGESONLY //draw root widget first pixel_t w=0,h=0,x=0,y=0; x = xGlobal(); y = yGlobal(); w = p.w; h = p.h; //delegate color from parent widget or screen PColor tmp = backgroundColorDelegated(); disp->putRectangle(x,x+w,y,y+h, tmp,true); #endif if (!visible()) return; #ifndef DRAWING_MODE_CHANGESONLY //draw root widget first pixel_t w=0,h=0,x=0,y=0; x = xGlobal(); y = yGlobal(); w = p.w; h = p.h; //delegate color from parent widget or screen PColor tmp = backgroundColorDelegated(); disp->putRectangle(x,x+w,y,y+h, tmp,true); #endif //draw all children PWidget * temp = child; while(temp != NULL) { temp->draw(disp); temp = temp->next; } if (hasFocus()) { disp->putRectangle(x,x+w,y,y+h,parentScreen()->focusColor()); disp->putRectangle(x+1,x+w-1,y+1,y+h-1,parentScreen()->focusColor()); } }
PColor PWidget::backgroundColorDelegated() const { if (color().isValid()) return color(); //delegate up to screen PWidget * wid = parent(); while(wid) { if (wid->color().isValid()) { return wid->color(); } wid = wid->parent(); } //no widget has valid font so take font from screen passert(parentScreen(),"screen is null"); return parentScreen()->color(); }
/** * @brief PWidget::fontDelegated * @return return delegated font up to screen */ PFont * PWidget::fontDelegated() const { if (p.font) return p.font; //delegate up to screen PWidget * wid = parent(); while(wid) { if (wid->font()) { return wid->font(); } wid = wid->parent(); } //no widget has valid font so take font from screen passert(parentScreen(),"screen is null"); return parentScreen()->font(); }
int PvrEglScreen::transformation() const { // We need to search for our parent screen, which is assumed to be // "Transformed". If it isn't, then there is no transformation. // There is no direct method to get the parent screen so we need // to search every screen until we find ourselves. if (!parent && qt_screen != this) parent = parentScreen(qt_screen, this); if (!parent) return 0; if (parent->classId() != QScreen::TransformedClass) return 0; return 90 * static_cast<const QTransformedScreen *>(parent) ->transformation(); }
/** * @brief PWidget::standardNextPrev * standard selecting previous/next widget by up/down key * @param key */ void PWidget::standardNextPrev(const PKeyEvent * key) { PWidget * p = 0; bool b = parentScreen()->inCircles(); typedef PWidget* (PWidget::*f)() const; f fc = NULL; if (key->event == PRESSED) { if (key->key == kUP) { if (b) fc = &PWidget::prevSiblingCircle; else fc = &PWidget::prevSibling; } if (key->key == kDOWN) { if (b) fc = &PWidget::nextSiblingCircle; else fc = &PWidget::nextSibling; } if (!fc) return; p = (this->*fc)(); while(p != NULL && !(p->visible() && p->selectable() && p->enabled())) p = (p->*fc)(); if (p) { p->setFocus(); #ifdef DRAWING_MODE_CHANGESONLY dirty = true; p->dirty = true; #endif } } }
PWidget * PWidget::prevSibling() const { PWidget * temp = 0; if (paren) { temp = paren->firstChild(); } else { passert(parScreen, "no parent screen"); temp = parentScreen()->firstChild(); } while(temp->nextSibling() != this) { temp = temp->nextSibling(); if (temp == 0) return temp; } return temp; }