Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!stanford.edu!rigel.csc.ti.com!sung From: sung@rigel.csc.ti.com ("Helen Chang ", sung@csc.ti.com) Newsgroups: comp.windows.interviews Subject: How to display a composition? Message-ID: <9105101454.AA02649@rigel.csc.ti.com> Date: 10 May 91 14:54:25 GMT Sender: news@shelby.stanford.edu (USENET News System) Organization: Internet-USENET Gateway at Stanford University Lines: 104 I'd like to display a Composition contains Labels, and update this display when new Labels are added. Could someone help me identify where is wrong and how to make it work? Thanks a lot. ---------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class TestViewer : public MonoGlyph, public Handler { public: TestViewer(Font*, Color*); virtual void event() {} void item_append(Glyph* ); void update(); private: Listener* _listener; Composition* _lines; Patch* _textPatch; }; TestViewer::TestViewer(Font* f, Color* fg) : MonoGlyph(nil), Handler() { _lines=new TBComposition( new Deck(), new ArrayCompositor(1), new Discretionary( 100, new Character(0216, f, fg) ), 8, 5); _textPatch = new Patch(_lines); _listener = new Listener(_textPatch, this); _listener->sensor()->button(true, Event::any); _listener->sensor()->key(true); body(_listener); } void TestViewer::item_append(Glyph* g) { _lines->append(g); } void TestViewer::update() { _lines->repair(); _textPatch->reallocate(); } 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(); TestViewer* viewer = new TestViewer(f, fg); // the original display in unreadable instead of blank. // Next 3 lines are supposed to put one line there. /* Glyph* g = new Label("first line", f, fg); viewer->item_append(g); viewer->update(); */ ApplicationWindow window(viewer); window.map(); world.run(); return 0; }