Author: AlbrechtS
Date: 2010-03-05 13:05:47 -0800 (Fri, 05 Mar 2010)
New Revision: 7220
Log:
Linux print dialog, release 0.02. This enables users to print to printers
configured on their systems with a direct print dialog. This first version
is not complete and will be modified in the future, but it works.
The print dialog was taken from fluid's internal printing functions.
Also: fixed a typo (filename case), added rotation to Linux printing, but
disabled it in the source file, added window scaling to Linux printing.
Added:
branches/branch-1.3-Fl_Printer/src/print_panel.cxx
branches/branch-1.3-Fl_Printer/src/print_panel.h
Modified:
branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx
branches/branch-1.3-Fl_Printer/src/Fl_win32.cxx
branches/branch-1.3-Fl_Printer/src/Fl_x.cxx
branches/branch-1.3-Fl_Printer/test/device.cxx
Modified: branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-05 18:53:00 UTC
(rev 7219)
+++ branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-05 21:05:47 UTC
(rev 7220)
@@ -2,7 +2,7 @@
#define Fl_Printer_H
#include <FL/Fl_Device.H>
-#include <FL/Fl_draw.H>
+#include <FL/fl_draw.H>
#include <FL/Fl_Pixmap.H>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_Bitmap.H>
Modified: branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx 2010-03-05
18:53:00 UTC (rev 7219)
+++ branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx 2010-03-05
21:05:47 UTC (rev 7220)
@@ -11,6 +11,10 @@
#include <stdio.h>
#include <math.h>
+#if ! (defined(__APPLE__) || defined(WIN32) )
+ #include "print_panel.cxx"
+#endif
+
const struct Fl_PSfile_Device::page_format
Fl_PSfile_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format
// comes from appendix B of 5003.PPD_Spec_v4.3.pdf
@@ -1140,8 +1144,14 @@
fprintf(output, "GR\n restore\n");
fputs("%%EOF",output);
reset();
+#if ! (defined(__APPLE__) || defined(WIN32) )
+ if (print_pipe)
+ pclose(output);
+ else
+ fclose(output);
+#else
fclose(output);
-
+#endif
while (clip_){
Clip * c= clip_;
clip_= clip_->prev;
@@ -1153,18 +1163,74 @@
#if ! (defined(__APPLE__) || defined(WIN32) )
int Fl_PS_Printer::start_job(int pages, int *firstpage, int *lastpage) {
- // TODO should start and close a print dialog and
- // transmit the selected paper format to the
Fl_PSfile_Device::start_postscript() call,
- // create a temp .ps file, open it for writing on member var output,
- // and strdup its name to member var ps_filename_
- // return the user's desired page range to the caller and transmit the range
total to start_postscript()
- // terminate by : return Fl_PSfile_Device::start_postscript(pages, format);
- enum Page_Format format = A4; // temporary
+ // TODO:
+ // should start and close a print dialog *DONE*
+ // transmit the selected paper format to
+ // the Fl_PSfile_Device::start_postscript() call *DONE*
+ // create a temp .ps file, open it for writing
+ // on member var output,
+ // and strdup its name to member var ps_filename_ *DONE*
+ // return the user's desired page range to the caller
+ // and transmit the range total to start_postscript() *TODO*
+ // terminate by:
+ // return Fl_PSfile_Device::start_postscript(pages, format); *DONE*
+
+ enum Page_Format format = A4; // default
if(firstpage) *firstpage = 1; // temporary
if(lastpage) *lastpage = pages; // temporary
- return Fl_PSfile_Device::start_job(pages, format); // temporary
+
+ // first test version for print dialog
+
+ if (!print_panel) make_print_panel();
+ print_load();
+ print_selection->deactivate();
+ print_all->setonly();
+ print_all->do_callback();
+ print_panel->show(); // this is modal
+ while (print_panel->shown()) Fl::wait();
+
+ if (!print_start) // user clicked cancel
+ return 1;
+
+ // get options
+
+ format = print_page_size->value() ? A4 : LETTER;
+
+ print_pipe = print_choice->value(); // 0 = print to file, >0 = printer
(pipe)
+
+ const char *media = print_page_size->text(print_page_size->value());
+ const char *printer = (const char
*)print_choice->menu()[print_choice->value()].user_data();
+ if (!print_pipe) printer = "<File>";
+
+ if (!print_pipe) // fall back to file printing
+ return Fl_PSfile_Device::start_job (pages, format);
+
+ // Print: pipe the output into the lp command...
+
+ char command[1024];
+ snprintf(command, sizeof(command), "lp -s -d %s -n %.0f -t '%s' -o media=%s",
+ printer, print_collate_button->value() ? 1.0 :
print_copies->value(),
+ "FLTK", media);
+
+ output = popen(command, "w");
+ if (!output) {
+ fl_alert("could not run command: %s\n",command);
+ return 1;
+ }
+
+ ps_filename_ = strdup("FLTK.ps"); // dummy filename (needed?)
+
+ return Fl_PSfile_Device::start_postscript(pages, format); // start printing
}
+/*
+void print_cb(Fl_Return_Button *, void *) {
+ printf ("print_cb called\n"); fflush(stdout);
+ print_panel->hide();
+ // return Fl_PSfile_Device::start_postscript(pages, format); // temporary
+}
+*/
+
void Fl_PS_Printer::end_job(void)
{
Fl_PSfile_Device::end_job();
Modified: branches/branch-1.3-Fl_Printer/src/Fl_win32.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_win32.cxx 2010-03-05 18:53:00 UTC
(rev 7219)
+++ branches/branch-1.3-Fl_Printer/src/Fl_win32.cxx 2010-03-05 21:05:47 UTC
(rev 7220)
@@ -1941,8 +1941,8 @@
Fl_Window *win = Fl::first_window();
if(!win) return;
int w, h;
- if( printer.start_job(1) ) return;
- if( printer.start_page() ) return;
+ if( printer.start_job(1) ) { o->window()->show(); return; }
+ if( printer.start_page() ) { o->window()->show(); return; }
printer.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
float scale = 1;
@@ -1951,11 +1951,12 @@
if ((float)h/win->h() < scale) scale = (float)h/win->h();
printer.scale(scale, scale);
}
+// #define ROTATE 20.0
#ifdef ROTATE
printer.scale(scale * 0.8, scale * 0.8);
printer.printable_rect(&w, &h);
printer.origin(w/2, h/2 );
- printer.rotate(20.);
+ printer.rotate(ROTATE);
printer.print_widget( win, - win->w()/2, - win->h()/2 );
#else
printer.print_widget( win );
Modified: branches/branch-1.3-Fl_Printer/src/Fl_x.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_x.cxx 2010-03-05 18:53:00 UTC (rev
7219)
+++ branches/branch-1.3-Fl_Printer/src/Fl_x.cxx 2010-03-05 21:05:47 UTC (rev
7220)
@@ -1770,9 +1770,28 @@
Fl_Window *win = Fl::first_window();
if(!win) return;
int w, h;
- if( printer.start_job(1) ) return;
- if( printer.start_page() ) return;
+ if( printer.start_job(1) ) { o->window()->show(); return; }
+ if( printer.start_page() ) { o->window()->show(); return; }
+ printer.printable_rect(&w,&h);
+ // scale the printer device so that the window fits on the page
+ float scale = 1;
+ if (win->w() > w || win->h() > h) {
+ scale = (float)w/win->w();
+ if ((float)h/win->h() < scale) scale = (float)h/win->h();
+ printer.scale(scale, scale);
+ }
+
+// #define ROTATE 20.0
+#ifdef ROTATE
+ printer.scale(scale * 0.8, scale * 0.8);
+ printer.printable_rect(&w, &h);
+ printer.origin(w/2, h/2 );
+ printer.rotate(ROTATE);
+ printer.print_widget( win, - win->w()/2, - win->h()/2 );
+#else
printer.print_widget( win );
+#endif
+
//printer.print_window_part( win, 0,0,win->w(), win->h() );
printer.end_page();
printer.end_job();
@@ -1785,7 +1804,7 @@
if(!first) return;
first=0;
static Fl_Window w(0,0,150,30);
- static Fl_Button b(0,0,w.w(),w.h(), "Front window to PS");
+ static Fl_Button b(0,0,w.w(),w.h(), "Print front window");
b.callback(printFront);
w.end();
w.show();
Added: branches/branch-1.3-Fl_Printer/src/print_panel.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/print_panel.cxx
(rev 0)
+++ branches/branch-1.3-Fl_Printer/src/print_panel.cxx 2010-03-05 21:05:47 UTC
(rev 7220)
@@ -0,0 +1,599 @@
+//
+// "$Id$"
+//
+// Print panel for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2009 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+//
+// This file is "work in progress". The main parts have been copied
+// from fluid's print_panel{.fl|.h|.cxx} and hand-edited to produce
+// a working version w/o global variables. The intention is to move
+// all static variables into an own class, and to name this class
+// Fl_Printer_Chooser or similar...
+//
+// Todo:
+//
+// - Currently preferences can't be saved, and there are options that
+// are not yet used for printing.
+// - This file can only be used as an include file in Fl_PS_Printer.cxx
+// - The use of static variables should be avoided.
+// - Probably much more ...
+//
+
+#include "print_panel.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "../src/flstring.h"
+#include <FL/Fl_Preferences.H>
+
+// extern Fl_Preferences fluid_prefs;
+
+static Fl_Double_Window *print_panel=(Fl_Double_Window *)0;
+static Fl_Group *print_panel_controls=(Fl_Group *)0;
+static Fl_Choice *print_choice=(Fl_Choice *)0;
+static Fl_Button *print_properties=(Fl_Button *)0;
+static Fl_Box *print_status=(Fl_Box *)0;
+static Fl_Round_Button *print_all=(Fl_Round_Button *)0;
+static Fl_Round_Button *print_pages=(Fl_Round_Button *)0;
+static Fl_Round_Button *print_selection=(Fl_Round_Button *)0;
+static Fl_Check_Button *print_collate_button=(Fl_Check_Button *)0;
+static Fl_Group *print_collate_group[2]={(Fl_Group *)0};
+static Fl_Progress *print_progress=(Fl_Progress *)0;
+static Fl_Double_Window *print_properties_panel=(Fl_Double_Window *)0;
+static Fl_Choice *print_page_size=(Fl_Choice *)0;
+static Fl_Input *print_from=(Fl_Input *)0;
+static Fl_Input *print_to=(Fl_Input *)0;
+static Fl_Spinner *print_copies=(Fl_Spinner *)0;
+
+static int print_start = 0; // 1 if print_okay has been clicked
+static int print_pipe = 0; // 0 = file, 1 = pipe (lp)
+
+static void cb_print_choice(Fl_Choice*, void*) {
+ print_update_status();
+}
+
+static void cb_print_properties(Fl_Button*, void*) {
+ print_properties_panel->show();
+}
+
+static void cb_print_all(Fl_Round_Button*, void*) {
+ print_from->deactivate();
+ print_to->deactivate();
+}
+
+static void cb_print_pages(Fl_Round_Button*, void*) {
+ print_from->activate();
+ print_to->activate();
+}
+
+static void cb_print_selection(Fl_Round_Button*, void*) {
+ print_from->deactivate();
+ print_to->deactivate();
+}
+
+static void cb_print_copies(Fl_Spinner*, void*) {
+ if (print_copies->value() == 1) {
+ print_collate_button->deactivate();
+ print_collate_group[0]->deactivate();
+ print_collate_group[1]->deactivate();
+ } else {
+ print_collate_button->activate();
+ print_collate_group[0]->activate();
+ print_collate_group[1]->activate();
+ };
+}
+
+static void cb_print_collate_button(Fl_Check_Button*, void*) {
+ int i = print_collate_button->value() != 0;
+ print_collate_group[i]->show();
+ print_collate_group[1 - i]->hide();
+}
+
+static void cb_Cancel(Fl_Button*, void*) {
+ print_start = 0;
+ print_panel->hide();
+}
+
+static void cb_print_properties_panel(Fl_Double_Window*, void*) {
+ print_properties_panel->hide();
+ print_update_status();
+}
+
+static Fl_Menu_Item menu_print_page_size[] = {
+ {"Letter", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {"A4", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
+#include <FL/Fl_Pixmap.H>
+static const char *idata_print_color[] = {
+"24 24 17 1",
+" \tc None",
+".\tc #FFFF00",
+"+\tc #C8FF00",
+"@\tc #00FF00",
+"#\tc #FFC800",
+"$\tc #FF0000",
+"%\tc #00FFFF",
+"&\tc #000000",
+"*\tc #FF00FF",
+"=\tc #00FFC8",
+"-\tc #FF00C8",
+";\tc #00C800",
+">\tc #C80000",
+",\tc #0000C8",
+"\'\tc #0000FF",
+")\tc #00C8FF",
+"!\tc #C800FF",
+" ...... ",
+" .......... ",
+" ............ ",
+" .............. ",
+" .............. ",
+" ................ ",
+" ................ ",
+" ................ ",
+" +@@@@@@+#$$$$$$# ",
+" %@@@@@@@&&$$$$$$$* ",
+" %%@@@@@@&&&&$$$$$$** ",
+" %%%=@@@@&&&&&&$$$$-*** ",
+" %%%%@@@;&&&&&&>$$$**** ",
+"%%%%%%@@&&&&&&&&$$******",
+"%%%%%%%@&&&&&&&&$*******",
+"%%%%%%%%,&&&&&&,********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+" %%%%%%%)\'\'\'\'\'\'!******* ",
+" %%%%%%%%\'\'\'\'\'\'******** ",
+" %%%%%%%%\'\'\'\'******** ",
+" %%%%%%%%\'\'******** ",
+" %%%%%% ****** "
+};
+static Fl_Pixmap image_print_color(idata_print_color);
+
+static const char *idata_print_gray[] = {
+"24 24 17 1",
+" \tc None",
+".\tc #E3E3E3",
+"+\tc #D2D2D2",
+"@\tc #969696",
+"#\tc #C2C2C2",
+"$\tc #4C4C4C",
+"%\tc #B2B2B2",
+"&\tc #000000",
+"*\tc #696969",
+"=\tc #ACACAC",
+"-\tc #626262",
+";\tc #767676",
+">\tc #3C3C3C",
+",\tc #161616",
+"\'\tc #1C1C1C",
+")\tc #929292",
+"!\tc #585858",
+" ...... ",
+" .......... ",
+" ............ ",
+" .............. ",
+" .............. ",
+" ................ ",
+" ................ ",
+" ................ ",
+" +@@@@@@+#$$$$$$# ",
+" %@@@@@@@&&$$$$$$$* ",
+" %%@@@@@@&&&&$$$$$$** ",
+" %%%=@@@@&&&&&&$$$$-*** ",
+" %%%%@@@;&&&&&&>$$$**** ",
+"%%%%%%@@&&&&&&&&$$******",
+"%%%%%%%@&&&&&&&&$*******",
+"%%%%%%%%,&&&&&&,********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+"%%%%%%%%\'\'\'\'\'\'\'\'********",
+" %%%%%%%)\'\'\'\'\'\'!******* ",
+" %%%%%%%%\'\'\'\'\'\'******** ",
+" %%%%%%%%\'\'\'\'******** ",
+" %%%%%%%%\'\'******** ",
+" %%%%%% ****** "
+};
+static Fl_Pixmap image_print_gray(idata_print_gray);
+
+static Fl_Button *print_output_mode[4]={(Fl_Button *)0};
+
+static void cb_Save(Fl_Return_Button*, void*) {
+ print_properties_panel->hide();
+
+ char name[1024];
+ int val;
+ const char *printer = (const char
*)print_choice->menu()[print_choice->value()].user_data();
+
+ snprintf(name, sizeof(name), "%s/page_size", printer);
+ // fluid_prefs.set(name, print_page_size->value());
+
+ snprintf(name, sizeof(name), "%s/output_mode", printer);
+ for (val = 0; val < 4; val ++) {
+ if (print_output_mode[val]->value()) break;
+ }
+ // fluid_prefs.set(name, val); // FIXME -- save prefs
+}
+
+static void cb_Cancel1(Fl_Button*, void*) {
+ print_properties_panel->hide();
+ print_update_status();
+}
+
+static void cb_Use(Fl_Button*, void*) {
+ print_properties_panel->hide();
+}
+
+Fl_Double_Window* make_print_panel() {
+ { print_panel = new Fl_Double_Window(465, 235, "Print");
+ { print_panel_controls = new Fl_Group(10, 10, 447, 216);
+ { print_choice = new Fl_Choice(113, 10, 181, 25, "Printer:");
+ print_choice->down_box(FL_BORDER_BOX);
+ print_choice->labelfont(1);
+ print_choice->callback((Fl_Callback*)cb_print_choice);
+ print_choice->when(FL_WHEN_CHANGED);
+ } // Fl_Choice* print_choice
+ { print_properties = new Fl_Button(294, 10, 105, 25, "Properties...");
+ print_properties->callback((Fl_Callback*)cb_print_properties);
+ } // Fl_Button* print_properties
+ { print_status = new Fl_Box(111, 41, 288, 17, "printer/job status");
+ print_status->align(Fl_Align(68|FL_ALIGN_INSIDE));
+ } // Fl_Box* print_status
+ { Fl_Group* o = new Fl_Group(10, 86, 227, 105, "Print Range");
+ o->box(FL_THIN_DOWN_BOX);
+ o->labelfont(1);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ { print_all = new Fl_Round_Button(20, 96, 38, 25, "All");
+ print_all->type(102);
+ print_all->down_box(FL_ROUND_DOWN_BOX);
+ print_all->value(1);
+ print_all->callback((Fl_Callback*)cb_print_all);
+ } // Fl_Round_Button* print_all
+ { print_pages = new Fl_Round_Button(20, 126, 64, 25, "Pages");
+ print_pages->type(102);
+ print_pages->down_box(FL_ROUND_DOWN_BOX);
+ print_pages->callback((Fl_Callback*)cb_print_pages);
+ } // Fl_Round_Button* print_pages
+ { print_selection = new Fl_Round_Button(20, 156, 82, 25, "Selection");
+ print_selection->type(102);
+ print_selection->down_box(FL_ROUND_DOWN_BOX);
+ print_selection->callback((Fl_Callback*)cb_print_selection);
+ } // Fl_Round_Button* print_selection
+ { print_from = new Fl_Input(136, 126, 28, 25, "From:");
+ print_from->type(2);
+ print_from->textfont(4);
+ print_from->deactivate();
+ } // Fl_Input* print_from
+ { print_to = new Fl_Input(199, 126, 28, 25, "To:");
+ print_to->type(2);
+ print_to->textfont(4);
+ print_to->deactivate();
+ } // Fl_Input* print_to
+ o->end();
+ } // Fl_Group* o
+ { Fl_Group* o = new Fl_Group(247, 86, 210, 105, "Copies");
+ o->box(FL_THIN_DOWN_BOX);
+ o->labelfont(1);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ { print_copies = new Fl_Spinner(321, 96, 45, 25, "# Copies:");
+ print_copies->callback((Fl_Callback*)cb_print_copies);
+ print_copies->when(FL_WHEN_CHANGED);
+ } // Fl_Spinner* print_copies
+ { print_collate_button = new Fl_Check_Button(376, 96, 64, 25,
"Collate");
+ print_collate_button->down_box(FL_DOWN_BOX);
+
print_collate_button->callback((Fl_Callback*)cb_print_collate_button);
+ print_collate_button->when(FL_WHEN_CHANGED);
+ print_collate_button->deactivate();
+ } // Fl_Check_Button* print_collate_button
+ { print_collate_group[0] = new Fl_Group(257, 131, 191, 50);
+ print_collate_group[0]->deactivate();
+ { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ o->deactivate();
+ } // Fl_Box* o
+ print_collate_group[0]->end();
+ } // Fl_Group* print_collate_group[0]
+ { print_collate_group[1] = new Fl_Group(257, 131, 191, 50);
+ print_collate_group[1]->hide();
+ print_collate_group[1]->deactivate();
+ { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "2");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "1");
+ o->box(FL_BORDER_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ print_collate_group[1]->end();
+ } // Fl_Group* print_collate_group[1]
+ o->end();
+ } // Fl_Group* o
+ { Fl_Return_Button* o = new Fl_Return_Button(309, 201, 70, 25, "Print");
+ o->callback((Fl_Callback*)print_cb);
+ } // Fl_Return_Button* o
+ { Fl_Button* o = new Fl_Button(389, 201, 68, 25, "Cancel");
+ o->callback((Fl_Callback*)cb_Cancel);
+ } // Fl_Button* o
+ print_panel_controls->end();
+ } // Fl_Group* print_panel_controls
+ { print_progress = new Fl_Progress(10, 203, 289, 21);
+ print_progress->selection_color((Fl_Color)4);
+ print_progress->hide();
+ } // Fl_Progress* print_progress
+ print_panel->set_modal();
+ print_panel->end();
+ } // Fl_Double_Window* print_panel
+ { print_properties_panel = new Fl_Double_Window(290, 130, "Printer
Properties");
+ print_properties_panel->callback((Fl_Callback*)cb_print_properties_panel);
+ { print_page_size = new Fl_Choice(110, 10, 80, 25, "Page Size:");
+ print_page_size->down_box(FL_BORDER_BOX);
+ print_page_size->labelfont(1);
+ print_page_size->menu(menu_print_page_size);
+ } // Fl_Choice* print_page_size
+ { Fl_Group* o = new Fl_Group(110, 45, 170, 40, "Output Mode:");
+ o->labelfont(1);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { print_output_mode[0] = new Fl_Button(110, 45, 30, 40);
+ print_output_mode[0]->type(102);
+ print_output_mode[0]->box(FL_BORDER_BOX);
+ print_output_mode[0]->down_box(FL_BORDER_BOX);
+ print_output_mode[0]->value(1);
+ print_output_mode[0]->color(FL_BACKGROUND2_COLOR);
+ print_output_mode[0]->selection_color(FL_FOREGROUND_COLOR);
+ print_output_mode[0]->image(image_print_color);
+ } // Fl_Button* print_output_mode[0]
+ { print_output_mode[1] = new Fl_Button(150, 50, 40, 30);
+ print_output_mode[1]->type(102);
+ print_output_mode[1]->box(FL_BORDER_BOX);
+ print_output_mode[1]->down_box(FL_BORDER_BOX);
+ print_output_mode[1]->color(FL_BACKGROUND2_COLOR);
+ print_output_mode[1]->selection_color(FL_FOREGROUND_COLOR);
+ print_output_mode[1]->image(image_print_color);
+ } // Fl_Button* print_output_mode[1]
+ { print_output_mode[2] = new Fl_Button(200, 45, 30, 40);
+ print_output_mode[2]->type(102);
+ print_output_mode[2]->box(FL_BORDER_BOX);
+ print_output_mode[2]->down_box(FL_BORDER_BOX);
+ print_output_mode[2]->color(FL_BACKGROUND2_COLOR);
+ print_output_mode[2]->selection_color(FL_FOREGROUND_COLOR);
+ print_output_mode[2]->image(image_print_gray);
+ } // Fl_Button* print_output_mode[2]
+ { print_output_mode[3] = new Fl_Button(240, 50, 40, 30);
+ print_output_mode[3]->type(102);
+ print_output_mode[3]->box(FL_BORDER_BOX);
+ print_output_mode[3]->down_box(FL_BORDER_BOX);
+ print_output_mode[3]->color(FL_BACKGROUND2_COLOR);
+ print_output_mode[3]->selection_color(FL_FOREGROUND_COLOR);
+ print_output_mode[3]->image(image_print_gray);
+ } // Fl_Button* print_output_mode[3]
+ o->end();
+ } // Fl_Group* o
+ { Fl_Return_Button* o = new Fl_Return_Button(123, 95, 79, 25, "Save");
+ o->callback((Fl_Callback*)cb_Save);
+ } // Fl_Return_Button* o
+ { Fl_Button* o = new Fl_Button(212, 95, 68, 25, "Cancel");
+ o->callback((Fl_Callback*)cb_Cancel1);
+ } // Fl_Button* o
+ { Fl_Button* o = new Fl_Button(60, 95, 53, 25, "Use");
+ o->callback((Fl_Callback*)cb_Use);
+ } // Fl_Button* o
+ print_properties_panel->set_modal();
+ print_properties_panel->end();
+ } // Fl_Double_Window* print_properties_panel
+ return print_properties_panel;
+}
+
+void print_cb(Fl_Return_Button *, void *) {
+ print_start = 1;
+ print_panel->hide();
+}
+
+void print_load() {
+ FILE *lpstat;
+ char line[1024], name[1024], *nptr, qname[2048], *qptr, defname[1024];
+ int i;
+
+ if (print_choice->size() > 1) {
+ for (i = 1; print_choice->text(i); i ++) {
+ free(print_choice->menu()[i].user_data());
+ }
+ }
+
+ print_choice->clear();
+ print_choice->add("Print To File", 0, 0, 0, FL_MENU_DIVIDER);
+ print_choice->value(0);
+
+ print_start = 0;
+
+ defname[0] = '\0';
+
+ if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) {
+ while (fgets(line, sizeof(line), lpstat)) {
+ if (!strncmp(line, "printer ", 8) &&
+ sscanf(line + 8, "%s", name) == 1) {
+ for (nptr = name, qptr = qname; *nptr; *qptr++ = *nptr++) {
+ if (*nptr == '/') *qptr++ = '\\';
+ }
+ *qptr = '\0';
+
+ print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
+ } else if (!strncmp(line, "system default destination: ", 28)) {
+ if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\0';
+ }
+ }
+ pclose(lpstat);
+ }
+
+ if (defname[0]) {
+ for (i = 1; print_choice->text(i); i ++) {
+ if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) {
+ print_choice->value(i);
+ break;
+ }
+ }
+ } else if (print_choice->size() > 2) print_choice->value(1);
+
+ print_update_status();
+
+} // print_load()
+
+void print_update_status() {
+ FILE *lpstat;
+ char command[1024];
+ static char status[1024];
+ const char *printer = (const char
*)print_choice->menu()[print_choice->value()].user_data();
+
+ if (print_choice->value()) {
+ snprintf(command, sizeof(command), "lpstat -p '%s'", printer);
+ if ((lpstat = popen(command, "r")) != NULL) {
+ fgets(status, sizeof(status), lpstat);
+ pclose(lpstat);
+ } else strcpy(status, "printer status unavailable");
+ } else status[0] = '\0';
+
+ print_status->label(status);
+
+ char name[1024];
+ // int val;
+ int val = 0; // FIXME -- see below: read preferences !
+
+ snprintf(name, sizeof(name), "%s/page_size", printer);
+ // fluid_prefs.get(name, val, 0);
+ print_page_size->value(val);
+
+ snprintf(name, sizeof(name), "%s/output_mode", printer);
+ // fluid_prefs.get(name, val, 0);
+ print_output_mode[val]->setonly();
+}
+
+//
+// End of "$Id$".
+//
Property changes on: branches/branch-1.3-Fl_Printer/src/print_panel.cxx
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
Added: branches/branch-1.3-Fl_Printer/src/print_panel.h
===================================================================
--- branches/branch-1.3-Fl_Printer/src/print_panel.h
(rev 0)
+++ branches/branch-1.3-Fl_Printer/src/print_panel.h 2010-03-05 21:05:47 UTC
(rev 7220)
@@ -0,0 +1,55 @@
+//
+// "$Id$"
+//
+// Print panel for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2009 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+//
+// This is a temporary file. It is only for development and will
+// probably be removed later.
+//
+
+#ifndef print_panel_h
+#define print_panel_h
+#include <FL/Fl.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Round_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Spinner.H>
+#include <FL/Fl_Check_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Progress.H>
+static Fl_Double_Window* make_print_panel();
+static void print_cb(Fl_Return_Button *, void *);
+static void print_load();
+static void print_update_status();
+#endif
+
+//
+// End of "$Id$".
+//
Property changes on: branches/branch-1.3-Fl_Printer/src/print_panel.h
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
Modified: branches/branch-1.3-Fl_Printer/test/device.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/test/device.cxx 2010-03-05 18:53:00 UTC
(rev 7219)
+++ branches/branch-1.3-Fl_Printer/test/device.cxx 2010-03-05 21:05:47 UTC
(rev 7220)
@@ -720,13 +720,7 @@
c2->end();
- Fl_Button *b4 = new Fl_Button(10,5, 150, 25,
-#if defined(__APPLE__) || defined(WIN32)
- "Print"
-#else
- "Save to PostScript file"
-#endif
- );
+ Fl_Button *b4 = new Fl_Button(10,5, 150, 25, "Print");
b4->callback(print,c2);
/*Fl_Button *b5 = new Fl_Button(165,5, 90, 25, "Print");
b5->tooltip("This is a tooltip");
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit