static void add_from_list(WidgetList &lst, Panel *self, int &X, bool inc) { WidgetListIt it = lst.begin(), ite = lst.end(); Fl_Widget *o; while(it != ite) { o = *it; /* 'inc == false' means we are going from right to left */ if(!inc) X -= o->w(); /* place it correctly */ o->position(X, o->y()); self->add(o); if(inc) { X += DEFAULT_SPACING; X += o->w(); } else { X -= DEFAULT_SPACING; } it = lst.erase(it); } }
// This method performs intersection testing at the given XY coords, and returns true if // any intersections were found. It will break after processing the first pickable Window // it finds. bool WindowManager::pickAtXY(float x, float y, WidgetList& wl) { Intersections intr; osg::Camera* camera = _view->getCamera(); osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(camera->getGraphicsContext()); if (gw) { _view->computeIntersections(camera, osgUtil::Intersector::WINDOW, x, y, intr, _nodeMask); } if (!intr.empty()) { // Get the first Window at the XY coordinates; if you want a Window to be // non-pickable, set the NodeMask to something else. Window* activeWin = 0; // Iterate over every picked result and create a list of Widgets that belong // to that Window. for(Intersections::iterator i = intr.begin(); i != intr.end(); i++) { Window* win = dynamic_cast<Window*>(i->nodePath.back()->getParent(0)); // Make sure that our window is valid, and that our pick is within the // "visible area" of the Window. if( !win || (win->getVisibilityMode() == Window::VM_PARTIAL && !win->isPointerXYWithinVisible(x, y)) ) { continue; } // Set our activeWin, so that we know when we've got all the Widgets // that belong to it. if(!activeWin) activeWin = win; // If we've found a new Widnow, break out! else if(activeWin != win) break; Widget* widget = dynamic_cast<Widget*>(i->drawable.get()); if(!widget) continue; // We need to return a list of every Widget that was picked, so // that the handler can operate on it accordingly. else wl.push_back(widget); } if(wl.size()) { // Potentially VERY expensive; only to be used for debugging. :) if(_flags & WM_PICK_DEBUG) _updatePickWindow(&wl, x, y); return true; } } if(_flags & WM_PICK_DEBUG) _updatePickWindow(0, x, y); return false; }
LuaRef getWidgetList( lua_State* L ) { LuaRef table = newTable(L); for( WidgetListIter i = gWidgets.begin(); i != gWidgets.end(); i++ ) { table[i->first] = i->second; } return table; }
bool Window::setFirstFocusable() { WidgetList focusList; if(getFocusList(focusList)) { _setFocused(focusList.front().get()); return true; } return false; }
void SplitBar::updateChildrenVisibility() { // Hide children that aren't first or second WidgetList children = getChildren(); for (WidgetList::iterator it = children.begin(); it != children.end(); ++it) { Widget* child = *it; child->setVisible(child == m_pane1 || child == m_pane2); } }
//____________________________________________________________ BaseEngine::WidgetList WidgetStateEngine::registeredWidgets( AnimationModes mode ) const { WidgetList out; // the typedef is needed to make Krazy happy typedef DataMap<WidgetStateData>::Value Value; if( mode&AnimationHover ) { foreach( const Value& value, hoverData_ ) { if( value ) out.insert( value.data()->target().data() ); } }
WidgetList * WidgetList::clone(){ WidgetList * list = WidgetList::createNiceList(parent()); list->setStyle(style()); list->setLocation(mapToParent(Nimble::Vector2(0, 0))); for (ItemList::iterator it = m_itemList.begin(); it != m_itemList.end(); ++it ) { RoundTextBox * tb = dynamic_cast<RoundTextBox*>(*it); RoundTextBox * tb2 = new RoundTextBox(0, 0, MultiWidgets::TextBox::HCENTER); tb2->setCSSClass("FloatingWord_clone"); tb2->setStyle(tb->style()); tb2->setText(tb->text()); tb2->setWidth(tb->width()); tb2->setHeight(tb->height()); tb2->setAlignFlags(MultiWidgets::TextBox::HCENTER | MultiWidgets::TextBox::VCENTER); list->addItem(tb2); } //layout(); list->layout(); list->setDepth(depth()); list->setScale(scale()); list->setRotation(rotation()); return list; }
void QFormScriptRunner::QFormScriptRunnerPrivate::initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine) { // Populate the script variables. This pushes a context which must be popped. QScriptContext *ctx = scriptEngine.pushContext(); QScriptValue widgetObject = scriptEngine.newQObject(w); QScriptValue childrenArray = scriptEngine.newArray (children.size()); for(int i = 0; i < children.size(); i++) { childrenArray.setProperty(i, scriptEngine.newQObject(children[i])); } const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); ctx ->activationObject().setProperty(strings.scriptWidgetVariable, widgetObject); ctx ->activationObject().setProperty(strings.scriptChildWidgetsVariable, childrenArray); }
/** Returns a MdiChild by its ID. */ MdiChild* MdiClient::getChildById(int wID) { WidgetList children = getChildren(); for (WidgetList::iterator it=children.begin(); it!=children.end(); ++it) { HWND hChild = (*it)->getHandle(); assert(hChild != NULL); if (GetWindowLong(hChild, GWL_ID) == wID) return static_cast<MdiChild*>(*it); } return NULL; }
bool Window::getFocusList(WidgetList& wl) const { for(ConstIterator i = begin(); i != end(); i++) if(i->valid()) { EmbeddedWindow* ew = dynamic_cast<EmbeddedWindow*>(i->get()); if(!ew) { if(i->get()->canFocus()) wl.push_back(i->get()); } else { if(ew->getWindow()) ew->getWindow()->getFocusList(wl); } } return wl.size() != 0; }
void Tab::onPageChange(Event& ev) { TabBase::onPageChange(ev); WidgetList pages = getChildren(); int pageIndex = 0; int selectedPage = getActivePage(); for (WidgetList::iterator it = pages.begin(); it != pages.end(); ++it, ++pageIndex) { TabPage* page = dynamic_cast<TabPage*>(*it); assert(page != NULL); page->setVisible(pageIndex == selectedPage); } layout(); }
PyObject *viewList(PyObject *, PyObject *args) { if( !PyArg_ParseTuple(args, "") ){ PyErr_SetString(PyExc_TypeError, "no args required"); return NULL; } CUTE *cute = static_cast<CUTE*>(qApp->mainWidget()); PyObject *tuple = PyTuple_New(cute->windowsCount()); WidgetList list = cute->windows(); int i = 0; for( QWidget* view = list.first(); view; view=list.next() ){ Buffer *buf = PyObject_New(Buffer, &buffer_type); buf->view = static_cast<CUTEView*>(view)->scintilla(); Py_INCREF((PyObject*)buf); PyTuple_SetItem(tuple, i, (PyObject*)buf); i++; } return (PyObject*)tuple; }
void test( lua_State* L ) { getGlobalNamespace( L ) .beginClass<Widget>("Widget") .addData("something", &Widget::something ) .endClass() .addFunction( "getWidgets", &getWidgetList ); gWidgets.insert( std::pair<int, Widget::Ptr>( 1, new Widget(10) ) ); gWidgets.insert( std::pair<int, Widget::Ptr>( 2, new Widget(20) ) ); gWidgets.insert( std::pair<int, Widget::Ptr>( 3, new Widget(30) ) ); const char *source = "print( _VERSION )\n" "function dump(t)\n" " print( 'Dump:' )\n" " for k,v in pairs(t) do\n" " print( k, v.something )\n" " end\n" "end\n"; cout << source << endl; if( luaL_dostring( L, source ) ) { cout << lua_tostring( L, -1 ) << endl; lua_pop( L, 1 ); return; } for( int i=0; i <= 500; i++ ) { luaL_dostring( L, "dump( getWidgets() )" ); lua_gc( L, LUA_GCCOLLECT, 0 ); } return; }
bool Window::setNextFocusable() { WidgetList focusList; if(!getFocusList(focusList)) return false; WidgetList::iterator w = focusList.begin(); // TODO: This needs to be a more complicated object, since the focus may be // in a child Window instead of a Widget. unsigned int focusedIndex = 0; for(unsigned int i = 0; w != focusList.end(); w++, i++) if(*w == _focused) { focusedIndex = i; break; } if(focusedIndex < focusList.size() - 1) _setFocused((++w)->get()); else _setFocused(focusList.front().get()); return true; }
WidgetList * WidgetList::createNiceList(Widget * parent, Widget * content) { WidgetList * list = new WidgetList(parent); if (content) list->addItem(content); list->setDepth(-1); list->raiseFlag(WidgetList::LOCK_DEPTH); list->addOperator(new MultiWidgets::StayInsideParentOperator); //list->addOperator(new MultiWidgets::RotateTowardsHandsOperator); list->addOperator(new MultiWidgets::LimitScaleOperator(MultiWidgets::LimitScaleOperator::COMPARE_SCALE, 1.0f, 2.0f)); return list; }
bool QFormScriptRunner::run(const DomWidget *domWidget, const QString &customWidgetScript, QWidget *widget, const WidgetList &children, QString *errorMessage) { typedef QList<DomScript*> DomScripts; const Options scriptOptions = m_impl->options(); if (scriptOptions & DisableScripts) return true; // get list const DomScripts domScripts = domWidget->elementScript(); // Concatenate snippets, starting with custom widget script QString script = customWidgetScript; if (script.isEmpty() && domScripts.empty()) return true; foreach (const DomScript *scriptSnippet, domScripts) { // Ensure new line if (!script.isEmpty() && !script.endsWith(QLatin1Char('\n'))) script += QLatin1Char('\n'); script += scriptSnippet->text(); } if (script.isEmpty()) return true; const bool rc = m_impl->run(script, widget, children, errorMessage); if (debugFormScriptRunner) { qDebug() << "For " << widget << " with " << children.size() << " children, ran: " << script; if (!rc) qDebug() << *errorMessage; } if (!rc) { if (!(scriptOptions & DisableWarnings)) { const QString message = QCoreApplication::tr("An error occurred while running the script for %1: %2\nScript: %3"). arg(widget->objectName()).arg(*errorMessage).arg(script); qWarning() << message; } } return rc; }
void callback_WidgetListScroller(Scrollbar* s) { WidgetList* f = (WidgetList*)s->mParent; f->UpdateChildrenPositions(); }