void TableRow::position()
{
   // position the fields in this table item
   Basic::PairStream* subcomponents = getComponents();
   if (subcomponents != 0) {
   
      int ln = line();
      int cp = column();
      
      Basic::List::Item* item = subcomponents->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         BasicGL::Field* ti = static_cast<BasicGL::Field*>(pair->object());
        
         ti->line(ln);
         ti->column(cp);
         cp += static_cast<int>(ti->width());
         
         item = item->getNext();
      }
      subcomponents->unref();
      subcomponents = 0;
   }
}
Exemple #2
0
//------------------------------------------------------------------------------
// drawFunc -- draw this text field
//------------------------------------------------------------------------------
void Field::drawFunc()
{
    // Get a pointer to the current display
    BasicGL::Display* dsp = getDisplay();
    if (dsp == 0) return;

    // ---
    // When our container is also a Field, get a pointer to it.
    // ---
    BasicGL::Field* parent = 0;
    if (container() != 0) {
        BasicGL::Field* fp = dynamic_cast<BasicGL::Field*>(container());
        if (fp != 0) parent = fp;
    }

    // ---
    // If we don't have a position, try to get one from our container
    // ---
    int ll = line();
    int cc = column();
    if (ll == 0 && parent != 0) {
        ll = parent->line();
        cc = parent->column();
    }

    // ---
    // Select the correct font based on font name if there is one, and if not, then do it normally
    // ---
    if (fontName != 0) dsp->selectFont(isReversed(), isUnderlined(), dsp->getFont(fontName->getString()));    
    else dsp->selectFont(isReversed(), isUnderlined());
    
    
    // ---
    // Set the color
    // ---
    bool restoreColor = false;
    osg::Vec4 ocolor = dsp->getCurrentColor();
    // only use default colors if we aren't inheriting our container's colors

    if (!isInheritColor()) {
        if (getColorName() == 0 && getColor() == 0) {
            const Basic::Color* cc = 0;
            if (isHighLighted()) cc = dsp->getHighlightColor();
            else cc = dsp->getNormColor();
            if (cc != 0) {
                const osg::Vec4* p = cc->getRGBA();
                dsp->setColor(*p);
                restoreColor = true;
            }
        }
    }

    // ---
    // draw the string
    // ---
    
    if (str.len() > 0) {
        // Draw the text string
        const char* sp = str;
        if (ll > 0 && cc > 0)
            dsp->outputTextLC(ll, cc, sp, int(width()), isVertical());
        else
            dsp->outputText(sp, int(width()), isVertical());
    }

    // ---
    // draw the brackets
    // ---
    if (areBracketsOn() && ll > 0 && cc > 0) {
        if (isVertical()) {
            // Position for vertical text
            dsp->drawLeftBracket(ll-1, cc);
            dsp->drawRightBracket(ll+int(width()), cc);
        }
        else {
            // Position for normal text
            dsp->drawLeftBracket(ll, cc-1);
            dsp->drawRightBracket(ll, cc+int(width()));
        }
    }

    // ---
    // If we used default colors, restore the old value
    // ---
    if (restoreColor) dsp->setColor(ocolor);

}