print_panel.fl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0300
  3. header_name {.h}
  4. code_name {.cxx}
  5. comment {//
  6. // "$Id: print_panel.fl 8864 2011-07-19 04:49:30Z greg.ercolano $"
  7. //
  8. // FLUID print panel for the Fast Light Tool Kit (FLTK).
  9. //
  10. // Copyright 1998-2010 by Bill Spitzak and others.
  11. //
  12. // This library is free software. Distribution and use rights are outlined in
  13. // the file "COPYING" which should have been included with this file. If this
  14. // file is missing or damaged, see the license at:
  15. //
  16. // http://www.fltk.org/COPYING.php
  17. //
  18. // Please report all bugs and problems on the following page:
  19. //
  20. // http://www.fltk.org/str.php
  21. //
  22. } {in_source in_header
  23. }
  24. decl {\#include <stdio.h>} {private local
  25. }
  26. decl {\#include <stdlib.h>} {private local
  27. }
  28. decl {\#include "../src/flstring.h"} {private local
  29. }
  30. decl {\#include <FL/Fl_Preferences.H>} {private local
  31. }
  32. decl {extern Fl_Preferences fluid_prefs;} {private local
  33. }
  34. Function {make_print_panel()} {open
  35. } {
  36. Fl_Window print_panel {
  37. label Print open
  38. xywh {342 28 465 235} type Double modal visible
  39. } {
  40. Fl_Group print_panel_controls {open
  41. xywh {10 10 447 216}
  42. } {
  43. Fl_Choice print_choice {
  44. label {Printer:}
  45. callback {print_update_status();} open
  46. xywh {113 10 181 25} down_box BORDER_BOX labelfont 1 when 1
  47. } {}
  48. Fl_Button print_properties {
  49. label {Properties...}
  50. callback {print_properties_panel->show();}
  51. xywh {294 10 105 25}
  52. }
  53. Fl_Box print_status {
  54. label {printer/job status}
  55. xywh {111 41 288 17} align 84
  56. }
  57. Fl_Group {} {
  58. label {Print Range} open
  59. xywh {10 86 227 105} box THIN_DOWN_BOX labelfont 1 align 5
  60. } {
  61. Fl_Round_Button print_all {
  62. label All
  63. callback {print_from->deactivate();
  64. print_to->deactivate();}
  65. xywh {20 96 38 25} type Radio down_box ROUND_DOWN_BOX value 1
  66. }
  67. Fl_Round_Button print_pages {
  68. label Pages
  69. callback {print_from->activate();
  70. print_to->activate();}
  71. xywh {20 126 64 25} type Radio down_box ROUND_DOWN_BOX
  72. }
  73. Fl_Round_Button print_selection {
  74. label Selection
  75. callback {print_from->deactivate();
  76. print_to->deactivate();}
  77. xywh {20 156 82 25} type Radio down_box ROUND_DOWN_BOX
  78. }
  79. Fl_Input print_from {
  80. label {From:}
  81. xywh {136 126 28 25} type Int textfont 4 deactivate
  82. }
  83. Fl_Input print_to {
  84. label {To:}
  85. xywh {199 126 28 25} type Int textfont 4 deactivate
  86. }
  87. }
  88. Fl_Group {} {
  89. label Copies open
  90. xywh {247 86 210 105} box THIN_DOWN_BOX labelfont 1 align 5
  91. } {
  92. Fl_Spinner print_copies {
  93. label {\# Copies:}
  94. callback {if (print_copies->value() == 1) {
  95. print_collate_button->deactivate();
  96. print_collate_group[0]->deactivate();
  97. print_collate_group[1]->deactivate();
  98. } else {
  99. print_collate_button->activate();
  100. print_collate_group[0]->activate();
  101. print_collate_group[1]->activate();
  102. }}
  103. xywh {321 96 45 25} when 1
  104. }
  105. Fl_Check_Button print_collate_button {
  106. label Collate
  107. callback {int i = print_collate_button->value() != 0;
  108. print_collate_group[i]->show();
  109. print_collate_group[1 - i]->hide();}
  110. xywh {376 96 64 25} down_box DOWN_BOX when 1 deactivate
  111. }
  112. Fl_Group {print_collate_group[0]} {
  113. xywh {257 131 191 50} deactivate
  114. } {
  115. Fl_Box {} {
  116. label 1
  117. xywh {287 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  118. }
  119. Fl_Box {} {
  120. label 1
  121. xywh {272 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  122. }
  123. Fl_Box {} {
  124. label 1
  125. xywh {257 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  126. }
  127. Fl_Box {} {
  128. label 2
  129. xywh {352 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  130. }
  131. Fl_Box {} {
  132. label 2
  133. xywh {337 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  134. }
  135. Fl_Box {} {
  136. label 2
  137. xywh {322 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  138. }
  139. Fl_Box {} {
  140. label 3
  141. xywh {417 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  142. }
  143. Fl_Box {} {
  144. label 3
  145. xywh {402 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  146. }
  147. Fl_Box {} {
  148. label 3
  149. xywh {387 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate
  150. }
  151. }
  152. Fl_Group {print_collate_group[1]} {
  153. xywh {257 131 191 50} hide deactivate
  154. } {
  155. Fl_Box {} {
  156. label 3
  157. xywh {287 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  158. }
  159. Fl_Box {} {
  160. label 2
  161. xywh {272 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  162. }
  163. Fl_Box {} {
  164. label 1
  165. xywh {257 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  166. }
  167. Fl_Box {} {
  168. label 3
  169. xywh {352 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  170. }
  171. Fl_Box {} {
  172. label 2
  173. xywh {337 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  174. }
  175. Fl_Box {} {
  176. label 1
  177. xywh {322 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  178. }
  179. Fl_Box {} {
  180. label 3
  181. xywh {417 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  182. }
  183. Fl_Box {} {
  184. label 2
  185. xywh {402 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  186. }
  187. Fl_Box {} {
  188. label 1
  189. xywh {387 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26
  190. }
  191. }
  192. }
  193. Fl_Return_Button {} {
  194. label Print
  195. callback print_cb
  196. xywh {309 201 70 25}
  197. }
  198. Fl_Button {} {
  199. label Cancel
  200. callback {print_panel->hide();}
  201. xywh {389 201 68 25}
  202. }
  203. }
  204. Fl_Progress print_progress {
  205. xywh {10 203 289 21} selection_color 4 hide
  206. }
  207. }
  208. Fl_Window print_properties_panel {
  209. label {Printer Properties}
  210. callback {print_properties_panel->hide();
  211. print_update_status();} open
  212. xywh {340 213 290 130} type Double modal visible
  213. } {
  214. Fl_Choice print_page_size {
  215. label {Page Size:}
  216. xywh {110 10 80 25} down_box BORDER_BOX labelfont 1
  217. } {
  218. MenuItem {} {
  219. label Letter
  220. xywh {0 0 35 25}
  221. }
  222. MenuItem {} {
  223. label A4
  224. xywh {0 0 35 25}
  225. }
  226. }
  227. Fl_Group {} {
  228. label {Output Mode:} open
  229. xywh {110 45 170 40} labelfont 1 align 4
  230. } {
  231. Fl_Button {print_output_mode[0]} {
  232. image {pixmaps/print_color.xpm} xywh {110 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX value 1 color 7 selection_color 0
  233. }
  234. Fl_Button {print_output_mode[1]} {
  235. image {pixmaps/print_color.xpm} xywh {150 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
  236. }
  237. Fl_Button {print_output_mode[2]} {
  238. image {pixmaps/print_gray.xpm} xywh {200 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
  239. }
  240. Fl_Button {print_output_mode[3]} {
  241. image {pixmaps/print_gray.xpm} xywh {240 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
  242. }
  243. }
  244. Fl_Return_Button {} {
  245. label Save
  246. callback {print_properties_panel->hide();
  247. char name[1024];
  248. int val;
  249. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  250. snprintf(name, sizeof(name), "%s/page_size", printer);
  251. fluid_prefs.set(name, print_page_size->value());
  252. snprintf(name, sizeof(name), "%s/output_mode", printer);
  253. for (val = 0; val < 4; val ++) {
  254. if (print_output_mode[val]->value()) break;
  255. }
  256. fluid_prefs.set(name, val);}
  257. xywh {123 95 79 25}
  258. }
  259. Fl_Button {} {
  260. label Cancel
  261. callback {print_properties_panel->hide();
  262. print_update_status();}
  263. xywh {212 95 68 25}
  264. }
  265. Fl_Button {} {
  266. label Use
  267. callback {print_properties_panel->hide();}
  268. xywh {60 95 53 25}
  269. }
  270. }
  271. }
  272. Function {print_cb(Fl_Return_Button *, void *)} {open return_type void
  273. } {
  274. code {} {selected
  275. }
  276. }
  277. Function {print_load()} {open return_type void
  278. } {
  279. code {FILE *lpstat;
  280. char line[1024], name[1024], *nptr, qname[2048], *qptr, defname[1024];
  281. int i;
  282. if (print_choice->size() > 1) {
  283. for (i = 1; print_choice->text(i); i ++) {
  284. free(print_choice->menu()[i].user_data());
  285. }
  286. }
  287. print_choice->clear();
  288. print_choice->add("Print To File", 0, 0, 0, FL_MENU_DIVIDER);
  289. print_choice->value(0);
  290. defname[0] = '\\0';
  291. if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) {
  292. while (fgets(line, sizeof(line), lpstat)) {
  293. if (!strncmp(line, "printer ", 8) &&
  294. sscanf(line + 8, "%s", name) == 1) {
  295. for (nptr = name, qptr = qname; *nptr; *qptr++ = *nptr++) {
  296. if (*nptr == '/') *qptr++ = '\\\\';
  297. }
  298. *qptr = '\\0';
  299. print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
  300. } else if (!strncmp(line, "system default destination: ", 28)) {
  301. if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\\0';
  302. }
  303. }
  304. pclose(lpstat);
  305. }
  306. if (defname[0]) {
  307. for (i = 1; print_choice->text(i); i ++) {
  308. if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) {
  309. print_choice->value(i);
  310. break;
  311. }
  312. }
  313. } else if (print_choice->size() > 2) print_choice->value(1);
  314. print_update_status();} {}
  315. }
  316. Function {print_update_status()} {open return_type void
  317. } {
  318. code {FILE *lpstat;
  319. char command[1024];
  320. static char status[1024];
  321. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  322. if (print_choice->value()) {
  323. snprintf(command, sizeof(command), "lpstat -p '%s'", printer);
  324. if ((lpstat = popen(command, "r")) != NULL) {
  325. if (fgets(status, sizeof(status), lpstat)==0) { /* ignore */ }
  326. pclose(lpstat);
  327. } else strcpy(status, "printer status unavailable");
  328. } else status[0] = '\\0';
  329. print_status->label(status);
  330. char name[1024];
  331. int val;
  332. snprintf(name, sizeof(name), "%s/page_size", printer);
  333. fluid_prefs.get(name, val, 0);
  334. print_page_size->value(val);
  335. snprintf(name, sizeof(name), "%s/output_mode", printer);
  336. fluid_prefs.get(name, val, 0);
  337. print_output_mode[val]->setonly();} {}
  338. }
  339. comment {
  340. //
  341. // End of "$Id: print_panel.fl 8864 2011-07-19 04:49:30Z greg.ercolano $".
  342. //} {in_source in_header
  343. }