diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GsWidget.H | 2 | ||||
-rw-r--r-- | src/GsWidget.cxx | 9 | ||||
-rw-r--r-- | src/flpsed.cxx | 40 |
3 files changed, 49 insertions, 2 deletions
diff --git a/src/GsWidget.H b/src/GsWidget.H index 9fb6372..659bc69 100644 --- a/src/GsWidget.H +++ b/src/GsWidget.H @@ -81,6 +81,8 @@ public: int get_page(); + int get_pages(); + private: void setProps(); diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx index 6f5eb44..7dded29 100644 --- a/src/GsWidget.cxx +++ b/src/GsWidget.cxx @@ -416,3 +416,12 @@ int GsWidget::zoom(int p) { return 0; } + +int +GsWidget::get_pages() { + if (dsc) { + return dsc->get_pages(); + } else { + return 0; + } +} diff --git a/src/flpsed.cxx b/src/flpsed.cxx index deb2579..391134c 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -40,6 +40,7 @@ #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Color_Chooser.H> +#include <FL/Fl_Hold_Browser.H> #include "PSEditor.H" #include "util.h" @@ -47,6 +48,7 @@ PSEditor *psed_p = NULL; Fl_Scroll *scroll = NULL; +Fl_Hold_Browser *page_sel = NULL; int xev_handler(int ev) { if (psed_p) { @@ -76,6 +78,31 @@ int check_save(void) { char filename[256] = ""; + +void page_sel_cb(Fl_Widget *w, void *) { + int p = page_sel->value() - 1; + if (p >= 0) { + psed_p->load_page(page_sel->value() - 1); + } +} + +void page_sel_fill() { + char buf[64]; + int p = psed_p->get_pages(); + + page_sel->clear(); + + if (p == 0) { + return; + } + + for(int i=1; i<=p; i++) { + snprintf(buf, sizeof(buf), "%d", i); + page_sel->add(buf); + } + page_sel->select(psed_p->get_page() + 1); +} + void open_cb() { if (!check_save()) return; char *file = fl_file_chooser("Open File?", "*.ps", filename); @@ -83,9 +110,11 @@ void open_cb() { psed_p->open_file(file); psed_p->load(); + page_sel_fill(); } } + void import_pdf_cb() { char *file; FILE *p; @@ -105,6 +134,8 @@ void import_pdf_cb() { if (p) { psed_p->open_file(p); + psed_p->load(); + page_sel_fill(); fclose(p); waitpid(pid, &status, 0); if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { @@ -165,10 +196,12 @@ void import_cb() { void first_cb() { psed_p->load(); + page_sel->select(psed_p->get_page() + 1); } void next_cb() { psed_p->next(); + page_sel->select(psed_p->get_page() + 1); } void quit_cb() { @@ -512,8 +545,10 @@ int main(int argc, char** argv) { color_b->shortcut(FL_ALT + 'c'); color_b->tooltip("Text Color"); props.end(); - - scroll = new Fl_Scroll(0, 55, win->w(), win->h()-55); + page_sel = new Fl_Hold_Browser(0, 55, 40, win->h()-55); + page_sel->callback(page_sel_cb); + page_sel->end(); + scroll = new Fl_Scroll(40, 55, win->w()-40, win->h()-55); psed_p = new PSEditor(0, 0, 700, 900); psed_p->property_changed_callback(property_changed_cb); scroll->end(); @@ -530,6 +565,7 @@ int main(int argc, char** argv) { if (in_fp) { psed_p->open_file(in_fp); psed_p->load(); + page_sel_fill(); fclose(in_fp); } |