diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_fl_copy_surface.cpp | 2 | ||||
-rw-r--r-- | src/c_fl_copy_surface.h | 7 | ||||
-rw-r--r-- | src/c_fl_image_surface.cpp | 2 | ||||
-rw-r--r-- | src/c_fl_image_surface.h | 7 | ||||
-rw-r--r-- | src/c_fl_paged_device.cpp | 48 | ||||
-rw-r--r-- | src/c_fl_paged_device.h | 17 | ||||
-rw-r--r-- | src/c_fl_printer.cpp | 167 | ||||
-rw-r--r-- | src/c_fl_printer.h | 48 | ||||
-rw-r--r-- | src/c_fl_surface_device.cpp | 4 | ||||
-rw-r--r-- | src/c_fl_surface_device.h | 1 | ||||
-rw-r--r-- | src/fltk-devices-surface-copy.ads | 7 | ||||
-rw-r--r-- | src/fltk-devices-surface-paged-printers.adb | 569 | ||||
-rw-r--r-- | src/fltk-devices-surface-paged-printers.ads | 185 | ||||
-rw-r--r-- | src/fltk-devices-surface-paged.adb | 189 | ||||
-rw-r--r-- | src/fltk-devices-surface-paged.ads | 74 |
15 files changed, 1271 insertions, 56 deletions
diff --git a/src/c_fl_copy_surface.cpp b/src/c_fl_copy_surface.cpp index 1c00ec1..ff88735 100644 --- a/src/c_fl_copy_surface.cpp +++ b/src/c_fl_copy_surface.cpp @@ -12,6 +12,8 @@ +// Flattened C API + COPY_SURFACE new_fl_copy_surface(int w, int h) { Fl_Copy_Surface *c = new Fl_Copy_Surface(w,h); return c; diff --git a/src/c_fl_copy_surface.h b/src/c_fl_copy_surface.h index fa5b3b7..ed74e39 100644 --- a/src/c_fl_copy_surface.h +++ b/src/c_fl_copy_surface.h @@ -8,19 +8,13 @@ #define CL_COPY_SURFACE_GUARD - - typedef void* COPY_SURFACE; - - extern "C" COPY_SURFACE new_fl_copy_surface(int w, int h); extern "C" void free_fl_copy_surface(COPY_SURFACE c); - - extern "C" int fl_copy_surface_get_w(COPY_SURFACE c); extern "C" int fl_copy_surface_get_h(COPY_SURFACE c); @@ -34,3 +28,4 @@ extern "C" void fl_copy_surface_set_current(COPY_SURFACE c); #endif + diff --git a/src/c_fl_image_surface.cpp b/src/c_fl_image_surface.cpp index da0b723..b03659f 100644 --- a/src/c_fl_image_surface.cpp +++ b/src/c_fl_image_surface.cpp @@ -12,6 +12,8 @@ +// Flattened C API + IMAGE_SURFACE new_fl_image_surface(int w, int h, int r) { Fl_Image_Surface *s = new Fl_Image_Surface(w,h,r); return s; diff --git a/src/c_fl_image_surface.h b/src/c_fl_image_surface.h index 45d3b84..d0f671b 100644 --- a/src/c_fl_image_surface.h +++ b/src/c_fl_image_surface.h @@ -8,19 +8,13 @@ #define FL_IMAGE_SURFACE_GUARD - - typedef void* IMAGE_SURFACE; - - extern "C" IMAGE_SURFACE new_fl_image_surface(int w, int h, int r); extern "C" void free_fl_image_surface(IMAGE_SURFACE s); - - extern "C" void fl_image_surface_draw(IMAGE_SURFACE s, void * w, int dx, int dy); extern "C" void fl_image_surface_draw_decorated_window(IMAGE_SURFACE s, void * w, int dx, int dy); @@ -34,3 +28,4 @@ extern "C" void fl_image_surface_set_current(IMAGE_SURFACE s); #endif + diff --git a/src/c_fl_paged_device.cpp b/src/c_fl_paged_device.cpp index fcb4bae..2d3e788 100644 --- a/src/c_fl_paged_device.cpp +++ b/src/c_fl_paged_device.cpp @@ -12,15 +12,44 @@ +// Enums and macro constants + +const int fl_page_format_media = Fl_Paged_Device::MEDIA; + +const int fl_page_layout_portrait = Fl_Paged_Device::PORTRAIT; +const int fl_page_layout_landscape = Fl_Paged_Device::LANDSCAPE; +const int fl_page_layout_reversed = Fl_Paged_Device::REVERSED; +const int fl_page_layout_orientation = Fl_Paged_Device::ORIENTATION; + +const int fl_no_page_formats = NO_PAGE_FORMATS; + + + + +// Helper functions + +void fl_paged_device_get_page_format(int i, const char ** n, int * w, int * h) { + *n = Fl_Paged_Device::page_formats[i].name; + *w = Fl_Paged_Device::page_formats[i].height; + *h = Fl_Paged_Device::page_formats[i].width; +} + + + + +// Adding relevant friends + class My_Paged_Device : public Fl_Paged_Device { - public: - using Fl_Paged_Device::Fl_Paged_Device; - friend PAGED_DEVICE new_fl_paged_device(void); +public: + using Fl_Paged_Device::Fl_Paged_Device; + friend PAGED_DEVICE new_fl_paged_device(void); }; +// Flattened C API + PAGED_DEVICE new_fl_paged_device(void) { My_Paged_Device *p = new My_Paged_Device(); return p; @@ -35,12 +64,12 @@ void free_fl_paged_device(PAGED_DEVICE p) { int fl_paged_device_start_job(PAGED_DEVICE p, int c) { // virtual so disable dispatch - return reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::start_job(c,0,0); + return reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::start_job(c, 0, 0); } -int fl_paged_device_start_job2(PAGED_DEVICE p, int c, int f, int t) { +int fl_paged_device_start_job2(PAGED_DEVICE p, int c, int * f, int * t) { // virtual so disable dispatch - return reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::start_job(c,&f,&t); + return reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::start_job(c, f, t); } void fl_paged_device_end_job(PAGED_DEVICE p) { @@ -113,9 +142,12 @@ void fl_paged_device_print_window(PAGED_DEVICE p, void * i, int dx, int dy) { reinterpret_cast<Fl_Paged_Device*>(p)->print_window(reinterpret_cast<Fl_Window*>(i),dx,dy); } -void fl_paged_device_print_window_part(PAGED_DEVICE p, void * i, int x, int y, int w, int h, int dx, int dy) { +void fl_paged_device_print_window_part(PAGED_DEVICE p, void * i, int x, int y, + int w, int h, int dx, int dy) +{ // virtual so disable dispatch - reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::print_window_part(reinterpret_cast<Fl_Window*>(i),x,y,w,h,dx,dy); + reinterpret_cast<Fl_Paged_Device*>(p)->Fl_Paged_Device::print_window_part + (reinterpret_cast<Fl_Window*>(i),x,y,w,h,dx,dy); } diff --git a/src/c_fl_paged_device.h b/src/c_fl_paged_device.h index ebdc3a8..aef50c1 100644 --- a/src/c_fl_paged_device.h +++ b/src/c_fl_paged_device.h @@ -8,21 +8,26 @@ #define FL_PAGED_DEVICE_GUARD +extern "C" const int fl_page_format_media; +extern "C" const int fl_page_layout_portrait; +extern "C" const int fl_page_layout_landscape; +extern "C" const int fl_page_layout_reversed; +extern "C" const int fl_page_layout_orientation; +extern "C" const int fl_no_page_formats; -typedef void* PAGED_DEVICE; +extern "C" void fl_paged_device_get_page_format(int i, const char ** n, int * w, int * h); +typedef void* PAGED_DEVICE; extern "C" PAGED_DEVICE new_fl_paged_device(void); extern "C" void free_fl_paged_device(PAGED_DEVICE p); - - extern "C" int fl_paged_device_start_job(PAGED_DEVICE p, int c); -extern "C" int fl_paged_device_start_job2(PAGED_DEVICE p, int c, int f, int t); +extern "C" int fl_paged_device_start_job2(PAGED_DEVICE p, int c, int * f, int * t); extern "C" void fl_paged_device_end_job(PAGED_DEVICE p); extern "C" int fl_paged_device_start_page(PAGED_DEVICE p); extern "C" int fl_paged_device_end_page(PAGED_DEVICE p); @@ -40,8 +45,10 @@ extern "C" void fl_paged_device_untranslate(PAGED_DEVICE p); extern "C" void fl_paged_device_print_widget(PAGED_DEVICE p, void * i, int dx, int dy); extern "C" void fl_paged_device_print_window(PAGED_DEVICE p, void * i, int dx, int dy); -extern "C" void fl_paged_device_print_window_part(PAGED_DEVICE p, void * i, int x, int y, int w, int h, int dx, int dy); +extern "C" void fl_paged_device_print_window_part(PAGED_DEVICE p, void * i, int x, int y, + int w, int h, int dx, int dy); #endif + diff --git a/src/c_fl_printer.cpp b/src/c_fl_printer.cpp index 84826e6..9967678 100644 --- a/src/c_fl_printer.cpp +++ b/src/c_fl_printer.cpp @@ -12,6 +12,8 @@ +// Flattened C API + PRINTER new_fl_printer(void) { Fl_Printer *p = new Fl_Printer(); return p; @@ -24,12 +26,167 @@ void free_fl_printer(PRINTER p) { +const char * fl_printer_get_dialog_title() { + return Fl_Printer::dialog_title; +} + +void fl_printer_set_dialog_title(const char * v) { + Fl_Printer::dialog_title = v; +} + +const char * fl_printer_get_dialog_printer() { + return Fl_Printer::dialog_printer; +} + +void fl_printer_set_dialog_printer(const char * v) { + Fl_Printer::dialog_printer = v; +} + +const char * fl_printer_get_dialog_range() { + return Fl_Printer::dialog_range; +} + +void fl_printer_set_dialog_range(const char * v) { + Fl_Printer::dialog_range = v; +} + +const char * fl_printer_get_dialog_copies() { + return Fl_Printer::dialog_copies; +} + +void fl_printer_set_dialog_copies(const char * v) { + Fl_Printer::dialog_copies = v; +} + +const char * fl_printer_get_dialog_all() { + return Fl_Printer::dialog_all; +} + +void fl_printer_set_dialog_all(const char * v) { + Fl_Printer::dialog_all = v; +} + +const char * fl_printer_get_dialog_pages() { + return Fl_Printer::dialog_pages; +} + +void fl_printer_set_dialog_pages(const char * v) { + Fl_Printer::dialog_pages = v; +} + +const char * fl_printer_get_dialog_from() { + return Fl_Printer::dialog_from; +} + +void fl_printer_set_dialog_from(const char * v) { + Fl_Printer::dialog_from = v; +} + +const char * fl_printer_get_dialog_to() { + return Fl_Printer::dialog_to; +} + +void fl_printer_set_dialog_to(const char * v) { + Fl_Printer::dialog_to = v; +} + +const char * fl_printer_get_dialog_properties() { + return Fl_Printer::dialog_properties; +} + +void fl_printer_set_dialog_properties(const char * v) { + Fl_Printer::dialog_properties = v; +} + +const char * fl_printer_get_dialog_copyno() { + return Fl_Printer::dialog_copyNo; +} + +void fl_printer_set_dialog_copyno(const char * v) { + Fl_Printer::dialog_copyNo = v; +} + +const char * fl_printer_get_dialog_print_button() { + return Fl_Printer::dialog_print_button; +} + +void fl_printer_set_dialog_print_button(const char * v) { + Fl_Printer::dialog_print_button = v; +} + +const char * fl_printer_get_dialog_cancel_button() { + return Fl_Printer::dialog_cancel_button; +} + +void fl_printer_set_dialog_cancel_button(const char * v) { + Fl_Printer::dialog_cancel_button = v; +} + +const char * fl_printer_get_dialog_print_to_file() { + return Fl_Printer::dialog_print_to_file; +} + +void fl_printer_set_dialog_print_to_file(const char * v) { + Fl_Printer::dialog_print_to_file = v; +} + +const char * fl_printer_get_property_title() { + return Fl_Printer::property_title; +} + +void fl_printer_set_property_title(const char * v) { + Fl_Printer::property_title = v; +} + +const char * fl_printer_get_property_pagesize() { + return Fl_Printer::property_pagesize; +} + +void fl_printer_set_property_pagesize(const char * v) { + Fl_Printer::property_pagesize = v; +} + +const char * fl_printer_get_property_mode() { + return Fl_Printer::property_mode; +} + +void fl_printer_set_property_mode(const char * v) { + Fl_Printer::property_mode = v; +} + +const char * fl_printer_get_property_use() { + return Fl_Printer::property_use; +} + +void fl_printer_set_property_use(const char * v) { + Fl_Printer::property_use = v; +} + +const char * fl_printer_get_property_save() { + return Fl_Printer::property_save; +} + +void fl_printer_set_property_save(const char * v) { + Fl_Printer::property_save = v; +} + +const char * fl_printer_get_property_cancel() { + return Fl_Printer::property_cancel; +} + +void fl_printer_set_property_cancel(const char * v) { + Fl_Printer::property_cancel = v; +} + + + + int fl_printer_start_job(PRINTER p, int c) { - return reinterpret_cast<Fl_Printer*>(p)->start_job(c,0,0); + return reinterpret_cast<Fl_Printer*>(p)->start_job(c, 0, 0); } -int fl_printer_start_job2(PRINTER p, int c, int f, int t) { - return reinterpret_cast<Fl_Printer*>(p)->start_job(c,&f,&t); +int fl_printer_start_job2(PRINTER p, int c, int * f, int * t) { + return reinterpret_cast<Fl_Printer*>(p)->start_job(c, f, t); } void fl_printer_end_job(PRINTER p) { @@ -86,7 +243,9 @@ void fl_printer_print_widget(PRINTER p, void * i, int dx, int dy) { reinterpret_cast<Fl_Printer*>(p)->print_widget(reinterpret_cast<Fl_Widget*>(i),dx,dy); } -void fl_printer_print_window_part(PRINTER p, void * i, int x, int y, int w, int h, int dx, int dy) { +void fl_printer_print_window_part(PRINTER p, void * i, int x, int y, + int w, int h, int dx, int dy) +{ reinterpret_cast<Fl_Printer*>(p)->print_window_part(reinterpret_cast<Fl_Window*>(i),x,y,w,h,dx,dy); } diff --git a/src/c_fl_printer.h b/src/c_fl_printer.h index a32edd9..90f070d 100644 --- a/src/c_fl_printer.h +++ b/src/c_fl_printer.h @@ -8,21 +8,55 @@ #define FL_PRINTER_GUARD - - typedef void* PRINTER; - - extern "C" PRINTER new_fl_printer(void); extern "C" void free_fl_printer(PRINTER p); +extern "C" const char * fl_printer_get_dialog_title(); +extern "C" void fl_printer_set_dialog_title(const char * v); +extern "C" const char * fl_printer_get_dialog_printer(); +extern "C" void fl_printer_set_dialog_printer(const char * v); +extern "C" const char * fl_printer_get_dialog_range(); +extern "C" void fl_printer_set_dialog_range(const char * v); +extern "C" const char * fl_printer_get_dialog_copies(); +extern "C" void fl_printer_set_dialog_copies(const char * v); +extern "C" const char * fl_printer_get_dialog_all(); +extern "C" void fl_printer_set_dialog_all(const char * v); +extern "C" const char * fl_printer_get_dialog_pages(); +extern "C" void fl_printer_set_dialog_pages(const char * v); +extern "C" const char * fl_printer_get_dialog_from(); +extern "C" void fl_printer_set_dialog_from(const char * v); +extern "C" const char * fl_printer_get_dialog_to(); +extern "C" void fl_printer_set_dialog_to(const char * v); +extern "C" const char * fl_printer_get_dialog_properties(); +extern "C" void fl_printer_set_dialog_properties(const char * v); +extern "C" const char * fl_printer_get_dialog_copyno(); +extern "C" void fl_printer_set_dialog_copyno(const char * v); +extern "C" const char * fl_printer_get_dialog_print_button(); +extern "C" void fl_printer_set_dialog_print_button(const char * v); +extern "C" const char * fl_printer_get_dialog_cancel_button(); +extern "C" void fl_printer_set_dialog_cancel_button(const char * v); +extern "C" const char * fl_printer_get_dialog_print_to_file(); +extern "C" void fl_printer_set_dialog_print_to_file(const char * v); +extern "C" const char * fl_printer_get_property_title(); +extern "C" void fl_printer_set_property_title(const char * v); +extern "C" const char * fl_printer_get_property_pagesize(); +extern "C" void fl_printer_set_property_pagesize(const char * v); +extern "C" const char * fl_printer_get_property_mode(); +extern "C" void fl_printer_set_property_mode(const char * v); +extern "C" const char * fl_printer_get_property_use(); +extern "C" void fl_printer_set_property_use(const char * v); +extern "C" const char * fl_printer_get_property_save(); +extern "C" void fl_printer_set_property_save(const char * v); +extern "C" const char * fl_printer_get_property_cancel(); +extern "C" void fl_printer_set_property_cancel(const char * v); extern "C" int fl_printer_start_job(PRINTER p, int c); -extern "C" int fl_printer_start_job2(PRINTER p, int c, int f, int t); +extern "C" int fl_printer_start_job2(PRINTER p, int c, int * f, int * t); extern "C" void fl_printer_end_job(PRINTER p); extern "C" int fl_printer_start_page(PRINTER p); extern "C" int fl_printer_end_page(PRINTER p); @@ -39,7 +73,8 @@ extern "C" void fl_printer_untranslate(PRINTER p); extern "C" void fl_printer_print_widget(PRINTER p, void * i, int dx, int dy); -extern "C" void fl_printer_print_window_part(PRINTER p, void * i, int x, int y, int w, int h, int dx, int dy); +extern "C" void fl_printer_print_window_part(PRINTER p, void * i, int x, int y, + int w, int h, int dx, int dy); extern "C" void fl_printer_set_current(PRINTER p); @@ -47,3 +82,4 @@ extern "C" void fl_printer_set_current(PRINTER p); #endif + diff --git a/src/c_fl_surface_device.cpp b/src/c_fl_surface_device.cpp index 34b2bac..50088cf 100644 --- a/src/c_fl_surface_device.cpp +++ b/src/c_fl_surface_device.cpp @@ -10,6 +10,8 @@ +// Adding relevant friends + class My_Surface_Device : public Fl_Surface_Device { public: using Fl_Surface_Device::Fl_Surface_Device; @@ -19,6 +21,8 @@ public: +// Flattened C API + SURFACEDEVICE new_fl_surface_device(void * g) { My_Surface_Device *s = new My_Surface_Device(reinterpret_cast<Fl_Graphics_Driver*>(g)); return s; diff --git a/src/c_fl_surface_device.h b/src/c_fl_surface_device.h index fa5946a..97096c6 100644 --- a/src/c_fl_surface_device.h +++ b/src/c_fl_surface_device.h @@ -25,3 +25,4 @@ extern "C" void fl_surface_device_set_driver(SURFACEDEVICE s, void * g); #endif + diff --git a/src/fltk-devices-surface-copy.ads b/src/fltk-devices-surface-copy.ads index f5069c5..41d331b 100644 --- a/src/fltk-devices-surface-copy.ads +++ b/src/fltk-devices-surface-copy.ads @@ -20,6 +20,13 @@ package FLTK.Devices.Surface.Copy is + -- The initial Graphics_Driver this is supposed to have upon construction + -- is not currently implemented properly. Please wait warmly until the + -- binding for the Graphics sub-hierarchy is done. + + + + package Forge is function Create diff --git a/src/fltk-devices-surface-paged-printers.adb b/src/fltk-devices-surface-paged-printers.adb index d454f78..3e605c8 100644 --- a/src/fltk-devices-surface-paged-printers.adb +++ b/src/fltk-devices-surface-paged-printers.adb @@ -6,7 +6,7 @@ with - Interfaces.C; + Interfaces.C.Strings; use type @@ -16,6 +16,10 @@ use type package body FLTK.Devices.Surface.Paged.Printers is + ------------------------ + -- Functions From C -- + ------------------------ + function new_fl_printer return Storage.Integer_Address; pragma Import (C, new_fl_printer, "new_fl_printer"); @@ -29,6 +33,199 @@ package body FLTK.Devices.Surface.Paged.Printers is + function fl_printer_get_dialog_title + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_title, "fl_printer_get_dialog_title"); + pragma Inline (fl_printer_get_dialog_title); + + procedure fl_printer_set_dialog_title + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_title, "fl_printer_set_dialog_title"); + pragma Inline (fl_printer_set_dialog_title); + + function fl_printer_get_dialog_printer + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_printer, "fl_printer_get_dialog_printer"); + pragma Inline (fl_printer_get_dialog_printer); + + procedure fl_printer_set_dialog_printer + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_printer, "fl_printer_set_dialog_printer"); + pragma Inline (fl_printer_set_dialog_printer); + + function fl_printer_get_dialog_range + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_range, "fl_printer_get_dialog_range"); + pragma Inline (fl_printer_get_dialog_range); + + procedure fl_printer_set_dialog_range + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_range, "fl_printer_set_dialog_range"); + pragma Inline (fl_printer_set_dialog_range); + + function fl_printer_get_dialog_copies + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_copies, "fl_printer_get_dialog_copies"); + pragma Inline (fl_printer_get_dialog_copies); + + procedure fl_printer_set_dialog_copies + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_copies, "fl_printer_set_dialog_copies"); + pragma Inline (fl_printer_set_dialog_copies); + + function fl_printer_get_dialog_all + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_all, "fl_printer_get_dialog_all"); + pragma Inline (fl_printer_get_dialog_all); + + procedure fl_printer_set_dialog_all + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_all, "fl_printer_set_dialog_all"); + pragma Inline (fl_printer_set_dialog_all); + + function fl_printer_get_dialog_pages + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_pages, "fl_printer_get_dialog_pages"); + pragma Inline (fl_printer_get_dialog_pages); + + procedure fl_printer_set_dialog_pages + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_pages, "fl_printer_set_dialog_pages"); + pragma Inline (fl_printer_set_dialog_pages); + + function fl_printer_get_dialog_from + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_from, "fl_printer_get_dialog_from"); + pragma Inline (fl_printer_get_dialog_from); + + procedure fl_printer_set_dialog_from + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_from, "fl_printer_set_dialog_from"); + pragma Inline (fl_printer_set_dialog_from); + + function fl_printer_get_dialog_to + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_to, "fl_printer_get_dialog_to"); + pragma Inline (fl_printer_get_dialog_to); + + procedure fl_printer_set_dialog_to + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_to, "fl_printer_set_dialog_to"); + pragma Inline (fl_printer_set_dialog_to); + + function fl_printer_get_dialog_properties + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_properties, "fl_printer_get_dialog_properties"); + pragma Inline (fl_printer_get_dialog_properties); + + procedure fl_printer_set_dialog_properties + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_properties, "fl_printer_set_dialog_properties"); + pragma Inline (fl_printer_set_dialog_properties); + + function fl_printer_get_dialog_copyno + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_copyno, "fl_printer_get_dialog_copyno"); + pragma Inline (fl_printer_get_dialog_copyno); + + procedure fl_printer_set_dialog_copyno + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_copyno, "fl_printer_set_dialog_copyno"); + pragma Inline (fl_printer_set_dialog_copyno); + + function fl_printer_get_dialog_print_button + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_print_button, "fl_printer_get_dialog_print_button"); + pragma Inline (fl_printer_get_dialog_print_button); + + procedure fl_printer_set_dialog_print_button + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_print_button, "fl_printer_set_dialog_print_button"); + pragma Inline (fl_printer_set_dialog_print_button); + + function fl_printer_get_dialog_cancel_button + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_cancel_button, "fl_printer_get_dialog_cancel_button"); + pragma Inline (fl_printer_get_dialog_cancel_button); + + procedure fl_printer_set_dialog_cancel_button + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_cancel_button, "fl_printer_set_dialog_cancel_button"); + pragma Inline (fl_printer_set_dialog_cancel_button); + + function fl_printer_get_dialog_print_to_file + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_dialog_print_to_file, "fl_printer_get_dialog_print_to_file"); + pragma Inline (fl_printer_get_dialog_print_to_file); + + procedure fl_printer_set_dialog_print_to_file + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_dialog_print_to_file, "fl_printer_set_dialog_print_to_file"); + pragma Inline (fl_printer_set_dialog_print_to_file); + + function fl_printer_get_property_title + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_title, "fl_printer_get_property_title"); + pragma Inline (fl_printer_get_property_title); + + procedure fl_printer_set_property_title + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_title, "fl_printer_set_property_title"); + pragma Inline (fl_printer_set_property_title); + + function fl_printer_get_property_pagesize + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_pagesize, "fl_printer_get_property_pagesize"); + pragma Inline (fl_printer_get_property_pagesize); + + procedure fl_printer_set_property_pagesize + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_pagesize, "fl_printer_set_property_pagesize"); + pragma Inline (fl_printer_set_property_pagesize); + + function fl_printer_get_property_mode + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_mode, "fl_printer_get_property_mode"); + pragma Inline (fl_printer_get_property_mode); + + procedure fl_printer_set_property_mode + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_mode, "fl_printer_set_property_mode"); + pragma Inline (fl_printer_set_property_mode); + + function fl_printer_get_property_use + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_use, "fl_printer_get_property_use"); + pragma Inline (fl_printer_get_property_use); + + procedure fl_printer_set_property_use + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_use, "fl_printer_set_property_use"); + pragma Inline (fl_printer_set_property_use); + + function fl_printer_get_property_save + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_save, "fl_printer_get_property_save"); + pragma Inline (fl_printer_get_property_save); + + procedure fl_printer_set_property_save + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_save, "fl_printer_set_property_save"); + pragma Inline (fl_printer_set_property_save); + + function fl_printer_get_property_cancel + return Interfaces.C.Strings.chars_ptr; + pragma Import (C, fl_printer_get_property_cancel, "fl_printer_get_property_cancel"); + pragma Inline (fl_printer_get_property_cancel); + + procedure fl_printer_set_property_cancel + (V : in Interfaces.C.Strings.chars_ptr); + pragma Import (C, fl_printer_set_property_cancel, "fl_printer_set_property_cancel"); + pragma Inline (fl_printer_set_property_cancel); + + + + function fl_printer_start_job (D : in Storage.Integer_Address; C : in Interfaces.C.int) @@ -37,8 +234,9 @@ package body FLTK.Devices.Surface.Paged.Printers is pragma Inline (fl_printer_start_job); function fl_printer_start_job2 - (D : in Storage.Integer_Address; - C, F, T : in Interfaces.C.int) + (D : in Storage.Integer_Address; + C : in Interfaces.C.int; + F, T : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_printer_start_job2, "fl_printer_start_job2"); pragma Inline (fl_printer_start_job2); @@ -137,6 +335,10 @@ package body FLTK.Devices.Surface.Paged.Printers is + ------------------- + -- Destructors -- + ------------------- + procedure Finalize (This : in out Printer) is begin @@ -147,7 +349,38 @@ package body FLTK.Devices.Surface.Paged.Printers is end Finalize; + procedure Finalize + (This : in out Printer_Final_Controller) + is + use Interfaces.C.Strings; + begin + Free (Dialog_Title); + Free (Dialog_Printer); + Free (Dialog_Range); + Free (Dialog_Copies); + Free (Dialog_All); + Free (Dialog_Pages); + Free (Dialog_From); + Free (Dialog_To); + Free (Dialog_Properties); + Free (Dialog_Copyno); + Free (Dialog_Print_Button); + Free (Dialog_Cancel_Button); + Free (Dialog_Print_To_File); + Free (Property_Title); + Free (Property_Pagesize); + Free (Property_Mode); + Free (Property_Use); + Free (Property_Save); + Free (Property_Cancel); + end Finalize; + + + + -------------------- + -- Constructors -- + -------------------- package body Forge is @@ -166,9 +399,333 @@ package body FLTK.Devices.Surface.Paged.Printers is + ------------------------- + -- Static Attributes -- + ------------------------- + + function Get_Dialog_Title + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_title); + end Get_Dialog_Title; + + + procedure Set_Dialog_Title + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Title); + Dialog_Title := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_title (Dialog_Title); + end Set_Dialog_Title; + + + function Get_Dialog_Printer + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_printer); + end Get_Dialog_Printer; + + + procedure Set_Dialog_Printer + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Printer); + Dialog_Printer := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_printer (Dialog_Printer); + end Set_Dialog_Printer; + + + function Get_Dialog_Range + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_range); + end Get_Dialog_Range; + + + procedure Set_Dialog_Range + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Range); + Dialog_Range := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_range (Dialog_Range); + end Set_Dialog_Range; + + + function Get_Dialog_Copies + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_copies); + end Get_Dialog_Copies; + + + procedure Set_Dialog_Copies + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Copies); + Dialog_Copies := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_copies (Dialog_Copies); + end Set_Dialog_Copies; + + + function Get_Dialog_All + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_all); + end Get_Dialog_All; + + + procedure Set_Dialog_All + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_All); + Dialog_All := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_all (Dialog_All); + end Set_Dialog_All; + + + function Get_Dialog_Pages + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_pages); + end Get_Dialog_Pages; + + + procedure Set_Dialog_Pages + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Pages); + Dialog_Pages := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_pages (Dialog_Pages); + end Set_Dialog_Pages; + + + function Get_Dialog_From + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_from); + end Get_Dialog_From; + + + procedure Set_Dialog_From + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_From); + Dialog_From := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_from (Dialog_From); + end Set_Dialog_From; + + + function Get_Dialog_To + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_to); + end Get_Dialog_To; + + + procedure Set_Dialog_To + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_To); + Dialog_To := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_to (Dialog_To); + end Set_Dialog_To; + + + function Get_Dialog_Properties + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_properties); + end Get_Dialog_Properties; + + + procedure Set_Dialog_Properties + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Properties); + Dialog_Properties := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_properties (Dialog_Properties); + end Set_Dialog_Properties; + + + function Get_Dialog_Number_Copies + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_copyno); + end Get_Dialog_Number_Copies; + + + procedure Set_Dialog_Number_Copies + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Copyno); + Dialog_Copyno := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_copyno (Dialog_Copyno); + end Set_Dialog_Number_Copies; + + + function Get_Dialog_Print_Button + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_print_button); + end Get_Dialog_Print_Button; + + + procedure Set_Dialog_Print_Button + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Print_Button); + Dialog_Print_Button := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_print_button (Dialog_Print_Button); + end Set_Dialog_Print_Button; + + + function Get_Dialog_Cancel_Button + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_cancel_button); + end Get_Dialog_Cancel_Button; + + + procedure Set_Dialog_Cancel_Button + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Cancel_Button); + Dialog_Cancel_Button := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_cancel_button (Dialog_Cancel_Button); + end Set_Dialog_Cancel_Button; + + + function Get_Dialog_Print_To_File + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_dialog_print_to_file); + end Get_Dialog_Print_To_File; + + + procedure Set_Dialog_Print_To_File + (Value : in String) is + begin + Interfaces.C.Strings.Free (Dialog_Print_To_File); + Dialog_Print_To_File := Interfaces.C.Strings.New_String (Value); + fl_printer_set_dialog_print_to_file (Dialog_Print_To_File); + end Set_Dialog_Print_To_File; + + + function Get_Property_Title + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_title); + end Get_Property_Title; + + + procedure Set_Property_Title + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Title); + Property_Title := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_title (Property_Title); + end Set_Property_Title; + + + function Get_Property_Page_Size + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_pagesize); + end Get_Property_Page_Size; + + + procedure Set_Property_Page_Size + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Pagesize); + Property_Pagesize := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_pagesize (Property_Pagesize); + end Set_Property_Page_Size; + + + function Get_Property_Mode + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_mode); + end Get_Property_Mode; + + + procedure Set_Property_Mode + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Mode); + Property_Mode := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_mode (Property_Mode); + end Set_Property_Mode; + + + function Get_Property_Use + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_use); + end Get_Property_Use; + + + procedure Set_Property_Use + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Use); + Property_Use := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_use (Property_Use); + end Set_Property_Use; + + + function Get_Property_Save + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_save); + end Get_Property_Save; + + + procedure Set_Property_Save + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Save); + Property_Save := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_save (Property_Save); + end Set_Property_Save; + + + function Get_Property_Cancel + return String is + begin + return Interfaces.C.Strings.Value (fl_printer_get_property_cancel); + end Get_Property_Cancel; + + + procedure Set_Property_Cancel + (Value : in String) is + begin + Interfaces.C.Strings.Free (Property_Cancel); + Property_Cancel := Interfaces.C.Strings.New_String (Value); + fl_printer_set_property_cancel (Property_Cancel); + end Set_Property_Cancel; + + + + + ----------------------- + -- API Subprograms -- + ----------------------- + + function Get_Original_Driver + (This : in out Printer) + return FLTK.Devices.Graphics.Graphics_Driver_Reference is + begin + return raise Program_Error with "Won't be implemented until Graphics_Drivers taken care of"; + end Get_Original_Driver; + + + + procedure Start_Job (This : in out Printer; - Count : in Natural) is + Count : in Natural := 0) is begin if fl_printer_start_job (This.Void_Ptr, Interfaces.C.int (Count)) /= 0 @@ -180,8 +737,8 @@ package body FLTK.Devices.Surface.Paged.Printers is procedure Start_Job (This : in out Printer; - Count : in Natural; - From, To : in Positive) is + Count : in Natural := 0; + From, To : out Positive) is begin if fl_printer_start_job2 (This.Void_Ptr, diff --git a/src/fltk-devices-surface-paged-printers.ads b/src/fltk-devices-surface-paged-printers.ads index ac5294d..b4beb82 100644 --- a/src/fltk-devices-surface-paged-printers.ads +++ b/src/fltk-devices-surface-paged-printers.ads @@ -8,6 +8,11 @@ with FLTK.Widgets.Groups.Windows; +private with + + Ada.Finalization, + Interfaces.C.Strings; + package FLTK.Devices.Surface.Paged.Printers is @@ -20,6 +25,13 @@ package FLTK.Devices.Surface.Paged.Printers is + -- The initial Graphics_Driver this is supposed to have upon construction + -- is not currently implemented properly. Please wait warmly until the + -- binding for the Graphics sub-hierarchy is done. + + + + package Forge is function Create @@ -30,14 +42,138 @@ package FLTK.Devices.Surface.Paged.Printers is + function Get_Dialog_Title + return String; + + procedure Set_Dialog_Title + (Value : in String); + + function Get_Dialog_Printer + return String; + + procedure Set_Dialog_Printer + (Value : in String); + + function Get_Dialog_Range + return String; + + procedure Set_Dialog_Range + (Value : in String); + + function Get_Dialog_Copies + return String; + + procedure Set_Dialog_Copies + (Value : in String); + + function Get_Dialog_All + return String; + + procedure Set_Dialog_All + (Value : in String); + + function Get_Dialog_Pages + return String; + + procedure Set_Dialog_Pages + (Value : in String); + + function Get_Dialog_From + return String; + + procedure Set_Dialog_From + (Value : in String); + + function Get_Dialog_To + return String; + + procedure Set_Dialog_To + (Value : in String); + + function Get_Dialog_Properties + return String; + + procedure Set_Dialog_Properties + (Value : in String); + + function Get_Dialog_Number_Copies + return String; + + procedure Set_Dialog_Number_Copies + (Value : in String); + + function Get_Dialog_Print_Button + return String; + + procedure Set_Dialog_Print_Button + (Value : in String); + + function Get_Dialog_Cancel_Button + return String; + + procedure Set_Dialog_Cancel_Button + (Value : in String); + + function Get_Dialog_Print_To_File + return String; + + procedure Set_Dialog_Print_To_File + (Value : in String); + + function Get_Property_Title + return String; + + procedure Set_Property_Title + (Value : in String); + + function Get_Property_Page_Size + return String; + + procedure Set_Property_Page_Size + (Value : in String); + + function Get_Property_Mode + return String; + + procedure Set_Property_Mode + (Value : in String); + + function Get_Property_Use + return String; + + procedure Set_Property_Use + (Value : in String); + + function Get_Property_Save + return String; + + procedure Set_Property_Save + (Value : in String); + + function Get_Property_Cancel + return String; + + procedure Set_Property_Cancel + (Value : in String); + + + + + function Get_Original_Driver + (This : in out Printer) + return FLTK.Devices.Graphics.Graphics_Driver_Reference; + + + + procedure Start_Job (This : in out Printer; - Count : in Natural); + Count : in Natural := 0); procedure Start_Job (This : in out Printer; - Count : in Natural; - From, To : in Positive); + Count : in Natural := 0; + From, To : out Positive); procedure End_Job (This : in out Printer); @@ -116,6 +252,40 @@ private (This : in out Printer); + Dialog_Title, Dialog_Printer, + Dialog_Range, Dialog_Copies, + Dialog_All, Dialog_Pages, + Dialog_From, Dialog_To, + Dialog_Properties, Dialog_Copyno, + Dialog_Print_Button, Dialog_Cancel_Button, + Dialog_Print_To_File, + Property_Title, Property_Pagesize, + Property_Mode, Property_Use, + Property_Save, Property_Cancel : Interfaces.C.Strings.chars_ptr; + + + pragma Inline (Get_Dialog_Title); + pragma Inline (Get_Dialog_Printer); + pragma Inline (Get_Dialog_Range); + pragma Inline (Get_Dialog_Copies); + pragma Inline (Get_Dialog_All); + pragma Inline (Get_Dialog_Pages); + pragma Inline (Get_Dialog_From); + pragma Inline (Get_Dialog_To); + pragma Inline (Get_Dialog_Properties); + pragma Inline (Get_Dialog_Number_Copies); + pragma Inline (Get_Dialog_Print_Button); + pragma Inline (Get_Dialog_Cancel_Button); + pragma Inline (Get_Dialog_Print_To_File); + pragma Inline (Get_Property_Title); + pragma Inline (Get_Property_Page_Size); + pragma Inline (Get_Property_Mode); + pragma Inline (Get_Property_Use); + pragma Inline (Get_Property_Save); + pragma Inline (Get_Property_Cancel); + + pragma Inline (Get_Original_Driver); + pragma Inline (Start_Job); pragma Inline (End_Job); pragma Inline (Start_Page); @@ -136,6 +306,15 @@ private pragma Inline (Set_Current); + -- Needed to ensure chars_ptr storage is properly cleaned up + type Printer_Final_Controller is new Ada.Finalization.Limited_Controlled with null record; + + overriding procedure Finalize + (This : in out Printer_Final_Controller); + + Cleanup : Printer_Final_Controller; + + end FLTK.Devices.Surface.Paged.Printers; diff --git a/src/fltk-devices-surface-paged.adb b/src/fltk-devices-surface-paged.adb index 75957c5..2fb6450 100644 --- a/src/fltk-devices-surface-paged.adb +++ b/src/fltk-devices-surface-paged.adb @@ -6,16 +6,63 @@ with - Interfaces.C; + Ada.Strings.Unbounded, + Interfaces.C.Strings; use type - Interfaces.C.int; + Interfaces.C.int, + Interfaces.C.Strings.chars_ptr; package body FLTK.Devices.Surface.Paged is + package SU renames Ada.Strings.Unbounded; + + + + + ------------------------ + -- Constants From C -- + ------------------------ + + fl_page_format_media : constant Interfaces.C.int; + pragma Import (C, fl_page_format_media); + + fl_page_layout_portrait : constant Interfaces.C.int; + pragma Import (C, fl_page_layout_portrait); + + fl_page_layout_landscape : constant Interfaces.C.int; + pragma Import (C, fl_page_layout_landscape); + + fl_page_layout_reversed : constant Interfaces.C.int; + pragma Import (C, fl_page_layout_reversed); + + fl_page_layout_orientation : constant Interfaces.C.int; + pragma Import (C, fl_page_layout_orientation); + + fl_no_page_formats : constant Interfaces.C.int; + pragma Import (C, fl_no_page_formats); + + + + + ------------------------ + -- Functions From C -- + ------------------------ + + procedure fl_paged_device_get_page_format + (Index : in Interfaces.C.int; + Name : out Interfaces.C.Strings.chars_ptr; + Width : out Interfaces.C.int; + Height : out Interfaces.C.int); + pragma Import (C, fl_paged_device_get_page_format, "fl_paged_device_get_page_format"); + pragma Inline (fl_paged_device_get_page_format); + + + + function new_fl_paged_device return Storage.Integer_Address; pragma Import (C, new_fl_paged_device, "new_fl_paged_device"); @@ -37,8 +84,9 @@ package body FLTK.Devices.Surface.Paged is pragma Inline (fl_paged_device_start_job); function fl_paged_device_start_job2 - (D : in Storage.Integer_Address; - C, F, T : in Interfaces.C.int) + (D : in Storage.Integer_Address; + C : in Interfaces.C.int; + F, T : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_paged_device_start_job2, "fl_paged_device_start_job2"); pragma Inline (fl_paged_device_start_job2); @@ -135,6 +183,125 @@ package body FLTK.Devices.Surface.Paged is + ------------------------ + -- Internal Utility -- + ------------------------ + + function To_Cint + (Value : in Page_Format) + return Interfaces.C.int is + begin + case Value is + when A0 .. Envelope => return Page_Format'Pos (Value); + when Media => return fl_page_format_media; + end case; + end To_Cint; + + + function To_Page_Format + (Value : in Interfaces.C.int) + return Page_Format is + begin + if Value in Page_Format'Pos (A0) .. Page_Format'Pos (Envelope) then + return Page_Format'Val (Value); + elsif Value = fl_page_format_media then + return Media; + else + raise Internal_FLTK_Error; + end if; + end To_Page_Format; + + + function To_Cint + (Value : in Page_Layout) + return Interfaces.C.int is + begin + case Value is + when Portrait => return fl_page_layout_portrait; + when Landscape => return fl_page_layout_landscape; + when Reversed => return fl_page_layout_reversed; + when Orientation => return fl_page_layout_orientation; + end case; + end To_Cint; + + + function To_Page_Layout + (Value : in Interfaces.C.int) + return Page_Layout is + begin + if Value = fl_page_layout_portrait then + return Portrait; + elsif Value = fl_page_layout_landscape then + return Landscape; + elsif Value = fl_page_layout_reversed then + return Reversed; + elsif Value = fl_page_layout_orientation then + return Orientation; + else + raise Internal_FLTK_Error; + end if; + end To_Page_Layout; + + + function Get_Page_Formats + return Page_Format_Info_Array + is + C_Name : Interfaces.C.Strings.chars_ptr; + C_Width : Interfaces.C.int; + C_Height : Interfaces.C.int; + begin + return Data : Page_Format_Info_Array (A0 .. To_Page_Format (fl_no_page_formats - 1)) do + for Index in Data'Range loop + fl_paged_device_get_page_format (To_Cint (Index), C_Name, C_Width, C_Height); + if C_Name = Interfaces.C.Strings.Null_Ptr then + Data (Index).My_Name := SU.To_Unbounded_String (""); + else + Data (Index).My_Name := SU.To_Unbounded_String + (Interfaces.C.Strings.Value (C_Name)); + end if; + Data (Index).My_Width := Natural (C_Width); + Data (Index).My_Height := Natural (C_Height); + end loop; + end return; + end Get_Page_Formats; + + + + + ---------------------------- + -- Datatype Subprograms -- + ---------------------------- + + function Name + (This : in Page_Format_Info) + return String is + begin + return SU.To_String (This.My_Name); + end Name; + + + function Width + (This : in Page_Format_Info) + return Natural is + begin + return This.My_Width; + end Width; + + + function Height + (This : in Page_Format_Info) + return Natural is + begin + return This.My_Height; + end Height; + + + + + ------------------- + -- Destructors -- + ------------------- + procedure Finalize (This : in out Paged_Device) is begin @@ -147,6 +314,10 @@ package body FLTK.Devices.Surface.Paged is + -------------------- + -- Constructors -- + -------------------- + package body Forge is function Create @@ -164,9 +335,13 @@ package body FLTK.Devices.Surface.Paged is + ----------------------- + -- API Subprograms -- + ----------------------- + procedure Start_Job (This : in out Paged_Device; - Count : in Natural) is + Count : in Natural := 0) is begin if fl_paged_device_start_job (This.Void_Ptr, Interfaces.C.int (Count)) /= 0 @@ -178,8 +353,8 @@ package body FLTK.Devices.Surface.Paged is procedure Start_Job (This : in out Paged_Device; - Count : in Natural; - From, To : in Positive) is + Count : in Natural := 0; + From, To : out Positive) is begin if fl_paged_device_start_job2 (This.Void_Ptr, diff --git a/src/fltk-devices-surface-paged.ads b/src/fltk-devices-surface-paged.ads index 1a3c13c..b445c62 100644 --- a/src/fltk-devices-surface-paged.ads +++ b/src/fltk-devices-surface-paged.ads @@ -8,25 +8,55 @@ with FLTK.Widgets.Groups.Windows; +private with + + Ada.Strings.Unbounded; + package FLTK.Devices.Surface.Paged is + pragma Elaborate_Body (FLTK.Devices.Surface.Paged); + + type Paged_Device is new Surface_Device with private; type Paged_Device_Reference (Data : not null access Paged_Device'Class) is limited null record with Implicit_Dereference => Data; + type Page_Format is (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, C5E, DLE, Executive, Folio, Ledger, - Legal, Letter, Tabloid, Envelope); + Legal, Letter, Tabloid, Envelope, Media); + + + -- Note that the Name in the format information may not quite + -- correspond to the 'Image of the indexing Page_Format enumeration! + type Page_Format_Info is tagged private; + + function Name + (This : in Page_Format_Info) + return String; + + function Width + (This : in Page_Format_Info) + return Natural; + + function Height + (This : in Page_Format_Info) + return Natural; + + type Page_Format_Info_Array is array (Page_Format range <>) of Page_Format_Info; + type Page_Layout is - (Potrait, Landscape, Reversed, Orientation); + (Portrait, Landscape, Reversed, Orientation); + -- Information for everything except for Media + Page_Formats : constant Page_Format_Info_Array (A0 .. Envelope); Page_Error : exception; @@ -36,6 +66,7 @@ package FLTK.Devices.Surface.Paged is package Forge is + -- Docs say there should be no reason to use this but it's here anyway. function Create return Paged_Device; @@ -46,12 +77,12 @@ package FLTK.Devices.Surface.Paged is procedure Start_Job (This : in out Paged_Device; - Count : in Natural); + Count : in Natural := 0); procedure Start_Job (This : in out Paged_Device; - Count : in Natural; - From, To : in Positive); + Count : in Natural := 0; + From, To : out Positive); procedure End_Job (This : in out Paged_Device); @@ -129,6 +160,39 @@ private (This : in out Paged_Device); + function To_Cint + (Value : in Page_Format) + return Interfaces.C.int; + + function To_Page_Format + (Value : in Interfaces.C.int) + return Page_Format; + + function To_Cint + (Value : in Page_Layout) + return Interfaces.C.int; + + function To_Page_Layout + (Value : in Interfaces.C.int) + return Page_Layout; + + + type Page_Format_Info is tagged record + My_Name : Ada.Strings.Unbounded.Unbounded_String; + My_Width : Natural; + My_Height : Natural; + end record; + + function Get_Page_Formats + return Page_Format_Info_Array; + + Page_Formats : constant Page_Format_Info_Array (A0 .. Envelope) := Get_Page_Formats; + + + pragma Inline (Name); + pragma Inline (Width); + pragma Inline (Height); + pragma Inline (Start_Job); pragma Inline (End_Job); pragma Inline (Start_Page); |