print_panel.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. //
  2. // "$Id: print_panel.fl 8864 2011-07-19 04:49:30Z greg.ercolano $"
  3. //
  4. // FLUID print panel for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. // generated by Fast Light User Interface Designer (fluid) version 1.0302
  19. #include "print_panel.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include "../src/flstring.h"
  23. #include <FL/Fl_Preferences.H>
  24. extern Fl_Preferences fluid_prefs;
  25. Fl_Double_Window *print_panel=(Fl_Double_Window *)0;
  26. Fl_Group *print_panel_controls=(Fl_Group *)0;
  27. Fl_Choice *print_choice=(Fl_Choice *)0;
  28. static void cb_print_choice(Fl_Choice*, void*) {
  29. print_update_status();
  30. }
  31. Fl_Button *print_properties=(Fl_Button *)0;
  32. static void cb_print_properties(Fl_Button*, void*) {
  33. print_properties_panel->show();
  34. }
  35. Fl_Box *print_status=(Fl_Box *)0;
  36. Fl_Round_Button *print_all=(Fl_Round_Button *)0;
  37. static void cb_print_all(Fl_Round_Button*, void*) {
  38. print_from->deactivate();
  39. print_to->deactivate();
  40. }
  41. Fl_Round_Button *print_pages=(Fl_Round_Button *)0;
  42. static void cb_print_pages(Fl_Round_Button*, void*) {
  43. print_from->activate();
  44. print_to->activate();
  45. }
  46. Fl_Round_Button *print_selection=(Fl_Round_Button *)0;
  47. static void cb_print_selection(Fl_Round_Button*, void*) {
  48. print_from->deactivate();
  49. print_to->deactivate();
  50. }
  51. Fl_Int_Input *print_from=(Fl_Int_Input *)0;
  52. Fl_Int_Input *print_to=(Fl_Int_Input *)0;
  53. Fl_Spinner *print_copies=(Fl_Spinner *)0;
  54. static void cb_print_copies(Fl_Spinner*, void*) {
  55. if (print_copies->value() == 1) {
  56. print_collate_button->deactivate();
  57. print_collate_group[0]->deactivate();
  58. print_collate_group[1]->deactivate();
  59. } else {
  60. print_collate_button->activate();
  61. print_collate_group[0]->activate();
  62. print_collate_group[1]->activate();
  63. };
  64. }
  65. Fl_Check_Button *print_collate_button=(Fl_Check_Button *)0;
  66. static void cb_print_collate_button(Fl_Check_Button*, void*) {
  67. int i = print_collate_button->value() != 0;
  68. print_collate_group[i]->show();
  69. print_collate_group[1 - i]->hide();
  70. }
  71. Fl_Group *print_collate_group[2]={(Fl_Group *)0};
  72. static void cb_Cancel(Fl_Button*, void*) {
  73. print_panel->hide();
  74. }
  75. Fl_Progress *print_progress=(Fl_Progress *)0;
  76. Fl_Double_Window *print_properties_panel=(Fl_Double_Window *)0;
  77. static void cb_print_properties_panel(Fl_Double_Window*, void*) {
  78. print_properties_panel->hide();
  79. print_update_status();
  80. }
  81. Fl_Choice *print_page_size=(Fl_Choice *)0;
  82. Fl_Menu_Item menu_print_page_size[] = {
  83. {"Letter", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
  84. {"A4", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
  85. {0,0,0,0,0,0,0,0,0}
  86. };
  87. #include <FL/Fl_Pixmap.H>
  88. static const char *idata_print_color[] = {
  89. "24 24 17 1",
  90. " \tc None",
  91. ".\tc #FFFF00",
  92. "+\tc #C8FF00",
  93. "@\tc #00FF00",
  94. "#\tc #FFC800",
  95. "$\tc #FF0000",
  96. "%\tc #00FFFF",
  97. "&\tc #000000",
  98. "*\tc #FF00FF",
  99. "=\tc #00FFC8",
  100. "-\tc #FF00C8",
  101. ";\tc #00C800",
  102. ">\tc #C80000",
  103. ",\tc #0000C8",
  104. "\'\tc #0000FF",
  105. ")\tc #00C8FF",
  106. "!\tc #C800FF",
  107. " ...... ",
  108. " .......... ",
  109. " ............ ",
  110. " .............. ",
  111. " .............. ",
  112. " ................ ",
  113. " ................ ",
  114. " ................ ",
  115. " +@@@@@@+#$$$$$$# ",
  116. " %@@@@@@@&&$$$$$$$* ",
  117. " %%@@@@@@&&&&$$$$$$** ",
  118. " %%%=@@@@&&&&&&$$$$-*** ",
  119. " %%%%@@@;&&&&&&>$$$**** ",
  120. "%%%%%%@@&&&&&&&&$$******",
  121. "%%%%%%%@&&&&&&&&$*******",
  122. "%%%%%%%%,&&&&&&,********",
  123. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  124. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  125. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  126. " %%%%%%%)\'\'\'\'\'\'!******* ",
  127. " %%%%%%%%\'\'\'\'\'\'******** ",
  128. " %%%%%%%%\'\'\'\'******** ",
  129. " %%%%%%%%\'\'******** ",
  130. " %%%%%% ****** "
  131. };
  132. static Fl_Pixmap image_print_color(idata_print_color);
  133. static const char *idata_print_gray[] = {
  134. "24 24 17 1",
  135. " \tc None",
  136. ".\tc #E3E3E3",
  137. "+\tc #D2D2D2",
  138. "@\tc #969696",
  139. "#\tc #C2C2C2",
  140. "$\tc #4C4C4C",
  141. "%\tc #B2B2B2",
  142. "&\tc #000000",
  143. "*\tc #696969",
  144. "=\tc #ACACAC",
  145. "-\tc #626262",
  146. ";\tc #767676",
  147. ">\tc #3C3C3C",
  148. ",\tc #161616",
  149. "\'\tc #1C1C1C",
  150. ")\tc #929292",
  151. "!\tc #585858",
  152. " ...... ",
  153. " .......... ",
  154. " ............ ",
  155. " .............. ",
  156. " .............. ",
  157. " ................ ",
  158. " ................ ",
  159. " ................ ",
  160. " +@@@@@@+#$$$$$$# ",
  161. " %@@@@@@@&&$$$$$$$* ",
  162. " %%@@@@@@&&&&$$$$$$** ",
  163. " %%%=@@@@&&&&&&$$$$-*** ",
  164. " %%%%@@@;&&&&&&>$$$**** ",
  165. "%%%%%%@@&&&&&&&&$$******",
  166. "%%%%%%%@&&&&&&&&$*******",
  167. "%%%%%%%%,&&&&&&,********",
  168. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  169. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  170. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  171. " %%%%%%%)\'\'\'\'\'\'!******* ",
  172. " %%%%%%%%\'\'\'\'\'\'******** ",
  173. " %%%%%%%%\'\'\'\'******** ",
  174. " %%%%%%%%\'\'******** ",
  175. " %%%%%% ****** "
  176. };
  177. static Fl_Pixmap image_print_gray(idata_print_gray);
  178. Fl_Button *print_output_mode[4]={(Fl_Button *)0};
  179. static void cb_Save(Fl_Return_Button*, void*) {
  180. print_properties_panel->hide();
  181. char name[1024];
  182. int val;
  183. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  184. snprintf(name, sizeof(name), "%s/page_size", printer);
  185. fluid_prefs.set(name, print_page_size->value());
  186. snprintf(name, sizeof(name), "%s/output_mode", printer);
  187. for (val = 0; val < 4; val ++) {
  188. if (print_output_mode[val]->value()) break;
  189. }
  190. fluid_prefs.set(name, val);
  191. }
  192. static void cb_Cancel1(Fl_Button*, void*) {
  193. print_properties_panel->hide();
  194. print_update_status();
  195. }
  196. static void cb_Use(Fl_Button*, void*) {
  197. print_properties_panel->hide();
  198. }
  199. Fl_Double_Window* make_print_panel() {
  200. { print_panel = new Fl_Double_Window(465, 235, "Print");
  201. { print_panel_controls = new Fl_Group(10, 10, 447, 216);
  202. { print_choice = new Fl_Choice(113, 10, 181, 25, "Printer:");
  203. print_choice->down_box(FL_BORDER_BOX);
  204. print_choice->labelfont(1);
  205. print_choice->callback((Fl_Callback*)cb_print_choice);
  206. print_choice->when(FL_WHEN_CHANGED);
  207. } // Fl_Choice* print_choice
  208. { print_properties = new Fl_Button(294, 10, 105, 25, "Properties...");
  209. print_properties->callback((Fl_Callback*)cb_print_properties);
  210. } // Fl_Button* print_properties
  211. { print_status = new Fl_Box(111, 41, 288, 17, "printer/job status");
  212. print_status->align(Fl_Align(68|FL_ALIGN_INSIDE));
  213. } // Fl_Box* print_status
  214. { Fl_Group* o = new Fl_Group(10, 86, 227, 105, "Print Range");
  215. o->box(FL_THIN_DOWN_BOX);
  216. o->labelfont(1);
  217. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  218. { print_all = new Fl_Round_Button(20, 96, 38, 25, "All");
  219. print_all->type(102);
  220. print_all->down_box(FL_ROUND_DOWN_BOX);
  221. print_all->value(1);
  222. print_all->callback((Fl_Callback*)cb_print_all);
  223. } // Fl_Round_Button* print_all
  224. { print_pages = new Fl_Round_Button(20, 126, 64, 25, "Pages");
  225. print_pages->type(102);
  226. print_pages->down_box(FL_ROUND_DOWN_BOX);
  227. print_pages->callback((Fl_Callback*)cb_print_pages);
  228. } // Fl_Round_Button* print_pages
  229. { print_selection = new Fl_Round_Button(20, 156, 82, 25, "Selection");
  230. print_selection->type(102);
  231. print_selection->down_box(FL_ROUND_DOWN_BOX);
  232. print_selection->callback((Fl_Callback*)cb_print_selection);
  233. } // Fl_Round_Button* print_selection
  234. { print_from = new Fl_Int_Input(136, 126, 28, 25, "From:");
  235. print_from->type(2);
  236. print_from->textfont(4);
  237. print_from->deactivate();
  238. } // Fl_Int_Input* print_from
  239. { print_to = new Fl_Int_Input(199, 126, 28, 25, "To:");
  240. print_to->type(2);
  241. print_to->textfont(4);
  242. print_to->deactivate();
  243. } // Fl_Int_Input* print_to
  244. o->end();
  245. } // Fl_Group* o
  246. { Fl_Group* o = new Fl_Group(247, 86, 210, 105, "Copies");
  247. o->box(FL_THIN_DOWN_BOX);
  248. o->labelfont(1);
  249. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  250. { print_copies = new Fl_Spinner(321, 96, 45, 25, "# Copies:");
  251. print_copies->callback((Fl_Callback*)cb_print_copies);
  252. print_copies->when(FL_WHEN_CHANGED);
  253. } // Fl_Spinner* print_copies
  254. { print_collate_button = new Fl_Check_Button(376, 96, 64, 25, "Collate");
  255. print_collate_button->down_box(FL_DOWN_BOX);
  256. print_collate_button->callback((Fl_Callback*)cb_print_collate_button);
  257. print_collate_button->when(FL_WHEN_CHANGED);
  258. print_collate_button->deactivate();
  259. } // Fl_Check_Button* print_collate_button
  260. { print_collate_group[0] = new Fl_Group(257, 131, 191, 50);
  261. print_collate_group[0]->deactivate();
  262. { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "1");
  263. o->box(FL_BORDER_BOX);
  264. o->color(FL_BACKGROUND2_COLOR);
  265. o->labelsize(11);
  266. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  267. o->deactivate();
  268. } // Fl_Box* o
  269. { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "1");
  270. o->box(FL_BORDER_BOX);
  271. o->color(FL_BACKGROUND2_COLOR);
  272. o->labelsize(11);
  273. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  274. o->deactivate();
  275. } // Fl_Box* o
  276. { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
  277. o->box(FL_BORDER_BOX);
  278. o->color(FL_BACKGROUND2_COLOR);
  279. o->labelsize(11);
  280. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  281. o->deactivate();
  282. } // Fl_Box* o
  283. { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "2");
  284. o->box(FL_BORDER_BOX);
  285. o->color(FL_BACKGROUND2_COLOR);
  286. o->labelsize(11);
  287. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  288. o->deactivate();
  289. } // Fl_Box* o
  290. { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
  291. o->box(FL_BORDER_BOX);
  292. o->color(FL_BACKGROUND2_COLOR);
  293. o->labelsize(11);
  294. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  295. o->deactivate();
  296. } // Fl_Box* o
  297. { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "2");
  298. o->box(FL_BORDER_BOX);
  299. o->color(FL_BACKGROUND2_COLOR);
  300. o->labelsize(11);
  301. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  302. o->deactivate();
  303. } // Fl_Box* o
  304. { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
  305. o->box(FL_BORDER_BOX);
  306. o->color(FL_BACKGROUND2_COLOR);
  307. o->labelsize(11);
  308. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  309. o->deactivate();
  310. } // Fl_Box* o
  311. { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "3");
  312. o->box(FL_BORDER_BOX);
  313. o->color(FL_BACKGROUND2_COLOR);
  314. o->labelsize(11);
  315. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  316. o->deactivate();
  317. } // Fl_Box* o
  318. { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "3");
  319. o->box(FL_BORDER_BOX);
  320. o->color(FL_BACKGROUND2_COLOR);
  321. o->labelsize(11);
  322. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  323. o->deactivate();
  324. } // Fl_Box* o
  325. print_collate_group[0]->end();
  326. } // Fl_Group* print_collate_group[0]
  327. { print_collate_group[1] = new Fl_Group(257, 131, 191, 50);
  328. print_collate_group[1]->hide();
  329. print_collate_group[1]->deactivate();
  330. { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "3");
  331. o->box(FL_BORDER_BOX);
  332. o->color(FL_BACKGROUND2_COLOR);
  333. o->labelsize(11);
  334. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  335. } // Fl_Box* o
  336. { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "2");
  337. o->box(FL_BORDER_BOX);
  338. o->color(FL_BACKGROUND2_COLOR);
  339. o->labelsize(11);
  340. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  341. } // Fl_Box* o
  342. { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
  343. o->box(FL_BORDER_BOX);
  344. o->color(FL_BACKGROUND2_COLOR);
  345. o->labelsize(11);
  346. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  347. } // Fl_Box* o
  348. { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "3");
  349. o->box(FL_BORDER_BOX);
  350. o->color(FL_BACKGROUND2_COLOR);
  351. o->labelsize(11);
  352. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  353. } // Fl_Box* o
  354. { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
  355. o->box(FL_BORDER_BOX);
  356. o->color(FL_BACKGROUND2_COLOR);
  357. o->labelsize(11);
  358. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  359. } // Fl_Box* o
  360. { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "1");
  361. o->box(FL_BORDER_BOX);
  362. o->color(FL_BACKGROUND2_COLOR);
  363. o->labelsize(11);
  364. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  365. } // Fl_Box* o
  366. { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
  367. o->box(FL_BORDER_BOX);
  368. o->color(FL_BACKGROUND2_COLOR);
  369. o->labelsize(11);
  370. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  371. } // Fl_Box* o
  372. { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "2");
  373. o->box(FL_BORDER_BOX);
  374. o->color(FL_BACKGROUND2_COLOR);
  375. o->labelsize(11);
  376. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  377. } // Fl_Box* o
  378. { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "1");
  379. o->box(FL_BORDER_BOX);
  380. o->color(FL_BACKGROUND2_COLOR);
  381. o->labelsize(11);
  382. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  383. } // Fl_Box* o
  384. print_collate_group[1]->end();
  385. } // Fl_Group* print_collate_group[1]
  386. o->end();
  387. } // Fl_Group* o
  388. { Fl_Return_Button* o = new Fl_Return_Button(309, 201, 70, 25, "Print");
  389. o->callback((Fl_Callback*)print_cb);
  390. } // Fl_Return_Button* o
  391. { Fl_Button* o = new Fl_Button(389, 201, 68, 25, "Cancel");
  392. o->callback((Fl_Callback*)cb_Cancel);
  393. } // Fl_Button* o
  394. print_panel_controls->end();
  395. } // Fl_Group* print_panel_controls
  396. { print_progress = new Fl_Progress(10, 203, 289, 21);
  397. print_progress->selection_color((Fl_Color)4);
  398. print_progress->hide();
  399. } // Fl_Progress* print_progress
  400. print_panel->set_modal();
  401. print_panel->end();
  402. } // Fl_Double_Window* print_panel
  403. { print_properties_panel = new Fl_Double_Window(290, 130, "Printer Properties");
  404. print_properties_panel->callback((Fl_Callback*)cb_print_properties_panel);
  405. { print_page_size = new Fl_Choice(110, 10, 80, 25, "Page Size:");
  406. print_page_size->down_box(FL_BORDER_BOX);
  407. print_page_size->labelfont(1);
  408. print_page_size->menu(menu_print_page_size);
  409. } // Fl_Choice* print_page_size
  410. { Fl_Group* o = new Fl_Group(110, 45, 170, 40, "Output Mode:");
  411. o->labelfont(1);
  412. o->align(Fl_Align(FL_ALIGN_LEFT));
  413. { print_output_mode[0] = new Fl_Button(110, 45, 30, 40);
  414. print_output_mode[0]->type(102);
  415. print_output_mode[0]->box(FL_BORDER_BOX);
  416. print_output_mode[0]->down_box(FL_BORDER_BOX);
  417. print_output_mode[0]->value(1);
  418. print_output_mode[0]->color(FL_BACKGROUND2_COLOR);
  419. print_output_mode[0]->selection_color(FL_FOREGROUND_COLOR);
  420. print_output_mode[0]->image(image_print_color);
  421. } // Fl_Button* print_output_mode[0]
  422. { print_output_mode[1] = new Fl_Button(150, 50, 40, 30);
  423. print_output_mode[1]->type(102);
  424. print_output_mode[1]->box(FL_BORDER_BOX);
  425. print_output_mode[1]->down_box(FL_BORDER_BOX);
  426. print_output_mode[1]->color(FL_BACKGROUND2_COLOR);
  427. print_output_mode[1]->selection_color(FL_FOREGROUND_COLOR);
  428. print_output_mode[1]->image(image_print_color);
  429. } // Fl_Button* print_output_mode[1]
  430. { print_output_mode[2] = new Fl_Button(200, 45, 30, 40);
  431. print_output_mode[2]->type(102);
  432. print_output_mode[2]->box(FL_BORDER_BOX);
  433. print_output_mode[2]->down_box(FL_BORDER_BOX);
  434. print_output_mode[2]->color(FL_BACKGROUND2_COLOR);
  435. print_output_mode[2]->selection_color(FL_FOREGROUND_COLOR);
  436. print_output_mode[2]->image(image_print_gray);
  437. } // Fl_Button* print_output_mode[2]
  438. { print_output_mode[3] = new Fl_Button(240, 50, 40, 30);
  439. print_output_mode[3]->type(102);
  440. print_output_mode[3]->box(FL_BORDER_BOX);
  441. print_output_mode[3]->down_box(FL_BORDER_BOX);
  442. print_output_mode[3]->color(FL_BACKGROUND2_COLOR);
  443. print_output_mode[3]->selection_color(FL_FOREGROUND_COLOR);
  444. print_output_mode[3]->image(image_print_gray);
  445. } // Fl_Button* print_output_mode[3]
  446. o->end();
  447. } // Fl_Group* o
  448. { Fl_Return_Button* o = new Fl_Return_Button(123, 95, 79, 25, "Save");
  449. o->callback((Fl_Callback*)cb_Save);
  450. } // Fl_Return_Button* o
  451. { Fl_Button* o = new Fl_Button(212, 95, 68, 25, "Cancel");
  452. o->callback((Fl_Callback*)cb_Cancel1);
  453. } // Fl_Button* o
  454. { Fl_Button* o = new Fl_Button(60, 95, 53, 25, "Use");
  455. o->callback((Fl_Callback*)cb_Use);
  456. } // Fl_Button* o
  457. print_properties_panel->set_modal();
  458. print_properties_panel->end();
  459. } // Fl_Double_Window* print_properties_panel
  460. return print_properties_panel;
  461. }
  462. void print_cb(Fl_Return_Button *, void *) {
  463. }
  464. void print_load() {
  465. FILE *lpstat;
  466. char line[1024], name[1024], *nptr, qname[2048], *qptr, defname[1024];
  467. int i;
  468. if (print_choice->size() > 1) {
  469. for (i = 1; print_choice->text(i); i ++) {
  470. free(print_choice->menu()[i].user_data());
  471. }
  472. }
  473. print_choice->clear();
  474. print_choice->add("Print To File", 0, 0, 0, FL_MENU_DIVIDER);
  475. print_choice->value(0);
  476. defname[0] = '\0';
  477. if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) {
  478. while (fgets(line, sizeof(line), lpstat)) {
  479. if (!strncmp(line, "printer ", 8) &&
  480. sscanf(line + 8, "%s", name) == 1) {
  481. for (nptr = name, qptr = qname; *nptr; *qptr++ = *nptr++) {
  482. if (*nptr == '/') *qptr++ = '\\';
  483. }
  484. *qptr = '\0';
  485. print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
  486. } else if (!strncmp(line, "system default destination: ", 28)) {
  487. if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\0';
  488. }
  489. }
  490. pclose(lpstat);
  491. }
  492. if (defname[0]) {
  493. for (i = 1; print_choice->text(i); i ++) {
  494. if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) {
  495. print_choice->value(i);
  496. break;
  497. }
  498. }
  499. } else if (print_choice->size() > 2) print_choice->value(1);
  500. print_update_status();
  501. }
  502. void print_update_status() {
  503. FILE *lpstat;
  504. char command[1024];
  505. static char status[1024];
  506. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  507. if (print_choice->value()) {
  508. snprintf(command, sizeof(command), "lpstat -p '%s'", printer);
  509. if ((lpstat = popen(command, "r")) != NULL) {
  510. if (fgets(status, sizeof(status), lpstat)==0) { /* ignore */ }
  511. pclose(lpstat);
  512. } else strcpy(status, "printer status unavailable");
  513. } else status[0] = '\0';
  514. print_status->label(status);
  515. char name[1024];
  516. int val;
  517. snprintf(name, sizeof(name), "%s/page_size", printer);
  518. fluid_prefs.get(name, val, 0);
  519. print_page_size->value(val);
  520. snprintf(name, sizeof(name), "%s/output_mode", printer);
  521. fluid_prefs.get(name, val, 0);
  522. print_output_mode[val]->setonly();
  523. }
  524. //
  525. // End of "$Id: print_panel.fl 8864 2011-07-19 04:49:30Z greg.ercolano $".
  526. //