Exemplo n.º 1
0
/**
 * Saves the settings to \a config into section \a group.
 * The original group is saved and restored at the end of this function.
 * See @p load() for more information.
 */
void KTinyTabBar::save( KConfigBase* config, const QString& group ) const
{
    KConfigGroup cg( config, group );

    // tabbar properties
    cg.writeEntry( "location top", locationTop() );
    cg.writeEntry( "count of rows", numRows() );
    cg.writeEntry( "minimum width", minimumTabWidth() );
    cg.writeEntry( "maximum width", maximumTabWidth() );
    cg.writeEntry( "fixed height", tabHeight() );
    cg.writeEntry( "sort type", (int)tabSortType() );
    cg.writeEntry( "button style", (int) tabButtonStyle() );
    cg.writeEntry( "follow current tab", followCurrentTab() );
    cg.writeEntry( "highlight modified", highlightModifiedTabs() );
    cg.writeEntry( "highlight previous", highlightPreviousTab() );
    cg.writeEntry( "highlight active", highlightActiveTab() );
    cg.writeEntry( "highlight opacity", highlightOpacity() );


    // color settings
    cg.writeEntry( "color modified", modifiedTabsColor() );
    cg.writeEntry( "color active", activeTabColor() );
    cg.writeEntry( "color previous", previousTabColor() );

    // highlighted entries
    cg.writeEntry( "highlighted documents", m_highlightedTabs.keys() );
    cg.writeEntry( "highlighted colors", m_highlightedTabs.values() );
}
Exemplo n.º 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);
	}
}
Exemplo n.º 3
0
AWgtSlider::AWgtSlider(int x, int y, int width, int numStops, int currStop,
		int lineColor, int shadowColor, int lineThickness)
{
	this->x = x;
	this->y = y;
	this->width = width;
	this->height = tabHeight();
	this->numStops = MIN(width, numStops);
	this->currStop = MIN(numStops, currStop);
	this->tabClicked = false;
	this->lineColor = lineColor;
	this->shadowColor = shadowColor;
	this->lineThickness = lineThickness;
	this->hotkeys = 0;
}
Exemplo n.º 4
0
/**
 * Recalculate geometry for all children.
 */
void KTinyTabBar::resizeEvent( QResizeEvent* event )
{
//     kDebug() << "resizeEvent";
    // if there are no tabs there is nothing to do. Do not delete otherwise
    // division by zero is possible.
    if( m_tabButtons.count() == 0 )
    {
        updateHelperButtons( event->size(), 0 );
        return;
    }

    int tabbar_width = event->size().width() - ( 4 - ( numRows()>3?3:numRows() ) ) * m_navigateSize;
    int tabs_per_row = tabbar_width / minimumTabWidth();
    if( tabs_per_row == 0 )
        tabs_per_row = 1;

    int tab_width = minimumTabWidth();

    int needed_rows = m_tabButtons.count() / tabs_per_row;
    if( needed_rows * tabs_per_row < (int)m_tabButtons.count() )
        ++needed_rows;

    // if we do not need more rows than available we can increase the tab
    // buttons' width up to maximumTabWidth.
    if( needed_rows <= numRows() )
    {
        // use available size optimal, but honor maximumTabWidth()
        tab_width = tabbar_width * numRows() / m_tabButtons.count();

        if( tab_width > maximumTabWidth() )
            tab_width = maximumTabWidth();

        tabs_per_row = tabbar_width / tab_width;

        // due to rounding fuzzys we have to increase the tabs_per_row if
        // the number of tabs does not fit.
        if( tabs_per_row * numRows() < (int)m_tabButtons.count() )
            ++tabs_per_row;
    }

    // On this point, we really know the value of tabs_per_row. So a final
    // calculation gives us the tab_width. With this the width can even get
    // greater than maximumTabWidth(), but that does not matter as it looks
    // more ugly if there is a lot wasted space on the right.
    tab_width = tabbar_width / tabs_per_row;

    updateHelperButtons( event->size(), needed_rows );

    KTinyTabButton* tabButton;

    foreach( tabButton, m_tabButtons )
        tabButton->hide();

    for( int row = 0; row < numRows(); ++row )
    {
        int current_row = row + currentRow();
        for( int i = 0; i < tabs_per_row; ++i )
        {
            // value returns 0L, if index is out of bounds
            tabButton = m_tabButtons.value( current_row * tabs_per_row + i );

            if( tabButton )
            {
                tabButton->setGeometry( i * tab_width, row * tabHeight(),
                                        tab_width, tabHeight() );
                tabButton->show();
            }
        }
    }
}
Exemplo n.º 5
0
/**
 * May modifies current row if more tabs fit into a row.
 * Sets geometry for the buttons 'up', 'down' and 'configure'.
 */
void KTinyTabBar::updateHelperButtons( QSize new_size, int needed_rows )
{
    // if the size increased so that more tabs fit into one row it can happen
    // that suddenly a row on the bottom is empty - or that even all rows are
    // empty. That is not desired, so make sure that currentRow has a
    // reasonable value.
    if( currentRow() + numRows() > needed_rows )
        m_currentRow = ( needed_rows - numRows() < 0 ?
                         0 : needed_rows - numRows() );

    m_upButton->setEnabled( currentRow() != 0 );
    m_downButton->setEnabled( needed_rows - currentRow() > numRows() );

    // set geometry for up, down, configure
    switch( numRows() )
    {
    case 1:
        m_upButton->setGeometry( new_size.width() - 3 * m_navigateSize,
                                 0, m_navigateSize, tabHeight() );
        m_downButton->setGeometry( new_size.width() - 2 * m_navigateSize,
                                   0, m_navigateSize, tabHeight() );
        m_configureButton->setGeometry( new_size.width() - m_navigateSize,
                                        0, m_navigateSize, tabHeight() );
        break;
    case 2:
        m_upButton->setGeometry( new_size.width() - 2 * m_navigateSize,
                                 0, m_navigateSize, tabHeight() );
        m_downButton->setGeometry( new_size.width() - 2 * m_navigateSize,
                                   tabHeight(), m_navigateSize, tabHeight() );
        m_configureButton->setGeometry( new_size.width() - m_navigateSize,
                                        0, m_navigateSize, 2 * tabHeight() );
        break;
    default:
        m_upButton->setGeometry( new_size.width() - m_navigateSize,
                                 0, m_navigateSize, tabHeight() );
        m_downButton->setGeometry( new_size.width() - m_navigateSize,
                                   tabHeight(), m_navigateSize, tabHeight() );
        m_configureButton->setGeometry( new_size.width() - m_navigateSize,
                                        2 * tabHeight(), m_navigateSize, tabHeight() );
        break;
    }
}
Exemplo n.º 6
0
/**
 * Updates the fixed height. Called when the tab height or the number of rows
 * changed.
 */
void KTinyTabBar::updateFixedHeight()
{
    setFixedHeight( numRows() * tabHeight() );
    triggerResizeEvent();
}