1 #include <../../nrnconf.h>
8 #if (MAC && !defined(carbon)) || defined(WIN32)
14 #if defined(WIN32) || MAC
38 #include <IV-Win/mprinter.h>
39 void iv_display_scale(
float);
44 #if MAC && !defined(carbon)
48 #define IOS_OUT (ios::out | ios::trunc)
49 extern char*
mktemp(
char*);
50 extern int unlink(
const char*);
51 #include <IV-Mac/mprinter.h>
59 #include <IV-look/kit.h>
60 #include <IV-look/dialogs.h>
61 #include <InterViews/layout.h>
62 #include <InterViews/hit.h>
63 #include <InterViews/display.h>
64 #include <InterViews/session.h>
65 #include <InterViews/color.h>
66 #include <InterViews/brush.h>
67 #include <InterViews/font.h>
68 #include <InterViews/event.h>
69 #include <InterViews/handler.h>
70 #include <InterViews/printer.h>
71 #include <InterViews/style.h>
72 #include <InterViews/background.h>
73 #include <InterViews/label.h>
96 extern bool (*ivoc_snapshot_)(
const Event*);
97 static bool ivoc_snapshot(
const Event*);
100 #define PWM_help_ "help"
101 #define PWM_do_print_ "Print PWM"
102 #define PWM_ScreenItem_ "ScreenItem PWM"
103 #define PWM_PaperItem_ "PaperItem PWM"
104 #define PWM_landscape_ "LandPort Other"
105 #define PWM_virt_screen_ "VirtualScreen Other"
106 #define PWM_printer_control_ "SelectPrinter Other"
107 #define PWM_file_control_ "PostScript PrintToFile"
108 #define PWM_idraw_control_ "Idraw PrintToFile"
109 #define PWM_save_control2_ "SaveAll Session"
110 #define PWM_save_control1_ "SaveSelected Session"
111 #define PWM_retrieve_control_ "Retrieve Session"
112 #define PWM_tray_ "Tray Other"
113 #define PWM_ascii_ "Ascii PrintToFile"
114 #define PWM_quit_ "Quit Other"
116 #define pwm_impl PrintableWindowManager::current()->pwmi_
119 static void save_all(ostream&);
137 printf(
" canvas %g %g %g %g\n",
e.left(),
e.bottom(),
e.right(),
e.top());
142 class ScreenScene:
public Scene {
149 class PaperScene:
public Scene {
155 class ScreenSceneHandler:
public Handler {
158 virtual bool event(
Event&);
166 class ScreenItem:
public Glyph {
168 friend class PaperItem;
180 PaperItem* paper_item()
const {
187 bool iconify_via_hide_;
196 class PaperItem:
public Glyph {
198 PaperItem(ScreenItem*);
205 void scale(
float s) {
211 ScreenItem* screen_item()
const {
218 friend class ScreenItem;
221 friend ScreenItem::~ScreenItem();
229 void append_paper(ScreenItem*);
230 void remove_paper(PaperItem*);
231 void unshow_paper(PaperItem*);
233 PaperScene* paper() {
236 ScreenScene* screen() {
242 void snapshot(
const Event*);
248 void do_print(
bool printer,
const char*
name);
249 void do_print_session(
bool also_controller =
true);
250 void do_print_session(
bool printer,
const char*
name);
251 void ps_file_print(
bool,
const char*,
bool,
bool);
252 void common_print(
Printer*,
bool,
bool);
258 MacPrinter* mprinter();
266 void landscape(
bool);
267 bool is_landscape() {
273 void printer_control();
276 void snapshot_control();
278 bool file_control1();
279 void idraw_control();
280 void idraw_write(
const char*
fname,
bool ses_style =
false);
281 void ascii_control();
282 void ascii_write(
const char*
fname,
bool ses_style =
false);
284 void save_selected_control();
285 void save_all_control();
286 void save_control(
int);
287 void save_session(
int,
const char*,
const char* head =
NULL);
288 int save_group(
Object*,
const char*);
289 void retrieve_control();
291 float round_factor() {
292 return round_factor_;
300 void all_window_bounding_box(
Extension&,
bool with_screen =
true,
bool also_controller =
true);
303 const Color* window_outline_;
310 PWMImpl(ScreenScene*, PaperScene*,
Rect*);
316 bool none_selected(
const char*,
const char*)
const;
317 void ses_group(ScreenItem* si, ostream&
o);
318 int ses_group_first_;
319 void save_begin(ostream&);
320 void save_list(
int, ScreenItem**, ostream&);
324 ScreenScene* screen_;
330 bool printer_control_accept_;
342 const Event* snap_event_;
343 bool print_leader_flag_;
349 MacPrinter* mprinter_;
355 static void makeVirtualWindow();
357 virtual ~VirtualWindow();
363 static VirtualWindow* virt_win_;
367 VirtualWindow* VirtualWindow::virt_win_;
371 class VirtualWindowScale:
public Action {
373 VirtualWindowScale(
float);
381 class PaperItem_handler:
public Handler {
385 virtual ~PaperItem_handler();
386 virtual bool event(
Event&);
399 class ScreenItemHandler:
public Handler {
402 virtual ~ScreenItemHandler();
403 virtual bool event(
Event&);
418 virtual ~PWMDismiss();
423 PWMDismiss::~PWMDismiss() {}
426 pwm_impl->unmap_all();
440 extern char** (*nrnpy_gui_helper3_str_)(
const char*
name,
Object* obj,
int handle_strptr);
463 cnt =
p->screen()->count();
474 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
475 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
477 return double(si->window()->is_mapped());
488 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
489 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
502 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
503 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
505 si->window()->hide();
516 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
517 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
520 *ps = (
char*) si->window()->name();
522 return (
const char**) ps;
532 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
533 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
534 if (
p->window() == si->window()) {
537 si->window()->dismiss();
543 static void pwman_iconify1(
void*
v) {
557 if (!nrn_is_gui_thread()) {
558 nrn_gui_exec(pwman_iconify1, pw);
584 int i,
cnt =
p->screen()->count();
585 for (
i = 0;
i <
cnt; ++
i) {
586 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
587 if (si->window() == pw) {
602 int i,
cnt =
p->screen()->count();
603 for (
i = 0;
i <
cnt; ++
i) {
604 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
605 if (si->window() == pw) {
642 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
643 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
662 p->snapshot_control();
672 static double scale_;
673 static void pwman_scale1(
void*) {
676 iv_display_scale(scale_);
684 double scale =
chkarg(1, .01, 100);
689 if (!nrn_is_gui_thread()) {
691 nrn_gui_exec(pwman_scale1, (
void*) ((intptr_t) 1));
695 iv_display_scale(scale);
708 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
709 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
726 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
727 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
729 PaperItem* pi = si->paper_item();
731 if ((
int(
chkarg(2, 0, 1))) == 0) {
735 pi->scale(
chkarg(4, 1
e-4, 1e4));
736 p->paper()->move(
p->paper_index(pi), *
getarg(2) / pr_scl, *
getarg(3) / pr_scl);
751 bool ses_style =
false;
753 ses_style = int(
chkarg(3, 0, 1)) ? true :
false;
756 switch ((
int)
chkarg(2, 0, 2)) {
758 p->ps_file_print(
false,
fname,
p->is_landscape(), ses_style);
761 p->idraw_write(
fname, ses_style);
764 p->ascii_write(
fname, ses_style);
777 p->landscape(
int(
chkarg(1, 0, 1)) ?
true :
false);
843 PaperItem_handler::PaperItem_handler(
int type,
852 index_ = pwm_impl->paper_index(pi);
854 pwm_impl->paper()->location(index_,
left, bottom);
858 action_ = &PaperItem_handler::resize_action;
861 t_.translate(
left - x, bottom - y);
862 action_ = &PaperItem_handler::move_action;
867 PaperItem_handler::~PaperItem_handler() {
872 bool PaperItem_handler::event(
Event&
e) {
878 e.window()->grab_pointer();
880 (this->*action_)(
e.pointer_x(),
e.pointer_y());
885 e.window()->ungrab_pointer();
889 (this->*action_)(
e.pointer_x(),
e.pointer_y());
895 void PaperItem_handler::move_action(
Coord x,
Coord y) {
898 t_.transform(x, y, xs, ys);
899 xs = pwm_impl->round(xs);
900 ys = pwm_impl->round(ys);
901 pwm_impl->paper()->move(index_, xs, ys);
904 void PaperItem_handler::resize_action(
Coord x,
Coord y) {
906 pwm_impl->paper()->allotment(index_,
Dimension_X, ax);
908 pwm_impl->paper()->allotment(index_,
Dimension_Y, ay);
910 t_.transform(x, y, xs, ys);
913 scl = pi_->scale() * scl;
914 scl = (scl > .1) ? scl : .1;
916 w1 = pwm_impl->round(scl * pi_->width());
917 w1 =
Math::max(w1, pwm_impl->round_factor());
918 scl = w1 / pi_->width();
920 pwm_impl->paper()->modified(index_);
929 style(
new Style(Session::instance()->style()));
930 style()->attribute(
"nrn_virtual_screen",
"0");
933 MenuItem* mi = append_menubar(
"Scale");
935 Menu* m = wk.pulldown();
939 mi->action(
new VirtualWindowScale(1.0));
943 mi->action(
new VirtualWindowScale(
fil));
947 mi->action(
new VirtualWindowScale(1.2));
951 mi->action(
new VirtualWindowScale(1.5));
955 mi->action(
new VirtualWindowScale(2.0));
960 VirtualWindow::~VirtualWindow() {
964 #if defined(WIN32) || carbon
968 void VirtualWindow::makeVirtualWindow() {
971 virt_win_ =
new VirtualWindow(
v,
972 LayoutKit::instance()->variable_span(
973 new Background(
v, WidgetKit::instance()->background())));
981 void virtual_window_top() {
982 VirtualWindow::makeVirtualWindow();
985 void VirtualWindow::view() {
987 View*
v = virt_win_->view_;
989 v->size(s->
x1(), s->
y1(), s->
x2(), s->
y2());
990 virt_win_->canvas()->damage_all();
995 VirtualWindowScale::VirtualWindowScale(
float scale) {
1000 float scale = scale_;
1001 if (scale_ >=
fil / 10.) {
1003 pwm_impl->all_window_bounding_box(
e);
1004 iv_display_scale(
e.right() -
e.left(),
e.top() -
e.bottom());
1006 iv_display_scale(scale);
1019 pwm_impl->screen()->location(si_->index(),
left, bottom);
1021 t_.translate(
left - x, bottom - y);
1024 ScreenItemHandler::~ScreenItemHandler() {
1029 bool ScreenItemHandler::event(
Event&
e) {
1035 e.window()->grab_pointer();
1037 move_action(
false,
e.pointer_x(),
e.pointer_y());
1042 e.window()->ungrab_pointer();
1044 move_action(
true,
e.pointer_x(),
e.pointer_y());
1047 move_action(
false,
e.pointer_x(),
e.pointer_y());
1053 void ScreenItemHandler::move_action(
bool doit,
Coord x,
Coord y) {
1056 t_.transform(x, y, xs, ys);
1058 if (si_->window()) {
1059 si_->window()->move(xs * Scl, ys * Scl);
1062 pwm_impl->screen()->move(si_->index(), xs, ys);
1067 :
Scene(x1, y1, x2, y2,
g) {}
1070 if (pwm_impl->tool(h.event()->pointer_button()) == Event::middle) {
1071 if (h.event()->type() == Event::down) {
1072 h.target(depth,
this, 0,
new ScreenSceneHandler(h.left() * Scl, h.bottom() * Scl));
1079 Coord ScreenScene::mbs()
const {
1084 :
Scene(x1, y1, x2, y2,
g) {}
1086 Coord PaperScene::mbs()
const {
1090 ScreenSceneHandler::ScreenSceneHandler(
Coord x,
Coord y)
1095 bool ScreenSceneHandler::event(
Event&) {
1096 pwm_impl->view_screen(
x_,
y_);
1102 declareActionCallback(PWMImpl) implementActionCallback(PWMImpl)
1112 LayoutKit& layout = *LayoutKit::instance();
1113 WidgetKit& kit = *WidgetKit::instance();
1114 PaperItem::fsize_ = kit.font()->size();
1116 Display* d = Session::instance()->default_display();
1120 Style*
q = Session::instance()->style();
1121 if (!
q->find_attribute(
"pwm_canvas_height", canvasheight)) {
1122 canvasheight = 100.;
1124 const Color* outline_color;
1126 Display* dis = Session::instance()->default_display();
1127 if (!
q->find_attribute(
"pwm_screen_outline_color",
c) ||
1131 Scl = d->height() / canvasheight;
1132 Rect* sr =
new Rect(0, 0, d->width() / Scl, d->height() / Scl, outline_color);
1134 ScreenScene* screen =
new ScreenScene(-5, -2, d->width() / Scl + 5, d->height() / Scl + 2, sr);
1137 if (!
q->find_attribute(
"pwm_paper_height", pageheight)) {
1140 if (!
q->find_attribute(
"pwm_paper_width", pagewidth)) {
1144 if (pageheight > pagewidth)
1145 pr_scl = pageheight / canvasheight;
1147 pr_scl = pagewidth / canvasheight;
1150 if (d->width() > d->height())
1151 wp1 = d->width() / Scl;
1155 Coord wp = pagewidth / pr_scl;
1156 Coord hp = pageheight / pr_scl;
1158 Rect* r =
new Rect(0, 0, wp, hp, outline_color);
1161 PaperScene* paper =
new PaperScene(-5, -2,
Math::max(
max, d->width() / Scl),
max + 2, r);
1164 pwmi_ =
new PWMImpl(screen, paper, r);
1165 if (!
q->find_attribute(
"pwm_window_outline_color",
c) ||
1169 outline_color->ref();
1170 pwmi_->window_outline_ = outline_color;
1171 pwmi_->screen_rect_ = sr;
1172 if (!
q->find_attribute(
"pwm_paper_resolution",
pwmi_->round_factor_)) {
1173 pwmi_->round_factor_ = .25;
1175 pwmi_->canvasheight_ = canvasheight;
1176 pwmi_->round_factor_ /= pr_scl;
1178 if (
q->find_attribute(
"pwm_pixel_resolution", ltmp)) {
1184 pwmi_->left_->ref();
1186 Menu *mbar, *mprint, *mses, *mother;
1189 if (
q->value_is_on(
"pwm_help")) {
1190 vb->append(kit.push_button(
"Help",
1196 hb->append(mbar = kit.menubar());
1200 mi = kit.menubar_item(
"Print");
1201 mbar->append_item(mi);
1202 mprint = kit.pulldown();
1205 mi = kit.menubar_item(
"Session");
1206 mbar->append_item(mi);
1207 mses = kit.pulldown();
1211 mi = kit.menubar_item(
"Other");
1212 mbar->append_item(mi);
1213 mother = kit.pulldown();
1218 mi = kit.radio_menu_item(ttg,
"select");
1219 mbar->append_item(mi);
1220 mi->state()->set(TelltaleState::is_chosen,
true);
1221 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::select_tool));
1223 mi = kit.radio_menu_item(ttg,
"move");
1224 mbar->append_item(mi);
1225 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::move_tool));
1227 mi = kit.radio_menu_item(ttg,
"resize");
1228 mbar->append_item(mi);
1229 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::resize_tool));
1232 mprint->append_item(mi);
1233 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::do_print0));
1236 mprint->append_item(mi);
1237 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::file_control));
1241 mprint->append_item(mi);
1242 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::snapshot_control));
1247 mprint->append_item(mi);
1248 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::idraw_control));
1251 mprint->append_item(mi);
1252 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::ascii_control));
1253 #if MAC && !defined(carbon)
1255 mprint->append_item(mi);
1256 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::paperscale));
1259 mprint->append_item(mi);
1260 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::printer_control));
1264 mprint->append_item(mi);
1265 pwmi_->p_title_ = mi->state();
1269 mprint->append_item(mi);
1270 pwmi_->p_deco_ = mi->state();
1273 pwmi_->p_deco_->set(TelltaleState::is_chosen,
true);
1275 pwmi_->p_deco_->set(TelltaleState::is_chosen,
false);
1280 mses->append_item(mi);
1281 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::retrieve_control));
1284 mses->append_item(mi);
1285 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::save_selected_control));
1288 mses->append_item(mi);
1289 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::save_all_control));
1292 mses->append_item(mi);
1293 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::virt_screen));
1297 mprint->append_item(mi);
1298 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::landscape));
1302 mses->append_item(mi);
1303 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::tray));
1307 mother->append_item(mi);
1308 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::quit_control));
1314 pwmi_->w_->replace_dismiss_action(
NULL);
1317 pwmi_->w_->xplace(-800, 0);
1320 pwmi_->w_->xplace(0, 40);
1322 pwmi_->w_->xplace(0, 0);
1331 void PWMImpl::select_tool() {
1334 void PWMImpl::move_tool() {
1337 void PWMImpl::resize_tool() {
1338 tool_ = Event::middle;
1350 LayoutKit& layout = *LayoutKit::instance();
1354 layout.hbox(layout.variable_span(
new View(screen_)),
1355 layout.variable_span(pview_ =
new View(paper_))),
1364 Style* s =
new Style(Session::instance()->style());
1365 s->attribute(
"name",
"Print & File Window Manager");
1386 bool m = (
ifarg(3) && int(*
getarg(3)) == 0) ?
false :
true;
1408 return pwm_impl->cur_ses_name_.string();
1420 }
else if (
ifarg(2)) {
1421 pwm_impl->do_print_session((
int)
chkarg(1, 0, 1),
gargstr(2));
1423 bool b =
ifarg(1) ? (
chkarg(1, 0, 1) == 1.) :
true;
1424 pwm_impl->do_print_session(b);
1435 if (!w->is_mapped()) {
1437 if (pw && pw->is_mapped() && pw != w) {
1439 w->transient_for(pw);
1441 w->group_leader(pw);
1478 pwmi_->screen_->append(
new ScreenItem(w));
1481 if (pw && pw->is_mapped() && pw != w) {
1483 w->transient_for(pw);
1486 w->group_leader(pw);
1495 PWMImpl* impl =
pwmi_;
1496 if (w == impl->window()) {
1501 Scene* s = impl->screen_;
1510 #define PIXROUND(x, y, r) x = int((y + r / 2) / r) * r
1526 PIXROUND(x, x1, pixres);
1527 PIXROUND(y, y1, pixres);
1528 if (x != x1 || y != y1) {
1538 w = canvas()->pwidth();
1539 h = canvas()->pheight();
1540 PIXROUND(x, w, pixres);
1541 PIXROUND(y, h, pixres);
1546 if (x != w || y != h) {
1547 canvas()->psize(x, y);
1554 PWMImpl* impl =
pwmi_;
1563 impl->screen_->move(
i, l / Scl, b / Scl);
1564 impl->screen_->change(
i);
1565 impl->screen_->show(
i, w->is_mapped());
1566 ScreenItem* si = (ScreenItem*) impl->screen_->component(
i);
1567 PaperItem* pi = si->paper_item();
1569 impl->paper_->change(impl->paper_index(pi));
1572 impl->all_window_bounding_box(
e);
1573 impl->screen_->new_size(
e.left() / Scl - 5,
1574 e.bottom() / Scl - 2,
1575 e.right() / Scl + 5,
1577 VirtualWindow::view();
1580 impl->screen_->location(
i, x, y);
1581 printf(
"reconfigured %d %d %g %g\n",
i, impl->screen_->showing(
i), x, y);
1597 void PWMImpl::all_window_bounding_box(
Extension&
e,
bool with_screen,
bool also_leader) {
1600 Display* d = Session::instance()->default_display();
1602 e.set_xy(
NULL, 0., 0., d->width(), d->height());
1608 for (
i = 0;
i < screen_->count();
i++) {
1609 w = ((ScreenItem*) (screen_->component(
i)))->window();
1610 if (w && w->is_mapped() && w != wl) {
1612 NULL, w->left(), w->bottom(), w->left() + w->width(), w->bottom() + w->height());
1617 if (w && w->is_mapped() && (also_leader || empty)) {
1618 e.merge_xy(
NULL, w->left(), w->bottom(), w->left() + w->width(), w->bottom() + w->height());
1619 print_leader_flag_ =
true;
1621 print_leader_flag_ =
false;
1623 screen_rect_->width(d->width() / Scl);
1624 screen_rect_->height(d->height() / Scl);
1628 void PWMImpl::view_screen(
Coord x,
Coord y) {
1633 Display* d = Session::instance()->default_display();
1634 xp = d->to_pixels(-x) + d->pwidth() / 2;
1635 yp = d->to_pixels(y) - d->pheight() / 2;
1636 for (
i = 0;
i < screen_->count();
i++) {
1637 ScreenItem* si = (ScreenItem*) screen_->component(
i);
1640 if (w != window()) {
1647 void PWMImpl::do_print0() {
1653 if (none_selected(
"No windows to print",
"Print Anyway")) {
1656 #if MAC && !defined(carbon)
1665 if (!printer_control_accept_) {
1672 do_print(use_printer,
name.string());
1679 do_print(use_printer, fc_print_->selected()->string());
1683 void PWMImpl::do_print(
bool use_printer,
const char*
name) {
1684 #if MAC && !defined(carbon)
1691 if (use_printer && strcmp(
name,
"Windows") == 0) {
1696 ps_file_print(use_printer,
name, landscape_,
false);
1699 void PWMImpl::do_print_session(
bool also_leader) {
1704 bool deco = p_deco_->test(TelltaleState::is_chosen);
1705 p_deco_->set(TelltaleState::is_chosen,
true);
1711 if (!mprinter()->
get()) {
1715 all_window_bounding_box(
e,
false, also_leader);
1717 float s1 = (mprinter()->width() - 72.) / (
e.right() -
e.left() + 6.);
1718 float s2 = (mprinter()->height() - 72.) / (
e.top() -
e.bottom() + 23.);
1719 float sfac = (s1 < s2) ? s1 : s2;
1720 float xoff = mprinter()->width() / 2 / sfac - (
e.right() +
e.left() + 6.) / 2.;
1721 float yoff = mprinter()->height() / 2 / sfac - (
e.top() +
e.bottom() + 23.) / 2.;
1723 t.translate(xoff, yoff);
1724 #if MAC && !defined(carbon)
1725 mprinter()->prolog();
1726 t.scale(sfac, sfac);
1728 mprinter()->prolog(sfac);
1730 mprinter()->push_transform();
1731 mprinter()->transform(
t);
1732 common_print(mprinter(),
false,
true);
1733 mprinter()->pop_transform();
1734 mprinter()->epilog();
1737 #if (!MAC || DARWIN) && !defined(WIN32)
1741 if (!printer_control_accept_) {
1749 ps_file_print(
true,
name.string(),
true,
true);
1754 p_deco_->set(TelltaleState::is_chosen, deco);
1756 print_leader_flag_ =
true;
1759 void PWMImpl::do_print_session(
bool use_printer,
const char*
name) {
1760 print_leader_flag_ =
true;
1761 ps_file_print(use_printer,
name,
true,
true);
1764 void PWMImpl::ps_file_print(
bool use_printer,
const char*
name,
bool land_style,
bool ses_style) {
1765 Style* s = Session::instance()->style();
1766 static char* tmpfile = (
char*) 0;
1785 bool deco = p_deco_->test(TelltaleState::is_chosen);
1786 p_deco_->set(TelltaleState::is_chosen,
true);
1788 Style* s = Session::instance()->style();
1791 if (!s->find_attribute(
"pwm_paper_height", pageheight)) {
1794 if (!s->find_attribute(
"pwm_paper_width", pagewidth)) {
1798 all_window_bounding_box(
e,
false,
true);
1800 float s1 = (pagewidth * 72 - 72.) / (
e.right() -
e.left() + 6.);
1801 float s2 = (pageheight * 72 - 72.) / (
e.top() -
e.bottom() + 23.);
1802 float sfac = (s1 < s2) ? s1 : s2;
1803 float xoff = pagewidth * 72 / 2 / sfac - (
e.right() +
e.left() + 6.) / 2.;
1804 float yoff = pageheight * 72 / 2 / sfac - (
e.top() +
e.bottom() + 23.) / 2.;
1806 t.translate(xoff, yoff);
1807 t.scale(sfac, sfac);
1808 pr->push_transform();
1810 common_print(
pr,
false, ses_style);
1811 pr->pop_transform();
1813 p_deco_->set(TelltaleState::is_chosen, deco);
1816 common_print(
pr, land_style, ses_style);
1822 s->find_attribute(
"pwm_postscript_filter", filt);
1823 char*
buf =
new char[200 + strlen(
name) + strlen(filt.string()) + 2 * strlen(tmpfile)];
1829 sprintf(
buf,
"%s < %s | %s ; rm %s", filt.string(), tmpfile,
name, tmpfile);
1835 sprintf(
buf,
"%s < %s > %s ; rm %s", filt.string(), tmpfile,
name, tmpfile);
1853 void PWMImpl::mac_do_print() {
1855 if (!mprinter()->
get()) {
1859 mprinter()->prolog();
1860 common_print(mprinter(), landscape_,
false);
1861 mprinter()->epilog();
1865 void PWMImpl::common_print(
Printer*
pr,
bool land_style,
bool ses_style) {
1872 Style* s = Session::instance()->style();
1875 if (!s->find_attribute(
"pwm_paper_height", pageheight)) {
1878 if (!s->find_attribute(
"pwm_paper_width", pagewidth)) {
1881 pr->resize(0, 0, pagewidth * 72, pageheight * 72);
1887 t.translate(20,
pr->height() - 70);
1889 t.translate(0,
pr->height());
1895 if (!
p->showing(
i)) {
1903 ScreenItem* pi = (ScreenItem*)
p->component(
i);
1905 if (!pw->is_mapped()) {
1911 float sfac = .9 * pagewidth * 72 / pw->display()->height();
1916 t.scale(sfac, sfac);
1920 PaperItem* pi = (PaperItem*)
p->component(
i);
1921 pw = pi->screen_item()->window();
1922 float sfac = pr_scl * 72 * pi->scale() / Scl;
1923 p->location(
i, x, y);
1924 t.scale(sfac, sfac);
1925 t.translate(72 * x * pr_scl, 72 * y * pr_scl);
1927 x1 = 72 * (x) *pr_scl;
1928 y1 = 72 * (y + pi->width() * pw->
height_pw() / pw->
width_pw() * pi->scale()) * pr_scl;
1940 pr->push_transform();
1942 pr->push_clipping();
1948 if (p_deco_->test(TelltaleState::is_chosen) ==
true) {
1949 print_deco(
pr, a, pw->
name());
1952 pr->pop_transform();
1961 if ((ses_style || p_title_->test(TelltaleState::is_chosen) ==
true)
1963 && p_deco_->test(TelltaleState::is_chosen) ==
false
1967 Label label(pw->
name(), wk.font(), wk.foreground());
1987 Coord l, b, r,
t, w, h, s, x, y, dx, xx;
1990 static const Color* ctitle;
1991 static const Color* ctitlebar;
1992 static const Color* coutline;
1993 static const Color* bright;
1994 static const Color* dark;
1995 static const Font* ftitle;
1996 static const Brush* br;
1997 static int first = 1;
2006 bright =
new Color(.9, .9, .9, 1.);
2008 dark =
new Color(.1, .1, .1, 1.);
2010 ctitle =
new Color(0., 0., 0., 1.);
2012 ctitlebar =
new Color(.8, .8, .8, 1.);
2014 coutline =
new Color(.7, .7, .7, 1.);
2028 pr->fill_rect(l,
t, r,
t + h, ctitlebar);
2037 Coord xo = (l + r) / 2 - x / 2;
2038 xo = (xo < h) ? h : xo;
2042 pr->push_clipping();
2043 pr->clip_rect(l + h,
t, r,
t + h);
2048 pr->fill_rect(l, b - w, l - w,
t + h + w, coutline);
2049 pr->fill_rect(r, b - w, r + w,
t + h + w, coutline);
2050 pr->fill_rect(l, b, r, b - w, coutline);
2051 pr->fill_rect(l,
t + h, r,
t + h + w, coutline);
2052 pr->rect(l - w, b - w, r + w,
t + h + w, dark, br);
2055 x = (l + (l + h - s)) / 2;
2056 y = (
t + s +
t + h) / 2;
2058 pr->rect(x - dx, y - dx, x + dx, y + dx, bright, br);
2060 pr->line(x - dx, y - dx, x + dx, y + dx, bright, br);
2061 pr->line(x - dx, y + dx, x + dx, y - dx, bright, br);
2066 static char* tmpfile = (
char*) 0;
2070 Style* s = Session::instance()->style();
2073 if (s->find_attribute(
"pwm_postscript_filter", filt)) {
2075 buf,
"cat %s > %s; %s < %s > %s", filename, tmpfile, filt.string(), tmpfile, filename);
2081 #if defined(WIN32) || MAC
2085 void PWMImpl::redraw(
Window* pw) {
2087 if (!pw->is_mapped()) {
2092 #if defined(WIN32) || MAC
2097 Coord xsize =
c->width();
2098 Coord ysize =
c->height();
2099 pw->glyph()->request(req);
2105 c->push_transform();
2107 pw->glyph()->draw(
c, a);
2119 iconify_via_hide_ =
false;
2122 ScreenItem::~ScreenItem() {
2127 pwm_impl->remove_paper(pi_);
2140 Glyph*
g = WidgetKit::instance()->label(
buf);
2147 void ScreenItem::reconfigured(
Scene* s) {
2152 s->
move(
i, l/Scl, b/Scl);
2158 if (
w_->is_mapped()) {
2159 impl->w_->canvas()->damage_all();
2164 void ScreenItem::request(
Requisition& req)
const {
2167 w =
w_->width_pw() / Scl;
2168 h =
w_->height_pw() / Scl;
2189 printf(
"ScreenItem::draw %d\n", i_);
2197 x + (
w_->width_pw()) / Scl,
2198 y + (
w_->height_pw()) / Scl,
2199 pwm_impl->window_outline_,
2207 Coord y = h.bottom();
2210 h.target(depth,
this, 0);
2211 if (h.event()->type() == Event::down) {
2216 switch (pwm_impl->tool(h.event()->pointer_button())) {
2218 h.target(depth,
this, 0,
new ScreenItemHandler(x, y,
this,
c->transformer()));
2222 pwm_impl->append_paper(
this);
2227 printf(
"ScreenItem::pick %d hit(%g,%g)\n", i_, x, y);
2228 print_alloc(
NULL,
"ScreenItem", a);
2236 PaperItem::PaperItem(ScreenItem* s) {
2242 PaperItem::~PaperItem() {
2250 Coord PaperItem::width() {
2251 return si_->w_->width_pw() / Scl;
2253 Coord PaperItem::fsize_;
2256 Requirement rx(scale_ * si_->w_->width_pw() / Scl);
2261 printf(
"PaperItem::request %d\n", screen_item()->
index());
2269 printf(
"PaperItem::allocate %d\n", screen_item()->
index());
2275 printf(
"PaperItem::draw %d\n", si_->i_);
2281 x + scale_ * (si_->w_->width_pw()) / Scl,
2282 y + scale_ * (si_->w_->height_pw()) / Scl,
2283 pwm_impl->window_outline_,
2285 si_->label_->draw(
c, a);
2292 pr->rect(x, y, x + scale_*(si_->w_->width_pw())/Scl, y + scale_*(si_->w_->height_pw())/Scl, blue,
NULL);
2293 pr->push_transform();
2297 si_->w_->glyph()->print(
pr, a);
2298 pr->pop_transform();
2303 Coord y = h.bottom();
2305 h.target(depth,
this, 0);
2306 if (h.event()->type() == Event::down) {
2311 switch (pwm_impl->tool(h.event()->pointer_button())) {
2327 pwm_impl->unshow_paper(
this);
2331 printf(
"PaperItem::pick %d hit(%g, %g)\n", si_->i_, x, y);
2338 PWMImpl::PWMImpl(ScreenScene* screen, PaperScene* paper,
Rect* prect) {
2348 printer_control_accept_ =
true;
2354 fc_retrieve_ =
NULL;
2362 PWMImpl::~PWMImpl() {
2383 MacPrinter* PWMImpl::mprinter() {
2385 mprinter_ =
new MacPrinter();
2392 void PWMImpl::all2front() {
2396 for (
i = 0;
i < screen_->count(); ++
i) {
2397 ScreenItem* si = (ScreenItem*) (screen_->component(
i));
2399 if (w && w != w->
leader() && w->is_mapped()) {
2406 void PWMImpl::map_all() {
2411 for (
i = 0;
i < screen_->count();
i++) {
2412 ScreenItem* si = (ScreenItem*) (screen_->component(
i));
2416 if (si->iconify_via_hide_ ==
true) {
2425 void PWMImpl::unmap_all() {
2430 for (
i = 0;
i < screen_->count();
i++) {
2431 ScreenItem* si = (ScreenItem*) (screen_->component(
i));
2435 if (screen_->showing(
i)) {
2437 si->iconify_via_hide_ =
true;
2439 si->iconify_via_hide_ =
false;
2451 for (
i = 0;
i < screen_->count();
i++) {
2452 ScreenItem* si = (ScreenItem*) screen_->component(
i);
2453 if (w == (
void*) si->window()) {
2460 void PWMImpl::relabel() {
2462 for (
i = 0;
i < screen_->count();
i++) {
2463 ((ScreenItem*) screen_->component(
i))->relabel(
i);
2470 void PWMImpl::append_paper(ScreenItem* si) {
2471 PaperItem* pi = si->paper_item();
2474 i = paper_index(pi);
2475 paper_->show(
i,
true);
2477 pi =
new PaperItem(si);
2480 i = paper_index(pi);
2481 Coord x = si->window()->left_pw() / Scl;
2482 Coord y = si->window()->bottom_pw() / Scl;
2483 x = (x < 0.) ? 0. : x;
2484 y = (y < 0.) ? 0. : y;
2485 x = (x > paper_->x2() * .8) ? paper_->x2() * .8 : x;
2486 y = (y > paper_->y2() * .8) ? paper_->y2() * .8 : y;
2487 paper_->move(
i, x, y);
2492 void PWMImpl::unshow_paper(PaperItem* pi) {
2493 paper_->show(paper_index(pi),
false);
2496 void PWMImpl::remove_paper(PaperItem* pi) {
2498 if (paper_ &&
i != -1) {
2503 GlyphIndex PWMImpl::paper_index(PaperItem* pi) {
2506 for (
i = 0;
i < paper_->count();
i++) {
2507 if (pi == (PaperItem*) paper_->component(
i)) {
2514 float PWMImpl::round(
float x) {
2515 return Math::round(x / round_factor_) * round_factor_;
2519 void PWMImpl::paperscale() {
2520 mprinter()->setup();
2522 w = mprinter()->width() / 72.;
2523 x = h = mprinter()->height() / 72.;
2527 x = x / canvasheight_;
2528 prect_->width(w / pr_scl);
2529 prect_->height(h / pr_scl);
2530 pview_->box_size(-.2, -.2, prect_->width() + .2, prect_->height() + .2);
2532 paper_->damage_all();
2537 void PWMImpl::landscape() {
2542 w = prect_->width();
2543 h = prect_->height();
2546 paper_->damage_all();
2547 landscape_ = !landscape_;
2550 void PWMImpl::landscape(
bool b) {
2551 if (landscape_ != b) {
2556 void PWMImpl::deco(
int i) {
2557 p_title_->set(TelltaleState::is_chosen,
false);
2558 p_deco_->set(TelltaleState::is_chosen,
false);
2560 p_title_->set(TelltaleState::is_chosen,
true);
2561 }
else if (
i == 2) {
2562 p_deco_->set(TelltaleState::is_chosen,
true);
2566 void PWMImpl::virt_screen() {
2571 VirtualWindow::makeVirtualWindow();
2575 static const char* DefaultPrintCmd() {
2577 Style* style = Session::instance()->style();
2579 if (style->find_attribute(
"printer_command", str)) {
2586 static char buf[200];
2587 static const char* print_cmd =
getenv(
"PRINT_CMD");
2588 if (print_cmd ==
NULL) {
2589 const char* printer_name =
getenv(
"PRINTER");
2591 if (printer_name ==
NULL) {
2602 void PWMImpl::printer_control() {
2607 Style* style =
new Style(Session::instance()->style());
2608 style->attribute(
"caption",
"Postscript Printer Command");
2614 if (
w_ &&
w_->is_mapped()) {
2615 b = b_printer_->post_for(
w_);
2628 b = b_printer_->post_at_aligned(x, y, ax, ay);
2631 printer_control_accept_ =
true;
2633 printer_control_accept_ =
false;
2637 void PWMImpl::quit_control() {
2650 void PWMImpl::snapshot_control() {
2651 if (file_control1()) {
2652 ivoc_snapshot_ = ivoc_snapshot;
2657 bool PWMImpl::file_control1() {
2662 Style* style =
new Style(Session::instance()->style());
2664 if (style->find_attribute(
"pwm_print_file_filter", str)) {
2665 style->attribute(
"filter",
"true");
2666 style->attribute(
"filterPattern", str);
2668 style->attribute(
"caption",
"Print Postscript to file");
2669 style->attribute(
"open",
"Print to file");
2670 fc_print_ = DialogKit::instance()->file_chooser(
"./", style);
2673 fc_print_->reread();
2675 while (fc_print_->post_for(
w_)) {
2683 void PWMImpl::file_control() {
2684 if (none_selected(
"No windows to save",
"Save Anyway")) {
2687 if (file_control1()) {
2688 use_printer =
false;
2695 void PWMImpl::snapshot(
const Event*
e) {
2698 obuf.open(fc_print_->selected()->string(),
IOS_OUT);
2702 pr->resize(0, 0, 1200, 1000);
2716 t.translate(w->left(), w->bottom());
2718 Glyph*
g = w->Window::glyph();
2722 Allotment ax(align_x * w->width(), w->width(), align_x);
2723 Allotment ay(align_y * w->width(), w->height(), align_y);
2729 Style* s = w->style();
2732 if (s && s->find_attribute(
"name", str)) {
2739 "BoundingBox: %g %g %g %g",
2742 w->left() + w->width() + 3,
2743 w->bottom() + w->height() + 20 + 3);
2745 sprintf(
buf,
"\\begin{picture}(%g, %g)", w->width() + 6, w->height() + 23);
2749 "BoundingBox: %g %g %g %g",
2752 w->left() + w->width(),
2753 w->bottom() + w->height());
2755 sprintf(
buf,
"\\begin{picture}(%g, %g)", w->width(), w->height());
2758 pr->push_transform();
2765 pr->pop_transform();
2770 pr->comment(
"End BoundingBox");
2775 if (rb && rb->
canvas()->window() ==
e->window()) {
2776 pr->comment(
"Begin Rubberband");
2778 t1.translate(
e->window()->left(),
e->window()->bottom());
2779 pr->push_transform();
2782 pr->pop_transform();
2783 pr->comment(
"End Rubberband");
2792 t.translate(
e->window()->left(),
e->window()->bottom());
2794 pr->comment(
"Begin cursor");
2795 pr->push_transform();
2799 pr->line_to(8, -14);
2800 pr->line_to(2, -12);
2801 pr->line_to(2, -20);
2802 pr->line_to(-2, -20);
2803 pr->line_to(-2, -12);
2804 pr->line_to(-8, -14);
2806 pr->fill(WidgetKit::instance()->foreground());
2808 pr->pop_transform();
2809 pr->comment(
"End cursor");
2813 void PWMImpl::idraw_control() {
2818 Style* style =
new Style(Session::instance()->style());
2820 if (style->find_attribute(
"pwm_idraw_file_filter", str)) {
2821 style->attribute(
"filter",
"true");
2822 style->attribute(
"filterPattern", str);
2824 style->attribute(
"caption",
"Idraw format to file");
2825 style->attribute(
"open",
"Write to file");
2826 fc_idraw_ = DialogKit::instance()->file_chooser(
"./", style);
2829 fc_idraw_->reread();
2831 if (none_selected(
"No windows to save",
"Save Anyway")) {
2834 while (fc_idraw_->post_for(
w_)) {
2836 idraw_write(fc_idraw_->selected()->string());
2842 void PWMImpl::idraw_write(
const char*
fname,
bool ses_style) {
2855 ScreenItem* pi = (ScreenItem*) screen()->component(
i);
2856 redraw(pi->window());
2860 if (!
p->showing(
i)) {
2863 PaperItem* pi = (PaperItem*)
p->component(
i);
2864 redraw(pi->screen_item()->window());
2872 void PWMImpl::ascii_control() {
2877 Style* style =
new Style(Session::instance()->style());
2879 if (style->find_attribute(
"pwm_ascii_file_filter", str)) {
2880 style->attribute(
"filter",
"true");
2881 style->attribute(
"filterPattern", str);
2883 style->attribute(
"caption",
"Ascii format to file");
2884 style->attribute(
"open",
"Write to file");
2885 fc_ascii_ = DialogKit::instance()->file_chooser(
"./", style);
2888 fc_ascii_->reread();
2890 if (none_selected(
"No windows to save",
"Save Anyway")) {
2893 while (fc_ascii_->post_for(
w_)) {
2895 ascii_write(fc_ascii_->selected()->string());
2901 void PWMImpl::ascii_write(
const char*
fname,
bool ses_style) {
2913 ScreenItem* pi = (ScreenItem*) screen()->component(
i);
2914 redraw(pi->window());
2918 if (!
p->showing(
i) && !ses_style) {
2921 PaperItem* pi = (PaperItem*)
p->component(
i);
2922 redraw(pi->screen_item()->window());
2931 void PWMImpl::save_selected_control() {
2934 void PWMImpl::save_all_control() {
2937 bool PWMImpl::none_selected(
const char*
title,
const char* accept)
const {
2940 for (
i = 0;
i < paper_->count(); ++
i) {
2941 if (paper_->showing(
i)) {
2953 void PWMImpl::save_control(
int mode) {
2963 if (none_selected(
"No windows to save",
"Save Anyway")) {
2967 Style* style =
new Style(Session::instance()->style());
2969 if (style->find_attribute(
"pwm_save_file_filter", str)) {
2970 style->attribute(
"filter",
"true");
2971 style->attribute(
"filterPattern", str);
2973 style->attribute(
"caption",
"Save windows on paper icon to file");
2974 style->attribute(
"open",
"Save to file");
2975 fc_save_ = DialogKit::instance()->file_chooser(
"./", style);
2980 while (fc_save_->post_for(
w_)) {
2982 save_session(mode, fc_save_->selected()->string());
2988 int PWMImpl::save_group(
Object* ho,
const char* filename) {
2991 ScreenItem** sivec =
NULL;
2993 if (screen_ && screen_->count()) {
2994 sivec =
new ScreenItem*[screen_->count()];
2995 for (
i = 0;
i < screen_->count();
i++) {
2996 si = (ScreenItem*) (screen_->component(
i));
2997 if (si->group_obj_ == ho) {
3003 cur_ses_name_ = filename;
3011 save_list(nwin, sivec,
o);
3020 void PWMImpl::save_session(
int mode,
const char* filename,
const char* head) {
3023 ScreenItem** sivec =
NULL;
3026 cur_ses_name_ = filename;
3031 if (!obuf.is_open()) {
3043 if (screen_ && screen_->count()) {
3044 sivec =
new ScreenItem*[screen_->count()];
3045 for (
i = 0;
i < screen_->count();
i++) {
3046 si = (ScreenItem*) (screen_->component(
i));
3055 "{pwman_place(%d,%d,%d)}\n",
3058 w->is_mapped() ? 1 : 0);
3066 if (paper_ && paper_->count()) {
3067 sivec =
new ScreenItem*[paper_->count()];
3068 for (
i = 0;
i < paper_->count();
i++) {
3069 if (paper_->showing(
i)) {
3070 si = ((PaperItem*) (paper_->component(
i)))->screen_item();
3085 save_list(nwin, sivec,
o);
3092 void PWMImpl::save_begin(ostream&
o) {
3095 HocPanel::save_all(
o);
3096 o <<
"objectvar ocbox_, ocbox_list_, scene_, scene_list_" << endl;
3097 o <<
"{ocbox_list_ = new List() scene_list_ = new List()}" << endl;
3100 void PWMImpl::save_list(
int nwin, ScreenItem** sivec, ostream&
o) {
3104 ses_group_first_ = 1;
3109 for (
i = 0;
i < nwin; ++
i) {
3110 if (sivec[
i]->window()) {
3111 ocg = (
OcGlyph*) sivec[
i]->window()->glyph();
3116 if (sivec[
i]->window()) {
3119 ses_group(sivec[
i],
o);
3121 if (pri < working && pri >
max) {
3127 o <<
"objectvar scene_vector_[1]\n{doNotify()}" << endl;
3130 void PWMImpl::ses_group(ScreenItem* si, ostream&
o) {
3133 if (si->group_obj_) {
3136 "{WindowMenu[0].ses_gid(%d, %d, %d, \"%s\")}\n",
3138 si->group_obj_->index,
3139 (screen()->showing(si->index()) ? 1 : 0),
3142 ses_group_first_ = 0;
3146 void PWMImpl::retrieve_control() {
3150 if (!fc_retrieve_) {
3151 Style* style =
new Style(Session::instance()->style());
3153 if (style->find_attribute(
"pwm_save_file_filter", str)) {
3154 style->attribute(
"filter",
"true");
3155 style->attribute(
"filterPattern", str);
3157 style->attribute(
"caption",
"Retrieve windows from file");
3158 style->attribute(
"open",
"Retrieve from file");
3159 fc_retrieve_ = DialogKit::instance()->file_chooser(
"./", style);
3160 fc_retrieve_->ref();
3162 fc_retrieve_->reread();
3164 while (fc_retrieve_->post_for(
w_)) {
3168 sprintf(
buf,
"{load_file(1, \"%s\")}\n", fc_retrieve_->selected()->string());
3176 class OcLabelGlyph:
public OcGlyph {
3179 virtual ~OcLabelGlyph();
3180 virtual void save(ostream&);
3187 OcLabelGlyph::OcLabelGlyph(
const char* label,
OcGlyph* og,
Glyph*
g) {
3195 OcLabelGlyph::~OcLabelGlyph() {
3196 og_->parents(
false);
3202 o <<
"{xpanel(\"\")" << endl;
3203 sprintf(
buf,
"xlabel(\"%s\")", label_.string());
3205 o <<
"xpanel()}" << endl;
3212 virtual ~TrayDismiss();
3216 class OcTray:
public OcBox {
3221 virtual void start_vbox();
3233 TrayDismiss::~TrayDismiss() {}
3235 if (
boolean_dialog(
"Dismiss or Dissolve into components?",
"Dissolve",
"Dismiss", win_)) {
3236 OcTray*
t = (OcTray*) win_->glyph();
3237 t->dissolve(win_->left(), win_->bottom());
3243 x_ =
new float[
cnt];
3244 y_ =
new float[
cnt];
3262 for (
i = 0;
i <
cnt; ++
i) {
3267 w =
g->make_window(l +
x_[
i] -
x_[0],
3275 void OcTray::start_vbox() {
3283 wk->begin_style(
"_tray_panel");
3285 pg_->append(w->
glyph());
3287 y_[
n] = w->bottom();
3288 v_->box_append(
new OcLabelGlyph(w->
name(),
3290 lk->vbox(wk->label(w->
name()),
3291 lk->fixed(w->
glyph(), w->width(), w->height()))));
3303 void PWMImpl::tray() {
3310 count = paper_->count();
3315 Coord minleft = -1000;
3317 OcTray* tray =
new OcTray(count);
3318 while ((
index = upper_left()) != -1) {
3319 PaperItem* pi = (PaperItem*) paper_->component(
index);
3326 minleft = l + w->width() / 2.;
3329 top = b + w->height();
3332 paper_->show(
index,
false);
3335 Window* w = tray->make_window();
3341 Coord minleft = 1e10;
3342 Coord maxbottom = -1e10;
3345 PaperItem* pi = (PaperItem*) paper_->component(
i);
3348 if (!paper_->showing(
i))
3350 if (w == pwm_impl->w_) {
3358 if (l < minleft - 50.) {
3362 }
else if (l < minleft + 50.) {
3363 if (maxbottom < b) {
3374 void PWMImpl::dissolve() {
3375 for (
long i = 0;
i < panelList_.count();
i++) {
3376 new HocWin(panelList_.item(
i));
3383 bool ivoc_snapshot(
const Event*
e) {
3386 if (
buf[0] ==
'p') {
3387 ivoc_snapshot_ =
NULL;
3396 #include <OS/table.h>
3398 #include <IV-X11/Xlib.h>
3399 #include <IV-X11/xdisplay.h>
3405 WindowTable* wt = Session::instance()->default_display()->rep()->wtable_;
3408 if (w->is_mapped()) {
3430 #if MAC && !defined(carbon)
3432 tmpfile =
new char[512];
3433 __temp_file_name(tmpfile, &spec);
3435 const char* tdir =
getenv(
"TEMP");
3439 #if defined(WIN32) && defined(__MWERKS__)
3440 char tname[L_tmpnam + 1];
3442 tmpfile =
new char[strlen(tdir) + 1 + strlen(tname) + 1];
3443 sprintf(tmpfile,
"%s/%s", tdir, tname);
3445 tmpfile =
new char[strlen(tdir) + 1 + 9 + 1];
3446 sprintf(tmpfile,
"%s/nrnXXXXXX", tdir);
3449 if ((fd = mkstemp(tmpfile)) == -1) {
void allot_y(const Allotment &)
Allotment & x_allotment()
Allotment & y_allotment()
void allot_x(const Allotment &)
static const Brush * default_brush()
virtual Glyph * glyph() const
virtual const char * name() const
static bool is_transient()
virtual void replace_dismiss_action(WinDismiss *)
void set(Canvas *, const Allocation &)
static FieldDialog * field_dialog_instance(const char *, Style *, Glyph *extra=NULL)
static std::ostream * ascii()
static MenuItem * menu_item(const char *)
static MenuItem * check_menu_item(const char *)
static void extend(Extension &, Coord)
virtual void attach(Observer *)
virtual void detach(Observer *)
static char * object_str(const char *symname, Object *=NULL)
virtual void save(std::ostream &)
virtual PrintableWindow * make_window(Coord left=-1, Coord bottom=-1, Coord width=-1, Coord height=-1)
static void help(const char *)
int run(int argc, const char **argv)
static ostream * save_stream
static ostream * idraw_stream
virtual Coord width_pw() const
virtual void reconfigured()
void xmove(int left, int top)
static OcGlyphContainer * intercept(OcGlyphContainer *)
static PrintableWindow * leader()
void xplace(int left, int top)
virtual Coord height_pw() const
virtual void map_notify()
virtual Coord bottom_pw() const
virtual Glyph * print_glyph()
virtual Coord left_pw() const
void xplace(int, int, bool map=true)
static PrintableWindowManager * current()
void append(PrintableWindow *)
void psfilter(const char *filename)
static PrintableWindowManager * current_
virtual ~PrintableWindowManager()
void reconfigured(PrintableWindow *)
virtual void disconnect(Observable *)
void remove(PrintableWindow *)
virtual void update(Observable *)
void require_x(const Requirement &)
const Requirement & x_requirement() const
void require_y(const Requirement &)
const Requirement & y_requirement() const
virtual void unref() const
static Rubberband * current()
virtual void snapshot(Printer *)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
void move(GlyphIndex, Coord x, Coord y)
bool showing(GlyphIndex) const
void location(GlyphIndex, Coord &x, Coord &y) const
virtual void remove(GlyphIndex)
static void save_all(std::ostream &)
virtual Coord mbs() const
const char * string() const
virtual void reconfigured()
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
double chkarg(int, double low, double high)
void hoc_execerror(const char *, const char *)
int hoc_is_object_arg(int narg)
char ** hoc_temp_charptr(void)
void hoc_obj_ref(Object *obj)
void hoc_obj_unref(Object *obj)
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
#define TRY_GUI_REDIRECT_DOUBLE(name, obj)
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
#define TRY_GUI_REDIRECT_OBJ(name, obj)
#define TRY_GUI_REDIRECT_ACTUAL_STR(name, obj)
#define TRY_GUI_REDIRECT_ACTUAL_OBJ(name, obj)
static void help(const char *)
Object ** hoc_objgetarg(int)
void pwmimpl_redraw(Window *w)
carbon
void ivoc_bring_to_top(Window *w)
void debugfile(const char *,...)
char * getenv(const char *s)
int hoc_copyfile(const char *src, const char *dest)
Object ** hoc_temp_objptr(Object *)
static double inside(void *)
int const size_t const size_t n
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
char * hoc_back2forward(char *s)
static void pr(N_Vector x)
const char * pwm_session_filename()
static double save(void *v)
static double ref(void *v)
static double resize(void *v)
static double working(void *v)
static void pwman_destruct(void *v)
static double pwman_deco(void *v)
static double pwman_deiconify(void *v)
static double pwman_close(void *v)
static double pwman_paper_place(void *v)
static double pwman_scale(void *v)
char * ivoc_get_temp_file()
static double pwman_leader(void *v)
static double pwman_map(void *v)
static double pwman_window_place(void *v)
static double pwman_save(void *v)
static Member_func members[]
double(* nrnpy_object_to_double_)(Object *)
static double pwman_hide(void *v)
static double pwman_is_mapped(void *v)
static double pwman_iconify(void *v)
static const char ** pwman_name(void *v)
static Member_ret_str_func s_memb[]
static Member_ret_obj_func retobj_members[]
static double pwman_landscape(void *v)
static void * pwman_cons(Object *)
static Object ** pwman_group(void *v)
static double pwman_manager(void *v)
static double pwman_count(void *v)
static double pwman_printfile(void *v)
static double pwman_snap(void *v)
bool nrn_spec_dialog_pos(Coord &x, Coord &y)
true if Style 'dialog_spec_position: on' and fills x,y with dialog_left_position and dialog_bottom_po...
bool ok_to_write(const String &, Window *w=NULL)
bool ok_to_read(const String &, Window *w=NULL)
bool boolean_dialog(const char *label, const char *accept, const char *cancel, Window *w=NULL, Coord x=400., Coord y=400.)
void continue_dialog(const char *label, Window *w=NULL, Coord x=400., Coord y=400.)
static const char * fname(const char *name)