void ListedTextItems::PaintArea( const Painter &painter, const Rect &area, int stateID)
{
    if ( _skins.Select(stateID) )
    {
        int cur_w = _skins.GetWidth();
        int cur_h = _skins.GetHeight();
        _skins.SetSize( Dim2i( area.GetW(), area.GetH()));
        _skins.Paint( painter, area.GetPos());
        _skins.SetSize( Dim2i( cur_w, cur_h));
    }
}
void TableListedItems::PaintClients( const WidgetPainter &painter )
{
    Pos p;
    Dim2i d( GetWidth(), 0);

    Rect client_area = GetParent()->GetClientRect(this)-GetPosition();
    Rect visibile = TableWidget::GetCrossing( client_area );
    
    p.y = RowRect( visibile.GetY1() ).GetY();
    for ( int i=visibile.GetY1(); i<visibile.GetY2(); ++i )
    {
        d.y = GetRowHeight(i);

        int last_col = GetNumColumns() -1;
        Rect fa = RowRect( i );

        if ( _skins.Select( GetState(i) ) )
        {
            _skins.SetSize( Dim2i(fa.GetW(),fa.GetH()) );
        }
        _skins.Paint( painter, fa.GetPos(), fa );

        p.y += d.y;
    }
}
void TableWidget::UpdateTable()
{
    SortedVector<int> xdividers;
    SortedVector<int> ydividers;
    
    const cell_t *p = &*_columns.begin();
    const cell_t *q = &*_columns.end();
    if (p!=q) while( ++p!=q )
    {
        xdividers.Insert( p->position + _frame_left );
    }

    p = &*_rows.begin();
    q = &*_rows.end();
    if (p!=q) while( ++p!=q )
    {
        ydividers.Insert( p->position + _frame_top );
    }

    //_sp_skin->SetSize( Dim2i(_w,_h) );
    _sp_skin->SetSize( Dim2i( GetWidth(), GetHeight()) );
    _sp_skin->SetVDividers(xdividers);
    _sp_skin->SetHDividers(ydividers);
    _need_update = false;
    
    OnTableUpdate.Send();
}
void ListedTextItems::SetSelectorSize( int w, int h)
{
    int _w = GetWidth();
    if ( h==-1 ) { h=_entry_height; }

    _skins.Get().SetSizeAll( Dim2i(w,h) );
    
    _selector_size = _skins.Get().GetMaxSize();

    if (           _w  < _selector_size.x )          { _w = _selector_size.x; }
    if ( _entry_height < _selector_size.y ) { _entry_height=_selector_size.y; }

    SetDimensions( _w, GetH() );
}
Beispiel #5
0
//-----------------------------------------------------------------
void GetSupportedVideoModes(std::vector<Dim2i>& out)
{
    out.clear();
    int num_modes = SDL_GetNumDisplayModes(0);
    for (int i = 0; i < num_modes; ++i) {
        SDL_DisplayMode mode;
        if (SDL_GetDisplayMode(0, i, &mode) == 0) {
            // see if the video mode is already listed
            bool vmode_not_yet_listed = true;
            for (int j = 0; j < (int)out.size(); j++) {
                if (out[j].width == mode.w && out[j].height == mode.h) {
                    vmode_not_yet_listed = false;
                }
            }
            if (vmode_not_yet_listed) {
                out.push_back(Dim2i(mode.w, mode.h));
            }
        }
    }
}
void TableSkin::TableDice( const Rect &bound, int x1, int x2, int x3, int y1, int y2, int y3, bool no_interrior)
{
    AssocVector<int ,Rect> assoc_rects;

    Pos p0;// = bound.GetPos();

    int x[5] = { 0, x1, x2, x3, bound.GetW() };
    int y[5] = { 0, y1, y2, y3, bound.GetH() };

    assoc_rects.Insert( TOP+HEAD, CheckedRect( x[0], y[0], x[1]-x[0], y[1]-y[0]) +p0);
    assoc_rects.Insert( TOP+BODY, CheckedRect( x[1], y[0], x[2]-x[1], y[1]-y[0]) +p0);
    assoc_rects.Insert( TOP+TAIL, CheckedRect( x[3], y[0], x[4]-x[3], y[1]-y[0]) +p0);

    assoc_rects.Insert( MIDDLE+HEAD, CheckedRect( x[0], y[1], x[1]-x[0], y[2]-y[1]) +p0);

    if ( !no_interrior )
    assoc_rects.Insert( MIDDLE+BODY, CheckedRect( x[1], y[1], x[2]-x[1], y[2]-y[1]) +p0);

    assoc_rects.Insert( MIDDLE+TAIL, CheckedRect( x[3], y[1], x[4]-x[3], y[2]-y[1]) +p0);

    assoc_rects.Insert( BOTTOM+HEAD, CheckedRect(x[0], y[3], x[1]-x[0], y[4]-y[3]) +p0);
    assoc_rects.Insert( BOTTOM+BODY, CheckedRect(x[1], y[3], x[2]-x[1], y[4]-y[3]) +p0);
    assoc_rects.Insert( BOTTOM+TAIL, CheckedRect(x[3], y[3], x[4]-x[3], y[4]-y[3]) +p0);

    assoc_rects.Insert( HEAD+HDIV , CheckedRect( x[0], y[2], x[1]-x[0], y[3]-y[2]) +p0);
    assoc_rects.Insert( BODY+HDIV , CheckedRect( x[1], y[2], x[2]-x[1], y[3]-y[2]) +p0);
    assoc_rects.Insert( TAIL+HDIV , CheckedRect( x[3], y[2], x[4]-x[3], y[3]-y[2]) +p0);

    assoc_rects.Insert( HEAD+VDIV , CheckedRect( x[2], y[0], x[3]-x[2], y[1]-y[0]) +p0);
    assoc_rects.Insert( BODY+VDIV , CheckedRect( x[2], y[1], x[3]-x[2], y[2]-y[1]) +p0);
    assoc_rects.Insert( TAIL+VDIV , CheckedRect( x[2], y[3], x[3]-x[2], y[4]-y[3]) +p0);

    assoc_rects.Insert( CROSSING  , CheckedRect( x[2], y[2], x[3]-x[2], y[3]-y[2]) +p0);

    ImageDicer::Dice(assoc_rects);
    SetSize( Dim2i(bound.GetW(), bound.GetH()) );
}
Resource* CreateGraphWidget( XMLIterator i, XMLCreatorEnv *env )
{
    XMLCreatorEnv ch_env;
    XMLAttributes attributes;
    XMLStyle      branch_style;
    CascadeStyles( i, env, attributes, branch_style, ch_env );

    std::string color = get_attribute( attributes, "color" );
    NormalPixel ncolor( to_hex( color ));

    int dotted = 0;
    try_attribute_i( attributes, "dotted", &dotted );

    GraphWidget *ptr = new GraphWidget( Dim2i( 100, 100 ), ncolor.c, 
                                        ( dotted ? GraphWidget::GT_POINTS : GraphWidget::GT_LINES ) 
                                      );
    
    std::string bounds;
    if ( try_attribute( attributes, "bounds", &bounds ))
    {
        std::vector< int > b = to_integer_vector( bounds );
        ptr->SetValueBounds( b[0], b[1], b[2], b[3] );
    }
    
    Useless::GraphWidget::tpe_input_vector initData( 100 );
    initData.resize(0);
    for ( double f=0.0; f <= 6.28; f += 3.14/100.0 )
    {
        double y = sin( f );
        initData.push_back( y );
    }
    ptr->SetInputData( initData );

    InsertChildWidget( ptr, attributes, env);    
    return new AnyResource<GraphWidget*>( ptr );
}
	void window_size_callback(GLFWwindow* window, int width, int height) {
		ProtoBaseApp* ba = (ProtoBaseApp*)glfwGetWindowUserPointer(window);
		ba->setWindowFrameSize(Dim2i(width, height));
	}