25 #define awt_assert(cond) arb_assert(cond)
29 #define AWAR_CANIO "NT/print/"
30 #define AWAR_CANIO_LANDSCAPE AWAR_CANIO "landscape"
31 #define AWAR_CANIO_CLIP AWAR_CANIO "clip"
32 #define AWAR_CANIO_HANDLES AWAR_CANIO "handles"
33 #define AWAR_CANIO_COLOR AWAR_CANIO "color"
34 #define AWAR_CANIO_DEST AWAR_CANIO "dest"
35 #define AWAR_CANIO_PRINTER AWAR_CANIO "printer"
36 #define AWAR_CANIO_OVERLAP_WANTED AWAR_CANIO "overlap"
37 #define AWAR_CANIO_OVERLAP_PERCENT AWAR_CANIO "operc"
38 #define AWAR_CANIO_BORDERSIZE AWAR_CANIO "border"
39 #define AWAR_CANIO_PAPER AWAR_CANIO "paper"
40 #define AWAR_CANIO_PAPER_USABLE AWAR_CANIO "useable"
41 #define AWAR_CANIO_F2DBUG AWAR_CANIO "f2dbug"
42 #define AWAR_CANIO_PAGES AWAR_CANIO "pages"
43 #define AWAR_CANIO_PAGELOCK AWAR_CANIO "plock"
45 #define AWAR_CANIO_TMP "tmp/" AWAR_CANIO
47 #define AWAR_CANIO_MAGNIFICATION AWAR_CANIO_TMP "magnification"
48 #define AWAR_CANIO_OVERLAP AWAR_CANIO_TMP "overlap"
49 #define AWAR_CANIO_GFX_SX AWAR_CANIO_TMP "gsizex" // graphic size in inch
50 #define AWAR_CANIO_GFX_SY AWAR_CANIO_TMP "gsizey"
51 #define AWAR_CANIO_OUT_SX AWAR_CANIO_TMP "osizex" // output size in inch
52 #define AWAR_CANIO_OUT_SY AWAR_CANIO_TMP "osizey"
53 #define AWAR_CANIO_PAPER_SX AWAR_CANIO_TMP "psizex" // paper size in inch
54 #define AWAR_CANIO_PAPER_SY AWAR_CANIO_TMP "psizey"
55 #define AWAR_CANIO_PAGE_SX AWAR_CANIO_TMP "sizex" // size in pages
56 #define AWAR_CANIO_PAGE_SY AWAR_CANIO_TMP "sizey"
58 #define AWAR_CANIO_FILE_BASE AWAR_CANIO_TMP "file"
59 #define AWAR_CANIO_FILE_NAME AWAR_CANIO_FILE_BASE "/file_name"
60 #define AWAR_CANIO_FILE_DIR AWAR_CANIO_FILE_BASE "/directory"
61 #define AWAR_CANIO_FILE_FILTER AWAR_CANIO_FILE_BASE "/filter"
80 const char *description;
81 const char *fig2dev_val;
83 float shortSide, longSide;
90 shortSide(shortSide_),
99 shortSide(shortSide_),
156 size_device->
reset();
170 float borderratio = border_percent*.01;
171 float draw2bordersize = -borderratio/(borderratio-1.0);
190 return int(sx+0.99)*
int(sy+0.99);
215 float usableSize = 0;
217 if (wantOverlap && wantedpages>1) {
219 float usableRatio = (100.0-overlapPercent)/100.0;
229 usableSize = wantedpages*papersize*usableRatio;
232 usableSize = (papersize*usableRatio)*(wantedpages-1)+papersize;
236 usableSize = wantedpages*papersize;
239 return usableSize*100/gfxsize;
256 int best_orientation = -1;
257 const char *best_zoom_awar_name =
NULp;
259 int best_magnification = 0;
265 if (!allow_orientation_change) {
269 for (
int o = 0; o <= 1; ++o) {
270 if (!allow_orientation_change && o != best_orientation)
continue;
274 for (
int xy = 0; xy <= 1; ++xy) {
277 for (
int pcount = 1; pcount <= wanted_pages; pcount++) {
278 float zoom = pcount*1.0;
287 if (pages>wanted_pages)
break;
289 if (pages <= wanted_pages && pages >= best_pages) {
291 if (magnification>best_magnification) {
293 best_magnification = magnification;
294 best_orientation = o;
295 best_zoom_awar_name = awar_name;
304 if (best_zoom_awar_name) {
311 if (best_pages != wanted_pages) {
313 wanted_pages, best_pages));
333 if (landscape != (px>py)) {
344 float ox = (gx*magnification)/100;
345 float oy = (gy*magnification)/100;
355 bool fits_on_one_page = (ox <= px && oy <= py);
357 if (wantOverlap && !fits_on_one_page) {
359 float pageRatio = (100.0-overlapPercent)/100.0;
361 float rpx = px*pageRatio;
362 float rpy = py*pageRatio;
364 while (ox>px) { ox -= rpx; sx += 1.0; }
379 while (oy>py) { oy -= rpy; sy += 1.0; }
401 bool willUseOverlap = wantOverlap && (pages != 1);
402 if (willUseOverlap != useOverlap) {
460 if (strcmp(current_filter, filter) != 0) {
464 free(current_filter);
502 char *print_command = getenv(
"PRINTER")
521 const char *checked_awars[] = {
531 for (
int ca = 0; checked_awars[ca]; ca++) {
556 device->set_color_mode(use_color);
569 world_drawsize = device->rtransform(drawsize);
572 Vector offset = device->rtransform(ulc2origin)*device->get_unscale();
574 device->set_offset(offset);
576 device->set_bottom_clip_border((
int)(with_border.
height()+1),
true);
577 device->set_right_clip_border((
int)(with_border.
width()+1),
true);
581 world_drawsize = device->rtransform(drawsize);
588 device->set_filter(filter);
591 if (add_invisibles) {
599 bool drawnUL =
false;
600 bool drawnLR =
false;
602 while (!(drawnLR && drawnUL) && maxloop-->0) {
604 drawnUL = device->invisible(ul);
608 drawnLR = device->invisible(lr);
628 error =
"Please enter a file name";
654 FILE *out = fopen(dest,
"w");
679 progress.
subtitle(
"Exporting Data");
691 progress.
subtitle(
"Converting to Postscript");
709 cmd.
nprintf(20,
" -m %f", magnification);
710 cmd.
cat(landscape ?
" -l 0" :
" -p 0");
714 cmd.
put(
' '); cmd.
cat(xfig);
715 cmd.
put(
' '); cmd.
cat(quotedDest);
747 #if defined(DEBUG) && 0
750 #else // !defined(DEBUG)
766 static AW_window_simple *aws =
NULp;
773 aws =
new AW_window_simple;
774 aws->init(awr,
"EXPORT_TREE_AS_XFIG",
"EXPORT TREE TO XFIG");
775 aws->load_xfig(
"awt/export.fig");
778 aws->create_button(
"CLOSE",
"CLOSE",
"C");
781 aws->create_button(
"HELP",
"HELP",
"H");
783 aws->label_length(15);
789 aws->insert_toggle(
"#print/clipscreen.xpm",
"S", 0);
790 aws->insert_toggle(
"#print/clipall.xpm",
"A", 1);
791 aws->update_toggle_field();
793 aws->at(
"remove_root");
795 aws->insert_toggle(
"#print/nohandles.xpm",
"S", 0);
796 aws->insert_toggle(
"#print/handles.xpm",
"A", 1);
797 aws->update_toggle_field();
800 aws->label(
"Export colors");
804 aws->create_autosize_button(
"START_XFIG",
"EXPORT to XFIG",
"X");
811 static AW_window_simple *aws =
NULp;
818 aws =
new AW_window_simple;
819 aws->init(awr,
"EXPORT_TREE_AS_XFIG",
"EXPORT STRUCTURE TO XFIG");
820 aws->load_xfig(
"awt/secExport.fig");
824 aws->create_button(
"CLOSE",
"CLOSE",
"C");
828 aws->create_button(
"HELP",
"HELP",
"H");
830 aws->label_length(15);
834 aws->label(
"Clip Options");
836 aws->insert_option(
"Export screen only",
"s", 0);
837 aws->insert_default_option(
"Export complete structure",
"c", 1);
838 aws->update_option_menu();
841 aws->label(
"Export colors");
846 aws->create_autosize_button(
"START_XFIG",
"EXPORT to XFIG",
"X");
857 if (wanted_pages<=0) {
865 static AW_window_simple *aws =
NULp;
871 aws =
new AW_window_simple;
872 aws->init(awr,
"PRINT_CANVAS",
"PRINT GRAPHIC");
873 aws->load_xfig(
"awt/print.fig");
876 aws->create_button(
"CLOSE",
"CLOSE",
"C");
879 aws->create_button(
"HELP",
"HELP",
"H");
884 aws->label_length(15);
888 aws->insert_toggle(
"#print/clipscreen.xpm",
"S", 0);
889 aws->insert_toggle(
"#print/clipall.xpm",
"A", 1);
890 aws->update_toggle_field();
892 aws->at(
"remove_root");
894 aws->insert_toggle(
"#print/nohandles.xpm",
"S", 0);
895 aws->insert_toggle(
"#print/handles.xpm",
"A", 1);
896 aws->update_toggle_field();
899 aws->label(
"Export colors");
907 aws->create_autosize_button(
"GetGfxSize",
"Get Graphic Size");
909 aws->button_length(6);
915 aws->at(
"magnification");
918 aws->label_length(0);
919 aws->at(
"orientation");
921 aws->insert_toggle(
"#print/landscape.xpm",
"L", 1);
922 aws->insert_toggle(
"#print/portrait.xpm",
"P", 0);
923 aws->update_toggle_field();
935 aws->insert_default_option(knownPaperFormat[0].get_description(),
"", 0);
940 aws->update_option_menu();
957 aws->create_autosize_button(
"fit_on",
"Fit on");
965 aws->button_length(1);
968 for (
int p = 1; p <= 9; ++p) {
970 if (aws->at_ifdef(name)) {
973 aws->create_button(name, name+1);
990 aws->label_length(12);
995 aws->update_toggle_field();
1000 aws->at(
"filename");
1006 aws->create_autosize_button(
"PRINT",
"PRINT",
"P");
static void fit_pages(AW_root *awr, int wanted_pages, bool allow_orientation_change)
GB_ERROR GBK_system(const char *system_command)
AW_device_print * get_print_device(AW_area area)
static void rows_changed_cb(AW_window *aww)
#define AWAR_CANIO_BORDERSIZE
#define AWAR_CANIO_FILE_FILTER
double round_psize(double psize)
void AWT_popup_tree_export_window(AW_window *parent_win, AWT_canvas *scr)
static Rectangle get_drawsize(AWT_canvas *scr, bool draw_all)
#define AWAR_CANIO_PAPER_USABLE
const AW_bitset AW_PRINTER_CLIP
const AW_bitset AW_PRINTER_EXT
AliDataPtr format(AliDataPtr data, const size_t wanted_len, GB_ERROR &error)
#define AWAR_CANIO_OVERLAP_WANTED
const AW_screen_area & get_area_size() const
#define AWAR_CANIO_MAGNIFICATION
void GB_unlink_or_warn(const char *path, GB_ERROR *error)
#define AWAR_CANIO_PAPER_SY
void AW_create_standard_fileselection(AW_window *aws, const char *awar_prefix)
#define AWAR_CANIO_FILE_BASE
char * ARB_strdup(const char *str)
AW_awar * set_minmax(float min, float max)
GB_ERROR GB_export_IO_error(const char *action, const char *filename)
#define AWAR_CANIO_PAPER_SX
#define AWAR_CANIO_OVERLAP_PERCENT
const char * GBS_global_string(const char *templat,...)
char * AW_get_selected_fullname(AW_root *awr, const char *awar_prefix)
#define AWAR_CANIO_PRINTER
void AW_POPDOWN(AW_window *window)
void set_paper_size_xy(AW_root *awr, float px, float py)
void cat(const char *from)
static void create_print_awars(AW_root *awr, AWT_canvas *scr)
#define AWAR_CANIO_PAGE_SX
static void columns_changed_cb(AW_window *aww)
#define ARRAY_ELEMS(array)
GB_CSTR GB_getenvARB_GS(void)
float inch2mm(float inches)
static const float mm_per_inch
static Rectangle add_border_to_drawsize(const Rectangle &drawsize, float border_percent)
AW_device_size * get_size_device(AW_area area)
AW_awar * add_callback(const RootCallback &cb)
struct Unfixed_cb_parameter * UNFIXED
void AWT_popup_sec_export_window(AW_window *parent_win, AWT_canvas *scr)
#define AWAR_CANIO_OVERLAP
const AW_bitset AW_PRINTER
GB_ERROR GB_await_error()
#define AWAR_CANIO_F2DBUG
WindowCallback makeHelpCallback(const char *helpfile)
char * GB_create_tempfile(const char *name)
#define AWAR_CANIO_PAGE_SY
#define AWAR_CANIO_GFX_SX
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
#define AWAR_CANIO_PAGELOCK
#define AWAR_CANIO_FILE_NAME
static GB_ERROR canvas_to_xfig(AWT_canvas *scr, const char *xfig_name, bool add_invisibles, float border)
static void error(const char *msg)
const Position & upper_left_corner() const
int xy2pages(float sx, float sy)
char * read_string() const
AW_awar * awar(const char *awar)
const Vector & diagonal() const
#define AWAR_CANIO_LANDSCAPE
#define AWAR_CANIO_HANDLES
static void set_mag_from_psize(AW_root *awr, bool use_x)
char * GB_unique_filename(const char *name_prefix, const char *suffix)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
static void canvas_to_xfig_and_run_xfig(AW_window *aww, AWT_canvas *scr)
char * GBK_singlequote(const char *arg)
static PaperFormat knownPaperFormat[]
void get_size_information(AW_world *ptr) const __ATTR__DEPRECATED_TODO("whole AW_world is deprecated")
void nprintf(size_t maxlen, const char *templat,...) __ATTR__FORMAT_MEMBER(2)
#define AWAR_CANIO_OUT_SX
void subtitle(const char *stitle)
void AWT_popup_print_window(AW_window *parent_win, AWT_canvas *scr)
void init_device(AW_device *device)
static void paper_changed_cb(AW_root *awr)
static void page_size_check_cb(AW_root *awr)
void aw_message(const char *msg)
#define AWAR_CANIO_FILE_DIR
char * GBS_eval_env(GB_CSTR p)
void set_filter(AW_bitset filteri)
static void fit_pages_cb(AW_window *aww, int wanted_pages)
static bool allow_overlap_toggled_cb
GB_ERROR write_string(const char *aw_string)
static void canvas_to_printer(AW_window *aww, AWT_canvas *scr)
const char * get_data() const
#define AWAR_CANIO_OUT_SY
Position lower_right_corner() const
GB_transaction ta(gb_var)
static void create_fig_export_awars(AW_root *awr)
static bool print_awars_created
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
#define AWAR_CANIO_GFX_SY
GB_ERROR write_float(float aw_float)
static bool allow_page_size_check_cb
static void resetFiletype(AW_root *awr, const char *filter, const char *defaultFilename)
static void overlap_toggled_cb(AW_root *awr)
GB_ERROR write_int(long aw_int)
static bool export_awars_created
static long calc_mag_from_psize(AW_root *awr, float papersize, float gfxsize, float wantedpages, bool use_x)
static void awt_print_tree_check_size(UNFIXED, AWT_canvas *scr)
bool GB_is_privatefile(const char *path, bool read_private)
virtual void show(AW_device *device)=0