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;
    }
}
示例#2
0
// Align Widget to another
void Widget::AlignTo( Widget const* widget, int alignment )
{
    //Rect rc = typeid(widget)!=typeid(BufferWidget) ? widget->GetBoundingRect() + widget->GetPosition() : widget->GetParent()->GetBoundingRect() + widget->GetParent()->GetPosition();
    Rect rc = widget->GetBoundingRect() + widget->GetPosition();
    Pos   p = GetPosition();

    int w=GetWidth(), h=GetHeight(), x=0, y=0, border=alignment&0x00FF, corner=alignment&0xFF00;
    
    switch( border )
    {
        case LEFT_BORDER:
            x = rc.GetX1() - w;
            y = corner==LU_CORNER ? rc.GetY1() : (corner==RB_CORNER ? rc.GetY2()-h : p.y);
            break;
        
        case RIGHT_BORDER:
            x = rc.GetX2();
            y = corner==LU_CORNER ? rc.GetY1() : (corner==RB_CORNER ? rc.GetY2()-h : p.y);
            break;

        case TOP_BORDER:
            y = rc.GetY1() - h;
            x = corner==LU_CORNER ? rc.GetX1() : (corner==RB_CORNER ? rc.GetX2()-w : p.x);
            break;

        case BOTTOM_BORDER:
            y = rc.GetY2();
            x = corner==LU_CORNER ? rc.GetX1() : (corner==RB_CORNER ? rc.GetX2()-w : p.x);
            break;
    }
    SetPosition( Pos(x,y) );
}
示例#3
0
DDClipper::DDClipper(const Rect &rect): _dd_clipper(NULL)
{
    if(!! rect)
    {
        DDraw7Ptr dd = DDCreator::GetDirectDraw();
        dd->CreateClipper(0, &_dd_clipper, NULL);

        char rgbf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
        LPRGNDATA regn = (LPRGNDATA)(&rgbf);
        regn->rdh.dwSize = sizeof(RGNDATAHEADER);
        regn->rdh.iType = RDH_RECTANGLES;
        regn->rdh.nCount = 1;
        regn->rdh.nRgnSize = sizeof(RECT);
        regn->rdh.rcBound.left  = rect.GetX1();
        regn->rdh.rcBound.top   = rect.GetY1();
        regn->rdh.rcBound.right = rect.GetX2();
        regn->rdh.rcBound.bottom= rect.GetY2();
        LPRECT rc = (LPRECT)(regn->Buffer);
        rc[0].left  = rect.GetX1();
        rc[0].top   = rect.GetY1();
        rc[0].right = rect.GetX2();
        rc[0].bottom= rect.GetY2();

        if ( _dd_clipper->SetClipList(regn,0) != DD_OK ) 
        { 
            DDClipper_ERROR( Useless::Error("DDClipper::DDClipper() :SetClipList() failed") ); 
        }
    }
}
示例#4
0
Rect TableWidget::GetCrossing( const Rect &an_area ) const
{
    Rect area = an_area - Pos( _frame_left, _frame_top );
    //return Rect(0,0,_columns.size(),_rows.size());
    cell_division_vector::range_t rg_c;
    rg_c = _columns.cross_range( area.GetX1(), area.GetX2() );

    cell_division_vector::range_t rg_r;
    rg_r = _rows.cross_range( area.GetY1(), area.GetY2() );

    int x = rg_c.first - _columns.begin();
    int y = rg_r.first - _rows.begin();
    int w = rg_c.second - rg_c.first;
    int h = rg_r.second - rg_r.first;
    if ( x<0 ) { x=0; --w; }
    if ( y<0 ) { y=0; --h; }

    //////////////////////////////////////
    // OUT:
    // X - first column crossing area
    // Y - first row crossing area
    // W - number of columns crossing area
    // H - number of rows crossing area
    return Rect(x,y, (w>0)? w:0, (h>0)? h:0);
}
    void WidgetTableWidget::RepaintImpl( const WidgetPainter &painter )
    {
        //HubWidget::Repaint(painter); -- nonsense

        Rect client_area = GetParent()->GetClientRect(this)-GetPosition();
        Rect influenced = GetCrossing( client_area );
        Pos p( influenced.GetX1(), influenced.GetY1() );

        for ( int j=0; j!=influenced.GetW(); ++j, ++p.x )
        {
            SettlerMap::Iterator iter;
            _settlers.Find( p, (SettlerMap::ConstIterator*)&iter);
            for ( int i=0; i!=influenced.GetH(); ++i, ++iter )
            {
                if (!iter) { break; }//< W/A GetCrossing() does not work corectly
                Widget &child = *iter->_settler;
                if ( child.IsVisible() )
                {
                    WidgetPainter child_painter( painter, child );
                    if ( child_painter.Intersect() ) 
                    {
                        child.Repaint(child_painter);
                        child_painter.RestoreClipper();
                    }
                }
            }
        }
    }
示例#6
0
RectList DDClipper::GetRectangles(const Rect &rect) const
{
    int r;
    if(! _dd_clipper) { return RectList(); }
    RECT crect;
    LPRECT prc=NULL;
    crect.left = rect.GetX1(); crect.right  = rect.GetX2();
    crect.top  = rect.GetY1(); crect.bottom = rect.GetY2();
    prc = &crect;
    Types::ULONG csize;
    r=_dd_clipper->GetClipList(prc,NULL,&csize);
    C_verify( r == DD_OK );

    MemBlock region_buffer( csize );
    LPRGNDATA regn = (LPRGNDATA)( region_buffer.GetPtr() );
    r=_dd_clipper->GetClipList(prc,regn,&csize);
    LPRECT rc = (LPRECT)(regn->Buffer);
    C_verify( r == DD_OK );

    RectList rect_list( regn->rdh.nCount );
    for( int i=0; i!= regn->rdh.nCount; ++i )
    {
        rect_list[i] = Rect( rc[i].left, rc[i].top, 0, 0 );
        rect_list[i].SetX2( rc[i].right  );
        rect_list[i].SetY2( rc[i].bottom );
    }

    return rect_list;
}
示例#7
0
Rect TableWidget::RowRect( int row ) const
{
    int last_col = GetNumColumns() -1;
    
    Rect R = CellRect( 0, row) | CellRect( last_col, row);
    Rect r = ClientRect( 0, row) | ClientRect( last_col, row);

    return Rect( R.GetX1(), r.GetY1(), R.GetW(), r.GetH() );
}
示例#8
0
Rect TableWidget::ColumnRect( int column ) const
{
    int last_row = GetNumRows() -1;
    
    Rect R = CellRect( column, 0) | CellRect( column, last_row);
    Rect r = ClientRect( column, 0) | ClientRect( column, last_row);

    return Rect( r.GetX1(), R.GetY1(), r.GetW(), R.GetH() );
}
示例#9
0
Rect TableWidget::ClientRect( int column, int row) const
{
    Rect cellrect = CellRect( column, row);
    if(!! cellrect)
    {
        int x[2], y[2];
        int vdl = _verti_divider/2;
        int vdr = _verti_divider-vdl;
        int hdl = _horiz_divider/2;
        int hdr = _horiz_divider-hdl;

        x[0] = cellrect.GetX1()+vdr;
        x[1] = cellrect.GetX2()-vdl;
        y[0] = cellrect.GetY1()+hdr;
        y[1] = cellrect.GetY2()-hdl;

        return Rect( x[0], y[0], (x[1]-x[0]>0)? x[1]-x[0]:0, (y[1]-y[0]>0)? y[1]-y[0]:0 );
    }
    else return Rect();
}
示例#10
0
/*! This function tesselates list of rectangles into belts of unified y's
 *
 *  RangesList = Array
 *
 *  (
 *
 *      Range(y1,y2) => Array( Range(x11,x12), Range(x12,x13), ... )
 *
 *      Range(y2,y3) => Array( Range(x21,x22), Range(x22,x23), ... )
 *
 *      ..........................................................
 *  )
 */
RangesList RectList::GetRanges( Range y_range ) const
{
    if ( this->empty() ) { return RangesList(); }

    bool clipped = y_range!=Range(0,0);

    typedef std::set<int> Ints;
    Ints    sorted_ys;
    int k = this->size();

    if (!clipped)
    {
        while (k--)
        {
            sorted_ys.insert( this->at(k).GetY1() );
            sorted_ys.insert( this->at(k).GetY2() );
        }
    }
    else
    {
        while (k--)
        {
            int y1 = this->at(k).GetY1();
            int y2 = this->at(k).GetY2();

            if ( y1 > y_range.first && y1 < y_range.second ) { sorted_ys.insert( y1 ); }
            if ( y2 > y_range.first && y2 < y_range.second ) { sorted_ys.insert( y2 ); }
        }
        sorted_ys.insert( y_range.first );
        sorted_ys.insert( y_range.second );
    }

    RangesList rangeslist;
    if ( sorted_ys.empty() ) { return rangeslist; }

    Ints::iterator    yi=sorted_ys.begin();
    int y1,y2 = *yi++;

    for ( ; yi!=sorted_ys.end(); ++yi)
    {
        y1 = y2; y2 = *yi;
    
        RangeList belt_ranges;

        int k = this->size(); while(k--)
        {
            Rect kr = this->at(k);
            if ( kr.GetY1()<y2 && kr.GetY2()>y1 )
            {
                Range rg = Range(kr.GetX1(), kr.GetX2() );
                belt_ranges.Insert(rg);
            }
        }

        k = belt_ranges.Size();
        int x1 = 0;
        int x2 = 0;
        int opened = 0;
        RangeList opt_ranges;

        for ( int i=0; i!=k; ++i )
        {
            Range rg = belt_ranges[i];
            if (!opened++)
            {
                x1 = rg.first;
                x2 = rg.second;
            }
            else
            {
                if ( rg.first<=x2 && rg.second>=x1 )
                { 
                    if ( x1 > rg.first)  x1 = rg.first;
                    if ( x2 < rg.second) x2 = rg.second;
                }
                else 
                {
                    opt_ranges.Insert( Range(x1,x2) );
                    x1 = rg.first;
                    x2 = rg.second;
                }
            }
        }
        if ( opened) { opt_ranges.Insert( Range(x1,x2) );  }

        if (!opt_ranges.Empty()) rangeslist.Insert( Range(y1, y2), opt_ranges );

    }

    return rangeslist;
}