Beispiel #1
0
void
area_focus(Area *a) {
	Frame *f;
	View *v;
	Area *old_a;

	v = a->view;
	f = a->sel;
	old_a = v->sel;

	if(!a->floating && view_fullscreen_p(v, a->screen))
		return;

	v->sel = a;
	if(!a->floating) {
		v->selcol = area_idx(a);
		v->selscreen = a->screen;
	}
	if(a != old_a)
		v->oldsel = nil;

	if(old_a && a->floating != old_a->floating) {
		v->revert = old_a;
		if(v->floating->max)
			view_update(v);
	}

	if(v == selview) {
		move_focus(old_a->sel, f);
		client_focus(f ? f->client : nil);

		if(a != old_a)
			event("AreaFocus %a\n", a);
	}
}
Beispiel #2
0
//---------------------------------------------------------------------------
void MainWindow::scrollAction(int action)
{
  if ( action == QAbstractSlider::SliderNoAction )
    return;
  QAbstractSlider *slider = (QAbstractSlider *) QObject::sender();
  int ScrollPos = slider->sliderPosition();
  bool reset_slider;
  int code = calc_scroll(action, ScrollPos, reset_slider);
  if ( code != 0 )
  {
    if ( reset_slider )
      slider->setSliderPosition(ScrollPos);
    if ( slider == (QAbstractSlider *) canvas->verticalScrollBar() )
      move_focus(0, code);
    else
      move_focus(code, 0);
    canvas->viewport()->update();
  }
}
Beispiel #3
0
void
area_focus(Area *a) {
	Frame *f;
	View *v;
	Area *old_a;

	v = a->view;
	f = a->sel;
	old_a = v->sel;

	if(!a->floating && view_fullscreen_p(v, a->screen))
		return;

	v->sel = a;
	if(!a->floating) {
		v->selcol = area_idx(a);
		v->selscreen = a->screen;
	}
	if(a != old_a)
		v->oldsel = nil;

	if((old_a) && (a->floating != old_a->floating)) {
		v->revert = old_a;
		if(v->floating->max)
			view_update(v);
	}

	if(v != selview)
		return;

	move_focus(old_a->sel, f);

	if(f)
		client_focus(f->client);
	else
		client_focus(nil);

	if(a != old_a) {
		event("AreaFocus %a\n", a);
		/* Deprecated */
		if(a->floating)
			event("FocusFloating\n");
		else
			event("ColumnFocus %d\n", area_idx(a));
	}
}
Beispiel #4
0
void MainWindow::KeyDown(int & Key, Qt::KeyboardModifiers Modifiers)
{
  switch ( Key )
  {
    case Qt::Key_Left:
      if ( (Modifiers & Qt::ControlModifier) != 0 )
        move_focus(-PAGE, 0);
      else
        move_focus(-STEP, 0);
      break;
    case Qt::Key_Right:
      if ( (Modifiers & Qt::ControlModifier) != 0 )
        move_focus(PAGE, 0);
      else
        move_focus(STEP, 0);
      break;
    case Qt::Key_Up:
      if ( (Modifiers & Qt::ControlModifier) != 0 )
        move_focus(0, -PAGE);
      else
        move_focus(0, -STEP);
      break;
    case Qt::Key_Down:
      if ( (Modifiers & Qt::ControlModifier) != 0 )
        move_focus(0, PAGE);
      else
        move_focus(0, STEP);
      break;
    /*case VK_PRIOR:
      move_focus(0, -ClientHeight / 2);
      break;
    case VK_NEXT:
      move_focus(0, ClientHeight / 2);
      break;*/
    default:
      return;
  }
  Key = 0;
}
Beispiel #5
0
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
   
  QClipboard * clipboard = QApplication::clipboard();		//added by AiO 
  if ( obj == canvas->viewport() )
  {
    // paint
    if ( event->type() == QEvent::Paint )
    {
      set_drawing_rectangle(canvas->viewport()->size().width(), canvas->viewport()->size().height());
      QPainter p(canvas->viewport());
      p.setPen(Qt::black);
      p.setBrush(Qt::green);
      PaintStruct ps;
      ps.p = &p;
      ps.border = 2;
      drawGraph(&ps);
    }

    // mouse
    else if ( event->type() == QEvent::MouseMove )
    {
      QMouseEvent *mevent = (QMouseEvent *) event;
      if ( qApp->overrideCursor() )
      {
        //cursor is overridden, we are panning
        if ( mevent->x() != ox || mevent->y() != oy )
        {
          move_focus(ox - mevent->x(), oy - mevent->y());
          ox = mevent->x();
          oy = mevent->y();
          canvas->viewport()->update();
          //update();
        }
      }
    }
    else if ( event->type() == QEvent::MouseButtonPress )
    {
      QMouseEvent *mevent = (QMouseEvent *) event;
      if ( mevent->button() == Qt::LeftButton )
      {
        Qt::KeyboardModifiers mods = mevent->modifiers();
        if (mods & Qt::ShiftModifier) zoomIn();
        else if (mods & Qt::ControlModifier) zoomOut();
        if ( !sticky )
        {
          qApp->setOverrideCursor(*MOVING_CURSOR);
        }
        else
        {
          if ( qApp->overrideCursor() )
          {
            //cursor is already overridden, release it
            qApp->restoreOverrideCursor();
            canvas->setMouseTracking(false);
          }
          else
          {
            qApp->setOverrideCursor(*MOVING_CURSOR);
            canvas->setMouseTracking(true);
          }
        }
        ox = mevent->x();
        oy = mevent->y();
      }
	  else if(mevent->button() == Qt::RightButton )		//Added by AiO
	  {
		  //query the cordinates of the mouse for node
		  char curNodeTitle[1024];
		  char * curNode;
		  char *index;	//used for search
		  QMessageBox msgBox;
		  curNode = node_xy_title(mevent->x(),mevent->y());
		  if(curNode == 0) return true;
		  strncpy(curNodeTitle, curNode, 1024-1);
		  curNodeTitle[1024-1] = 0;
		  //label ends with ':'
		  //test for color characters format sym num num TEXT sym :
		  
		  // replace : -1 with 0 and use &curNodeTitle[3]
		  
		  
		  //test with popup
		  if(curNodeTitle[0] == 0x0c)
		  {
			index = strchr(curNodeTitle, ':');
			if(index == 0) goto nocolon; //test for no label but color
			--index;
			--index;
			--index;
			*index = 0;
			msgBox.setText(&curNodeTitle[3]);
			clipboard->setText(&curNodeTitle[3]);
		  }
		  else
		  {
			  nocolon:
			msgBox.setText(curNodeTitle);
		    clipboard->setText(curNodeTitle);
		  }
		  msgBox.exec();
	  }
    }
    else if ( event->type() == QEvent::MouseButtonRelease )
    {
      if ( !sticky )
        qApp->restoreOverrideCursor();
    }

    // wheel
    else if ( event->type() == QEvent::Wheel )
    {
      QWheelEvent *wevent = (QWheelEvent *) event;
      if ( (qApp->keyboardModifiers() & Qt::ControlModifier) != 0 )
      {
        wevent->accept();
        int numDegrees = wevent->delta() / 8;
        int numSteps = numDegrees / 15;
        if ( numSteps < 0)
        {
          numSteps = -numSteps;
          for ( int x = 0; x < numSteps; x++ )
            zoomOut();
        }
        else
        {
          for ( int x = 0; x < numSteps; x++ )
            zoomIn();
        }
        return true;
      }
      else
      {
        bool ret = QMainWindow::eventFilter(obj, event);
        QAbstractSlider *slider = (QAbstractSlider *) (wevent->orientation() == Qt::Vertical?
                                                       canvas->verticalScrollBar() :
                                                       canvas->horizontalScrollBar());
        int ScrollPos = slider->sliderPosition();
        bool reset_slider;
        calc_scroll(QAbstractSlider::SliderMove + 100, ScrollPos, reset_slider);
        slider->setSliderPosition(ScrollPos);
        return ret;
      }
    }

    // keyboard
    else if ( event->type() == QEvent::KeyPress )
    {
      QKeyEvent *kevent = (QKeyEvent *) event;
      int key = kevent->key();
      KeyDown(key, kevent->modifiers());
      if ( key == 0 )
      {
        event->accept();
        return true;
      }
    }
  }

  return QMainWindow::eventFilter(obj, event);
}