XMPRINTSHELL(3)
๐ธ NAME ๐ธ
okay so this is the XmPrintShell(library call) page, and it's all about one thing:
XmPrintShellโ a shell widget class used for printing in Motif ๐จ๏ธโจ
๐ฆ SYNOPSIS ๐ฆ
#include <Xm/Print.h>
Boolean XmIsPrintShell(
Widget);
๐ DESCRIPTION ๐
bestie, XmPrintShell hands the Motif application programmer an Xt widget oriented API to some of the X Print resources, plus a callback to drive the pagination. it's giving "printing, but make it widget-y" ๐ฅ
So it gives you a simple callback to handle the pagination logic, and a whole set of resources to get and set common printer attributes.
Here's the tea: if it's not created on an XPrint connection, XmPrintShell just behaves as a regular applicationShell. no drama, no printing, just vibes.
It also initializes the Xp extension event handling mechanism, by registering an extension selector that calls XpSelectInput and an event dispatcher for print and attributes Xp events โ so applications can use XtInsertEventTypeHandler to register their own handler with the Xp events. iykyk ๐ซถ
๐ Arguments ๐
No XmCreate function is provided, since this is a toplevel shell, most likely created thru some Xt shell creation routine or XmPrintSetup.
โจ Classes โจ
XmPrintShell is a subclass of ApplicationShell; it inherits behavior, resources and traits from all its superclasses. The class pointer is XmPrintShellWidgetClass.
๐ New Resources ๐
๐ XmPrintShell Resource Set ๐
one bullet per resource, because we do NOT skip rows in this house:
XmNstartJobCallbackโ ClassXmCCallback, typeXtCallbackList, defaultNULL, accessCSGXmNendJobCallbackโ ClassXmCCallback, typeXtCallbackList, defaultNULL, accessCSGXmNpageSetupCallbackโ ClassXmCCallback, typeXtCallbackList, defaultNULL, accessCSGXmNminXโ ClassXmCMinX, typeDimension, defaultdynamic, accessGXmNminYโ ClassXmCMinY, typeDimension, defaultdynamic, accessGXmNmaxXโ ClassXmCMaxX, typeDimension, defaultdynamic, accessGXmNmaxYโ ClassXmCMaxY, typeDimension, defaultdynamic, accessGXmNdefaultPixmapResolutionโ ClassXmCDefaultPixmapResolution, typeunsigned short, default100, accessCSGXmNpdmNotificationCallbackโ ClassXmCCallback, typeXtCallbackList, defaultNULL, accessCSG
XmNstartJobCallbackโ specifies the callback driving the beginning of rendering. it is safe for an application to start rendering after this callback has been activated.XpStartJobmust be called to trigger this callback. โญXmNendJobCallbackโ specifies the callback driving the end of rendering. it notifies the client that all rendering has been processed (whether on print-to-file or regular spool).XpEndJobis called by the print shell to trigger this callback. ๐ฌXmNpageSetupCallbackโ specifies the callback driving the page layout. it is safe for an app to start rendering from this callback even if theXmNstartJobCallbackis not used. ๐XmNminX,XmNminY,XmNmaxX,XmNmaxYโ specify the imageable area of the page in the current print context.XmPrintShellalso maintains a proper size at all times by updating its own widget dimension whenever an attribute, such as resolution or orientation, changes. it is sized in its Initialize routine so that the application can rely on a proper size before the firstStartPagecall is issued. ๐XmNdefaultPixmapResolutionโ indicates the resolution in dpi (dot per inch) of the image files read and converted by Motif for the widget descendants of this shell. it is used to determine a scaling ratio to be applied to pixmap created thru regular pixmap/icon conversion of the following Widget resources:XmLabel.label*Pixmap,XmIconG.*IconPixmapXmToggleB.selectPixmap,XmPushBG.armPixmap,XmIconG.*IconMask,XmMessageBox.symbolPixmap,XmContainer.*StatePixmap, ...- leaving out the pixmap resources being used for tiling (
XmNhighlightPixmap,XmNtopShadowPixmap,XmNbottomShadowPixmap,XmNbackgroundPixmap, ...)
XmNpdmNotificationCallbackโ a callback notifying the application about the status of the PDM (seeXmPrintPopupPDM). aXmPrintShellCallbackStructis used, with reason:XmCR_PDM_NONE: no PDM available on this display for the named selection (provided indetail)XmCR_PDM_START_VXAUTH: the PDM is not authorized to connect to the video display.XmCR_PDM_START_PXAUTH: the PDM is not authorized to connect to the print display.XmCR_PDM_UP: the PDM is up and runningXmCR_PDM_OK: the PDM has exited with OK statusXmCR_PDM_CANCEL: the PDM has exited with CANCELXmCR_PDM_START_ERROR: the PDM cannot start due to some error (usually logged)XmCR_PDM_EXIT_ERROR: the PDM has exited with an error
๐ง Callback Information ๐ง
The XmNstartJobCallback, XmNendJobCallback, XmNpageSetupCallback and XmNpdmNotificationCallback operate on a XmPrintShellCallbackStruct, which is defined as follow:
typedef struct
{
int reason; /* XmCR_START_JOB, XmCR_END_JOB,
XmCR_PAGE_SETUP, XmCR_PDM_* */
XEvent *event;
XPContext print_context;
Boolean last_page; /* in_out */
XtPointer detail;
} XmPrintShellCallbackStruct;
๐ Additional Behavior ๐
The last_page field is only meaningful when the reason is XmCR_PAGE_SETUP.
The page setup callback is called with last_page False to notify the application that it has to get its internal layout state ready for the next page. typically, a widget based application will change the content of a Label showing the page number, or scroll the content of the Text widget. ๐
When the application has processed its last page, it should set the last_page field in the callback struct to True. The callback will be called a last time after that with last_page False to notify the application that it can safely clean-up its internal state (e.g., destroy widgets). ๐งน
No drawing should occur from within the callback function in the application, this is an Exposure event-driven programming model where widgets render themselves from their expose methods. ๐ (do NOT try to draw in there, bestie, that's not the vibe)
The print shell calls XpStartPage after the pageSetupCallback returns, and XpEndPage upon reception of StartPageNotify.
๐ ERRORS/WARNINGS ๐
XmPrintShell can generate the following warnings:
- Not connected to a valid X Print Server: behavior undefined. ๐จ
- Attempt to set an invalid resolution on a printer:
%s - Attempt to set an invalid orientation on a printer:
%s
๐ RETURN VALUE ๐
Not applicable
โญ EXAMPLES โญ
okay, code time. look at her go:
PrintOnePageCB(Widget pshell, XtPointer npages,
/*----------*/ XmPrintSetPageCBStruct psp)
{
static int cur_page = 0;
cur_page++;
if (! psp->last_page
&& curPage > 1) /* no need to scroll for the first page */
{
XmTextScroll(ptext, prows); /* get ready for next page */
} else { /**** I'm done */
XtDestroyWidget(pshell);
XtCloseDisplay(XtDisplay(pshell));
}
if (cur_page == (int) n_pages) psp->last_page = True;
}
PrintOKCallback(...)
/*-------------*/
{
pshell = XmPrintSetup (widget, pbs->print_screen,
"Print", NULL, 0);
XpStartJob(XtDisplay(pshell), XPSpool);
/**** here I get the size of the shell, create my widget
hierarchy: a bulleting board, and then a text widget,
that I stuff with the video text widget buffer */
/* get the total number of pages to print */
/* same code as previous example to get n_pages */
/**** set up my print callback */
XtAddCallback(pshell, XmNpageSetUpCallback,
PrintOnePageCB, n_pages);
}
Examples of XmNdefaultPixmapResolution usage:
- An application reuses the same image sources it uses for the video interface, in XBM, XPM, PNG ot JPEG, to layout on its printed pages. In this case, scaling is seamless. โจ
! icon.xpm is 30x30 pixels
app*dialog.pushb.labelPixmap:icon.xpm
! print is 400dpi
app.print*form.lab.labelPixmap:icon.xpm
! 120x120 pixels on the paper (auto scaling)
- An application provides a new set of image files, for a given printer resolution (say 300). It doesn't want automatic scaling by the toolkit for that resolution, it wants scaling based on these 300dpi images for higher resolution. It creates its print shell inside using the name
"printHiRes"and adds the following in its resource file:
app.printHiRes.defaultPixmapResolution:300
! icon300.xpm is 120x120 pixels
app.printHiRes*form.lab.labelPixmap:icon300.xpm
! 120x120 pixels on the paper (no scaling)
This way a printer resolution of 600 will result in a scale of a 300 dpi image by 2 (dpi=600 divided by base=300), while a printer resolution of 150 (using default print shell name "print") will use the 100 dpi icon scaled by 1.5 (dpi=150 divided by default base=100). math ate, honestly ๐งฎ๐
๐ฅ SEE ALSO ๐ฅ
and that's the whole page, bestie ๐ซถ this was XmPrintShell(library call) โ that's the source and the manual name right there in the footer, no date or version in sight, so consider this your cute lil sign-off. go print something iconic. ๐๐จ๏ธ๐
๐ฆ where this page comes from
- arch rolling: openmotif 2.3.8-4 ยท LGPL-2.1-or-later
- centos-stream 9: motif-devel 2.3.4-32.el9 ยท LGPLv2+
- centos-stream 9: motif-devel 2.3.4-32.el9 ยท LGPLv2+
- epel 10: motif-devel 2.3.8-2.el10_2 ยท LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 ยท LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 ยท LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 ยท LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 ยท LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 ยท LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 ยท LicenseRef-Callaway-LGPLv2+
- nixos 26.05: motif 2.3.8
- nixpkgs unstable: motif 2.3.8
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 ยท LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms