www.riscos.com Technical Support: |
|
When a Print dialogue is created, it has the following components:
Pressing Escape cancels the dialogue (as well as clicking on the Cancel button).
The title bar of the dialogue box displays the name of the currently selected printer or 'Unknown printer' if there is no such printer.
All processing of the dialogue box is handled by the Print module, and the client is informed of any user actions via Toolbox events (PrintDbox_Print, PrintDbox_SetUp, PrintDbox_DialogueCompleted and PrintDbox_Save).
A Print Dialogue object has the following attributes which are specified in its object template and can be manipulated at run-time by the client application:
Attributes | Description | |
---|---|---|
flags word | Bit | Meaning |
0 | when set, this bit indicates that a PrintDbox_AboutToBeShown event should be raised when SWI Toolbox_ShowObject is called for this object. | |
1 | when set, this bit indicates that a PrintDbox_DialogueCompleted event should be raised when the Print Dialogue object has been removed from the screen. | |
2 | when set, this bit indicates generate PrintDbox_SetUpAboutToBeShown event before the underlying SetUp object is shown | |
3 | when set, dialogue box has the All/From/To Page Range options | |
4 | when set, dialogue box has the Copies writable field | |
5 | when set, dialogue box has the Scale writable field | |
6 | when set, dialogue box has the Orientation options (i.e. Upright and Sideways) | |
7 | when set, dialogue box has Save action button | |
8 | when set, dialogue box has Set Up ... action button | |
9 | when set, dialogue box has Draft option button | |
10 | when set, dialogue box has From/to set from All/From/to | |
11 | when set, dialogue box has Sideways (and not Upright) selected | |
12 | when set, dialogue box has Draft selected | |
from | initial value to put in the From writable field | |
to | initial value to put in the to writable field | |
copies | initial value to put in the Copies number range | |
scale | initial value to put in the Scale number range | |
further options | name of the template for a Window object to be displayed when Setup... is clicked | |
window | name of the template for an alternative window to use instead of the default one (0 means use default) |
A Print Dialogue object is created using SWI Toolbox_CreateObject.
When a Print Dialogue object is created, the following attached object (see Attached objects) will be created (if specified):
A Print Dialogue object is deleted using SWI Toolbox_DeleteObject. If it has any attached objects (see above), these are also deleted, unless the non-recursive bit is set for this SWI.
The setting of the non-recursive delete bit means that the SetUp dialogue box will not be deleted.
When a Print Dialogue object is displayed on the screen using SWI Toolbox_ShowObject it has the following behaviour:
Show type | Position | ||
---|---|---|---|
0 (default) | the underlying window is shown at the last place shown on the screen, or the coordinates given in its template, if it has not already been shown | ||
1 (full spec) | R3 + 0 | visible area minimum x coordinate | |
R3 + 4 | visible area minimum y coordinate | ||
R3 + 8 | visible area maximum x coordinate | ||
R3 + 12 | visible area maximum y coordinate | ||
R3 + 16 | scroll x offset relative to work area | ||
R3 + 20 | scroll y offset relative to work area | ||
R3 + 24 | Wimp window handle of window to open behind | ||
-1 | means top of stack | ||
-2 | means bottom of stack | ||
-3 | means the window behind the Wimp's backwindow | ||
2 (topleft) | R3 + 0 | visible area minimum x coordinate | |
R3 + 4 | visible area minimum y coordinate |
When the client (or the Toolbox) calls Toolbox_ShowObject on a Print Dialogue object, a PrintDbox_AboutToBeShown Toolbox event is raised before the dialogue box becomes visible on the screen (if the appropriate flags bit is set).
This allows the client to set up the contents of the dialogue box appropriately.
A Print dialogue box contains many fields which are either options or writable fields. These are:
Each of these components can be read and set dynamically using the following methods:
PrintDbox_SetPageRange
PrintDbox_GetPageRange
PrintDbox_SetCopies
PrintDbox_GetCopies
PrintDbox_SetScale
PrintDbox_GetScale
PrintDbox_SetOrientation
PrintDbox_GetOrientation
PrintDbox_SetDraft
PrintDbox_GetDraft
When the user clicks a particular action button (or presses Return or Escape), the client receives one of the following Toolbox events:
The string appearing in the Print Dialogue's title bar is the currently selected printer (or 'unknown printer' if there is no such printer). This string can be read using the PrintDbox_GetTitle method.
If the Print Dialogue is persistent, and the currently selected Printer is changed, then the Title Bar will change to reflect this.
The object id of the Window used to implement a Print Dialogue can be obtained using the PrintDbox_GetWindowID method.
It is possible to specify the name of a template to be used for showing an object when the SetUp... button is pressed. This object is shown in its default place persistently.
The following methods are all invoked by calling SWI Toolbox_ObjectMiscOp with:
R0 | holding a flags word |
R1 | being a Print Dialogue object id |
R2 | being the method code which distinguishes this method |
R3-R9 | potentially holding method-specific data |
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 0 |
R0 | = | Window object id for this Print object |
This method returns the id of the underlying Window object used to implement this Print object.
extern _kernel_oserror *printdbox_get_window_id ( unsigned int flags, ObjectId printdbox, ObjectId *window );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 1 |
R3 | = | start of page range |
R4 | = | end of page range |
R1-R9 preserved |
This method is used to set the page range for a Print Dialogue.
A 'start' value of -1 means 'All'.
extern _kernel_oserror *printdbox_set_page_range ( unsigned int flags, ObjectId printdbox, int start, int end );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 2 |
R0 | = | start of page range (a 'start' value of -1 means 'All') |
R1 | = | end of page range |
This method is used to return the page range for a Print Dialogue.
extern _kernel_oserror *printdbox_get_page_range ( unsigned int flags, ObjectId printdbox, int *start, int *end );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 3 |
R3 | = | number of copies |
R1-R9 preserved |
This method is used to set the number of copies field for a Print Dialogue.
extern _kernel_oserror *printdbox_set_copies ( unsigned int flags, ObjectId printdbox, int copies );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 4 |
R0 | = | number of copies to be printed |
This method returns the value of the Copies field for a Print Dialogue.
extern _kernel_oserror *printdbox_get_copies ( unsigned int flags, ObjectId printdbox, int *copies );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 5 |
R3 | = | percentage value to scale by |
R1-R9 preserved |
This method is used to set the scale factor for a Print Dialogue.
extern _kernel_oserror *printdbox_set_scale ( unsigned int flags, ObjectId printdbox, int scale_factor );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 6 |
R0 | = | percentage scale factor |
This method returns the value of the scale factor for a Print Dialogue.
extern _kernel_oserror *printdbox_get_scale ( unsigned int flags, ObjectId printdbox, int *scale_factor );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 7 |
R3 | = | non-zero means Sideways, 0 means Upright |
R1-R9 preserved |
This method is used to set the orientation for a Print Dialogue.
extern _kernel_oserror *printdbox_set_orientation ( unsigned int flags, ObjectId printdbox, int orientation );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 8 |
R0 | = | orientation non-zero means Sideways, 0 means Upright |
This method returns the orientation for a Print Dialogue.
extern _kernel_oserror *printdbox_get_orientation ( unsigned int flags, ObjectId printdbox, int *orientation );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 9 |
R3 | = | pointer to buffer to hold title string |
R4 | = | size of buffer to hold title string |
R4 | = | size of buffer required to hold title string (if R3 was 0)
else buffer pointed at by R3 holds title string R4 holds number of bytes written to buffer |
This method returns the current string used in a Print object's title bar.
extern _kernel_oserror *printdbox_get_title ( unsigned int flags, ObjectId printdbox, char *buffer, int buff_size, int *nbytes );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 10 |
R3 | = | non-zero means Draft, 0 means 'non-draft' |
R1-R9 preserved |
This method is used to set whether draft printing is used for a Print Dialogue.
extern _kernel_oserror *printdbox_set_draft ( unsigned int flags, ObjectId printdbox, int draft );
R0 | = | flags |
R1 | = | Print Dbox object id |
R2 | = | 11 |
R0 | = | draft non-zero means Draft, 0 means 'non-draft' |
This method returns whether draft printing is used for a Print Dialogue.
extern _kernel_oserror *printdbox_get_draft ( unsigned int flags, ObjectId printdbox, int *draft );
+ 8 | 0x82b00 |
+ 12 | flags (as passed in to Toolbox_ShowObject) |
+ 16 | value which will be passed in R2 to ToolBox_ShowObject |
+ 20... | block which will be passed in R3 to ToolBox_ShowObject for the
underlying dialogue box |
This Toolbox event is raised just before the Print module is going to show its underlying Window object.
typedef struct { ToolboxEventHeader hdr; int show_type; union { TopLeft pos; WindowShowObjectBlock full; } info; } PrintDboxAboutToBeShownEvent;
+ 8 | 0x82b01 |
+ 12 | flags |
This Toolbox event is raised after the Print object has been hidden, either by a Cancel click, or after a successful print, or by the user clicking outside the dialogue box (if it is transient) or pressing Escape. It allows the client to tidy up its own state associated with this dialogue.
typedef struct { ToolboxEventHeader hdr; } PrintDboxDialogueCompletedEvent;
+ 8 | 0x82b02 |
+ 16 | object id of the object about to be shown
(note that the 'self' id in the id block will be for the Print Dialogue object, not the object which will be shown) |
+ 20 | value which will be passed in R2 to ToolBox_ShowObject |
+ 24... | block which will be passed in R3 to ToolBox_ShowObject for the
underlying dialogue box |
This Toolbox event is raised just before the Print module is going to show its underlying Window object.
typedef struct { ToolboxEventHeader hdr; ObjectId object_id; int show_type; union { TopLeft pos; WindowShowObjectBlock full; } info; } PrintDboxSetUpAboutToBeShownEvent;
+ 8 | 0x82b03 |
+ 12 | flags
bit 0 set means print Sideways (default is Upright) bit 1 set means print Draft (default is non-draft) |
+ 16 | page range start (-1 means All) |
+ 20 | page range end |
+ 24 | number of copies |
+ 28 | value to scale by (a percentage) |
This Toolbox event is raised when the user clicks on the Save button. The client should save any options associated with this Print Dialogue (usually in a document which is being edited).
typedef struct { ToolboxEventHeader hdr; int start_page; int finish_page; int copies; int scale_factor; } PrintDboxSaveEvent;
+ 8 | 0x82b04 |
This Toolbox event is raised when the user clicks on the Set Up... button, if there is no dialogue box associated with this button.
typedef struct { ToolboxEventHeader hdr; } PrintDboxSetUpEvent;
+ 8 | 0x82b05 |
+ 12 | flags
bit 0 set means print Sideways (default is Upright) bit 1 set means print Draft (default is non-draft) |
+ 16 | page range start (-1 means All) |
+ 20 | page range end |
+ 24 | number of copies |
+ 28 | value to scale by (a percentage) |
This Toolbox event is raised when the user clicks on the Print button or presses Return.
typedef struct { ToolboxEventHeader hdr; int start_page; int finish_page; int copies; int scale_factor; } PrintDboxPrintEvent;
The layout of a Print template is shown below. Fields which have types MsgReference and StringReference are those which will require relocation when they are loaded from a resource file. If the template is being constructed in memory, then these fields should be real pointers (i.e. they do not require relocation).
For more details on relocation, see Resource File Formats.
Field | Size in bytes | Type |
---|---|---|
flags | 4 | word |
from | 4 | word |
to | 4 | word |
copies | 4 | word |
scale | 4 | word |
further_options | 4 | StringReference |
window | 4 | StringReference |
The Window object used to implement a Print dialogue, has the following characteristics. These must be reproduced if the Window is replaced by a client-specified alternative Window template:
Title bar must be indirected.
Component ids are derived by adding to 0x82b000.
Component id | Details | |
---|---|---|
0 | action button (Print) | this should be marked as the 'default' action button |
1 | action button (Save) | this should be marked as a 'local' action button |
2 | action button (Cancel) | this should be marked as the 'cancel' action button |
3 | radio button (From/To) | this is selected to allow page ranges to be printed |
4 | radio button (All) | selected for all page print |
5 & 6 | writable field (From) writable field (To) | these are used by the user to enter a page range |
7 | number range (Copies) | these are used by the user to enter the number of copies |
8 | number range (Scale) | these are used by the user to specify a scale |
9 | radio button (Upright) | selected for portrait |
10 | radio button (Sideways) | selected for landscape |
11 | option button (Draft) | selected for draft |
12 | action button (SetUp...) | this is used to bring up a Window of further options |
13 | label (To) | |
14 | label (Copies) | |
15 | label (Scale) | |
16 | label (%) |