stay-up dialog boxes
Brought to you by:
johnston
|
From: <ivt...@li...> - 2000-01-26 22:06:54
|
Patch: ivtools-000127-johnston-015
For: ivtools-0.8
Author: joh...@us...
This is an intermediate patch to ivtools-0.8. To apply, cd to the
top-level directory of the ivtools source tree (the directory with src
and config subdirs), and apply like this:
patch -p0 <ThisFile
Summary of Changes:
- new Dialog methods to support stay-up dialog boxes that don't block
events being handled by the main application:
void map_for(Window*);
virtual void map_for_aligned(Window*, float xalign, float yalign);
void map_at(Coord x, Coord y);
virtual void map_at_aligned(
Coord x, Coord y, float xalign, float yalign
);
void unmap();
boolean mapped();
These are an alternate to the pre-existing Dialog::post_* methods,
which map the dialog box to the screen then enter their own event
handling loop (the run() method), then unmap the dialog box when done.
With this new approach you call one of the Dialog::map_* methods to
bring up the dialog box, and control returns to the normal
event-handling loop of the main application. The action taken when a
Close or OK button has to be different with this new approach.
Instead of setting a flag that causes the local run loop to terminate,
you need to explicitly call Dialog::unmap.
Dialog::unmapped is provided as a way to test if the dialog is
currently displayed. Repeated calls to Dialog::map_* are ok, because
the first thing these methods do is check if already mapped, and if so
they do nothing.
- create a new ObsTextDialog that uses the new Dialog::map_* methods.
- modify the GraphicLoc tool to use the new ObsTextDialog box. Now
the GraphicLoc dialog box can stay up between uses of the tool, and
each new click refreshes the displayed text.
Index: top_ivtools/COPYRIGHT
diff -c top_ivtools/COPYRIGHT:1.1 top_ivtools/COPYRIGHT:1.2
*** top_ivtools/COPYRIGHT:1.1 Thu Jan 27 01:51:22 2000
--- ./COPYRIGHT Thu Jan 27 01:51:22 2000
***************
*** 1,6 ****
/*
! * Copyright (c) 2000 Vectaport Inc., I.E.T. Inc
! * Copyright (c) 1999 Vectaport Inc., I.E.T. Inc, R.B. Kissh and Associates
* Copyright (c) 1998 Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler
* Copyright (c) 1997 Vectaport Inc., R.B. Kissh and Associates
* Copyright (c) 1996 Vectaport Inc., R.B. Kissh and Associates, Cider Press
--- 1,6 ----
/*
! * Copyright (c) 2000 Vectaport Inc., IET Inc
! * Copyright (c) 1999 Vectaport Inc., IET Inc, R.B. Kissh and Associates
* Copyright (c) 1998 Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler
* Copyright (c) 1997 Vectaport Inc., R.B. Kissh and Associates
* Copyright (c) 1996 Vectaport Inc., R.B. Kissh and Associates, Cider Press
Index: top_ivtools/INSTALL
diff -c top_ivtools/INSTALL:1.3 top_ivtools/INSTALL:1.4
*** top_ivtools/INSTALL:1.3 Thu Jan 27 01:51:22 2000
--- ./INSTALL Thu Jan 27 01:51:22 2000
***************
*** 150,158 ****
Also you may want to review the rest of the entries in the
site.def.<CPU> file to see if they are good defaults for your system.
- Some of these, like UseRpath and InstallRelative, are overridden in
- the config/config-<os>-gcc.defs file, so their value in
- config/site.def.<CPU> has no affect.
** See http://www.vectaport.com/ivtools/faq.html for more info.
--- 150,155 ----
Index: src_interviews/dialogs.c
diff -c src_interviews/dialogs.c:1.1 src_interviews/dialogs.c:1.2
*** src_interviews/dialogs.c:1.1 Thu Jan 27 01:51:29 2000
--- src/InterViews/dialogs.c Thu Jan 27 01:51:29 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1991 Stanford University
* Copyright (c) 1991 Silicon Graphics, Inc.
*
***************
*** 154,160 ****
/* class Dialog */
! Dialog::Dialog(Glyph* g, Style* s) : InputHandler(g, s) { }
Dialog::~Dialog() { }
boolean Dialog::post_for_aligned(Window* w, float x_align, float y_align) {
--- 155,161 ----
/* class Dialog */
! Dialog::Dialog(Glyph* g, Style* s) : InputHandler(g, s) { t_ = nil;}
Dialog::~Dialog() { }
boolean Dialog::post_for_aligned(Window* w, float x_align, float y_align) {
***************
*** 186,191 ****
--- 187,228 ----
t->display()->sync();
delete t;
return b;
+ }
+
+ void Dialog::map_for_aligned(Window* w, float x_align, float y_align) {
+ if (t_) return;
+ t_ = new TransientWindow(this);
+ t_->style(new Style(style()));
+ t_->transient_for(w);
+ t_->wm_delete(new DialogHandler(this));
+ t_->place(w->left() + 0.5 * w->width(), w->bottom() + 0.5 * w->height());
+ t_->align(x_align, y_align);
+ t_->map();
+ }
+
+ void Dialog::map_at_aligned(
+ Coord x, Coord y, float x_align, float y_align
+ ) {
+ if (t_) return;
+ t_ = new TransientWindow(this);
+ t_->style(new Style(style()));
+ t_->wm_delete(new DialogHandler(this));
+ t_->place(x, y);
+ t_->align(x_align, y_align);
+ t_->map();
+ }
+
+ void Dialog::unmap() {
+ if (t_) {
+ t_->unmap();
+ t_->display()->sync();
+ delete t_;
+ t_ = nil;
+ }
+ }
+
+ boolean Dialog::mapped() {
+ return t_ != nil;
}
boolean Dialog::run() {
Index: IVGlyph/Imakefile
diff -c IVGlyph/Imakefile:1.1 IVGlyph/Imakefile:1.2
*** IVGlyph/Imakefile:1.1 Thu Jan 27 01:51:37 2000
--- src/IVGlyph/Imakefile Thu Jan 27 01:51:37 2000
***************
*** 1,5 ****
XCOMM
! XCOMM IVGlyph - InterViews-3.1-derived glyphs
XCOMM
PACKAGE = IVGlyph
--- 1,5 ----
XCOMM
! XCOMM IVGlyph - InterViews-3.1-derived glyphs, observables, and dialog boxes
XCOMM
PACKAGE = IVGlyph
***************
*** 28,33 ****
--- 28,34 ----
Obj(importchooser)
Obj(namestate)
Obj(observables)
+ Obj(odialogs)
Obj(ofilechooser)
Obj(printchooser)
Obj(saveaschooser)
Index: IVGlyph/observables.c
diff -c IVGlyph/observables.c:1.1 IVGlyph/observables.c:1.2
*** IVGlyph/observables.c:1.1 Thu Jan 27 01:51:37 2000
--- src/IVGlyph/observables.c Thu Jan 27 01:51:37 2000
***************
*** 216,221 ****
}
void ObservableText::accept() {
! if (ptr)
! strcpy(*ptr, text);
}
--- 216,223 ----
}
void ObservableText::accept() {
! if (ptr) {
! delete text;
! text = strdup(*ptr);
! }
}
Index: IVGlyph/odialogs.c
diff -c /dev/null IVGlyph/odialogs.c:1.1
*** /dev/null Thu Jan 27 01:51:37 2000
--- src/IVGlyph/odialogs.c Thu Jan 27 01:51:37 2000
***************
*** 0 ****
--- 1,147 ----
+ /*
+ * Copyright 2000 IET Inc.
+ * Copyright 1996 Vectaport Inc.
+ * Copyright 1995 Cartoactive Systems, Cider Press
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ #include <IVGlyph/odialogs.h>
+ #include <IVGlyph/textform.h>
+
+ #include <IV-look/kit.h>
+
+ #include <InterViews/action.h>
+ #include <InterViews/cursor.h>
+ #include <InterViews/event.h>
+ #include <InterViews/layout.h>
+ #include <InterViews/style.h>
+ #include <InterViews/target.h>
+ #include <InterViews/window.h>
+
+ #include <OS/string.h>
+
+ #include <stdio.h>
+
+
+ /*****************************************************************************/
+
+ class ObsTextDialogImpl {
+ private:
+ friend class ObsTextDialog;
+
+ WidgetKit* kit_;
+ Style* style_;
+ ObsTextDialog* dialog_;
+
+ void init(ObsTextDialog*, Style*, ObservableText*, const char*);
+ void build(ObservableText*, const char*);
+
+ void close();
+ };
+
+ declareActionCallback(ObsTextDialogImpl)
+ implementActionCallback(ObsTextDialogImpl)
+
+ ObsTextDialog::ObsTextDialog(ObservableText* otext, const char* title)
+ : Dialog(nil, WidgetKit::instance()->style())
+ {
+ impl_ = new ObsTextDialogImpl;
+ ObsTextDialogImpl& impl = *impl_;
+ impl.kit_ = WidgetKit::instance();
+ impl.init(this, WidgetKit::instance()->style(), otext, title);
+ }
+
+ ObsTextDialog::~ObsTextDialog() {
+ delete impl_;
+ }
+
+ void ObsTextDialog::keystroke(const Event& e) {
+ ObsTextDialogImpl& i = *impl_;
+ char c;
+ if (e.mapkey(&c, 1) != 0) {
+ i.close();
+ }
+ }
+
+ #if 0
+ void ObsTextDialog::post(Window* window, const char* message,
+ const char* submsg, const char* title) {
+ WidgetKit& kit = *WidgetKit::instance();
+ if (title) {
+ Style* ts = new Style(kit.style());
+ ts->attribute("name", title);
+ kit.push_style(ts);
+ }
+
+ ObsTextDialog* dialog = new ObsTextDialog(message, submsg);
+ Resource::ref(dialog);
+ dialog->post_for(window);
+ Resource::unref(dialog);
+ window->cursor(defaultCursor);
+ if (title)
+ kit.pop_style();
+ }
+ #endif
+
+
+ /** class ObsTextDialogImpl **/
+
+ void ObsTextDialogImpl::init(ObsTextDialog* d, Style* s,
+ ObservableText* otext, const char* title) {
+ dialog_ = d;
+ style_ = s;
+ build(otext, title);
+ }
+
+ void ObsTextDialogImpl::build(ObservableText* otext, const char* title) {
+ WidgetKit& kit = *kit_;
+ const LayoutKit& layout = *LayoutKit::instance();
+ Style* s = style_;
+ String titlestr(title);
+
+ Action* close = new ActionCallback(ObsTextDialogImpl)(
+ this, &ObsTextDialogImpl::close);
+
+ Glyph *g;
+ TextObserver* otextview = new TextObserver(otext, "");
+ g = layout.vbox(
+ kit.fancy_label(titlestr),
+ layout.vglue(5.0, 0.0, 2.0),
+ layout.hbox(
+ layout.hglue(),
+ layout.hcenter(otextview),
+ layout.hglue()),
+ layout.vspace(15.0),
+ layout.hbox(
+ layout.hglue(),
+ layout.hcenter(kit.push_button(kit.label("Close"), close)),
+ layout.hglue()
+ ));
+
+ dialog_->body(
+ kit.outset_frame(layout.margin(g, 10.0))
+ );
+ }
+
+ void ObsTextDialogImpl::close() {
+ dialog_->unmap();
+ }
+
Index: IVGlyph/odialogs.h
diff -c /dev/null IVGlyph/odialogs.h:1.1
*** /dev/null Thu Jan 27 01:51:37 2000
--- src/IVGlyph/odialogs.h Thu Jan 27 01:51:37 2000
***************
*** 0 ****
--- 1,50 ----
+ /*
+ * Copyright 2000 IET Inc.
+ * Copyright 1996 Vectaport Inc.
+ * Copyright 1995 Cartoactive Systems, Cider Press
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ #ifndef odialogs_h
+ #define odialogs_h
+
+ #include <IV-3_1/InterViews/dialog.h>
+
+ #include <InterViews/_enter.h>
+
+ class ObservableText;
+ class ObsTextDialogImpl;
+ class WidgetKit;
+
+ class ObsTextDialog : public Dialog {
+ public:
+ ObsTextDialog(ObservableText* otext, const char* title);
+ virtual ~ObsTextDialog();
+
+ virtual void keystroke(const Event&);
+
+ private:
+ ObsTextDialogImpl* impl_;
+ };
+
+ #include <InterViews/_leave.h>
+
+ #endif
Index: OverlayUnidraw/grloctool.c
diff -c OverlayUnidraw/grloctool.c:1.1 OverlayUnidraw/grloctool.c:1.2
*** OverlayUnidraw/grloctool.c:1.1 Thu Jan 27 01:51:58 2000
--- src/OverlayUnidraw/grloctool.c Thu Jan 27 01:51:58 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright 2000 IET Inc.
* Copyright 1998 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 30,36 ****
#include <Unidraw/iterator.h>
#include <Unidraw/selection.h>
! #include <IVGlyph/gdialogs.h>
#include <InterViews/event.h>
#include <InterViews/transformer.h>
--- 31,38 ----
#include <Unidraw/iterator.h>
#include <Unidraw/selection.h>
! #include <IVGlyph/observables.h>
! #include <IVGlyph/odialogs.h>
#include <InterViews/event.h>
#include <InterViews/transformer.h>
***************
*** 49,56 ****
--- 51,78 ----
GrLocTool::GrLocTool (ControlInfo* m) : Tool(m)
{
+ _dialog = nil;
+ _bufsiz = 64;
+ _buffer = new char[_bufsiz];
+ strcpy(_buffer, "test string");
+ _otext = new ObservableText(&_buffer);
}
+ GrLocTool::~GrLocTool() {
+ delete _buffer;
+ delete _otext;
+ }
+
+ Dialog* GrLocTool::dialog() {
+ if (!_dialog) {
+ _dialog = new ObsTextDialog(_otext, "Location relative to graphic's coordinate system");
+ Resource::ref(_dialog);
+ }
+ return _dialog;
+ }
+
+
+
Tool* GrLocTool::Copy () { return new GrLocTool(CopyControlInfo()); }
Manipulator* GrLocTool::CreateManipulator (
***************
*** 66,77 ****
Graphic* gr;
if (view && (gr = view->GetGraphic())) {
viewer->ScreenToGraphic(e.x, e.y, gr, xgr, ygr);
! char buffer[BUFSIZ];
! sprintf( buffer, "x,y: %.2f %.2f", xgr, ygr);
! GAcknowledgeDialog* dialog = new GAcknowledgeDialog(buffer);
! Resource::ref(dialog);
! dialog->post_for(v->GetEditor()->GetWindow());
! Resource::unref(dialog);
}
}
Manipulator* m = nil;
--- 88,99 ----
Graphic* gr;
if (view && (gr = view->GetGraphic())) {
viewer->ScreenToGraphic(e.x, e.y, gr, xgr, ygr);
! sprintf( _buffer, "x,y: %.2f %.2f", xgr, ygr);
! _otext->accept();
! if (!dialog()->mapped())
! dialog()->map_for(v->GetEditor()->GetWindow());
! else
! _otext->notify();
}
}
Manipulator* m = nil;
Index: OverlayUnidraw/grloctool.h
diff -c OverlayUnidraw/grloctool.h:1.1 OverlayUnidraw/grloctool.h:1.2
*** OverlayUnidraw/grloctool.h:1.1 Thu Jan 27 01:51:58 2000
--- src/OverlayUnidraw/grloctool.h Thu Jan 27 01:51:58 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright 2000 IET Inc.
* Copyright 1998-1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 26,31 ****
--- 27,35 ----
#include <Unidraw/Tools/tool.h>
+ class Dialog;
+ class ObservableText;
+
//: tool to display coordinates relative to a graphic.
// For a raster or stencil the origin is 0,0.
// For all other graphics the origin is relative to the coordinates used to
***************
*** 34,39 ****
--- 38,44 ----
class GrLocTool : public Tool {
public:
GrLocTool(ControlInfo* = nil);
+ virtual ~GrLocTool();
virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer* =nil);
// use event to select a component and determine graphic-relative coordinates
***************
*** 43,48 ****
--- 48,60 ----
virtual ClassId GetClassId();
virtual boolean IsA(ClassId);
+ Dialog* dialog();
+
+ protected:
+ Dialog* _dialog;
+ ObservableText* _otext;
+ char* _buffer;
+ int _bufsiz;
};
#endif
Index: OverlayUnidraw/ovimport.c
diff -c OverlayUnidraw/ovimport.c:1.2 OverlayUnidraw/ovimport.c:1.3
*** OverlayUnidraw/ovimport.c:1.2 Thu Jan 27 01:51:58 2000
--- src/OverlayUnidraw/ovimport.c Thu Jan 27 01:51:58 2000
***************
*** 93,98 ****
--- 93,99 ----
#include <Dispatch/iohandler.h>
#include <Dispatch/dispatcher.h>
#include <fstream.h>
+ #include <string.h>
#include <strstream.h>
#include <fcntl.h>
#include <errno.h>
Index: include_interviews/dialog.h
diff -c include_interviews/dialog.h:1.1 include_interviews/dialog.h:1.2
*** include_interviews/dialog.h:1.1 Thu Jan 27 01:52:06 2000
--- src/include/InterViews/dialog.h Thu Jan 27 01:52:06 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1992 Stanford University
* Copyright (c) 1992 Silicon Graphics, Inc.
*
***************
*** 34,39 ****
--- 35,41 ----
#include <InterViews/_enter.h>
class Window;
+ class TransientWindow;
/*
* The post*_aligned operations replaced default parameters
***************
*** 51,61 ****
--- 53,72 ----
virtual boolean post_at_aligned(
Coord x, Coord y, float xalign, float yalign
);
+ void map_for(Window*);
+ virtual void map_for_aligned(Window*, float xalign, float yalign);
+ void map_at(Coord x, Coord y);
+ virtual void map_at_aligned(
+ Coord x, Coord y, float xalign, float yalign
+ );
+ void unmap();
+ boolean mapped();
virtual boolean run();
virtual void dismiss(boolean accept);
private:
boolean done_;
boolean accepted_;
+ TransientWindow* t_;
};
inline boolean Dialog::post_for(Window* w) {
***************
*** 64,69 ****
--- 75,88 ----
inline boolean Dialog::post_at(Coord x, Coord y) {
return post_at_aligned(x, y, 0.5, 0.5);
+ }
+
+ inline void Dialog::map_for(Window* w) {
+ map_for_aligned(w, 0.5, 0.5);
+ }
+
+ inline void Dialog::map_at(Coord x, Coord y) {
+ map_at_aligned(x, y, 0.5, 0.5);
}
#include <InterViews/_leave.h>
Index: config_ivtools/site.def.LINUX
diff -c config_ivtools/site.def.LINUX:1.2 config_ivtools/site.def.LINUX:1.3
*** config_ivtools/site.def.LINUX:1.2 Thu Jan 27 01:52:16 2000
--- config/site.def.LINUX Thu Jan 27 01:52:16 2000
***************
*** 56,60 ****
/* file output by configure script */
#include "config-linux-gcc.defs"
-
-
--- 56,58 ----
|