Exemple #1
0
void QTodoList::pasteAtBottom()
{
	int last_depth = -1;
	int base_depth = -QCB::get()->minDepth();

	QTodoItem* item = 0;
	for(QTodoItemVector::iterator it = QCB::get()->getItems()->begin(); it != QCB::get()->getItems()->end(); ++it)
	{
		item = new QTodoItem(*(*it));
		insertTodoAtBottom(item);
		QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth()));
		item->setDepth(item->getDepth() + base_depth);
		
		if(item->getDepth() > last_depth + 1)
		{
			QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth()));
			item->setDepth(last_depth + 1);
		}

		last_depth = item->getDepth();
	}
	QCB::get()->clear();
	jumpToLast();
	fixItemSize(item);
}
Exemple #2
0
bool Screen::mouseButtonCallbackEvent(int button, int action, int modifiers) {
    mModifiers = modifiers;
    mLastInteraction = glfwGetTime();
    try {
        if (mFocusPath.size() > 1) {
            const Window *window =
                dynamic_cast<Window *>(mFocusPath[mFocusPath.size() - 2]);
            if (window && window->modal()) {
                if (!window->contains(mMousePos))
                    return false;
            }
        }

        if (action == GLFW_PRESS)
            mMouseState |= 1 << button;
        else
            mMouseState &= ~(1 << button);

        auto dropWidget = findWidget(mMousePos);
        if (mDragActive && action == GLFW_RELEASE &&
            dropWidget != mDragWidget)
            mDragWidget->mouseButtonEvent(
                mMousePos - mDragWidget->parent()->absolutePosition(), button,
                false, mModifiers);

        if (dropWidget != nullptr && dropWidget->cursor() != mCursor) {
            mCursor = dropWidget->cursor();
            glfwSetCursor(mGLFWWindow, mCursors[(int) mCursor]);
        }

        if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_1) {
            mDragWidget = findWidget(mMousePos);
            if (mDragWidget == this)
                mDragWidget = nullptr;
            mDragActive = mDragWidget != nullptr;
            if (!mDragActive)
                updateFocus(nullptr);
        } else {
            mDragActive = false;
            mDragWidget = nullptr;
        }

        return mouseButtonEvent(mMousePos, button, action == GLFW_PRESS,
                                mModifiers);
    } catch (const std::exception &e) {
        std::cerr << "Caught exception in event handler: " << e.what() << std::endl;
        abort();
    }

    return false;
}
Exemple #3
0
bool Screen::cursorPosCallbackEvent(double x, double y) {
    Vector2i p((int) x, (int) y);
    bool ret = false;
    mLastInteraction = glfwGetTime();
    try {
        if (mDragActive) {
            ret = mDragWidget->mouseDragEvent(
                p - mDragWidget->parent()->absolutePosition(), p - mMousePos,
                mMouseState, mModifiers);
        } else {
            Widget *widget = findWidget(mMousePos);
            if (widget != nullptr && widget->cursor() != mCursor) {
                mCursor = widget->cursor();
                glfwSetCursor(mGLFWWindow, mCursors[(int) mCursor]);
            }
        }

        if (!ret)
            ret = mouseMotionEvent(p, p - mMousePos, mMouseState, mModifiers);

        mMousePos = p;

        return ret;
    } catch (const std::exception &e) {
        std::cerr << "Caught exception in event handler: " << e.what() << std::endl;
        abort();
    }

    return false;
}
Exemple #4
0
void fileExecFile(Widget w, XEvent *event, String *params, 
		  Cardinal *num_params)
{
  int i, l;
  char *path;
  char **argv;
  FileWindowRec *fw;

  i = findWidget(w, &fw);
  if (i == -1 || !fw) {
/*
    error("Internal error:","widget not found in fileExecFile");
*/
    return;
  }

  l = strlen(fw->directory);
  path = (char *)alloca(l+strlen(fw->files[i]->name)+2);
  strcpy(path, fw->directory);
  if (path[l-1] != '/')
    path[l++] = '/';
  strcpy(path+l, fw->files[i]->name);
  argv = (char **) XtMalloc(2 * sizeof(char *));
  argv[0] = XtNewString(fw->files[i]->name);
  argv[1] = NULL;
  executeApplication(path, fw->directory, argv);

  freeArgv(argv);
}
QString DSystemFuncs::getVariable(const QString &widget, const QString &name)
{
    QWidget* w = findWidget( widget );
    if (w == NULL)
        return g_sNull;
    return w->property( qPrintable(QString("mib_").append(name.trimmed())) ).toString();
}
Exemple #6
0
void fileRestoreSelect(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
  int i, j;
  FileWindowRec *fw;
  Pixel back, fore;

  j = findWidget(w, &fw);
  if (!fw) {
/*
    error("Internal error:", "widget not found in fileSelect");
*/
    return;
  }
  	for (i=0; i<fw->n_files; i++)
	{
    	XtCallActionProc(fw->files[i]->icon.toggle, "unset", event, NULL, 0);
    	XtVaGetValues(fw->files[i]->icon.toggle, XtNbackground, 
					  							&back, NULL);
    	XtVaSetValues(fw->files[i]->icon.toggle, XtNborder, 
					  							(XtArgVal) back,NULL);
		if (fw->files[i]->selected) 
		{	  
			XtVaGetValues(fw->files[i]->icon.toggle, XtNforeground, 
						  						&fore, NULL);
			XtVaSetValues(fw->files[i]->icon.toggle, XtNborder, 
						  						(XtArgVal) fore, NULL);
    	}		  
	}
	
}
Exemple #7
0
QIcon WidgetBox::iconForWidget(const QString &className, const QString &category) const
{
    Widget widgetData;
    if (!findWidget(this, className, category, &widgetData))
        return QIcon();
    return m_view->iconForWidget(widgetData.iconName());
}
void CustomWidgetEditor::classNameChanged( const QString &s )
{
    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );
    if ( !i || !w )
	return;

    WidgetDatabase::customWidgetClassNameChanged( w->className, s );

    checkTimer->stop();
    boxWidgets->blockSignals( TRUE );
    oldName = w->className;
    w->className = s;
    QListBoxItem *old = i;
    if ( w->pixmap )
	boxWidgets->changeItem( *w->pixmap, s, boxWidgets->currentItem() );
    else
	boxWidgets->changeItem( s, boxWidgets->currentItem() );
    i = boxWidgets->item( boxWidgets->currentItem() );
    oldItem = i;
    customWidgets.insert( i, w );
    customWidgets.remove( old );
    boxWidgets->blockSignals( FALSE );
    checkTimer->start( 1000, TRUE );
}
void CustomWidgetEditor::deleteWidgetClicked()
{
    oldItem = 0;
    checkTimer->stop();
    checkWidgetName();

    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );

    if ( mainWindow->isCustomWidgetUsed( w ) ) {
	QMessageBox::information( mainWindow, i18n( "Removing Custom Widget" ),
				  i18n( "The custom widget '%1' is in use, so it cannot be removed." ).
				  arg( w->className ) );
	return;
    }

    if ( !i || !w )
	return;

    MetaDataBase::CustomWidget *cw = MetaDataBase::customWidget( mainWindow->currentTool() );
    if ( cw == w )
	mainWindow->resetTool();

    MetaDataBase::removeCustomWidget( w );
    customWidgets.remove( i );
    delete i;

    i = boxWidgets->item( boxWidgets->currentItem() );
    if ( i ) {
	boxWidgets->setCurrentItem( i );
	boxWidgets->setSelected( i, TRUE );
    }
}
Exemple #10
0
void QTodoList::removeTodo(QTodoItem* item)
{
	QTUM::get()->addChange(new QTodoChangeDelete(this,findWidget(item),new QTodoItem(*item)));
	removeWidget(item);
	delete item;
	setModified();
}
Exemple #11
0
void QTodoList::adjustDepth(int i)
{
	QTodoListIterator it(this);
	QCB::get()->clear();
	int last_depth = -1;
	int new_depth;
	for(;it.current();++it)
	{
		if(QTodoItem* item = dynamic_cast<QTodoItem*>(it.current()))
		{
			if(item->isSelected())
			{
				new_depth = item->getDepth()+i;
				if(new_depth < 0)
					new_depth = 0;
				if(new_depth > last_depth + 1)
					new_depth = last_depth + 1;

				if(new_depth != item->getDepth())
					QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth()));
				item->setDepth(new_depth);
			}

			last_depth = item->getDepth();
		}
	}
	deselectAll();
}
void HierarchyList::showRMBMenu( QListViewItem *i, const QPoint & p )
{
    if ( !i )
  return;


    QWidget *w = findWidget( i );
    if ( !w )
  return;

    if ( w != formWindow &&
   !formWindow->widgets()->find( w ) )
  return;

    if ( w->isVisibleTo( formWindow ) ) {
  if ( !w->inherits( "QTabWidget" ) && !w->inherits( "QWizard" ) ) {
      if ( !normalMenu )
    normalMenu = formWindow->mainWindow()->setupNormalHierarchyMenu( this );
      normalMenu->popup( p );
  } else {
      if ( !tabWidgetMenu )
    tabWidgetMenu =
        formWindow->mainWindow()->setupTabWidgetHierarchyMenu( this, SLOT( addTabPage() ),
                        SLOT( removeTabPage() ) );
      tabWidgetMenu->popup( p );
  }
    }
}
Exemple #13
0
void Screen::drawWidgets() {
    if (!mVisible)
        return;

    glfwMakeContextCurrent(mGLFWWindow);
    glfwGetFramebufferSize(mGLFWWindow, &mFBSize[0], &mFBSize[1]);
    glfwGetWindowSize(mGLFWWindow, &mSize[0], &mSize[1]);
    glViewport(0, 0, mFBSize[0], mFBSize[1]);

    /* Calculate pixel ratio for hi-dpi devices. */
    mPixelRatio = (float) mFBSize[0] / (float) mSize[0];
    nvgBeginFrame(mNVGContext, mSize[0], mSize[1], mPixelRatio);

    draw(mNVGContext);

    double elapsed = glfwGetTime() - mLastInteraction;

    if (elapsed > 0.5f) {
        /* Draw tooltips */
        const Widget *widget = findWidget(mMousePos);
        if (widget && !widget->tooltip().empty()) {
            int tooltipWidth = 150;

            float bounds[4];
            nvgFontFace(mNVGContext, "sans");
            nvgFontSize(mNVGContext, 15.0f);
            nvgTextAlign(mNVGContext, NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
            nvgTextLineHeight(mNVGContext, 1.1f);
            Vector2i pos = widget->absolutePosition() +
                           Vector2i(widget->width() / 2, widget->height() + 10);

            nvgTextBoxBounds(mNVGContext, pos.x(), pos.y(), tooltipWidth,
                             widget->tooltip().c_str(), nullptr, bounds);

            nvgGlobalAlpha(mNVGContext,
                           std::min(1.0, 2 * (elapsed - 0.5f)) * 0.8);

            nvgBeginPath(mNVGContext);
            nvgFillColor(mNVGContext, Color(0, 255));
            int h = (bounds[2] - bounds[0]) / 2;
            nvgRoundedRect(mNVGContext, bounds[0] - 4 - h, bounds[1] - 4,
                           (int) (bounds[2] - bounds[0]) + 8,
                           (int) (bounds[3] - bounds[1]) + 8, 3);

            int px = (int) ((bounds[2] + bounds[0]) / 2) - h;
            nvgMoveTo(mNVGContext, px, bounds[1] - 10);
            nvgLineTo(mNVGContext, px + 7, bounds[1] + 1);
            nvgLineTo(mNVGContext, px - 7, bounds[1] + 1);
            nvgFill(mNVGContext);

            nvgFillColor(mNVGContext, Color(255, 255));
            nvgFontBlur(mNVGContext, 0.0f);
            nvgTextBox(mNVGContext, pos.x() - h, pos.y(), tooltipWidth,
                       widget->tooltip().c_str(), nullptr);
        }
    }

    nvgEndFrame(mNVGContext);
}
Exemple #14
0
void fileRefresh(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
  FileWindowRec *fw;
  
  findWidget(w, &fw);
  if (fw)
    updateFileDisplay(fw);
}
Exemple #15
0
void QTodoList::adjustDepth(std::vector<QTodoItem*> todos, int i)
{
	for(std::vector<QTodoItem*>::iterator it = todos.begin(); it != todos.end(); ++it)
	{
		QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget((*it)),(*it)->getDepth()));
		(*it)->setDepth((*it)->getDepth() + i);
	}
}
Exemple #16
0
void QTodoList::takeTodo(QTodoItem* item)
{
	item->hide();
	QTUM::get()->addChange(new QTodoChangeDelete(this,findWidget(item),new QTodoItem(*item)));
	dynamic_cast<QBoxLayout*>(vbox->layout())->remove(item);
	removeWidget(item);
	setModified();
}
Exemple #17
0
void QTodoList::insertTodo(QTodoItem* item, int index)
{
	if(index == -1)
		index = findWidget(spacer);

	if(item->parent() != vbox)
		item->reparent(vbox,QPoint(0,0));
	dynamic_cast<QBoxLayout*>(vbox->layout())->insertWidget(index,item);
	item->show();

	content.insert(content.begin()+index, item);

	QTUM::get()->addChange(new QTodoChangeInsert(this,findWidget(item)));
	if(QTUM::get()->isRecording())
			setModified();
	//refreshSpacer();
}
Exemple #18
0
void MainMenuDialog::reflowLayout() {
	if (_engine->hasFeature(Engine::kSupportsLoadingDuringRuntime))
		_loadButton->setEnabled(_engine->canLoadGameStateCurrently());
	if (_engine->hasFeature(Engine::kSupportsSavingDuringRuntime))
		_saveButton->setEnabled(_engine->canSaveGameStateCurrently());

	// Overlay size might have changed since the construction of the dialog.
	// Update labels when it might be needed
	// FIXME: it might be better to declare GUI::StaticTextWidget::setLabel() virtual
	// and to reimplement it in GUI::ButtonWidget to handle the hotkey.
	if (g_system->getOverlayWidth() > 320)
		_rtlButton->setLabel(_rtlButton->cleanupHotkey(_("~R~eturn to Launcher")));
	else
		_rtlButton->setLabel(_rtlButton->cleanupHotkey(_c("~R~eturn to Launcher", "lowres")));

#ifndef DISABLE_FANCY_THEMES
	if (g_gui.xmlEval()->getVar("Globals.ShowGlobalMenuLogo", 0) == 1 && g_gui.theme()->supportsImages()) {
		if (!_logo)
			_logo = new GUI::GraphicsWidget(this, "GlobalMenu.Logo");
		_logo->useThemeTransparency(true);
		_logo->setGfx(g_gui.theme()->getImageSurface(GUI::ThemeEngine::kImageLogoSmall));

		GUI::StaticTextWidget *title = (GUI::StaticTextWidget *)findWidget("GlobalMenu.Title");
		if (title) {
			removeWidget(title);
			title->setNext(0);
			delete title;
		}
	} else {
		GUI::StaticTextWidget *title = (GUI::StaticTextWidget *)findWidget("GlobalMenu.Title");
		if (!title) {
			title = new GUI::StaticTextWidget(this, "GlobalMenu.Title", "ScummVM");
			title->setAlign(Graphics::kTextAlignCenter);
		}

		if (_logo) {
			removeWidget(_logo);
			_logo->setNext(0);
			delete _logo;
			_logo = 0;
		}
	}
#endif

	Dialog::reflowLayout();
}
Exemple #19
0
geom::Area AngelWidgetTarget::findScreenAreaImpl()
{
	Handler<Widget> const widget = findWidget();
	if( unlikely(!widget) ) {
		return geom::Area();
	}
	return widget->findTargetInRoot(guide_);
}
void CustomWidgetEditor::includePolicyChanged( int p )
{
    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );
    if ( !i || !w )
	return;

    w->includePolicy = (MetaDataBase::CustomWidget::IncludePolicy)p;
}
void CustomWidgetEditor::addSignal()
{
    QListBoxItem *i = new QListBoxText( listSignals, "signal()" );
    listSignals->setCurrentItem( i );
    listSignals->setSelected( i, TRUE );
    MetaDataBase::CustomWidget *w = findWidget( boxWidgets->item( boxWidgets->currentItem() ) );
    if ( w )
	w->lstSignals.append( i->text().latin1() );
}
void CustomWidgetEditor::headerFileChanged( const QString &s )
{
    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );
    if ( !i || !w )
	return;

    w->includeFile = s;
}
bool DSystemFuncs::refreshWidget(const QString &widget)
{
    QWidget* w = findWidget( widget );
    if (w == NULL)
        return false;
    if (!w->inherits( "DWorkWidget" ))
        return false;
    return static_cast<DWorkWidget*>(w)->refreshUri();
}
void CustomWidgetEditor::removeSignal()
{
    QString s = listSignals->currentText();
    delete listSignals->item( listSignals->currentItem() );
    if ( listSignals->currentItem() != -1 )
	listSignals->setSelected( listSignals->currentItem(), TRUE );
    MetaDataBase::CustomWidget *w = findWidget( boxWidgets->item( boxWidgets->currentItem() ) );
    if ( w )
	w->lstSignals.remove( s.latin1() );
}
void CustomWidgetEditor::widthChanged( int wid )
{
    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );
    if ( !i || !w )
	return;

    w->sizeHint.setWidth( wid );
    updateCustomWidgetSizes();
}
Exemple #26
0
void QTodoList::cut()
{
	preserveContentsYPos();
	QTodoListIterator it(this);
	QCB::get()->clear();
	QCB::get()->setCut(true);
	QTUM::get()->startRecording();
	int last_depth = -1;
	int above = -1;
	QTodoItem* previous = 0;
	bool last_cut = false;
	for(;it.current();++it)
	{
		if(QTodoItem* item = dynamic_cast<QTodoItem*>(it.current()))
		{
			if(!item->isSelected())
			{
				if(above == -1)
					above = it.currentIndex() - 1;
				if(item->getDepth() - 1 > last_depth)
				{
					QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth()));
					item->setDepth(last_depth+1);
				}

				if(last_cut)
					item->setDepth(item->getDepth());

				last_depth = item->getDepth();
				last_cut = false;
				continue;
			}
			else
			{
				last_cut = true;
			}

			if(!previous)
			{
				--it;
				previous = it.item();
				++it;
			}
			QCB::get()->add(item);
			it.take();
		}
	}
	if(previous)
		previous->setFocusOnTask();
	else
		jumpToFirst();
	QTUM::get()->stopRecording();
	QCB::get()->doExport();
	restoreContentsYPos();
}
void DSystemFuncs::setVariable(const QString &widget,
                               const QString &name,
                               const QString &value
                               )
{
    QWidget* w = findWidget( widget );
    if (w == NULL)
        return;
    w->setProperty( qPrintable(QString("mib_").append(name.trimmed())),
                    value );
}
void CustomWidgetEditor::widgetIsContainer( bool b )
{
    QListBoxItem *i = boxWidgets->item( boxWidgets->currentItem() );
    MetaDataBase::CustomWidget *w = findWidget( i );
    if ( !i || !w )
	return;

    w->isContainer = b;
    WidgetDatabaseRecord *r = WidgetDatabase::at( w->id );
    if ( r )
	r->isContainer = b;
}
Exemple #29
0
/*---------------------------------------------------------------------------*/
void fileExecAction(Widget w, XEvent *event, String *params, 
		    Cardinal *num_params)
{
  int i;
  FileWindowRec *fw;
   char **argv;

  i = findWidget(w, &fw);
  if (i == -1 || !fw) {
/*
    error("Internal error:","widget not found in fileExecAction");
*/
    return;
  }

  if (fw->files[i]->type) 
  {
    if (*fw->files[i]->type->push_action)
      if (!strcmp(fw->files[i]->type->push_action, "EDIT"))
		doEdit(fw->directory, fw->files[i]->name);
      else if (!strcmp(fw->files[i]->type->push_action, "VIEW"))
		doView(fw->directory, fw->files[i]->name);
      else if (!strcmp(fw->files[i]->type->push_action, "IMAGE"))
		doImage(fw->directory, fw->files[i]->name);
      else if (!strcmp(fw->files[i]->type->push_action, "SIAGHELP"))
		doSiaghelp(fw->directory, fw->files[i]->name);

	  else 
	  {
        int k = 0;
	    char *action = varPopup(fw->files[i]->type->icon_bm,
				fw->files[i]->type->push_action);

	 	if (!action) return;

		argv = (char **) XtMalloc( (user.arg0flag ? 6 : 5) * sizeof(char *));
		argv[k++] = user.shell;
		argv[k++] = "-c";
		argv[k++] = action;
        if (user.arg0flag)
          argv[k++] = user.shell;
		argv[k++] = fw->files[i]->name;
		argv[k] = NULL;

		executeApplication(user.shell, fw->directory, argv);

		XTFREE(argv);
      }
  } 
  else
    doEdit(fw->directory, fw->files[i]->name);
}
Exemple #30
0
void Dialog::handleMouseWheel(int x, int y, int direction) {
	Widget *w;

	// This may look a bit backwards, but I think it makes more sense for
	// the mouse wheel to primarily affect the widget the mouse is at than
	// the widget that happens to be focused.

	w = findWidget(x, y);
	if (!w)
		w = _focusedWidget;
	if (w)
		w->handleMouseWheel(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), direction);
}