summaryrefslogtreecommitdiff
path: root/xc/unsupported/examples
diff options
context:
space:
mode:
Diffstat (limited to 'xc/unsupported/examples')
-rw-r--r--xc/unsupported/examples/Fresco/Imakefile2
-rw-r--r--xc/unsupported/examples/Fresco/box.cxx55
-rw-r--r--xc/unsupported/examples/Fresco/buttons.cxx44
-rw-r--r--xc/unsupported/examples/Fresco/check.cxx42
-rw-r--r--xc/unsupported/examples/Fresco/circle.cxx17
-rw-r--r--xc/unsupported/examples/Fresco/figviewer.cxx179
-rw-r--r--xc/unsupported/examples/Fresco/narrow.cxx20
-rw-r--r--xc/unsupported/examples/Fresco/stubs/Imakefile2
-rw-r--r--xc/unsupported/examples/Fresco/stubs/client.cxx2
-rw-r--r--xc/unsupported/examples/Fresco/subpaths.cxx112
-rw-r--r--xc/unsupported/examples/Imakefile2
11 files changed, 4 insertions, 473 deletions
diff --git a/xc/unsupported/examples/Fresco/Imakefile b/xc/unsupported/examples/Fresco/Imakefile
index 856da822a..97f16d5b9 100644
--- a/xc/unsupported/examples/Fresco/Imakefile
+++ b/xc/unsupported/examples/Fresco/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XConsortium: Imakefile,v 1.6 94/03/25 19:58:22 matt Exp $
+XCOMM $XConsortium: Imakefile,v 1.7 94/04/01 16:57:37 matt Exp $
#define IHaveSubdirs
#define PassCDebugFlags /**/
diff --git a/xc/unsupported/examples/Fresco/box.cxx b/xc/unsupported/examples/Fresco/box.cxx
deleted file mode 100644
index 41710a7db..000000000
--- a/xc/unsupported/examples/Fresco/box.cxx
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <X11/Fresco/drawing.h>
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <X11/Fresco/layouts.h>
-#include <X11/Fresco/Impls/glyphs.h>
-
-static Option options[] = {
- { "-s1", "*string1", Option::value, "on" },
- { "-s2", "*string2", Option::value, "on" },
- { "-string1", "*string1", Option::value, "on" },
- { "-string2", "*string2", Option::value, "on" },
- { "-v", "*verbose", Option::implicit, "on" },
- { "-verbose", "*verbose", Option::implicit, "on" },
- { nil }
-};
-
-static Boolean verbose;
-
-static GlyphRef debug(GlyphRef g, const char* name) {
- return (
- verbose ?
- new DebugGlyph(g, name, DebugGlyph::trace_request_traverse) : g
- );
-}
-
-int main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv, options);
- StyleObj s = f->style();
- CharString hello = Fresco::string_ref("hello");
- StyleValue a = s->resolve(Fresco::string_ref("string1"));
- if (is_not_nil(a)) {
- a->read_string(hello);
- }
- CharString goodbye = Fresco::string_ref("goodbye");
- a = s->resolve(Fresco::string_ref("string2"));
- if (is_not_nil(a)) {
- a->read_string(goodbye);
- }
- verbose = s->is_on(Fresco::string_ref("verbose"));
- FigureKit figures = f->figure_kit();
- LayoutKit layouts = f->layout_kit();
- FigureStyle fs = figures->default_style();
- Glyph g = layouts->hbox();
- g->append(debug(figures->label(fs, hello), "label 1"));
- g->append(layouts->hfil());
- g->append(debug(figures->label(fs, goodbye), "label 2"));
- Glyph b = layouts->vbox();
- b->append(debug(g, "hbox instance 1"));
- b->append(layouts->vfil());
- b->append(debug(g, "hbox instance 2"));
- g = debug(b, "vbox");
- f->main(nil, g);
- Fresco::unref(f);
- return 0;
-}
diff --git a/xc/unsupported/examples/Fresco/buttons.cxx b/xc/unsupported/examples/Fresco/buttons.cxx
deleted file mode 100644
index 00ca8ddeb..000000000
--- a/xc/unsupported/examples/Fresco/buttons.cxx
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <X11/Fresco/layouts.h>
-#include <X11/Fresco/widgets.h>
-#include <X11/Fresco/Impls/action.h>
-#include <stdio.h>
-
-class App {
-public:
- App() { }
- ~App() { }
-
- int main(int argc, char** argv);
-private:
- void push_me();
-};
-
-declareActionCallback(App)
-implementActionCallback(App)
-
-int main(int argc, char** argv) {
- App a;
- return a.main(argc, argv);
-}
-
-int App::main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- FigureKit figures = f->figure_kit();
- WidgetKit widgets = f->widget_kit();
- LayoutKit layouts = f->layout_kit();
- Button b = widgets->push_button(
- figures->label(
- figures->default_style(), Fresco::string_ref("Push me")
- ),
- new ActionCallback(App)(this, &App::push_me)
- );
- f->main(b, layouts->margin(b, 10.0));
- Fresco::unref(f);
- return 0;
-}
-
-void App::push_me() {
- printf("pushed\n");
-}
diff --git a/xc/unsupported/examples/Fresco/check.cxx b/xc/unsupported/examples/Fresco/check.cxx
deleted file mode 100644
index 6ec92b867..000000000
--- a/xc/unsupported/examples/Fresco/check.cxx
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <X11/Fresco/layouts.h>
-#include <X11/Fresco/widgets.h>
-#include <X11/Fresco/Impls/action.h>
-#include <stdio.h>
-
-class App {
-public:
- App() { }
- ~App() { }
-
- int main(int argc, char** argv);
-private:
- void push_me();
-};
-
-declareActionCallback(App)
-implementActionCallback(App)
-
-int main(int argc, char** argv) {
- App a;
- return a.main(argc, argv);
-}
-
-int App::main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- FigureKit figures = f->figure_kit();
- Button b = f->widget_kit()->check_box(
- figures->label(
- figures->default_style(), Fresco::string_ref("Push me")
- ),
- Action(new ActionCallback(App)(this, &App::push_me))
- );
- f->main(b, f->layout_kit()->margin(b, 10.0));
- Fresco::unref(f);
- return 0;
-}
-
-void App::push_me() {
- printf("pushed\n");
-}
diff --git a/xc/unsupported/examples/Fresco/circle.cxx b/xc/unsupported/examples/Fresco/circle.cxx
deleted file mode 100644
index c45231406..000000000
--- a/xc/unsupported/examples/Fresco/circle.cxx
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-
-int main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- FigureKit figures = f->figure_kit();
- f->main(
- nil,
- figures->figure_root(
- figures->circle(
- FigureKit::fill, figures->default_style(), 0.0, 0.0, 100.0
- )
- )
- );
- Fresco::unref(f);
- return 0;
-}
diff --git a/xc/unsupported/examples/Fresco/figviewer.cxx b/xc/unsupported/examples/Fresco/figviewer.cxx
deleted file mode 100644
index c437de349..000000000
--- a/xc/unsupported/examples/Fresco/figviewer.cxx
+++ /dev/null
@@ -1,179 +0,0 @@
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <X11/Fresco/layouts.h>
-#include <X11/Fresco/widgets.h>
-#include <X11/Fresco/Impls/viewers.h>
-#include <X11/Fresco/Impls/transform.h>
-#include <X11/Fresco/Impls/region.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-class PageFigure : public GlyphImpl {
-public:
- PageFigure(Coord width, Coord height);
- virtual ~PageFigure();
-
- void request(Glyph::Requisition& r);
- void extension(const Glyph::AllocationInfo& a, RegionRef r);
- void draw(GlyphTraversalRef t);
-private:
- Coord w_, h_;
-};
-
-PageFigure::PageFigure(Coord w, Coord h) {
- w_ = w;
- h_ = h;
-}
-
-PageFigure::~PageFigure () {}
-
-void PageFigure::draw(GlyphTraversalRef) {}
-
-void PageFigure::request(Glyph::Requisition& r) {
- r.x.natural = r.x.maximum = r.x.minimum = w_;
- r.y.natural = r.y.maximum = r.y.minimum = h_;
- r.x.align = r.y.align = 0.5;
- r.z.natural = 0;
-}
-
-void PageFigure::extension(const Glyph::AllocationInfo& a, RegionRef r) {
- RegionImpl region;
- region.lower_.x = 0;
- region.lower_.y = 0;
- region.lower_.z = 0;
- region.upper_.x = w_;
- region.upper_.y = h_;
- region.upper_.z = 0;
- region.xalign_ = region.yalign_ = 0.5;
- region.zalign_ = 0;
- if (is_not_nil(a.transform)) {
- region.transform(a.transform);
- }
- r->copy(&region);
-}
-
-class FigureViewer : public ViewerImpl {
-public:
- FigureViewer(Fresco* f);
- ~FigureViewer();
-
- void need_resize();
- Boolean press(GlyphTraversalRef, EventRef);
- Boolean drag(GlyphTraversalRef, EventRef);
- Boolean release(GlyphTraversalRef, EventRef);
- void add(Coord x, Coord y);
-protected:
- FigureKit figures_;
- FigureStyle def_style_;
- Glyph root_, figroot_;
- Coord width_, height_;
- enum { move_tool, create_tool } curtool_;
- GlyphRef target_;
- Coord start_x_, start_y_;
-};
-
-FigureViewer::FigureViewer(Fresco* f) : ViewerImpl(f) {
- width_ = 300; height_ = 300;
- figures_ = f->figure_kit();
- def_style_ = figures_->default_style();
- LayoutKit layouts = f->layout_kit();
-
- figroot_ = figures_->group();
- Glyph g = new TransformAllocator(0.5, 0.5, 0, 0.5, 0.5, 0);
- g->body(figroot_);
- root_ = layouts->fixed(g, width_, height_);
- body(root_);
- figroot_->append(new PageFigure(width_ * 10, height_ * 10));
-}
-
-FigureViewer::~FigureViewer() { }
-
-void FigureViewer::need_resize() { }
-
-void FigureViewer::add(Coord x, Coord y) {
- static int toggle = 0;
- Glyph fig;
- if (++toggle%2) {
- const float r = 36;
- fig = figures_->circle(FigureKit::fill, def_style_, x, y, r);
- } else {
- const Coord hh=25, hw=25; // half-height,width
- fig = figures_->rectangle(
- FigureKit::stroke, def_style_, x-hw,y-hh, x+hw, y+hh
- );
- }
- Glyph::AllocationInfoList al;
- figroot_->allocations(al);
- if (al._length < 1) {
- fprintf(stderr, "%d allocations!\n", al._length);
- exit(1);
- }
- Glyph::AllocationInfo& ai = al._buffer[0];
- TransformObj figtr = fig->transform();
- figtr->postmultiply(ai.transform);
- figtr->invert();
- figroot_->append(fig);
- fig->need_redraw();
- fig->need_resize();
- Fresco::unref(ai.allocation);
-}
-
-Boolean FigureViewer::press(GlyphTraversalRef t, EventRef e) {
- const Coord slop = 4;
- start_x_ = e->pointer_x();
- start_y_ = e->pointer_y();
- GlyphTraversal::Operation orig_op;
- orig_op = t->swap_op(GlyphTraversal::pick_top);
- t->begin_trail(this);
- PainterObj p = t->painter();
- p->push_clipping();
- p->clip_rect(start_x_-slop, start_y_-slop, start_x_+slop, start_y_+slop);
- root_->traverse(t);
-
- GlyphTraversal picked = t->picked();
- if (is_not_nil(picked)) {
- target_ = picked->_c_current_glyph();
- curtool_ = move_tool;
- } else {
- curtool_ = create_tool;
- }
- p->pop_clipping();
- t->end_trail();
- return true;
-}
-
-Boolean FigureViewer::drag(GlyphTraversalRef, EventRef e) {
- if (curtool_ == move_tool) {
- TransformObj tx = target_->transform();
- if (is_not_nil(tx)) {
- Vertex v;
- v.x = e->pointer_x() - start_x_;
- v.y = e->pointer_y() - start_y_;
- start_x_ = e->pointer_x();
- start_y_ = e->pointer_y();
- target_->need_redraw();
- tx->translate(v);
- target_->need_redraw();
- target_->need_resize();
- }
- }
- return true;
-}
-
-Boolean FigureViewer::release(GlyphTraversalRef, EventRef) {
- if (curtool_ == create_tool) {
- add(start_x_, start_y_);
- } else {
- Fresco::unref(target_);
- }
- return true;
-}
-
-int main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- LayoutKit layouts = f->layout_kit();
- Viewer fv = new FigureViewer(f);
- f->main(fv, layouts->margin(fv, 10.0));
- Fresco::unref(f);
- return 0;
-}
diff --git a/xc/unsupported/examples/Fresco/narrow.cxx b/xc/unsupported/examples/Fresco/narrow.cxx
deleted file mode 100644
index 14ee2381c..000000000
--- a/xc/unsupported/examples/Fresco/narrow.cxx
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <X11/Fresco/display.h>
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <stdio.h>
-
-int main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- FigureKit figures = f->figure_kit();
- StyleObj s = figures->default_style();
- FigureStyle fs = FigureStyle::_narrow(s);
- if (is_not_nil(fs)) {
- printf("s narrowed to FigureStyle\n");
- }
- DisplayStyle ds = DisplayStyle::_narrow(s);
- if (is_nil(ds)) {
- printf("failed to narrow to DisplayStyle\n");
- }
- Fresco::unref(f);
- return 0;
-}
diff --git a/xc/unsupported/examples/Fresco/stubs/Imakefile b/xc/unsupported/examples/Fresco/stubs/Imakefile
index 36a1ba3b6..3723db0ae 100644
--- a/xc/unsupported/examples/Fresco/stubs/Imakefile
+++ b/xc/unsupported/examples/Fresco/stubs/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XConsortium: Imakefile,v 1.2 94/03/23 15:53:18 matt Exp $
+XCOMM $XConsortium: Imakefile,v 1.3 94/04/01 16:58:11 matt Exp $
XCOMM
XCOMM Sample client-server
XCOMM
diff --git a/xc/unsupported/examples/Fresco/stubs/client.cxx b/xc/unsupported/examples/Fresco/stubs/client.cxx
index 762db07cf..b0553791a 100644
--- a/xc/unsupported/examples/Fresco/stubs/client.cxx
+++ b/xc/unsupported/examples/Fresco/stubs/client.cxx
@@ -1,5 +1,5 @@
/*
- * $XConsortium$
+ * $XConsortium: client.cxx,v 1.2 94/03/23 15:52:55 matt Exp $
*/
#include "naming.h"
diff --git a/xc/unsupported/examples/Fresco/subpaths.cxx b/xc/unsupported/examples/Fresco/subpaths.cxx
deleted file mode 100644
index cbc63a77c..000000000
--- a/xc/unsupported/examples/Fresco/subpaths.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Example program using Painter subpaths.
- */
-
-#include <X11/Fresco/drawing.h>
-#include <X11/Fresco/figures.h>
-#include <X11/Fresco/fresco.h>
-#include <X11/Fresco/layouts.h>
-#include <X11/Fresco/Impls/fresco-impl.h>
-#include <X11/Fresco/Impls/glyphs.h>
-#include <X11/Fresco/Impls/styles.h>
-#include <X11/Fresco/OS/math.h>
-
-class Rects : public GlyphImpl {
-public:
- Rects(Coord width, Coord height, FigureKit::Mode, FigureStyleRef style);
- virtual ~Rects();
-
- void request(Glyph::Requisition& r); //+ Glyph::request
- void draw(GlyphTraversalRef t); //+ Glyph::draw
-private:
- Coord width_, height_;
- FigureKit::Mode mode_;
- FigureStyle style_;
-};
-
-Rects::Rects(
- Coord width, Coord height, FigureKit::Mode mode, FigureStyleRef style
-) {
- width_ = width;
- height_ = height;
- style_ = FigureStyle::_duplicate(style);
- mode_ = mode;
-}
-
-Rects::~Rects() { }
-
-void Rects::request(Glyph::Requisition& r) {
- GlyphImpl::require_lead_trail(
- r.x, 0, 0, 0, width_, width_, width_
- );
- GlyphImpl::require_lead_trail(
- r.y, 0, 0, 0, height_, height_, height_
- );
-}
-
-void Rects::draw(GlyphTraversalRef t) {
- Vertex o;
-
- t->origin(o);
-
- PainterObj p = t->painter();
-
- // Draws two rectangles one inside the other.
- p->begin_path();
- p->move_to(o.x, o.y);
- p->line_to(o.x + width_, o.y);
- p->line_to(o.x + width_, o.y + height_);
- p->line_to(o.x, o.y + height_);
- p->close_path();
-
- Coord nw = width_ / 2;
- Coord nh = height_ / 2;
- o.x += nw / 2;
- o.y += nh / 2;
- // turn in the other direction
- p->move_to(o.x, o.y);
- p->line_to(o.x, o.y + nh);
- p->line_to(o.x + nw, o.y + nh);
- p->line_to(o.x + nw, o.y);
- p->close_path();
-
- if (mode_ == FigureKit::stroke || mode_ == FigureKit::fill_stroke) {
- p->brush_attr(style_->brush_attr());
- }
- if (mode_ == FigureKit::fill || mode_ == FigureKit::stroke) {
- p->color_attr(style_->foreground());
- }
- switch (mode_) {
- case FigureKit::fill:
- p->fill();
- break;
- case FigureKit::stroke:
- p->stroke();
- break;
- case FigureKit::fill_stroke:
- p->color_attr(style_->background());
- p->fill();
- p->color_attr(style_->foreground());
- p->stroke();
- break;
- }
-}
-
-int main(int argc, char** argv) {
- Fresco* f = Fresco_open("Test", argc, argv);
- FigureKit figures = f->figure_kit();
-
- FigureStyle style = figures->new_style(figures->default_style());
- style->background(f->drawing_kit()->find_color(f->string_ref("blue")));
-
- Glyph group = f->layout_kit()->overlay();
- group->append(
- figures->circle(
- FigureKit::fill, figures->default_style(), 100, 100, 50
- )
- );
- group->append(Glyph(new Rects(100, 100, FigureKit::fill_stroke, style)));
- f->main(nil, group);
- Fresco::unref(f);
- return 0;
-}
diff --git a/xc/unsupported/examples/Imakefile b/xc/unsupported/examples/Imakefile
index 9f0026aa6..956ae1537 100644
--- a/xc/unsupported/examples/Imakefile
+++ b/xc/unsupported/examples/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XConsortium: Imakefile,v 1.2 94/02/10 20:42:10 matt Exp matt $
+XCOMM $XConsortium: Imakefile,v 1.3 95/05/23 21:43:57 matt Exp $
all::
depend::