Article View: comp.windows.interviews
Article #1120How to display a composition?
From: "Helen Chang ", sung
Date: Fri, 10 May 1991 14:54
Date: Fri, 10 May 1991 14:54
104 lines
2730 bytes
2730 bytes
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 <stream.h>
#include <string.h>
#include <InterViews/arraycomp.h>
#include <InterViews/character.h>
#include <InterViews/color.h>
#include <InterViews/composition.h>
#include <InterViews/deck.h>
#include <InterViews/discretion.h>
#include <InterViews/font.h>
#include <InterViews/glyph.h>
#include <InterViews/handler.h>
#include <InterViews/label.h>
#include <InterViews/listener.h>
#include <InterViews/monoglyph.h>
#include <InterViews/patch.h>
#include <InterViews/sensor.h>
#include <InterViews/strut.h>
#include <InterViews/window.h>
#include <InterViews/world.h>
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;
}
Technical Details
Message-ID:
<9105101454.AA02649@rigel.csc.ti.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!stanford.edu!rigel.csc.ti.com!sungShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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