Example #1
0
FXint FXTabSim::buscarPARAM(tDato tipo) {
	FXint resultado, i;
	tDato tipoParam;

	if ( posParam > iniProc + numPar )
		return 1;

	// Seleccionamos el parametro formal comparado
	setSelTextColor(colores[PARAM_FG]);
	setSelBackColor(colores[PARAM_BG]);
	selectRange(posParam, posParam, COL_LEXEMA, COL_ETQ_ELSE);


	// Busqueda inversa...
	/** @todo Usar un hash para convertir Nombres en Numeros */

	for ( i = 0
		; strcmp(nomTiposDato[i]
		, getItemText(posParam, COL_TDATO).text()) != 0
		; i++);

	tipoParam = (tDato)i;

	posParam++;

	if ( tipo == tipoParam )
		return 0;
	else
		return 2;
	}
void TorrentsListWidget::changeSelection(TorrentWidget *item) {
  if(shiftKeyPressed && !controlKeyPressed) {
    selectRange(row(torrentWidgetItems.value(item)),row(torrentWidgetItems.value(selectedItems.last())));
    return;
  }
  if(!controlKeyPressed) clearSelection(item);

  if(item->isSelected()) {
    if(controlKeyPressed || shiftKeyPressed) unselectItem(item);
  }
  else selectItem(item);
};
Example #3
0
/*************************************************************************
	Handler for when mouse button is pressed
*************************************************************************/
void Listbox::onMouseButtonDown(MouseEventArgs& e)
{
	// base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		bool modified = false;

		// clear old selections if no control key is pressed or if multi-select is off
		if (!(e.sysKeys & Control) || !d_multiselect)
		{
			modified = clearAllSelections_impl();
		}

		Point localPos(screenToWindow(e.position));

		if (getMetricsMode() == Relative)
		{
			localPos = relativeToAbsolute(localPos);
		}

		ListboxItem* item = getItemAtPoint(localPos);

		if (item != NULL)
		{
			modified = true;

			// select range or item, depending upon keys and last selected item
			if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect)
			{
				selectRange(getItemIndex(item), getItemIndex(d_lastSelected));
			}
			else
			{
				item->setSelected(item->isSelected() ^ true);
			}

			// update last selected item
			d_lastSelected = item->isSelected() ? item : NULL;
		}

		// fire event if needed
		if (modified)
		{
			WindowEventArgs args(this);
			onSelectionChanged(args);
		}
		
		e.handled = true;
	}

}
Example #4
0
tDato FXTabSim::buscarSIM(char *id) {
	FXint i, j, num, fin;
	FXString nomTipo;
	FXString strAux;
	FXint *tipo;
	FXchar clave[20];

	j = tope;

	while ( j > 0 ) {

		// Los parametros formales NO sirven
		fin = 0;
		do {

			strAux = getItemText(j, COL_TIPOTS);
			if ( strcmp(strAux.text(), "PAR_FORMAL") != 0 )
				fin = 1;
			else
				j--;

		} while ( fin == 0 );

		strAux = getItemText(j, COL_LEXEMA);

		if ( strcmp(strAux.text(), id) == 0 ) {

			nomTipo = getItemText(j, COL_TDATO);

			for ( i = 0
				; strcmp(nomTipo.text(), nomTiposDato[i]) != 0
				; i++ );

			printf("Encontrado %s tipo: %d\n", id, i);

			// Seleccionamos el item encontrado en la TS
			setSelTextColor(colores[SIM_FG]);
			setSelBackColor(colores[SIM_BG]);
			// selectRange(j, j, COL_LEXEMA, COL_TDATO);
			selectRange(j, j, COL_LEXEMA, COL_ETQ_ELSE);
			itemSelMin = j;
			itemSelMax = j+1;

			return (tDato)i;

		} else {
			j--;
			}
		}

	return DESC;
	}
/************************************************************************
    Notify item clicked
************************************************************************/
void ItemListbox::notifyItemClicked(ItemEntry* li)
{
    bool sel_state = !(li->isSelected() && d_multiSelect);
    bool skip = false;

    // multiselect enabled
    if (d_multiSelect)
    {
        uint syskeys = getGUIContext().getSystemKeys().get();
        ItemEntry* last = d_lastSelected;

        // no Control? clear others
        if (!(syskeys & Control))
        {
            clearAllSelections();
            if (!sel_state)
            {
                sel_state=true;
            }
        }

        // select range if Shift if held, and we have a 'last selection'
        if (last && (syskeys & Shift))
        {
            selectRange(getItemIndex(last),getItemIndex(li));
            skip = true;
        }
    }
    else
    {
        clearAllSelections();
    }

    if (!skip)
    {
        li->setSelected_impl(sel_state,false);
        if (sel_state)
        {
            d_lastSelected = li;
        }
        else if (d_lastSelected == li)
        {
            d_lastSelected = 0;
        }
    }

    WindowEventArgs e(this);
    onSelectionChanged(e);
}
Example #6
0
WSpacePlot::WSpacePlot(QSize size, bool dg, 
		       QWidget* parent, QWidget *colorBarParent,
		       WGraphXAxis::Position xAxisPos,
		       WGraphYAxis::Position yAxisPos,
		       int border)
  : WGraphWidget(parent,xAxisPos,yAxisPos,border),
    paintColor(red), dataRange(0.0, 1.0),
    recRects(0), cellLabelRect(QRect()),
    colorBar(0), startCell(0,0), currCell(0,0), 
    selecting(true), dragEnabled(false), drawGrid(dg), 
    autoScale(true), multiSelect(true) {
    
    if (colorBarParent) {
      colorBar = new WColorBar(colorBarParent);
      connect(this,SIGNAL(colorChanged(QColor)),
	      colorBar,SLOT(setColor(QColor)));
      connect(colorBar,SIGNAL(rangeSelected(WRange)),
	      this,SLOT(selectRange(WRange)));
      connect(colorBar,SIGNAL(yVisRangeChanged(WRange)),
	      this,SLOT(setDataRange(WRange)));
      colorBar->show();
    } 
    
    setCursor(crossCursor);

    if (drawGrid) setBackgroundColor(white);
    
    setFocusPolicy(TabFocus);
    
    xAxis()->setBaseTick(1.0);
    yAxis()->setBaseTick(1.0);
    
    showGrid(false);
    
    setSize(size);
    
    autoPanTimer = new QTimer(this);
    labelClearTimer = new QTimer(this);
    
    connect(frame(),SIGNAL(aboutToDraw()),this,SLOT(checkDataRange()));
    connect(autoPanTimer,SIGNAL(timeout()),this,SLOT(autoPan()));
    connect(labelClearTimer,SIGNAL(timeout()),this,SLOT(clearCellLabel()));
    connect(this,SIGNAL(frameResized()),SLOT(calcGeometry()));
    connect(this,SIGNAL(visRangeChanged()),SLOT(calcGeometry()));
  }
Example #7
0
Literal ClaspBerkmin::doSelect(Solver& s) {
	const uint32 decayMask = order_.huang ? 127 : 511;
	if ( ((s.stats.solve.choices + 1)&decayMask) == 0 ) {
		if ((order_.decay += (1+!order_.huang)) == BERK_MAX_DECAY) {
			order_.resetDecay();
		}
	}
	if (hasTopUnsat(s)) {        // Berkmin based decision
		assert(!freeLits_.empty());
		Literal x = selectRange(s, &freeLits_[0], &freeLits_[0]+freeLits_.size());
		return selectLiteral(s, x.var(), false);
	}
	else if (hasActivities()) {  // Vsids based decision
		return selectLiteral(s, getMostActiveFreeVar(s), true);
	}
	else {                       // Moms based decision
		return selectLiteral(s, getTopMoms(s), true);
	}
}
Example #8
0
void FXTabSim::marcar(void) {
	FXint i;
	FXint filaFin, filaIni;
	FXint iniLocales;
	FXint blqActual;

	setSelTextColor(colores[DEL_FG]);
	setSelBackColor(colores[DEL_BG]);

	if ( bloques->no() == 0 ) {
		printf("ACCESO A BLOQUES VACIO!!!\n");
		blqActual = 2;
	} else {
		blqActual = (*bloques)[bloques->no()-1];
		}

	selectRange(blqActual-1, tope, COL_LEXEMA, COL_ETQ_ELSE);

	return;
	}
Example #9
0
int FXTabSim::marcarCTRL(void) {
	FXint index, num;
	FXString strAux;

	index = tope+1;

	do {
		index--;
		strAux = getItemText(index, COL_TIPOTS);

	} while ( strcmp(strAux.text(), "DESC_CTRL") != 0 );

	num = tope-index+1;
	indexCtrl = index;

	setSelTextColor(colores[DEL_FG]);
	setSelBackColor(colores[DEL_BG]);
	selectRange(index, tope, COL_LEXEMA, COL_ETQ_ELSE);

	return num;
	}
Example #10
0
int FXTabSim::buscarPROC(char *lex) {
	FXint index;
	FXString lexAct;
	FXString strNParam;

	index = tope;

	do {
		lexAct = getItemText(index, COL_TIPOTS);

		printf("Index: %d TipoTS: %s\n", index, lexAct.text());

		/** @todo Tener en cuenta las FUNCIONES */
		if ( compare(lexAct.text(), "PROC") == 0 ) {
			lexAct = getItemText(index, COL_LEXEMA);
			printf("Es un PROC >> Lexema: %s\n", lexAct.text());
			if ( compare(lexAct.text(), lex) == 0 ) {
				// Encontrado...
				iniProc = index;
				posParam = iniProc+1;
				strNParam = getItemText(index, COL_NPAR);
				numPar = FXIntVal(strNParam.text());

				// Lo marcamos
				setSelTextColor(colores[PROC_FG]);
				setSelBackColor(colores[PROC_BG]);
				selectRange(index, index
					, COL_LEXEMA, COL_ETQ_ELSE);

				return numPar;
				}
			}

		index--;

	} while ( index > -1 );

	return -1;
	}
Example #11
0
void MVListBase::selectNext(uint direction,int count,ulong modifiers,
    ibool toTop)
/****************************************************************************
*
* Function:     MVListBase::selectNext
* Parameters:   direction   - Flags indicating the direction to move
*               count       - Number of cells to move down
*               modifiers   - Keyboard shift modifiers
*               toTop       - True if the cell should be moved to the top
*
* Description:  Adjusts the selection by the specified number of cells in
*               the specified direction. If the shift modifiers are set,
*               then the selection is extended.
*
****************************************************************************/
{
    MVPoint oldCursor(cursor);
    int maxv = maxV(),minv = minV();
    int maxh = maxH(),minh = minH();

    if (direction & lsBelow)
        if ((cursor.y += count) > maxv)
            cursor.y = maxv;
    if (direction & lsAbove)
        if ((cursor.y -= count) < minv)
            cursor.y = minv;
    if (direction & lsRight)
        if ((cursor.x += count) > maxh)
            cursor.x = maxh;
    if (direction & lsLeft)
        if ((cursor.x -= count) < minh)
            cursor.x = minh;

    if (cursor != oldCursor || (flags & lsExtending)) {
        if ((flags & lsMultipleSelect) && (modifiers & mdShift)) {
            if (cursor == oldCursor)
                return;

            if (direction & lsLeft) {
                if (flags & lsExtendRight) {
                    // We are currently extending in the opposite direction,
                    // so clear all of the cells from the old cursor position
                    // to one above the new cursor position. If the selection
                    // is only one high, then turn off the extending flags.
                    if (cursor.x <= selection.left()) {
                        flags &= ~lsExtendHoriz;
                        selection.right() = selection.left()+1;
                        selection.left() = cursor.x;
                        if (selection.left() != selection.right()-1) {
                            flags |= lsExtendLeft;
                            selectRange(selection);
                            }
                        }
                    else
                        selection.right() = cursor.x+1;
                    clearRange(selection.right(),selection.top(),
                        oldCursor.x+1,selection.bottom());
                    }
                else {
                    // We are currently extending the selection in the same
                    // direction, or have just started to extend the selection
                    flags |= lsExtendLeft;
                    selection.left() = cursor.x;
                    selectRange(cursor.x,selection.top(),
                        oldCursor.x,selection.bottom());
                    }
                }

            if (direction & lsRight) {
                if (flags & lsExtendLeft) {
                    if (cursor.x >= selection.right()-1) {
                        flags &= ~lsExtendHoriz;
                        selection.left() = selection.right()-1;
                        selection.right() = cursor.x+1;
                        if (selection.left() != selection.right()-1) {
                            flags |= lsExtendRight;
                            selectRange(selection);
                            }
                        }
                    else
                        selection.left() = cursor.x;
                    clearRange(oldCursor.x,selection.top(),
                        selection.left(),selection.bottom());
                    }
                else {
                    flags |= lsExtendRight;
                    selection.right() = cursor.x+1;
                    selectRange(oldCursor.x+1,selection.top(),
                        cursor.x+1,selection.bottom());
                    }
                }

            if (direction & lsAbove) {
                if (flags & lsExtendDown) {
                    if (cursor.y <= selection.top()) {
                        flags &= ~lsExtendVert;
                        selection.bottom() = selection.top()+1;
                        selection.top() = cursor.y;
                        if (selection.top() != selection.bottom()-1) {
                            flags |= lsExtendUp;
                            selectRange(selection);
                            }
                        }
                    else
                        selection.bottom() = cursor.y+1;
                    clearRange(selection.left(),selection.bottom(),
                        selection.right(),oldCursor.y+1);
                    }
                else {
                    flags |= lsExtendUp;
                    selection.top() = cursor.y;
                    selectRange(selection.left(),cursor.y,
                        selection.right(),oldCursor.y);
                    }
                }

            if (direction & lsBelow) {
                if (flags & lsExtendUp) {
                    if (cursor.y >= selection.bottom()-1) {
                        flags &= ~lsExtendVert;
                        selection.top() = selection.bottom()-1;
                        selection.bottom() = cursor.y+1;
                        if (selection.top() != selection.bottom()-1) {
                            flags |= lsExtendDown;
                            selectRange(selection);
                            }
                        }
                    else
                        selection.top() = cursor.y;
                    clearRange(selection.left(),oldCursor.y,
                        selection.right(),selection.top());
                    }
                else {
                    flags |= lsExtendDown;
                    selection.bottom() = cursor.y+1;
                    selectRange(selection.left(),oldCursor.y+1,
                        selection.right(),cursor.y+1);
                    }
                }
            dirtyCell(oldCursor);
            }
        else {
            // The selection is not being extended, so clear any previous
            // selection and turn extending off, and reselect the cell
            // under the cursor.
            flags &= ~lsExtending;
            if (!(flags & lsDisjointSelect)) {
                clearSelection();
                selectCell(cursor);
                }
            else {
                dirtyCell(oldCursor);
                dirtyCell(cursor);
                }
            }

        MV_message(owner,evBroadcast,cmListCursorChanged,this);
        refresh();
        }
    focusCurrent(toTop);
}
Example #12
0
FXbool FXTabSim::intro(stEntrada reg) {
	FXint nFilas, nCols, i, j, npars;
	FXString id;
	FXint colFin, num;
	FXString strAux;
	FXint nuevoBlq;
	FXint indx, fin, posMarca;


	nFilas = getNumRows();

	if ( (tope+1) == nFilas )
		insertRows(nFilas);

	if ( reg.tipoTs == MARCA ) {
		numRegs++;
		tope++;

		posMarca = tope;

		setItemText(tope, COL_LEXEMA, "FIN_PARAMS");
		setItemText(tope, COL_TIPOTS, nomTiposTS[reg.tipoTs]);
		setItemText(tope, COL_NPAR, "<ACTIVOS>");

		// El bloque empieza en la posicion siguiente a la marca
		bloques->append(posMarca+1);

		// Copia de los parametros como variables locales
		indx = tope;
		fin = 0;

		do {

			nFilas = getNumRows();
			if ( (tope+1) == nFilas )
				insertRows(nFilas, 5);

			indx--;
			strAux = getItemText(indx, COL_TIPOTS);
			if ( strcmp(strAux.text(), "PAR_FORMAL") == 0 ) {
				tope++;
				strAux = getItemText(indx, COL_LEXEMA);
				setItemText(tope, COL_LEXEMA, strAux.text());
				setItemText(tope, COL_TIPOTS, "COPIA_PARAM");
				strAux = getItemText(indx, COL_TDATO);
				setItemText(tope, COL_TDATO, strAux.text());
			} else {
				fin = 1;
				}

		} while ( !fin );

				
		itemSelMin = posMarca;
		itemSelMax = tope+1;

		setSelTextColor(colores[NEW_FG]);
		setSelBackColor(colores[NEW_BG]);

		// selectRange(posMarca, tope, COL_LEXEMA, COL_NPAR);
		selectRange(posMarca, tope, COL_LEXEMA, COL_ETQ_ELSE);

		return true;
		}

	if ( reg.tipoTs == DESC_CTRL ) {

		tope++;
		numRegs++;

		setItemText(tope, COL_LEXEMA, reg.lexema);
		setItemText(tope, COL_TIPOTS, nomTiposTS[reg.tipoTs]);
		setItemText(tope, COL_NOM_CTRL, reg.nomVarCtrl);
		setItemText(tope, COL_ETQ_ENT, reg.etqtEnt);
		setItemText(tope, COL_ETQ_SAL, reg.etqtSal);
		setItemText(tope, COL_ETQ_ELSE, reg.etqtElse);

		itemSelMin = tope;
		itemSelMax = tope+1;

		setSelTextColor(colores[NEW_FG]);
		setSelBackColor(colores[NEW_BG]);
		selectRange(tope, tope, COL_LEXEMA, COL_ETQ_ELSE);

		return true;
		}

	// Si es un parametro formal buscamos si el simbolo
	// esta duplicado hasta el proc/funcion

	if ( reg.tipoTs == PAR_FORMAL ) {
		indx = tope;
		strAux = getItemText(indx, COL_TIPOTS);

		while ( compare(strAux.text(), "PAR_FORMAL") == 0 )
			{
			strAux = getItemText(indx, COL_LEXEMA);
			if ( compare(strAux.text(), reg.lexema) == 0 ) {
				// Simbolo duplicado => Lo marcamos
				setSelTextColor(colores[DUP_FG]);
				setSelBackColor(colores[DUP_BG]);

				//selectRange(indx, indx, COL_LEXEMA, COL_TDATO);
				selectRange(indx, indx, COL_LEXEMA, COL_ETQ_ELSE);
				return false;
				}

			strAux = getItemText(--indx, COL_TIPOTS);
			}

		// Solo queda comparar con el proc/funcion
		if ( compare(strAux.text(), "PROC") == 0 ) {
			strAux = getItemText(indx, COL_LEXEMA);
			if ( compare(strAux.text(), reg.lexema) == 0 ) {
				// Simbolo duplicado
				setSelTextColor(colores[DUP_FG]);
				setSelBackColor(colores[DUP_BG]);

				//selectRange(indx, indx, COL_LEXEMA, COL_TDATO);
				selectRange(indx, indx, COL_LEXEMA, COL_ETQ_ELSE);
				return false;
				}
			}

		// Ya podemos insertarlo
		tope++;
		setItemText(tope, COL_LEXEMA, reg.lexema);
		setItemText(tope, COL_TIPOTS, nomTiposTS[reg.tipoTs]);
		setItemText(tope, COL_TDATO, nomTiposDato[reg.tipoDato]);

		// Actualizamos num de parametros del proc
		setItemText(iniProc, COL_NPAR, FXStringVal(++numPar));

		// Seleccionamos nuevo simbolo
		setSelTextColor(colores[NEW_FG]);
		setSelBackColor(colores[NEW_BG]);

		// Otra forma: seleccionar SIEMPRE la fila entera
		//selectRange(tope, tope, COL_LEXEMA, COL_TDATO);
		selectRange(tope, tope, COL_LEXEMA, COL_ETQ_ELSE);

		return true;
		}
				

	// Verificamos que el simbolo NO ha sido declarado previamente
	// => Hasta encontrar MARCA !!!!

	if ( bloques->no() > 0 )
		j = (*bloques)[bloques->no()-1];
	else
		j = 0;


	while ( (j <= tope) && (tope != -1) ) {

		strAux = getItemText(j, COL_TIPOTS);

		/************   Ya no hace falta
		if ( strcmp(strAux.text(), "MARCA") == 0 )
			j++;
		********************************/


		if ( strcmp(reg.lexema, getItemText(j, COL_LEXEMA).text()) == 0 ) {
			// Simbolo ya declarado... Lo Marcamos
			printf("Simbolo repetido: %s y %s\n"
				, getItemText(j, COL_LEXEMA).text(), reg.lexema);

			itemSelMin = j;
			itemSelMax = j+1;

			setSelTextColor(colores[DUP_FG]);
			setSelBackColor(colores[DUP_BG]);

			// selectRange(j, j, COL_LEXEMA, COL_TDATO);
			selectRange(j, j, COL_LEXEMA, COL_ETQ_ELSE);
			return false;
		
		} else {
			j++;
			}

		}

	// Si no lo hemos encontrado podemos insertarlo
	
	numRegs++;
	tope++;

	FXTable::setItemText(tope, COL_LEXEMA, reg.lexema);
	FXTable::setItemText(tope, COL_TIPOTS, nomTiposTS[reg.tipoTs]);
	// FXTable::setItemText(tope, COL_TDATO, nomTiposDato[reg.tipoDato]);

	if ( reg.tipoTs == PROC ) {
		FXTable::setItemText(tope, COL_NPAR, "0");
		iniProc = tope;
		numPar = 0;
		colFin = COL_NPAR;

		/*******************************
		blqAnt = (bloque == -1)?0:bloque;
		bloque = tope;
		nuevoBlq = tope;
		bloques->append(nuevoBlq);
		printf(">> Ini BLOQUE: %d\n", (*bloques)[bloques->no()-1]);
		************************************************************/

	} else if ( reg.tipoTs == PAR_FORMAL ) {
		FXTable::setItemText(tope, COL_TDATO, nomTiposDato[reg.tipoDato]);
		FXTable::setItemText(iniProc, COL_NPAR, FXStringVal(++numPar));
		colFin = COL_TDATO;
	} else {
		FXTable::setItemText(tope, COL_TDATO, nomTiposDato[reg.tipoDato]);
		colFin = COL_TDATO;
		}


	// Seleccionamos nuevo simbolo

	setSelTextColor(colores[NEW_FG]);
	setSelBackColor(colores[NEW_BG]);

	// Otra forma: seleccionar SIEMPRE la fila entera
	// selectRange(tope, tope, COL_LEXEMA, colFin);
	selectRange(tope, tope, COL_LEXEMA, COL_ETQ_ELSE);

	itemSelMin = tope;
	itemSelMax = tope+1;

	return true;
	}
Example #13
0
void CEditableRange::OnSelectRange() 
{
	selectRange();
}
Example #14
0
bool PaletteView::onProcessMessage(Message* msg)
{
  switch (msg->type) {

    case JM_REQSIZE:
      request_size(&msg->reqsize.w, &msg->reqsize.h);
      return true;

    case JM_DRAW: {
      div_t d = div(Palette::MaxColors, m_columns);
      int cols = m_columns;
      int rows = d.quot + ((d.rem)? 1: 0);
      int x, y, u, v;
      int c, color;
      BITMAP *bmp;
      Palette* palette = get_current_palette();
      int bordercolor = makecol(255, 255, 255);

      bmp = create_bitmap(jrect_w(this->rc), jrect_h(this->rc));
      clear_to_color(bmp, makecol(0 , 0, 0));

      y = this->border_width.t;
      c = 0;

      for (v=0; v<rows; v++) {
        x = this->border_width.l;

        for (u=0; u<cols; u++) {
          if (c >= palette->size())
            break;

          if (bitmap_color_depth(ji_screen) == 8)
            color = c;
          else
            color = makecol_depth
              (bitmap_color_depth(ji_screen),
               _rgba_getr(palette->getEntry(c)),
               _rgba_getg(palette->getEntry(c)),
               _rgba_getb(palette->getEntry(c)));

          rectfill(bmp, x, y, x+m_boxsize-1, y+m_boxsize-1, color);

          if (m_selectedEntries[c]) {
            const int max = Palette::MaxColors;
            bool top    = (c >= m_columns            && c-m_columns >= 0  ? m_selectedEntries[c-m_columns]: false);
            bool bottom = (c < max-m_columns         && c+m_columns < max ? m_selectedEntries[c+m_columns]: false);
            bool left   = ((c%m_columns)>0           && c-1         >= 0  ? m_selectedEntries[c-1]: false);
            bool right  = ((c%m_columns)<m_columns-1 && c+1         < max ? m_selectedEntries[c+1]: false);

            if (!top) hline(bmp, x-1, y-1, x+m_boxsize, bordercolor);
            if (!bottom) hline(bmp, x-1, y+m_boxsize, x+m_boxsize, bordercolor);
            if (!left) vline(bmp, x-1, y-1, y+m_boxsize, bordercolor);
            if (!right) vline(bmp, x+m_boxsize, y-1, y+m_boxsize, bordercolor);
          }

          x += m_boxsize+this->child_spacing;
          c++;
        }

        y += m_boxsize+this->child_spacing;
      }

      blit(bmp, ji_screen,
           0, 0, this->rc->x1, this->rc->y1, bmp->w, bmp->h);
      destroy_bitmap(bmp);
      return true;
    }

    case JM_BUTTONPRESSED:
      captureMouse();
      /* continue... */

    case JM_MOTION: {
      JRect cpos = jwidget_get_child_rect(this);

      int req_w, req_h;
      request_size(&req_w, &req_h);

      int mouse_x = MID(cpos->x1, msg->mouse.x, cpos->x1+req_w-this->border_width.r-1);
      int mouse_y = MID(cpos->y1, msg->mouse.y, cpos->y1+req_h-this->border_width.b-1);

      jrect_free(cpos);

      Color color = getColorByPosition(mouse_x, mouse_y);
      if (color.getType() == Color::IndexType) {
        int idx = color.getIndex();

        app_get_statusbar()->showColor(0, "", color, 255);

        if (hasCapture() && idx != m_currentEntry) {
          if (!(msg->any.shifts & KB_CTRL_FLAG))
            clearSelection();

          if (msg->any.shifts & KB_SHIFT_FLAG)
            selectRange(m_rangeAnchor, idx);
          else
            selectColor(idx);

          // Emit signals
          jwidget_emit_signal(this, SIGNAL_PALETTE_EDITOR_CHANGE);
          IndexChange(idx);
        }
      }

      if (hasCapture())
        return true;

      break;
    }

    case JM_BUTTONRELEASED:
      releaseMouse();
      return true;

    case JM_WHEEL: {
      View* view = View::getView(this);
      if (view) {
        gfx::Point scroll = view->getViewScroll();
        scroll.y += (jmouse_z(1)-jmouse_z(0)) * 3 * m_boxsize;
        view->setViewScroll(scroll);
      }
      break;
    }

    case JM_MOUSELEAVE:
      app_get_statusbar()->clearText();
      break;

  }

  return Widget::onProcessMessage(msg);
}
Example #15
0
/*************************************************************************
    Handler for when mouse button is pressed
*************************************************************************/
void Tree::onMouseButtonDown(MouseEventArgs& e)
{
    // base class processing
    // populateGeometryBuffer();
    Window::onMouseButtonDown(e);
    
    if (e.button == LeftButton)
    {
        //bool modified = false;
        
        Vector2f localPos(CoordConverter::screenToWindow(*this, e.position));
        //      Point localPos(screenToWindow(e.position));
        
        TreeItem* item = getItemAtPoint(localPos);
        
        if (item != 0)
        {
            //modified = true;
            TreeEventArgs args(this);
            args.treeItem = item;
            populateGeometryBuffer();
            Rectf buttonLocation = item->getButtonLocation();
            if ((localPos.d_x >= buttonLocation.left()) && (localPos.d_x <= buttonLocation.right()) &&
                (localPos.d_y >= buttonLocation.top()) && (localPos.d_y <= buttonLocation.bottom()))
            {
                item->toggleIsOpen();
                if (item->getIsOpen())
                {
                    TreeItem *lastItemInList = item->getTreeItemFromIndex(item->getItemCount() - 1);
                    ensureItemIsVisible(lastItemInList);
                    ensureItemIsVisible(item);
                    onBranchOpened(args);
                }
                else
                {
                    onBranchClosed(args);
                }
                
                // Update the item screen locations, needed to update the scrollbars.
                //	populateGeometryBuffer();
                
                // Opened or closed a tree branch, so must update scrollbars.
                configureScrollbars();
            }
            else
            {
                // clear old selections if no control key is pressed or if multi-select is off
                if (!(e.sysKeys & Control) || !d_multiselect)
                    clearAllSelections_impl();
                
                // select range or item, depending upon keys and last selected item
#if 0 // TODO: fix this
                if (((e.sysKeys & Shift) && (d_lastSelected != 0)) && d_multiselect)
                    selectRange(getItemIndex(item), getItemIndex(d_lastSelected));
                else
#endif
                    item->setSelected(item->isSelected() ^ true);
                
                // update last selected item
                d_lastSelected = item->isSelected() ? item : 0;
                onSelectionChanged(args);
            }
        }
        else
        {
            // clear old selections if no control key is pressed or if multi-select is off
            if (!(e.sysKeys & Control) || !d_multiselect)
            {
                if (clearAllSelections_impl())
                {
                    // Changes to the selections were actually made
                    TreeEventArgs args(this);
                    args.treeItem = item;
                    onSelectionChanged(args);
                }
            }
        }
        
        
        ++e.handled;
    }
}