1 #include <../../nrnconf.h>
38 #include <IV-Win/mprinter.h>
39 void iv_display_scale(
float);
47 #define IOS_OUT std::ios::out
49 #include <IV-look/kit.h>
50 #include <IV-look/dialogs.h>
51 #include <InterViews/layout.h>
52 #include <InterViews/hit.h>
53 #include <InterViews/display.h>
54 #include <InterViews/session.h>
55 #include <InterViews/color.h>
56 #include <InterViews/brush.h>
57 #include <InterViews/font.h>
58 #include <InterViews/event.h>
59 #include <InterViews/handler.h>
60 #include <InterViews/printer.h>
61 #include <InterViews/style.h>
62 #include <InterViews/background.h>
63 #include <InterViews/label.h>
65 #include <OS/string.h>
87 extern bool (*ivoc_snapshot_)(
const Event*);
88 static bool ivoc_snapshot(
const Event*);
91 #define PWM_help_ "help"
92 #define PWM_do_print_ "Print PWM"
93 #define PWM_ScreenItem_ "ScreenItem PWM"
94 #define PWM_PaperItem_ "PaperItem PWM"
95 #define PWM_landscape_ "LandPort Other"
96 #define PWM_virt_screen_ "VirtualScreen Other"
97 #define PWM_printer_control_ "SelectPrinter Other"
98 #define PWM_file_control_ "PostScript PrintToFile"
99 #define PWM_idraw_control_ "Idraw PrintToFile"
100 #define PWM_save_control2_ "SaveAll Session"
101 #define PWM_save_control1_ "SaveSelected Session"
102 #define PWM_retrieve_control_ "Retrieve Session"
103 #define PWM_tray_ "Tray Other"
104 #define PWM_ascii_ "Ascii PrintToFile"
105 #define PWM_quit_ "Quit Other"
107 #define pwm_impl PrintableWindowManager::current()->pwmi_
110 static void save_all(std::ostream&);
133 class ScreenScene:
public Scene {
140 class PaperScene:
public Scene {
146 class ScreenSceneHandler:
public Handler {
149 virtual bool event(
Event&);
157 class ScreenItem:
public Glyph {
159 friend class PaperItem;
171 PaperItem* paper_item()
const {
178 bool iconify_via_hide_;
187 class PaperItem:
public Glyph {
189 PaperItem(ScreenItem*);
196 void scale(
float s) {
202 ScreenItem* screen_item()
const {
209 friend class ScreenItem;
212 friend ScreenItem::~ScreenItem();
220 void append_paper(ScreenItem*);
221 void remove_paper(PaperItem*);
222 void unshow_paper(PaperItem*);
224 PaperScene* paper() {
227 ScreenScene* screen() {
233 void snapshot(
const Event*);
239 void do_print(
bool printer,
const char*
name);
240 void do_print_session(
bool also_controller =
true);
241 void do_print_session(
bool printer,
const char*
name);
242 void ps_file_print(
bool,
const char*,
bool,
bool);
243 void common_print(
Printer*,
bool,
bool);
249 MacPrinter* mprinter();
257 void landscape(
bool);
258 bool is_landscape() {
264 void printer_control();
267 void snapshot_control();
269 bool file_control1();
270 void idraw_control();
271 void idraw_write(
const char* fname,
bool ses_style =
false);
272 void ascii_control();
273 void ascii_write(
const char* fname,
bool ses_style =
false);
275 void save_selected_control();
276 void save_all_control();
277 void save_control(
int);
278 void save_session(
int,
const char*,
const char* head =
NULL);
279 int save_group(
Object*,
const char*);
280 void retrieve_control();
282 float round_factor() {
283 return round_factor_;
291 void all_window_bounding_box(
Extension&,
bool with_screen =
true,
bool also_controller =
true);
294 const Color* window_outline_;
295 CopyString cur_ses_name_;
299 PWMImpl(ScreenScene*, PaperScene*,
Rect*);
305 bool none_selected(
const char*,
const char*)
const;
306 void ses_group(ScreenItem* si, std::ostream& o);
307 int ses_group_first_;
308 void save_begin(std::ostream&);
309 void save_list(
int, ScreenItem**, std::ostream&);
313 ScreenScene* screen_;
319 bool printer_control_accept_;
331 const Event* snap_event_;
332 bool print_leader_flag_;
338 MacPrinter* mprinter_;
344 static void makeVirtualWindow();
346 virtual ~VirtualWindow();
352 static VirtualWindow* virt_win_;
356 VirtualWindow* VirtualWindow::virt_win_;
360 class VirtualWindowScale:
public Action {
362 VirtualWindowScale(
float);
363 virtual void execute();
370 class PaperItem_handler:
public Handler {
374 virtual ~PaperItem_handler();
375 virtual bool event(
Event&);
382 void (PaperItem_handler::*action_)(
Coord,
Coord);
388 class ScreenItemHandler:
public Handler {
391 virtual ~ScreenItemHandler();
392 virtual bool event(
Event&);
407 virtual ~PWMDismiss();
412 PWMDismiss::~PWMDismiss() {}
413 void PWMDismiss::execute() {
415 pwm_impl->unmap_all();
448 cnt =
p->screen()->count();
459 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
460 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
462 return double(si->window()->is_mapped());
473 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
474 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
487 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
488 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
490 si->window()->hide();
501 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
502 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
505 *ps = (
char*) si->window()->name();
507 return (
const char**) ps;
517 int i = (int)
chkarg(1, 0,
p->screen()->count() - 1);
518 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
519 if (
p->window() == si->window()) {
522 si->window()->dismiss();
528 static void pwman_iconify1(
void*
v) {
543 if (!nrn_is_gui_thread()) {
544 nrn_gui_exec(pwman_iconify1, pw);
570 int i,
cnt =
p->screen()->count();
571 for (
i = 0;
i <
cnt; ++
i) {
572 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
573 if (si->window() == pw) {
588 int i,
cnt =
p->screen()->count();
589 for (
i = 0;
i <
cnt; ++
i) {
590 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
591 if (si->window() == pw) {
628 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
629 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
648 p->snapshot_control();
658 static double scale_;
659 static void pwman_scale1(
void*) {
662 iv_display_scale(scale_);
670 double scale =
chkarg(1, .01, 100);
675 if (!nrn_is_gui_thread()) {
677 nrn_gui_exec(pwman_scale1, (
void*) ((intptr_t) 1));
681 iv_display_scale(scale);
694 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
695 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
712 i = int(
chkarg(1, 0,
p->screen()->count() - 1));
713 ScreenItem* si = (ScreenItem*)
p->screen()->component(
i);
715 PaperItem*
pi = si->paper_item();
717 if ((
int(
chkarg(2, 0, 1))) == 0) {
722 p->paper()->move(
p->paper_index(
pi), *
getarg(2) / pr_scl, *
getarg(3) / pr_scl);
737 bool ses_style =
false;
739 ses_style = int(
chkarg(3, 0, 1)) ? true :
false;
742 switch ((
int)
chkarg(2, 0, 2)) {
744 p->ps_file_print(
false, fname,
p->is_landscape(), ses_style);
747 p->idraw_write(fname, ses_style);
750 p->ascii_write(fname, ses_style);
763 p->landscape(
int(
chkarg(1, 0, 1)) ?
true :
false);
811 PaperItem_handler::PaperItem_handler(
int type,
820 index_ = pwm_impl->paper_index(
pi);
822 pwm_impl->paper()->location(index_, left, bottom);
826 action_ = &PaperItem_handler::resize_action;
829 t_.translate(left - x, bottom - y);
830 action_ = &PaperItem_handler::move_action;
835 PaperItem_handler::~PaperItem_handler() {
840 bool PaperItem_handler::event(
Event& e) {
846 e.window()->grab_pointer();
848 (this->*action_)(e.pointer_x(), e.pointer_y());
853 e.window()->ungrab_pointer();
857 (this->*action_)(e.pointer_x(), e.pointer_y());
863 void PaperItem_handler::move_action(
Coord x,
Coord y) {
866 t_.transform(x, y, xs, ys);
867 xs = pwm_impl->round(xs);
868 ys = pwm_impl->round(ys);
869 pwm_impl->paper()->move(index_, xs, ys);
872 void PaperItem_handler::resize_action(
Coord x,
Coord y) {
874 pwm_impl->paper()->allotment(index_,
Dimension_X, ax);
876 pwm_impl->paper()->allotment(index_,
Dimension_Y, ay);
878 t_.transform(x, y, xs, ys);
881 scl = pi_->scale() * scl;
882 scl = (scl > .1) ? scl : .1;
884 w1 = pwm_impl->round(scl * pi_->width());
885 w1 = std::max(
w1, pwm_impl->round_factor());
886 scl =
w1 / pi_->width();
888 pwm_impl->paper()->modified(index_);
891 VirtualWindow::VirtualWindow(
View*
v,
Glyph* g)
897 style(
new Style(Session::instance()->style()));
898 style()->attribute(
"nrn_virtual_screen",
"0");
901 MenuItem* mi = append_menubar(
"Scale");
903 Menu* m = wk.pulldown();
907 mi->action(
new VirtualWindowScale(1.0));
911 mi->action(
new VirtualWindowScale(
fil));
915 mi->action(
new VirtualWindowScale(1.2));
919 mi->action(
new VirtualWindowScale(1.5));
923 mi->action(
new VirtualWindowScale(2.0));
928 VirtualWindow::~VirtualWindow() {
933 extern void ivoc_bring_to_top(
Window*);
936 void VirtualWindow::makeVirtualWindow() {
939 virt_win_ =
new VirtualWindow(
v,
940 LayoutKit::instance()->variable_span(
941 new Background(
v, WidgetKit::instance()->background())));
945 ivoc_bring_to_top(virt_win_);
949 void virtual_window_top() {
950 VirtualWindow::makeVirtualWindow();
953 void VirtualWindow::view() {
955 View*
v = virt_win_->view_;
957 v->size(
s->x1(),
s->y1(),
s->x2(),
s->y2());
958 virt_win_->canvas()->damage_all();
963 VirtualWindowScale::VirtualWindowScale(
float scale) {
967 void VirtualWindowScale::execute() {
968 float scale = scale_;
969 if (scale_ >=
fil / 10.) {
971 pwm_impl->all_window_bounding_box(e);
974 iv_display_scale(scale);
987 pwm_impl->screen()->location(si_->index(), left, bottom);
989 t_.translate(left - x, bottom - y);
992 ScreenItemHandler::~ScreenItemHandler() {
997 bool ScreenItemHandler::event(
Event& e) {
1003 e.window()->grab_pointer();
1005 move_action(
false, e.pointer_x(), e.pointer_y());
1010 e.window()->ungrab_pointer();
1012 move_action(
true, e.pointer_x(), e.pointer_y());
1015 move_action(
false, e.pointer_x(), e.pointer_y());
1021 void ScreenItemHandler::move_action(
bool doit,
Coord x,
Coord y) {
1024 t_.transform(x, y, xs, ys);
1026 if (si_->window()) {
1027 si_->window()->move(xs * Scl, ys * Scl);
1030 pwm_impl->screen()->move(si_->index(), xs, ys);
1035 :
Scene(x1, y1, x2, y2, g) {}
1038 if (pwm_impl->tool(h.event()->pointer_button()) == Event::middle) {
1039 if (h.event()->type() == Event::down) {
1040 h.target(depth,
this, 0,
new ScreenSceneHandler(h.left() * Scl, h.bottom() * Scl));
1047 Coord ScreenScene::mbs()
const {
1052 :
Scene(x1, y1, x2, y2, g) {}
1054 Coord PaperScene::mbs()
const {
1058 ScreenSceneHandler::ScreenSceneHandler(
Coord x,
Coord y)
1063 bool ScreenSceneHandler::event(
Event&) {
1064 pwm_impl->view_screen(
x_,
y_);
1070 declareActionCallback(PWMImpl)
1071 implementActionCallback(PWMImpl)
1081 LayoutKit& layout = *LayoutKit::instance();
1082 WidgetKit& kit = *WidgetKit::instance();
1083 PaperItem::fsize_ = kit.font()->size();
1085 Display* d = Session::instance()->default_display();
1089 Style*
q = Session::instance()->style();
1090 if (!
q->find_attribute(
"pwm_canvas_height", canvasheight)) {
1091 canvasheight = 100.;
1093 const Color* outline_color;
1095 Display* dis = Session::instance()->default_display();
1096 if (!
q->find_attribute(
"pwm_screen_outline_color",
c) ||
1100 Scl = d->height() / canvasheight;
1101 Rect* sr =
new Rect(0, 0, d->width() / Scl, d->height() / Scl, outline_color);
1103 ScreenScene* screen =
new ScreenScene(-5, -2, d->width() / Scl + 5, d->height() / Scl + 2, sr);
1106 if (!
q->find_attribute(
"pwm_paper_height", pageheight)) {
1109 if (!
q->find_attribute(
"pwm_paper_width", pagewidth)) {
1113 if (pageheight > pagewidth)
1114 pr_scl = pageheight / canvasheight;
1116 pr_scl = pagewidth / canvasheight;
1119 if (d->width() > d->height())
1120 wp1 = d->width() / Scl;
1124 Coord wp = pagewidth / pr_scl;
1125 Coord hp = pageheight / pr_scl;
1126 Coord max = std::max(wp, hp);
1127 Rect* r =
new Rect(0, 0, wp, hp, outline_color);
1130 PaperScene* paper =
new PaperScene(-5, -2, std::max(max, d->width() / Scl), max + 2, r);
1133 pwmi_ =
new PWMImpl(screen, paper, r);
1134 if (!
q->find_attribute(
"pwm_window_outline_color",
c) ||
1138 outline_color->ref();
1139 pwmi_->window_outline_ = outline_color;
1140 pwmi_->screen_rect_ = sr;
1141 if (!
q->find_attribute(
"pwm_paper_resolution",
pwmi_->round_factor_)) {
1142 pwmi_->round_factor_ = .25;
1144 pwmi_->canvasheight_ = canvasheight;
1145 pwmi_->round_factor_ /= pr_scl;
1147 if (
q->find_attribute(
"pwm_pixel_resolution", ltmp)) {
1153 pwmi_->left_->ref();
1155 Menu *mbar, *mprint, *mses, *mother;
1157 if (
q->value_is_on(
"pwm_help")) {
1158 vb->append(kit.push_button(
"Help",
1159 new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::help)
1163 hb->append(mbar = kit.menubar());
1167 mi = kit.menubar_item(
"Print");
1168 mbar->append_item(mi);
1169 mprint = kit.pulldown();
1172 mi = kit.menubar_item(
"Session");
1173 mbar->append_item(mi);
1174 mses = kit.pulldown();
1178 mi = kit.menubar_item(
"Other");
1179 mbar->append_item(mi);
1180 mother = kit.pulldown();
1185 mi = kit.radio_menu_item(ttg,
"select");
1186 mbar->append_item(mi);
1187 mi->state()->set(TelltaleState::is_chosen,
true);
1188 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::select_tool));
1190 mi = kit.radio_menu_item(ttg,
"move");
1191 mbar->append_item(mi);
1192 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::move_tool));
1194 mi = kit.radio_menu_item(ttg,
"resize");
1195 mbar->append_item(mi);
1196 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::resize_tool));
1199 mprint->append_item(mi);
1200 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::do_print0));
1203 mprint->append_item(mi);
1204 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::file_control));
1208 mprint->append_item(mi);
1209 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::snapshot_control));
1213 mprint->append_item(mi);
1214 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::idraw_control));
1217 mprint->append_item(mi);
1218 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::ascii_control));
1221 mprint->append_item(mi);
1222 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::printer_control));
1225 mprint->append_item(mi);
1226 pwmi_->p_title_ = mi->state();
1230 mprint->append_item(mi);
1231 pwmi_->p_deco_ = mi->state();
1234 pwmi_->p_deco_->set(TelltaleState::is_chosen,
true);
1236 pwmi_->p_deco_->set(TelltaleState::is_chosen,
false);
1241 mses->append_item(mi);
1242 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::retrieve_control));
1245 mses->append_item(mi);
1246 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::save_selected_control));
1249 mses->append_item(mi);
1250 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::save_all_control));
1253 mses->append_item(mi);
1254 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::virt_screen));
1257 mprint->append_item(mi);
1258 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::landscape));
1261 mses->append_item(mi);
1262 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::tray));
1266 mother->append_item(mi);
1267 mi->action(
new ActionCallback(PWMImpl)(
pwmi_, &PWMImpl::quit_control));
1273 pwmi_->w_->replace_dismiss_action(
NULL);
1276 pwmi_->w_->xplace(-800, 0);
1278 pwmi_->w_->xplace(0, 0);
1286 void PWMImpl::select_tool() {
1287 tool_ = Event::right;
1289 void PWMImpl::move_tool() {
1290 tool_ = Event::left;
1292 void PWMImpl::resize_tool() {
1293 tool_ = Event::middle;
1297 if (b == Event::left) {
1305 LayoutKit& layout = *LayoutKit::instance();
1309 layout.hbox(layout.variable_span(
new View(screen_)),
1310 layout.variable_span(pview_ =
new View(paper_))),
1319 Style*
s =
new Style(Session::instance()->style());
1320 s->attribute(
"name",
"Print & File Window Manager");
1341 bool m = (
ifarg(3) && int(*
getarg(3)) == 0) ?
false :
true;
1363 return pwm_impl->cur_ses_name_.string();
1375 }
else if (
ifarg(2)) {
1376 pwm_impl->do_print_session((
int)
chkarg(1, 0, 1),
gargstr(2));
1378 bool b =
ifarg(1) ? (
chkarg(1, 0, 1) == 1.) :
true;
1379 pwm_impl->do_print_session(b);
1390 if (!w->is_mapped()) {
1392 if (pw && pw->is_mapped() && pw != w) {
1394 w->transient_for(pw);
1396 w->group_leader(pw);
1403 w->
xmove(left, top);
1425 pwmi_->screen_->append(
new ScreenItem(w));
1428 if (pw && pw->is_mapped() && pw != w) {
1430 w->transient_for(pw);
1433 w->group_leader(pw);
1442 PWMImpl* impl =
pwmi_;
1443 if (w == impl->window()) {
1448 Scene*
s = impl->screen_;
1457 #define PIXROUND(x, y, r) x = int((y + r / 2) / r) * r
1474 PIXROUND(x, x1, pixres);
1475 PIXROUND(y, y1, pixres);
1476 if (x != x1 || y != y1) {
1487 w = canvas()->pwidth();
1488 h = canvas()->pheight();
1489 PIXROUND(x, w, pixres);
1490 PIXROUND(y, h, pixres);
1495 if (x != w || y != h) {
1496 canvas()->psize(x, y);
1503 PWMImpl* impl =
pwmi_;
1512 impl->screen_->move(
i, l / Scl, b / Scl);
1513 impl->screen_->change(
i);
1514 impl->screen_->show(
i, w->is_mapped());
1515 ScreenItem* si = (ScreenItem*) impl->screen_->component(
i);
1516 PaperItem*
pi = si->paper_item();
1518 impl->paper_->change(impl->paper_index(
pi));
1521 impl->all_window_bounding_box(e);
1522 impl->screen_->new_size(e.
left() / Scl - 5,
1524 e.
right() / Scl + 5,
1526 VirtualWindow::view();
1529 impl->screen_->location(
i, x, y);
1530 printf(
"reconfigured %d %d %g %g\n",
i, impl->screen_->showing(
i), x, y);
1538 void PWMImpl::help() {
1546 void PWMImpl::all_window_bounding_box(
Extension& e,
bool with_screen,
bool also_leader) {
1549 Display* d = Session::instance()->default_display();
1551 e.
set_xy(
NULL, 0., 0., d->width(), d->height());
1557 for (
i = 0;
i < screen_->count();
i++) {
1558 w = ((ScreenItem*) (screen_->component(
i)))->window();
1559 if (w && w->is_mapped() && w != wl) {
1561 NULL, w->left(), w->bottom(), w->left() + w->width(), w->bottom() + w->height());
1566 if (w && w->is_mapped() && (also_leader ||
empty)) {
1567 e.
merge_xy(
NULL, w->left(), w->bottom(), w->left() + w->width(), w->bottom() + w->height());
1568 print_leader_flag_ =
true;
1570 print_leader_flag_ =
false;
1572 screen_rect_->width(d->width() / Scl);
1573 screen_rect_->height(d->height() / Scl);
1577 void PWMImpl::view_screen(
Coord x,
Coord y) {
1582 Display* d = Session::instance()->default_display();
1583 xp = d->to_pixels(-x) + d->pwidth() / 2;
1584 yp = d->to_pixels(y) - d->pheight() / 2;
1585 for (
i = 0;
i < screen_->count();
i++) {
1586 ScreenItem* si = (ScreenItem*) screen_->component(
i);
1589 if (w != window()) {
1596 void PWMImpl::do_print0() {
1602 if (none_selected(
"No windows to print",
"Print Anyway")) {
1608 if (!printer_control_accept_) {
1614 CopyString
name(b_printer_->text()->string());
1615 do_print(use_printer,
name.string());
1621 do_print(use_printer, fc_print_->selected()->string());
1625 void PWMImpl::do_print(
bool use_printer,
const char*
name) {
1627 if (use_printer && strcmp(
name,
"Windows") == 0) {
1632 ps_file_print(use_printer,
name, landscape_,
false);
1635 void PWMImpl::do_print_session(
bool also_leader) {
1640 bool deco = p_deco_->test(TelltaleState::is_chosen);
1641 p_deco_->set(TelltaleState::is_chosen,
true);
1647 if (!mprinter()->
get()) {
1651 all_window_bounding_box(e,
false, also_leader);
1653 float s1 = (mprinter()->width() - 72.) / (e.
right() - e.
left() + 6.);
1654 float s2 = (mprinter()->height() - 72.) / (e.
top() - e.
bottom() + 23.);
1655 float sfac = (s1 < s2) ? s1 : s2;
1656 float xoff = mprinter()->width() / 2 / sfac - (e.
right() + e.
left() + 6.) / 2.;
1657 float yoff = mprinter()->height() / 2 / sfac - (e.
top() + e.
bottom() + 23.) / 2.;
1659 t.translate(xoff, yoff);
1660 mprinter()->prolog(sfac);
1661 mprinter()->push_transform();
1662 mprinter()->transform(
t);
1663 common_print(mprinter(),
false,
true);
1664 mprinter()->pop_transform();
1665 mprinter()->epilog();
1672 if (!printer_control_accept_) {
1679 CopyString
name(b_printer_->text()->string());
1680 ps_file_print(
true,
name.string(),
true,
true);
1685 p_deco_->set(TelltaleState::is_chosen, deco);
1687 print_leader_flag_ =
true;
1690 void PWMImpl::do_print_session(
bool use_printer,
const char*
name) {
1691 print_leader_flag_ =
true;
1692 ps_file_print(use_printer,
name,
true,
true);
1695 void PWMImpl::ps_file_print(
bool use_printer,
const char*
name,
bool land_style,
bool ses_style) {
1696 Style*
s = Session::instance()->style();
1697 static char* tmpfile = (
char*) 0;
1705 obuf.open(tmpfile, IOS_OUT);
1706 std::ostream o(&obuf);
1712 bool deco = p_deco_->test(TelltaleState::is_chosen);
1713 p_deco_->set(TelltaleState::is_chosen,
true);
1715 Style*
s = Session::instance()->style();
1718 if (!
s->find_attribute(
"pwm_paper_height", pageheight)) {
1721 if (!
s->find_attribute(
"pwm_paper_width", pagewidth)) {
1725 all_window_bounding_box(e,
false,
true);
1727 float s1 = (pagewidth * 72 - 72.) / (e.
right() - e.
left() + 6.);
1728 float s2 = (pageheight * 72 - 72.) / (e.
top() - e.
bottom() + 23.);
1729 float sfac = (s1 < s2) ? s1 : s2;
1730 float xoff = pagewidth * 72 / 2 / sfac - (e.
right() + e.
left() + 6.) / 2.;
1731 float yoff = pageheight * 72 / 2 / sfac - (e.
top() + e.
bottom() + 23.) / 2.;
1733 t.translate(xoff, yoff);
1734 t.scale(sfac, sfac);
1735 pr->push_transform();
1737 common_print(
pr,
false, ses_style);
1738 pr->pop_transform();
1740 p_deco_->set(TelltaleState::is_chosen, deco);
1743 common_print(
pr, land_style, ses_style);
1749 s->find_attribute(
"pwm_postscript_filter", filt);
1750 auto const buf_size = 200 + strlen(
name) + strlen(filt.string()) + 2 * strlen(tmpfile);
1751 char*
buf =
new char[buf_size];
1755 std::snprintf(
buf, buf_size,
"%s %s %s", filt.string(), tmpfile,
name);
1758 buf, buf_size,
"%s < %s | %s ; rm %s", filt.string(), tmpfile,
name, tmpfile);
1762 std::snprintf(
buf, buf_size,
"%s %s > %s", filt.string(), tmpfile,
name);
1764 std::snprintf(
buf, buf_size,
"%s < %s > %s ; rm %s", filt.string(), tmpfile,
name, tmpfile);
1777 extern bool hoc_copyfile(
const char*,
const char*);
1781 void PWMImpl::mac_do_print() {
1783 if (!mprinter()->
get()) {
1787 mprinter()->prolog();
1788 common_print(mprinter(), landscape_,
false);
1789 mprinter()->epilog();
1793 void PWMImpl::common_print(
Printer*
pr,
bool land_style,
bool ses_style) {
1800 Style*
s = Session::instance()->style();
1803 if (!
s->find_attribute(
"pwm_paper_height", pageheight)) {
1806 if (!
s->find_attribute(
"pwm_paper_width", pagewidth)) {
1809 pr->resize(0, 0, pagewidth * 72, pageheight * 72);
1815 t.translate(20,
pr->height() - 70);
1817 t.translate(0,
pr->height());
1823 if (!
p->showing(
i)) {
1831 ScreenItem*
pi = (ScreenItem*)
p->component(
i);
1833 if (!pw->is_mapped()) {
1839 float sfac = .9 * pagewidth * 72 / pw->display()->height();
1844 t.scale(sfac, sfac);
1848 PaperItem*
pi = (PaperItem*)
p->component(
i);
1849 pw =
pi->screen_item()->window();
1850 float sfac = pr_scl * 72 *
pi->scale() / Scl;
1851 p->location(
i, x, y);
1852 t.scale(sfac, sfac);
1853 t.translate(72 * x * pr_scl, 72 * y * pr_scl);
1855 x1 = 72 * (x) *pr_scl;
1868 pr->push_transform();
1870 pr->push_clipping();
1876 if (p_deco_->test(TelltaleState::is_chosen) ==
true) {
1877 print_deco(
pr, a, pw->
name());
1880 pr->pop_transform();
1887 if ((ses_style || p_title_->test(TelltaleState::is_chosen) ==
true)
1889 && p_deco_->test(TelltaleState::is_chosen) ==
false
1893 Label label(pw->
name(), wk.font(), wk.foreground());
1913 Coord l, b, r,
t, w, h,
s, x, y, dx, xx;
1916 static const Color* ctitle;
1917 static const Color* ctitlebar;
1918 static const Color* coutline;
1919 static const Color* bright;
1920 static const Color* dark;
1921 static const Font* ftitle;
1922 static const Brush* br;
1923 static int first = 1;
1932 bright =
new Color(.9, .9, .9, 1.);
1934 dark =
new Color(.1, .1, .1, 1.);
1936 ctitle =
new Color(0., 0., 0., 1.);
1938 ctitlebar =
new Color(.8, .8, .8, 1.);
1940 coutline =
new Color(.7, .7, .7, 1.);
1954 pr->fill_rect(l,
t, r,
t + h, ctitlebar);
1963 Coord xo = (l + r) / 2 - x / 2;
1964 xo = (xo < h) ? h : xo;
1968 pr->push_clipping();
1969 pr->clip_rect(l + h,
t, r,
t + h);
1974 pr->fill_rect(l, b - w, l - w,
t + h + w, coutline);
1975 pr->fill_rect(r, b - w, r + w,
t + h + w, coutline);
1976 pr->fill_rect(l, b, r, b - w, coutline);
1977 pr->fill_rect(l,
t + h, r,
t + h + w, coutline);
1978 pr->rect(l - w, b - w, r + w,
t + h + w, dark, br);
1981 x = (l + (l + h -
s)) / 2;
1982 y = (
t +
s +
t + h) / 2;
1984 pr->rect(x - dx, y - dx, x + dx, y + dx, bright, br);
1986 pr->line(x - dx, y - dx, x + dx, y + dx, bright, br);
1987 pr->line(x - dx, y + dx, x + dx, y - dx, bright, br);
1992 static char* tmpfile = (
char*) 0;
1996 Style*
s = Session::instance()->style();
1999 if (
s->find_attribute(
"pwm_postscript_filter", filt)) {
2001 buf,
"cat %s > %s; %s < %s > %s", filename, tmpfile, filt.string(), tmpfile, filename);
2008 void pwmimpl_redraw(
Window* pw);
2011 void PWMImpl::redraw(
Window* pw) {
2013 if (!pw->is_mapped()) {
2023 Coord xsize =
c->width();
2024 Coord ysize =
c->height();
2025 pw->glyph()->request(req);
2031 c->push_transform();
2033 pw->glyph()->draw(
c, a);
2045 iconify_via_hide_ =
false;
2048 ScreenItem::~ScreenItem() {
2053 pwm_impl->remove_paper(pi_);
2066 Glyph* g = WidgetKit::instance()->label(
buf);
2073 void ScreenItem::reconfigured(
Scene*
s) {
2078 s->move(
i, l/Scl, b/Scl);
2080 s->location(
i, x, y);
2082 printf(
"reconfigured %d %d %g %g\n",
i,
s->showing(
i), x, y);
2084 if (
w_->is_mapped()) {
2085 impl->w_->canvas()->damage_all();
2090 void ScreenItem::request(
Requisition& req)
const {
2093 w =
w_->width_pw() / Scl;
2094 h =
w_->height_pw() / Scl;
2115 printf(
"ScreenItem::draw %d\n", i_);
2123 x + (
w_->width_pw()) / Scl,
2124 y + (
w_->height_pw()) / Scl,
2125 pwm_impl->window_outline_,
2133 Coord y = h.bottom();
2136 h.target(depth,
this, 0);
2137 if (h.event()->type() == Event::down) {
2142 switch (pwm_impl->tool(h.event()->pointer_button())) {
2144 h.target(depth,
this, 0,
new ScreenItemHandler(x, y,
this,
c->transformer()));
2148 pwm_impl->append_paper(
this);
2153 printf(
"ScreenItem::pick %d hit(%g,%g)\n", i_, x, y);
2154 print_alloc(
NULL,
"ScreenItem", a);
2162 PaperItem::PaperItem(ScreenItem*
s) {
2168 PaperItem::~PaperItem() {
2176 Coord PaperItem::width() {
2177 return si_->w_->width_pw() / Scl;
2179 Coord PaperItem::fsize_;
2182 Requirement rx(scale_ * si_->w_->width_pw() / Scl);
2183 Requirement ry(std::max(fsize_, scale_ * si_->w_->height_pw() / Scl));
2187 printf(
"PaperItem::request %d\n", screen_item()->
index());
2195 printf(
"PaperItem::allocate %d\n", screen_item()->
index());
2201 printf(
"PaperItem::draw %d\n", si_->i_);
2207 x + scale_ * (si_->w_->width_pw()) / Scl,
2208 y + scale_ * (si_->w_->height_pw()) / Scl,
2209 pwm_impl->window_outline_,
2211 si_->label_->draw(
c, a);
2218 pr->rect(x, y, x + scale_*(si_->w_->width_pw())/Scl, y + scale_*(si_->w_->height_pw())/Scl, blue,
NULL);
2219 pr->push_transform();
2223 si_->w_->glyph()->print(
pr, a);
2224 pr->pop_transform();
2229 Coord y = h.bottom();
2231 h.target(depth,
this, 0);
2232 if (h.event()->type() == Event::down) {
2237 switch (pwm_impl->tool(h.event()->pointer_button())) {
2253 pwm_impl->unshow_paper(
this);
2257 printf(
"PaperItem::pick %d hit(%g, %g)\n", si_->i_, x, y);
2264 PWMImpl::PWMImpl(ScreenScene* screen, PaperScene* paper,
Rect* prect) {
2274 printer_control_accept_ =
true;
2280 fc_retrieve_ =
NULL;
2285 tool_ = Event::right;
2288 PWMImpl::~PWMImpl() {
2309 MacPrinter* PWMImpl::mprinter() {
2311 mprinter_ =
new MacPrinter();
2317 void PWMImpl::map_all() {
2322 for (
i = 0;
i < screen_->count();
i++) {
2323 ScreenItem* si = (ScreenItem*) (screen_->component(
i));
2327 if (si->iconify_via_hide_ ==
true) {
2336 void PWMImpl::unmap_all() {
2341 for (
i = 0;
i < screen_->count();
i++) {
2342 ScreenItem* si = (ScreenItem*) (screen_->component(
i));
2346 if (screen_->showing(
i)) {
2348 si->iconify_via_hide_ =
true;
2350 si->iconify_via_hide_ =
false;
2362 for (
i = 0;
i < screen_->count();
i++) {
2363 ScreenItem* si = (ScreenItem*) screen_->component(
i);
2364 if (w == (
void*) si->window()) {
2371 void PWMImpl::relabel() {
2373 for (
i = 0;
i < screen_->count();
i++) {
2374 ((ScreenItem*) screen_->component(
i))->relabel(
i);
2381 void PWMImpl::append_paper(ScreenItem* si) {
2382 PaperItem*
pi = si->paper_item();
2385 i = paper_index(
pi);
2386 paper_->show(
i,
true);
2388 pi =
new PaperItem(si);
2391 i = paper_index(
pi);
2392 Coord x = si->window()->left_pw() / Scl;
2393 Coord y = si->window()->bottom_pw() / Scl;
2394 x = (x < 0.) ? 0. : x;
2395 y = (y < 0.) ? 0. : y;
2396 x = (x > paper_->x2() * .8) ? paper_->x2() * .8 : x;
2397 y = (y > paper_->y2() * .8) ? paper_->y2() * .8 : y;
2398 paper_->move(
i, x, y);
2403 void PWMImpl::unshow_paper(PaperItem*
pi) {
2404 paper_->show(paper_index(
pi),
false);
2407 void PWMImpl::remove_paper(PaperItem*
pi) {
2409 if (paper_ &&
i != -1) {
2417 for (
i = 0;
i < paper_->count();
i++) {
2418 if (
pi == (PaperItem*) paper_->component(
i)) {
2425 float PWMImpl::round(
float x) {
2426 return std::round(x / round_factor_) * round_factor_;
2430 void PWMImpl::paperscale() {
2431 mprinter()->setup();
2433 w = mprinter()->width() / 72.;
2434 x = h = mprinter()->height() / 72.;
2438 x = x / canvasheight_;
2439 prect_->width(w / pr_scl);
2440 prect_->height(h / pr_scl);
2441 pview_->box_size(-.2, -.2, prect_->width() + .2, prect_->height() + .2);
2443 paper_->damage_all();
2448 void PWMImpl::landscape() {
2453 w = prect_->width();
2454 h = prect_->height();
2457 paper_->damage_all();
2458 landscape_ = !landscape_;
2461 void PWMImpl::landscape(
bool b) {
2462 if (landscape_ != b) {
2467 void PWMImpl::deco(
int i) {
2468 p_title_->set(TelltaleState::is_chosen,
false);
2469 p_deco_->set(TelltaleState::is_chosen,
false);
2471 p_title_->set(TelltaleState::is_chosen,
true);
2472 }
else if (
i == 2) {
2473 p_deco_->set(TelltaleState::is_chosen,
true);
2477 void PWMImpl::virt_screen() {
2482 VirtualWindow::makeVirtualWindow();
2486 static const char* DefaultPrintCmd() {
2488 Style* style = Session::instance()->style();
2490 if (style->find_attribute(
"printer_command", str)) {
2495 return str.string();
2497 static char buf[200];
2498 static const char* print_cmd = getenv(
"PRINT_CMD");
2499 if (print_cmd ==
NULL) {
2500 const char* printer_name = getenv(
"PRINTER");
2502 if (printer_name ==
NULL) {
2513 void PWMImpl::printer_control() {
2518 Style* style =
new Style(Session::instance()->style());
2519 style->attribute(
"caption",
"Postscript Printer Command");
2525 if (
w_ &&
w_->is_mapped()) {
2526 b = b_printer_->post_for(
w_);
2539 b = b_printer_->post_at_aligned(x, y, ax, ay);
2542 printer_control_accept_ =
true;
2544 printer_control_accept_ =
false;
2548 void PWMImpl::quit_control() {
2561 void PWMImpl::snapshot_control() {
2562 if (file_control1()) {
2563 ivoc_snapshot_ = ivoc_snapshot;
2568 bool PWMImpl::file_control1() {
2573 Style* style =
new Style(Session::instance()->style());
2575 if (style->find_attribute(
"pwm_print_file_filter", str)) {
2576 style->attribute(
"filter",
"true");
2577 style->attribute(
"filterPattern", str);
2579 style->attribute(
"caption",
"Print Postscript to file");
2580 style->attribute(
"open",
"Print to file");
2581 fc_print_ = DialogKit::instance()->file_chooser(
"./", style);
2584 fc_print_->reread();
2586 while (fc_print_->post_for(
w_)) {
2594 void PWMImpl::file_control() {
2595 if (none_selected(
"No windows to save",
"Save Anyway")) {
2598 if (file_control1()) {
2599 use_printer =
false;
2606 void PWMImpl::snapshot(
const Event* e) {
2609 obuf.open(fc_print_->selected()->string(), IOS_OUT);
2610 std::ostream o(&obuf);
2613 pr->resize(0, 0, 1200, 1000);
2627 t.translate(w->left(), w->bottom());
2629 Glyph* g = w->Window::glyph();
2633 Allotment ax(align_x * w->width(), w->width(), align_x);
2634 Allotment ay(align_y * w->width(), w->height(), align_y);
2643 if (
s &&
s->find_attribute(
"name", str)) {
2645 pr->comment(str.string());
2650 "BoundingBox: %g %g %g %g",
2653 w->left() + w->width() + 3,
2654 w->bottom() + w->height() + 20 + 3);
2656 Sprintf(
buf,
"\\begin{picture}(%g, %g)", w->width() + 6, w->height() + 23);
2660 "BoundingBox: %g %g %g %g",
2663 w->left() + w->width(),
2664 w->bottom() + w->height());
2666 Sprintf(
buf,
"\\begin{picture}(%g, %g)", w->width(), w->height());
2669 pr->push_transform();
2673 print_deco(
pr, a, str.string());
2676 pr->pop_transform();
2681 pr->comment(
"End BoundingBox");
2686 if (rb && rb->
canvas()->window() == e->window()) {
2687 pr->comment(
"Begin Rubberband");
2689 t1.translate(e->window()->left(), e->window()->bottom());
2690 pr->push_transform();
2693 pr->pop_transform();
2694 pr->comment(
"End Rubberband");
2703 t.translate(e->window()->left(), e->window()->bottom());
2705 pr->comment(
"Begin cursor");
2706 pr->push_transform();
2710 pr->line_to(8, -14);
2711 pr->line_to(2, -12);
2712 pr->line_to(2, -20);
2713 pr->line_to(-2, -20);
2714 pr->line_to(-2, -12);
2715 pr->line_to(-8, -14);
2717 pr->fill(WidgetKit::instance()->foreground());
2719 pr->pop_transform();
2720 pr->comment(
"End cursor");
2724 void PWMImpl::idraw_control() {
2729 Style* style =
new Style(Session::instance()->style());
2731 if (style->find_attribute(
"pwm_idraw_file_filter", str)) {
2732 style->attribute(
"filter",
"true");
2733 style->attribute(
"filterPattern", str);
2735 style->attribute(
"caption",
"Idraw format to file");
2736 style->attribute(
"open",
"Write to file");
2737 fc_idraw_ = DialogKit::instance()->file_chooser(
"./", style);
2740 fc_idraw_->reread();
2742 if (none_selected(
"No windows to save",
"Save Anyway")) {
2745 while (fc_idraw_->post_for(
w_)) {
2747 idraw_write(fc_idraw_->selected()->string());
2753 void PWMImpl::idraw_write(
const char* fname,
bool ses_style) {
2758 obuf.open(fname, IOS_OUT);
2759 std::ostream o(&obuf);
2766 ScreenItem*
pi = (ScreenItem*) screen()->component(
i);
2767 redraw(
pi->window());
2771 if (!
p->showing(
i)) {
2774 PaperItem*
pi = (PaperItem*)
p->component(
i);
2775 redraw(
pi->screen_item()->window());
2783 void PWMImpl::ascii_control() {
2788 Style* style =
new Style(Session::instance()->style());
2790 if (style->find_attribute(
"pwm_ascii_file_filter", str)) {
2791 style->attribute(
"filter",
"true");
2792 style->attribute(
"filterPattern", str);
2794 style->attribute(
"caption",
"Ascii format to file");
2795 style->attribute(
"open",
"Write to file");
2796 fc_ascii_ = DialogKit::instance()->file_chooser(
"./", style);
2799 fc_ascii_->reread();
2801 if (none_selected(
"No windows to save",
"Save Anyway")) {
2804 while (fc_ascii_->post_for(
w_)) {
2806 ascii_write(fc_ascii_->selected()->string());
2812 void PWMImpl::ascii_write(
const char* fname,
bool ses_style) {
2817 obuf.open(fname, IOS_OUT);
2818 std::ostream o(&obuf);
2824 ScreenItem*
pi = (ScreenItem*) screen()->component(
i);
2825 redraw(
pi->window());
2829 if (!
p->showing(
i) && !ses_style) {
2832 PaperItem*
pi = (PaperItem*)
p->component(
i);
2833 redraw(
pi->screen_item()->window());
2842 void PWMImpl::save_selected_control() {
2845 void PWMImpl::save_all_control() {
2848 bool PWMImpl::none_selected(
const char*
title,
const char* accept)
const {
2851 for (
i = 0;
i < paper_->count(); ++
i) {
2852 if (paper_->showing(
i)) {
2864 void PWMImpl::save_control(
int mode) {
2874 if (none_selected(
"No windows to save",
"Save Anyway")) {
2878 Style* style =
new Style(Session::instance()->style());
2880 if (style->find_attribute(
"pwm_save_file_filter", str)) {
2881 style->attribute(
"filter",
"true");
2882 style->attribute(
"filterPattern", str);
2884 style->attribute(
"caption",
"Save windows on paper icon to file");
2885 style->attribute(
"open",
"Save to file");
2886 fc_save_ = DialogKit::instance()->file_chooser(
"./", style);
2891 while (fc_save_->post_for(
w_)) {
2893 save_session(mode, fc_save_->selected()->string());
2899 int PWMImpl::save_group(
Object* ho,
const char* filename) {
2902 ScreenItem** sivec =
NULL;
2904 if (screen_ && screen_->count()) {
2905 sivec =
new ScreenItem*[screen_->count()];
2906 for (
i = 0;
i < screen_->count();
i++) {
2907 si = (ScreenItem*) (screen_->component(
i));
2908 if (si->group_obj_ == ho) {
2914 cur_ses_name_ = filename;
2919 obuf.open(filename, IOS_OUT);
2920 std::ostream o(&obuf);
2922 save_list(nwin, sivec, o);
2931 void PWMImpl::save_session(
int mode,
const char* filename,
const char* head) {
2934 ScreenItem** sivec =
NULL;
2937 cur_ses_name_ = filename;
2941 obuf.open(filename, IOS_OUT);
2942 if (!obuf.is_open()) {
2945 std::ostream o(&obuf);
2947 o << head << std::endl;
2954 if (screen_ && screen_->count()) {
2955 sivec =
new ScreenItem*[screen_->count()];
2956 for (
i = 0;
i < screen_->count();
i++) {
2957 si = (ScreenItem*) (screen_->component(
i));
2966 "{pwman_place(%d,%d,%d)}\n",
2969 w->is_mapped() ? 1 : 0);
2977 if (paper_ && paper_->count()) {
2978 sivec =
new ScreenItem*[paper_->count()];
2979 for (
i = 0;
i < paper_->count();
i++) {
2980 if (paper_->showing(
i)) {
2981 si = ((PaperItem*) (paper_->component(
i)))->screen_item();
2996 save_list(nwin, sivec, o);
3003 void PWMImpl::save_begin(std::ostream& o) {
3007 o <<
"objectvar ocbox_, ocbox_list_, scene_, scene_list_" << std::endl;
3008 o <<
"{ocbox_list_ = new List() scene_list_ = new List()}" << std::endl;
3011 void PWMImpl::save_list(
int nwin, ScreenItem** sivec, std::ostream& o) {
3015 ses_group_first_ = 1;
3020 for (
i = 0;
i < nwin; ++
i) {
3021 if (sivec[
i]->window()) {
3022 ocg = (
OcGlyph*) sivec[
i]->window()->glyph();
3027 if (sivec[
i]->window()) {
3030 ses_group(sivec[
i], o);
3032 if (pri < working && pri > max) {
3038 o <<
"objectvar scene_vector_[1]\n{doNotify()}" << std::endl;
3041 void PWMImpl::ses_group(ScreenItem* si, std::ostream& o) {
3044 if (si->group_obj_) {
3047 "{WindowMenu[0].ses_gid(%d, %d, %d, \"%s\")}\n",
3049 si->group_obj_->index,
3050 (screen()->showing(si->index()) ? 1 : 0),
3053 ses_group_first_ = 0;
3057 void PWMImpl::retrieve_control() {
3061 if (!fc_retrieve_) {
3062 Style* style =
new Style(Session::instance()->style());
3064 if (style->find_attribute(
"pwm_save_file_filter", str)) {
3065 style->attribute(
"filter",
"true");
3066 style->attribute(
"filterPattern", str);
3068 style->attribute(
"caption",
"Retrieve windows from file");
3069 style->attribute(
"open",
"Retrieve from file");
3070 fc_retrieve_ = DialogKit::instance()->file_chooser(
"./", style);
3071 fc_retrieve_->ref();
3073 fc_retrieve_->reread();
3075 while (fc_retrieve_->post_for(
w_)) {
3079 Sprintf(
buf,
"{load_file(1, \"%s\")}\n", fc_retrieve_->selected()->string());
3087 class OcLabelGlyph:
public OcGlyph {
3090 virtual ~OcLabelGlyph();
3091 virtual void save(std::ostream&);
3098 OcLabelGlyph::OcLabelGlyph(
const char* label,
OcGlyph* og,
Glyph* g) {
3106 OcLabelGlyph::~OcLabelGlyph() {
3107 og_->parents(
false);
3113 o <<
"{xpanel(\"\")" << std::endl;
3114 Sprintf(
buf,
"xlabel(\"%s\")", label_.string());
3115 o <<
buf << std::endl;
3116 o <<
"xpanel()}" << std::endl;
3123 virtual ~TrayDismiss();
3127 class OcTray:
public OcBox {
3132 virtual void start_vbox();
3144 TrayDismiss::~TrayDismiss() {}
3145 void TrayDismiss::execute() {
3146 if (
boolean_dialog(
"Dismiss or Dissolve into components?",
"Dissolve",
"Dismiss", win_)) {
3147 OcTray*
t = (OcTray*) win_->glyph();
3148 t->dissolve(win_->left(), win_->bottom());
3154 x_ =
new float[
cnt];
3155 y_ =
new float[
cnt];
3167 void OcTray::dissolve(
Coord left,
Coord bottom) {
3173 for (
i = 0;
i <
cnt; ++
i) {
3186 void OcTray::start_vbox() {
3194 wk->begin_style(
"_tray_panel");
3196 pg_->append(w->
glyph());
3198 y_[
n] = w->bottom();
3199 v_->box_append(
new OcLabelGlyph(w->
name(),
3201 lk->vbox(wk->label(w->
name()),
3202 lk->fixed(w->
glyph(), w->width(), w->height()))));
3214 void PWMImpl::tray() {
3221 count = paper_->count();
3226 Coord minleft = -1000;
3228 OcTray* tray =
new OcTray(count);
3229 while ((
index = upper_left()) != -1) {
3230 PaperItem*
pi = (PaperItem*) paper_->component(
index);
3237 minleft = l + w->width() / 2.;
3240 top = b + w->height();
3243 paper_->show(
index,
false);
3246 Window* w = tray->make_window();
3252 Coord minleft = 1e10;
3253 Coord maxbottom = -1e10;
3256 PaperItem*
pi = (PaperItem*) paper_->component(
i);
3259 if (!paper_->showing(
i))
3261 if (w == pwm_impl->w_) {
3269 if (l < minleft - 50.) {
3273 }
else if (l < minleft + 50.) {
3274 if (maxbottom < b) {
3285 void PWMImpl::dissolve() {
3286 for (
long i = 0;
i < panelList_.count();
i++) {
3287 new HocWin(panelList_.item(
i));
3294 bool ivoc_snapshot(
const Event* e) {
3297 if (
buf[0] ==
'p') {
3298 ivoc_snapshot_ =
NULL;
3307 #include <OS/table.h>
3309 #include <IV-X11/Xlib.h>
3310 #include <IV-X11/xdisplay.h>
3316 WindowTable* wt = Session::instance()->default_display()->rep()->wtable_;
3319 if (w->is_mapped()) {
3340 const char* tdir = getenv(
"TEMP");
3344 auto const length = strlen(tdir) + 1 + 9 + 1;
3345 tmpfile =
new char[length];
3346 std::snprintf(tmpfile, length,
"%s/nrnXXXXXX", tdir);
3349 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_xy(Canvas *, Coord left, Coord bottom, Coord right, Coord top)
void set(Canvas *, const Allocation &)
void merge_xy(Canvas *, Coord left, Coord bottom, Coord right, Coord top)
static FieldDialog * field_dialog_instance(const char *, Style *, Glyph *extra=NULL)
static std::ostream * ascii()
static void save_all(std::ostream &)
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 std::ostream * save_stream
static std::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 &)
static void save_all(std::ostream &)
virtual Coord mbs() const
virtual void reconfigured()
void class2oc(const char *, ctor_f *cons, dtor_f *destruct, Member_func *, Member_ret_obj_func *, Member_ret_str_func *)
char * hoc_back2forward(char *)
HocReturnType hoc_return_type_code
#define y_(arg)
Crout matrix decomposition : Forward/Backward substitution.
double chkarg(int, double low, double high)
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)
Object ** hoc_objgetarg(int)
Symbol * lookup(const char *)
void move(Item *q1, Item *q2, Item *q3)
static double inside(void *)
void hoc_execerror(const char *s1, const char *s2)
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
int const size_t const size_t n
static void pr(N_Vector x)
static double working(void *v)
const char * pwm_session_filename()
static double save(void *v)
static double ref(void *v)
static double resize(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[]
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 *)
HAVE_IV.
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)
Object ** hoc_temp_objptr(Object *)
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.)