diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-21 17:34:03 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-21 17:34:03 +0000 |
| commit | 880928146d1022fdd5e6a9a79130cd7c55adf8da (patch) | |
| tree | 82374803b7dbe11455ced2422033c5eaa15007b3 | |
| parent | 562198fa3131684e7911ce8c8b0082bbbc617671 (diff) | |
Image reading, template handling, and printing bug fixes.
CHANGES:
- Add fl_read_image() note and move documentation STRs back
to the top of the list...
fluid/fluid.cxx:
- Use printer choice data instead of the label text, since
we have to escape / in printer names.
- Change page number in header to n/N.
fluid/print_panel.*:
- Don't disable properties button, ever.
- Quote / in printer names.
- Put copy of real printer name in the user data.
- Use user data instead of label text for printer name.
fluid/template_panel.*:
- Only free the files array if num_files > 0.
src/fl_read_image.cxx:
- Use fl_visual->visual->*_mask instead of fl_*mask and
fl_*shift when the XGetImage() data does not have them
set.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4157 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 9 | ||||
| -rw-r--r-- | fluid/fluid.cxx | 10 | ||||
| -rw-r--r-- | fluid/print_panel.cxx | 38 | ||||
| -rw-r--r-- | fluid/print_panel.fl | 47 | ||||
| -rw-r--r-- | fluid/template_panel.cxx | 2 | ||||
| -rw-r--r-- | fluid/template_panel.fl | 7 | ||||
| -rw-r--r-- | src/fl_read_image.cxx | 20 |
7 files changed, 83 insertions, 50 deletions
@@ -1,10 +1,13 @@ CHANGES IN FLTK 1.1.7 - - Fixed Quickdraw drawing of 3 and 4 sided polygons (STR #765) - - Fixed fl_message code so that it does not get accidentaly - addded to the current group (STR #253) - Documentation fixes (STR #648, STR #692, STR #730, STR #744, STR #745) + - fl_read_image() didn't use the right red, green, and + blue masks on XFree86. + - Fixed Quickdraw drawing of 3 and 4 sided polygons (STR + #765) + - Fixed fl_message code so that it does not get + accidentaly addded to the current group (STR #253) - FLUID now highlights code in the widget callback and code editors. - FLUID now supports printing of windows. diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 76fd2845e..069828b49 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -922,9 +922,10 @@ void print_cb(Fl_Return_Button *, void *) { // Open the print stream... if (print_choice->value()) { // Pipe the output into the lp command... + const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data(); + snprintf(command, sizeof(command), "lp -s -d %s -n %d -t '%s' -o media=%s", - print_choice->text(print_choice->value()), - print_collate_button->value() ? 1 : print_copies->value(), + printer, print_collate_button->value() ? 1 : print_copies->value(), basename, print_page_size->text(print_page_size->value())); outfile = popen(command, "w"); } else { @@ -934,6 +935,7 @@ void print_cb(Fl_Return_Button *, void *) { fl_ok = "OK"; if (outname) outfile = fopen(outname, "w"); + else outfile = NULL; } if (outfile) { @@ -1038,10 +1040,10 @@ void print_cb(Fl_Return_Button *, void *) { "/Helvetica findfont 14 scalefont setfont\n" "%d %d moveto (%s) show\n" "%.1f %d moveto (%s) dup stringwidth pop -0.5 mul 0 rmoveto show\n" - "%d %d moveto (%d) dup stringwidth pop neg 0 rmoveto show\n", + "%d %d moveto (%d/%d) dup stringwidth pop neg 0 rmoveto show\n", left, top - 15, basename, 0.5 * (left + right), top - 15, date, - right, top - 15, winpage + 1); + right, top - 15, winpage + 1, num_windows); // Get window image... uchar *pixels; // Window image data diff --git a/fluid/print_panel.cxx b/fluid/print_panel.cxx index 0625c9628..fcc9d5a49 100644 --- a/fluid/print_panel.cxx +++ b/fluid/print_panel.cxx @@ -222,11 +222,12 @@ static void cb_Save(Fl_Return_Button*, void*) { 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", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/page_size", printer); fluid_prefs.set(name, print_page_size->value()); -snprintf(name, sizeof(name), "%s/output_mode", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/output_mode", printer); for (val = 0; val < 4; val ++) { if (print_output_mode[val]->value()) break; } @@ -505,22 +506,31 @@ void print_cb(Fl_Return_Button *, void *); void print_load() { FILE *lpstat; -char line[1024], name[1024], defname[1024]; +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_properties->deactivate(); - defname[0] = '\0'; if ((lpstat = popen("lpstat -p -d", "r")) != NULL) { while (fgets(line, sizeof(line), lpstat)) { if (!strncmp(line, "printer ", 8) && sscanf(line + 8, "%s", name) == 1) { - print_choice->add(name, 0, 0, (void *)name, 0); + 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'; } @@ -530,16 +540,12 @@ if ((lpstat = popen("lpstat -p -d", "r")) != NULL) { if (defname[0]) { for (i = 1; print_choice->text(i); i ++) { - if (!strcmp(print_choice->text(i), defname)) { + if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) { print_choice->value(i); - print_properties->activate(); break; } } -} else if (print_choice->size() > 2) { - print_choice->value(1); - print_properties->activate(); -} +} else if (print_choice->size() > 2) print_choice->value(1); print_update_status(); @@ -549,10 +555,10 @@ 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'", - print_choice->text(print_choice->value())); + snprintf(command, sizeof(command), "lpstat -p '%s'", printer); if ((lpstat = popen(command, "r")) != NULL) { fgets(status, sizeof(status), lpstat); pclose(lpstat); @@ -564,11 +570,11 @@ print_status->label(status); char name[1024]; int val; -snprintf(name, sizeof(name), "%s/page_size", print_choice->text(print_choice->value())); +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", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/output_mode", printer); fluid_prefs.get(name, val, 0); print_output_mode[val]->setonly(); } diff --git a/fluid/print_panel.fl b/fluid/print_panel.fl index bd931f4c1..1500d243f 100644 --- a/fluid/print_panel.fl +++ b/fluid/print_panel.fl @@ -52,7 +52,7 @@ Function {make_print_panel()} {open } { Fl_Choice print_choice { label {Printer:} - callback {print_update_status();} open selected + callback {print_update_status();} open xywh {113 10 181 25} down_box BORDER_BOX labelfont 1 when 1 } {} Fl_Button print_properties { @@ -235,7 +235,7 @@ print_update_status();} open } } Fl_Group {} { - label {Output Mode:} open + label {Output Mode:} xywh {110 45 170 40} labelfont 1 align 4 } { Fl_Button {print_output_mode[0]} { @@ -257,11 +257,12 @@ print_update_status();} open 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", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/page_size", printer); fluid_prefs.set(name, print_page_size->value()); -snprintf(name, sizeof(name), "%s/output_mode", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/output_mode", printer); for (val = 0; val < 4; val ++) { if (print_output_mode[val]->value()) break; } @@ -280,25 +281,34 @@ print_update_status();} decl {void print_cb(Fl_Return_Button *, void *);} {public } -Function {print_load()} {return_type void +Function {print_load()} {open return_type void } { code {FILE *lpstat; -char line[1024], name[1024], defname[1024]; +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_properties->deactivate(); - defname[0] = '\\0'; if ((lpstat = popen("lpstat -p -d", "r")) != NULL) { while (fgets(line, sizeof(line), lpstat)) { if (!strncmp(line, "printer ", 8) && sscanf(line + 8, "%s", name) == 1) { - print_choice->add(name, 0, 0, (void *)name, 0); + 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'; } @@ -308,16 +318,12 @@ if ((lpstat = popen("lpstat -p -d", "r")) != NULL) { if (defname[0]) { for (i = 1; print_choice->text(i); i ++) { - if (!strcmp(print_choice->text(i), defname)) { + if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) { print_choice->value(i); - print_properties->activate(); break; } } -} else if (print_choice->size() > 2) { - print_choice->value(1); - print_properties->activate(); -} +} else if (print_choice->size() > 2) print_choice->value(1); print_update_status();} {} @@ -328,10 +334,10 @@ Function {print_update_status()} {open return_type void code {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'", - print_choice->text(print_choice->value())); + snprintf(command, sizeof(command), "lpstat -p '%s'", printer); if ((lpstat = popen(command, "r")) != NULL) { fgets(status, sizeof(status), lpstat); pclose(lpstat); @@ -343,13 +349,14 @@ print_status->label(status); char name[1024]; int val; -snprintf(name, sizeof(name), "%s/page_size", print_choice->text(print_choice->value())); +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", print_choice->text(print_choice->value())); +snprintf(name, sizeof(name), "%s/output_mode", printer); fluid_prefs.get(name, val, 0); -print_output_mode[val]->setonly();} {} +print_output_mode[val]->setonly();} {selected + } } comment { diff --git a/fluid/template_panel.cxx b/fluid/template_panel.cxx index 3dd57c3e9..a64bdcfc8 100644 --- a/fluid/template_panel.cxx +++ b/fluid/template_panel.cxx @@ -257,7 +257,7 @@ for (i = 0; i < num_files; i ++) { free(files[i]); } -if (files) free(files); +if (num_files > 0) free(files); } // diff --git a/fluid/template_panel.fl b/fluid/template_panel.fl index 5267ea39d..6074d2d9b 100644 --- a/fluid/template_panel.fl +++ b/fluid/template_panel.fl @@ -67,7 +67,7 @@ template_preview->image(0); template_browser->deselect(); template_name->value(""); template_instance->value(""); -template_panel->hide();} open selected +template_panel->hide();} open xywh {340 237 460 355} type Double resizable modal visible } { Fl_Browser template_browser { @@ -208,7 +208,7 @@ template_browser->remove(item); template_browser->do_callback();} {} } -Function {template_load()} {return_type void +Function {template_load()} {open return_type void } { code {int i; char name[1024], filename[1024], path[1024], *ptr; @@ -239,7 +239,8 @@ for (i = 0; i < num_files; i ++) { free(files[i]); } -if (files) free(files);} {} +if (num_files > 0) free(files);} {selected + } } comment { diff --git a/src/fl_read_image.cxx b/src/fl_read_image.cxx index 71afda059..e0405328f 100644 --- a/src/fl_read_image.cxx +++ b/src/fl_read_image.cxx @@ -111,6 +111,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate printf("red_mask = %08x\n", image->red_mask); printf("green_mask = %08x\n", image->green_mask); printf("blue_mask = %08x\n", image->blue_mask); + printf("map_entries = %d\n", fl_visual->visual->map_entries); #endif // DEBUG d = alpha ? 4 : 3; @@ -124,9 +125,22 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate // Check that we have valid mask/shift values... if (!image->red_mask && image->bits_per_pixel > 12) { // Greater than 12 bits must be TrueColor... - image->red_mask = fl_redmask << fl_redshift; - image->green_mask = fl_greenmask << fl_greenshift; - image->blue_mask = fl_bluemask << fl_blueshift; + image->red_mask = fl_visual->visual->red_mask; + image->green_mask = fl_visual->visual->green_mask; + image->blue_mask = fl_visual->visual->blue_mask; + +#ifdef DEBUG + puts("\n---- UPDATED ----"); + printf("fl_redmask = %08x\n", fl_redmask); + printf("fl_redshift = %d\n", fl_redshift); + printf("fl_greenmask = %08x\n", fl_greenmask); + printf("fl_greenshift = %d\n", fl_greenshift); + printf("fl_bluemask = %08x\n", fl_bluemask); + printf("fl_blueshift = %d\n", fl_blueshift); + printf("red_mask = %08x\n", image->red_mask); + printf("green_mask = %08x\n", image->green_mask); + printf("blue_mask = %08x\n", image->blue_mask); +#endif // DEBUG } // Check if we have colormap image... |
