Beispiel #1
0
void FXTabSim::limpiar(void) {
	FXint sr, er, sc, ec;
	FXint i, j;

	sr = getSelStartRow();
	er = getSelEndRow();
	sc = getSelStartColumn();
	ec = getSelEndColumn();

	printf("ANTES LIMPIAR sr %d er %d sc %d ec %d\n", sr, er, sc, ec);

	/********************
	for ( i = sr; i <= er; i++ )
		for( j = sc; j <= ec; j++ )
			deselectItem(i,j);
	 *******************************************/

	if ( sr != -1 && sc != -1 )
		killSelection();

	/*******************
	sr = getSelStartRow();
	er = getSelEndRow();
	sc = getSelStartColumn();
	ec = getSelEndColumn();

	printf("TRAS KILL SELECTION sr %d er %d sc %d ec %d\n", sr, er, sc, ec);

	if ( sr != -1 && ec != -1 )
		deselectItem(sr, ec);
	*************************************/
	}
void
MFXEditableTable::editEnd() {
    if (!myEditedItem) {
        return;
    }
    FXTableItem* item = myEditedItem;
    myEditedItem = NULL;
    myEditor->hide();
    setFocus();
    FXString text = myEditor->getText();
    myEditedItem = 0;
    if (item->getText() == text) {
        return;
    }
    if (handle(item, FXSEL(SEL_COMMAND, ID_EDITEND), &text)) {
        item->setText(text);
        handle(this, FXSEL(SEL_CHANGED, 0), item);
    }
    killSelection(true);
    if (target) {
        MFXEditedTableItem edited;
        edited.item = item;
        edited.row = myEditedRow;
        edited.col = myEditedCol;
        if (!target->handle(this, FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) {
            item->setText(myPreviousText);
        }
    }
}
Beispiel #3
0
// Pressed left button
long TextLabel::onLeftBtnPress(FXObject*,FXSelector,void* ptr)
{
    FXEvent* ev=(FXEvent*)ptr;
    handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
    if (isEnabled())
    {
        grab();
        if (target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr))
        	return 1;
        flags&=~FLAG_UPDATE;
        if (ev->click_count==1)
        {
            setCursorPos(index(ev->win_x));
            if (ev->state&SHIFTMASK)
                extendSelection(cursor);
            else
            {
                killSelection();
                setAnchorPos(cursor);
            }
            makePositionVisible(cursor);
            flags|=FLAG_PRESSED;
        }
        else
        {
            setAnchorPos(0);
            setCursorPos(contents.length());
            extendSelection(contents.length());
            makePositionVisible(cursor);
        }
        return 1;
    }
    return 0;
}
Beispiel #4
0
void
MFXEditableTable::editCancel() {
    if (!myEditedItem) return;
    myEditedItem = 0;
    myEditor->hide();
    setFocus();
    killSelection(true);
}
// Pressed button
long
MFXAddEditTypedTable::onLeftBtnPress(FXObject*, FXSelector, void* ptr) {
    FXEvent* event = (FXEvent*)ptr;
    FXTablePos tablepos;
    flags &= ~FLAG_TIP;
    handle(this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
    if (isEnabled()) {
        grab();
        if (target && target->tryHandle(this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
            return 1;
        }

        // Cell being clicked on
        tablepos.row = rowAtY(event->win_y);
        tablepos.col = colAtX(event->win_x);

        // Outside table
        if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
            setCurrentItem(-1, -1, TRUE);
            return 0;
        }

        // Change current item
        bool wasEdited = editor != 0;
        setCurrentItem(tablepos.row, tablepos.col, TRUE);
        if (!wasEdited) {

            // Select or deselect
            if (event->state & SHIFTMASK) {
                if (0 <= anchor.row && 0 <= anchor.col) {
                    if (isItemEnabled(anchor.row, anchor.col)) {
                        extendSelection(current.row, current.col, TRUE);
                    }
                } else {
                    setAnchorItem(current.row, current.col);
                    if (isItemEnabled(current.row, current.col)) {
                        extendSelection(current.row, current.col, TRUE);
                    }
                }
                mode = MOUSE_SELECT;
            } else {
                if (isItemEnabled(current.row, current.col)) {
                    killSelection(TRUE);
                    setAnchorItem(current.row, current.col);
                    extendSelection(current.row, current.col, TRUE);
                } else {
                    setAnchorItem(current.row, current.col);
                }
                mode = MOUSE_SELECT;
            }
        }
        flags &= ~FLAG_UPDATE;
        flags |= FLAG_PRESSED;
        return 1;
    }
    return 0;
}
void
MFXAddEditTypedTable::setItemFromControl(FXint r, FXint c, FXWindow* control) {
    register FXTableItem* item = cells[r * ncols + c];
    if (item == NULL) {
        cells[r * ncols + c] = item = createItem("", NULL, NULL);
        if (isItemSelected(r, c)) {
            item->setSelected(FALSE);
        }
    }
    switch (getCellType(c)) {
        case CT_UNDEFINED:
        case CT_STRING:
            item->setFromControl(control);
            break;
        case CT_REAL:
            item->setText(toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_INT:
            item->setText(toString((int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_BOOL:
//        return myBoolEditor;
        case CT_ENUM:
//        return myEnumEditor;
        default:
            throw 1;
    }
//    current.row = -1;
//    current.col = -1;
    EditedTableItem edited;
    edited.item = item;
    edited.row = r;
    edited.col = c;
    edited.updateOnly = false;
    killSelection(true);
    bool accepted = true;
    if (target) {
        if (!target->handle(this, FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) {
            accepted = false;
            // !!! item->setText(myPreviousText);
        }
    }
    if (accepted) {
        if (edited.row == getNumRows() - 1) {
            insertRows(getNumRows(), 1, true);
            for (int i = 0; i < getNumColumns(); i++) {
                setItemText(getNumRows() - 1, i, "");
                setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
            }
        }
    }
    mode = MOUSE_NONE;
}
long
MFXEditableTable::onLeftBtnClicked(FXObject* , FXSelector , void* ptr) {
    FXTablePos* e = (FXTablePos*)ptr;
    int r = e->row;
    int c = e->col;
    if (c == -1 || r == -1) {
        return 1;
    }
    killSelection(false);
    myEditedItem = getItem(r, c);
    myEditedCol = c;
    myEditedRow = r;
    if (c >= 0 && r >= 0) {
        editItem(myEditedItem, 0);
    } else {
        editEnd();
    }
    return 1;
}