Exemple #1
0
int AWgtSlider::getStopPos(int stop)
{
	if (stop == 0)
		return x + (tabWidth() / 2);
	else if (stop >= (numStops-1))
		return x+width-(tabWidth() / 2);
	else {
		return x + (width / (numStops - 1) * stop);
	}
}
Exemple #2
0
void AWgtSlider::draw()
{
	int ly = y + (tabHeight() / 2) - lineThickness;

	rectfill(tguiBitmap, x, ly, x+width-1, ly+lineThickness, lineColor);
	rectfill(tguiBitmap, x, ly+lineThickness, x+width-1,
			ly+(lineThickness*2), shadowColor);

	if (focus) {
		drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0);
		rect(tguiBitmap, x-1, ly-1, x+width, ly+(lineThickness*2)+1,
				aWgtFocusColor);
		drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);
	}

	int tx = getStopPos(currStop) - (tabWidth() / 2);

	if (sliderTabBmp) {
		draw_sprite(tguiBitmap, sliderTabBmp, tx, y);
	}
	else {
		rect(tguiBitmap, tx, y, tx+sliderDefaultTabWidth-1,
				y+sliderDefaultTabHeight-1, shadowColor);
		rectfill(tguiBitmap, tx+1, y+1, tx+sliderDefaultTabWidth-2,
				y+sliderDefaultTabHeight-2, lineColor);
	}
}
Exemple #3
0
/**
 * Fills a Config structure with the current configuration options.
 * Used to get QScintilla's default values.
 * @param config
 */
void Editor::getConfig(Config& config)
{
	QsciLexer* lex = lexer();
	if (lex)
		config.font_ = lex->defaultFont();
	else
		config.font_ = font();

	config.indentTabs_ = indentationsUseTabs();
	config.tabWidth_ = tabWidth();
	config.hlCurLine_ = false;
}
Exemple #4
0
void AWgtSlider::mouseDown()
{
	int mx = tguiActiveWidgetClickedPoint.x;

	int tcx = getStopPos(currStop) - x; // center of tab;
	int tlx = tcx - (tabWidth() / 2); // left of tab
	int trx = tcx + (tabWidth() / 2); // right of tab

	if (mx < tlx) {
		if (currStop)
			currStop--;
	}
	else if (mx > trx) {
		if (currStop < (numStops-1))
			currStop++;
	}
	else {
		tabClicked = true;
		clickX = mouse_x;
	}
}
void ScintillaEditor::changeSpacesToTabs() {
/*  -changes spaces into tabs */
    //go through the text line by line and replace spaces with tabs
    QStringList editorTextLines = text().split( QRegularExpression("\n") );

    QString textExpression = tr("\\s{2,%1}").arg( tabWidth() );

    for (int i = 0, l = editorTextLines.length(); i < l; i++) {
        editorTextLines[i].replace( QRegularExpression(textExpression), "\t");
    }

    setText( editorTextLines.join("\n") );
}
Exemple #6
0
void AllegroTabBar::setSizeAndPos(int newX, int newY, int newWidth, int newHeight)
{
    StandardAllegroWidget::setSizeAndPos(newX, newY, newWidth, newHeight);
    
    for(int i=0; i<tabs.size(); i++)
    {
        tabs[i].setSizeAndPos(newX+3+tabX[i], newY, tabWidth(i)+1, newHeight);
        if(newX+3+tabX[i+1]>=newX+newWidth-3)
            tabs[i].setActive(false);
        else
            lastVisible=i;
    }
    
    tooBig=lastVisible!=tabs.size()-1;
}
void ScintillaEditor::changeTabsToSpaces() {
/*  -changes indentation tabs into spaces */
    //go through the text line by line and replace tabs with spaces
    QStringList editorTextLines = text().split( QRegularExpression("\n") );

    QString replaceText("");
    for (int i = 0, l = tabWidth(); i < l; i++) {
        replaceText.append(' ');
    }

    for (int i = 0, l = editorTextLines.length(); i < l; i++) {
        editorTextLines[i].replace('\t', replaceText);
    }

    setText( editorTextLines.join("\n") );
}
Exemple #8
0
void pEditor::convertTabs()
{
    // get original text
    QString originalText = text();
    // all modifications must believe as only one action
    beginUndoAction();
    // get indent width
    const int indentWidth = indentationWidth() != 0 ? indentationWidth() : tabWidth();
    // iterate each line
    for ( int i = 0; i < lines(); i++ )
    {
        // remember if last line was troncate
        static bool lastLineWasTroncate = false;
        // get current line indent width
        int lineIndent = indentation( i );
        // check if need troncate
        int t = lineIndent /indentWidth;
        int r = lineIndent %indentWidth;
        if ( r != 0 && r != indentWidth )
        {
            r += indentWidth -r;
            lineIndent = ( t *indentWidth) +r;
            lastLineWasTroncate = true;
        }
        else if ( lastLineWasTroncate && lineIndent != 0 )
        {
            lastLineWasTroncate = indentation( i +1 ) == lineIndent;
            lineIndent  += indentWidth;
        }
        // remove indentation
        setIndentation( i, 0 );
        // restore it with possible troncate indentation
        setIndentation( i, lineIndent );
    }
    // end global undo action
    endUndoAction();
    // compare original and newer text
    if ( originalText == text() )
    {
        // clear undo buffer
        SendScintilla( SCI_EMPTYUNDOBUFFER );
        // set unmodified
        setModified( false );
    }
}