sung@rigel.csc.ti.com ("Helen Chang ", sung@csc.ti.com) (05/23/91)
Question 1: Suppose Glyph* in = ...; y is Dimension, and size is Coord. FixedSpan* out = new FixedSpan( in, y, size); If the natural size of "in" is smaller than the "size" specified, is "in" always lay in the middle of "out"? How can I make "in" align to the top of the fixedspan? Question 2: Why is it the append of a LRBox to a FixedSpan only shown once (refer to the h1 and h2 below)? How can I make it display everything appended? Thanks in advance. Helen Chang ------- #include <InterViews/background.h> #include <InterViews/box.h> #include <InterViews/color.h> #include <InterViews/font.h> #include <InterViews/handler.h> #include <InterViews/listener.h> #include <InterViews/margin.h> #include <InterViews/monoglyph.h> #include <InterViews/patch.h> #include <InterViews/sensor.h> #include <InterViews/fixedspan.h> #include <InterViews/glyph.h> #include <InterViews/label.h> #include <InterViews/window.h> #include <InterViews/world.h> #include <string.h> class TestViewer : public MonoGlyph, public Handler { public: TestViewer(Glyph*, Glyph*); void update(); void event() { }; private: Listener* _listener; FixedSpan* _lines; Patch* _textPatch; }; TestViewer::TestViewer(Glyph* head, Glyph* tail) : MonoGlyph(nil), Handler() { World* world = World::current(); Color* bg = world->background(); _lines = new FixedSpan( new TBBox( head, tail ), Dimension_Y, 4.0*inch) ; _textPatch = new Patch(_lines); Coord side = 0.02 * inch; _listener = new Listener( new Background( new Margin( new TBBox( _textPatch ), side + 1, 0, side - 1, side + 5, fil, side - 1, side + 5, 0, side - 1, side + 1, 0, side - 1 ), bg), this ); _listener->sensor()->button(true, Event::any); _listener->sensor()->key(true); body(_listener); } void TestViewer::update() { _textPatch->reallocate(); _textPatch->redraw(); } static PropertyData props[] = { { nil } }; static OptionDesc options[] = { { nil } }; int main(int argc, char** argv) { World world("Test", argc, argv, options, props); Font* f = world.font(); Color* fg = world.foreground(); Color* bg = world.background(); Glyph* g1 = new Label("name", f, fg); Glyph* g2 = new Label("end", f, fg); LRBox* h1 = new LRBox(g1, g2); LRBox* h2 = new LRBox(g2, g1); TestViewer* viewer = new TestViewer(g1, g2); viewer->append(g1); viewer->append(g2); viewer->append(h1); viewer->append(h2); viewer->append(h1); viewer->append(h2); viewer->update(); ApplicationWindow window(new Background(viewer, bg)); window.map(); world.run(); return 0; }