Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions
PDECustom.h File Reference
#include "nsPDECommon.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MyControls
struct  MySettings
struct  MyCustomContextBlock

Defines

#define kMyBundleIdentifier   CFSTR("org.mozilla.pde." kMozPDESignature)
#define kMyPaneKindID   kMyBundleIdentifier
#define kMyNibFile   CFSTR("PrintPDE")
#define kMyNibWindow   CFSTR("PrintPDE")
#define kMyAppPrintSettingsKey   CFSTR("com.apple.print.PrintSettingsTicket." kMozPDESignature)
#define kMyAppPageFormatKey   CFSTR("com.apple.print.PageFormatTicket." kMozPDESignature)

Typedefs

typedef MyCustomContextBlockMyCustomContext

Enumerations

enum  { kMyMaxV = 292, kMyMaxH = 478 }
enum  { kFramesAsLaidOutIndex = 1, kFramesSelectedIndex, kFramesEachSeparatelyIndex }

Functions

CFStringRef MyGetCustomTitle (Boolean stillNeeded)
MyCustomContext MyCreateCustomContext ()
void MyReleaseCustomContext (MyCustomContext)
OSStatus MyEmbedCustomControls (MyCustomContext, WindowRef, ControlRef)
OSStatus MyGetSummaryText (MyCustomContext, CFMutableArrayRef, CFMutableArrayRef)
OSStatus MySyncPaneFromTicket (MyCustomContext, PMPrintSession)
OSStatus MySyncTicketFromPane (MyCustomContext, PMPrintSession)

Class Documentation

struct MyControls

Definition at line 172 of file PDECustom.h.

Class Members
ControlRef footerCenterPopup
ControlRef footerLeftPopup
ControlRef footerRightPopup
ControlRef frameRadioGroup
ControlRef headerCenterPopup
ControlRef headerLeftPopup
ControlRef headerRightPopup
ControlRef printBGColorsCheck
ControlRef printBGImagesCheck
ControlRef printSelCheck
ControlRef shrinkToFitCheck
struct MySettings

Definition at line 186 of file PDECustom.h.

Class Members
CFStringRef mFooterCenter
CFStringRef mFooterLeft
CFStringRef mFooterRight
Boolean mHaveFrames
Boolean mHaveFrameSelected
Boolean mHaveSelection
CFStringRef mHeaderCenter
CFStringRef mHeaderLeft
CFStringRef mHeaderRight
Boolean mPrintBGColors
Boolean mPrintBGImages
Boolean mPrintFrameAsIs
Boolean mPrintFramesSeparately
Boolean mPrintSelectedFrame
Boolean mPrintSelection
Boolean mShrinkToFit
struct MyCustomContextBlock

Definition at line 203 of file PDECustom.h.

Collaboration diagram for MyCustomContextBlock:
Class Members
MyControls controls
MySettings settings

Define Documentation

#define kMyAppPageFormatKey   CFSTR("com.apple.print.PageFormatTicket." kMozPDESignature)

Definition at line 126 of file PDECustom.h.

#define kMyAppPrintSettingsKey   CFSTR("com.apple.print.PrintSettingsTicket." kMozPDESignature)

Definition at line 112 of file PDECustom.h.

#define kMyBundleIdentifier   CFSTR("org.mozilla.pde." kMozPDESignature)

Definition at line 57 of file PDECustom.h.

#define kMyNibFile   CFSTR("PrintPDE")

Definition at line 87 of file PDECustom.h.

#define kMyNibWindow   CFSTR("PrintPDE")

Definition at line 98 of file PDECustom.h.

Definition at line 75 of file PDECustom.h.


Typedef Documentation

Definition at line 208 of file PDECustom.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
kMyMaxV 
kMyMaxH 

Definition at line 148 of file PDECustom.h.

     {
    kMyMaxV = 292,
    kMyMaxH = 478
};
anonymous enum
Enumerator:
kFramesAsLaidOutIndex 
kFramesSelectedIndex 
kFramesEachSeparatelyIndex 

Definition at line 159 of file PDECustom.h.


Function Documentation

Definition at line 64 of file PDECustom.c.

{
    // allocate zeroed storage for a custom context
    MyCustomContext context = calloc (1, sizeof (MyCustomContextBlock));

    return context;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MyEmbedCustomControls ( MyCustomContext  ,
WindowRef  ,
ControlRef   
)

Definition at line 153 of file PDECustom.c.

{
    static const ControlID containerControlID = { kMozPDECreatorCode, 4000 };
    static const ControlID radioGroupControlID = { kMozPDECreatorCode, 4001 };
    static const ControlID printSelCheckControlID = { kMozPDECreatorCode, 4002 };
    static const ControlID shrinkToFitCheckControlID = { kMozPDECreatorCode, 4003 };
    static const ControlID printBGColorsCheckControlID = { kMozPDECreatorCode, 4004 };
    static const ControlID printBGImagesCheckControlID = { kMozPDECreatorCode, 4005 };
    static const ControlID headerLeftPopupControlID = { kMozPDECreatorCode, 4006 };
    static const ControlID headerCenterPopupControlID = { kMozPDECreatorCode, 4007 };
    static const ControlID headerRightPopupControlID = { kMozPDECreatorCode, 4008 };
    static const ControlID footerLeftPopupControlID = { kMozPDECreatorCode, 4009 };
    static const ControlID footerCenterPopupControlID = { kMozPDECreatorCode, 4010 };
    static const ControlID footerRightPopupControlID = { kMozPDECreatorCode, 4011 };
    
    OSStatus result = noErr;
    
    if (context != NULL)
    {
        ControlHandle paneControl = NULL;
        
        // The control we're embedding into the given
        // userPane is itself a user pane control.
        result = MyEmbedControl(nibWindow,
                                userPane,
                                &containerControlID,
                                &paneControl);
        
        if (paneControl)
        {
            WindowRef controlOwner = GetControlOwner(paneControl);
            
            GetControlByID(controlOwner,
                           &radioGroupControlID,
                           &(context->controls.frameRadioGroup));
            if (context->controls.frameRadioGroup != NULL)
            {

                // It doesn't seem to be possible to specify the titles of the
                // radio buttons within a radio group control, so do it by hand :-/
                // This is not done as a loop, but instead using CFSTR("abc") so
                // that genstrings can grok this file. Maybe that's not worth it?
                
                CFStringRef radioTitle;
                ControlRef radioControl;
                    
                if (GetIndexedSubControl(context->controls.frameRadioGroup,
                                         kFramesAsLaidOutIndex, &radioControl) == noErr)
                {
                    radioTitle = CFCopyLocalizedStringFromTableInBundle(
                                        CFSTR("As laid out on the screen"),
                                        CFSTR("Localizable"),
                                        MyGetBundle(),
                                        "top radio title");
                    if (radioTitle)
                    {
                        SetControlTitleWithCFString(radioControl, radioTitle);
                        CFRelease(radioTitle);
                    }
                }
                if (GetIndexedSubControl(context->controls.frameRadioGroup,
                                         kFramesSelectedIndex, &radioControl) == noErr)
                {
                    radioTitle = CFCopyLocalizedStringFromTableInBundle(
                                        CFSTR("The selected frame"),
                                        CFSTR("Localizable"),
                                        MyGetBundle(),
                                        "middle radio title");
                    if (radioTitle)
                    {
                        SetControlTitleWithCFString(radioControl, radioTitle);
                        CFRelease(radioTitle);
                    }
                }
                if (GetIndexedSubControl(context->controls.frameRadioGroup,
                                         kFramesEachSeparatelyIndex, &radioControl) == noErr)
                {
                    radioTitle = CFCopyLocalizedStringFromTableInBundle(
                                        CFSTR("Each frame separately"),
                                        CFSTR("Localizable"),
                                        MyGetBundle(),
                                        "bottom radio title");
                    if (radioTitle)
                    {
                        SetControlTitleWithCFString(radioControl, radioTitle);
                        CFRelease(radioTitle);
                    }
                }                
            }
 
            GetControlByID(controlOwner,
                           &printSelCheckControlID,
                           &(context->controls.printSelCheck));
            GetControlByID(controlOwner,
                           &shrinkToFitCheckControlID,
                           &(context->controls.shrinkToFitCheck));
            GetControlByID(controlOwner,
                           &printBGColorsCheckControlID,
                           &(context->controls.printBGColorsCheck));
            GetControlByID(controlOwner,
                           &printBGImagesCheckControlID,
                           &(context->controls.printBGImagesCheck));

            GetControlByID(controlOwner,
                           &headerLeftPopupControlID,
                           &(context->controls.headerLeftPopup));

            GetControlByID(controlOwner,
                           &headerCenterPopupControlID,
                           &(context->controls.headerCenterPopup));

            GetControlByID(controlOwner,
                           &headerRightPopupControlID,
                           &(context->controls.headerRightPopup));

            GetControlByID(controlOwner,
                           &footerLeftPopupControlID,
                           &(context->controls.footerLeftPopup));

            GetControlByID(controlOwner,
                           &footerCenterPopupControlID,
                           &(context->controls.footerCenterPopup));

            GetControlByID(controlOwner,
                           &footerRightPopupControlID,
                           &(context->controls.footerRightPopup));
                           
            // Now that the controls are in, sync with data.
            SyncPaneFromSettings(context);
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CFStringRef MyGetCustomTitle ( Boolean  stillNeeded)

Definition at line 105 of file PDECustom.c.

{
    static CFStringRef sTitle = NULL;

    if (stillNeeded)
    {
        if (sTitle == NULL)
        {
            // Get the name of the application hosting us.
            CFBundleRef appBundle = CFBundleGetMainBundle();
            if (appBundle)
            {
                CFStringRef bundleString = CFBundleGetValueForInfoDictionaryKey(
                                            appBundle, CFSTR("CFBundleName"));
                // We don't get an owning reference here, so make a copy.
                if (bundleString && (CFGetTypeID(bundleString) == CFStringGetTypeID()))
                    sTitle = CFStringCreateCopy(NULL, bundleString);
            }
        }
        // If that failed, use a resource - we may be hosted by an unbundled app.
        if (sTitle == NULL)
        {
            sTitle = CFCopyLocalizedStringFromTableInBundle (
                CFSTR("Web Browser"),
                CFSTR("Localizable"),
                MyGetBundle(),
                "the custom pane title");
        }
    }
    else 
    {
        if (sTitle != NULL)
        {
            CFRelease (sTitle);
            sTitle = NULL;
        }
    }

    return sTitle;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MyGetSummaryText ( MyCustomContext  ,
CFMutableArrayRef  ,
CFMutableArrayRef   
)

Definition at line 300 of file PDECustom.c.

{
    CFStringRef title = NULL;
    CFStringRef value = NULL;
    CFStringRef format = NULL;

    OSStatus result = noErr;

    // "Print Frames" Radio Group
    title = CFCopyLocalizedStringFromTableInBundle (
                CFSTR("Print Frames"),
                CFSTR("Localizable"),
                MyGetBundle(),
                "the Print Frames radio group (for summary)");

    if (title != NULL)
    {        
        if (context->settings.mHaveFrames)
        {
            if (context->settings.mPrintFrameAsIs)
                value = CFCopyLocalizedStringFromTableInBundle(
                                    CFSTR("As laid out on the screen"),
                                    CFSTR("Localizable"),
                                    MyGetBundle(),
                                    "Print Frames choice #1 (for summary)");
            else if (context->settings.mPrintSelectedFrame)
                value = CFCopyLocalizedStringFromTableInBundle(
                                    CFSTR("The selected frame"),
                                    CFSTR("Localizable"),
                                    MyGetBundle(),
                                    "Print Frames choice #2 (for summary)");
            else if (context->settings.mPrintFramesSeparately)
                value = CFCopyLocalizedStringFromTableInBundle(
                                    CFSTR("Each frame separately"),
                                    CFSTR("Localizable"),
                                    MyGetBundle(),
                                    "Print Frames choice #3 (for summary)");
        }
        else
            value = GetSummaryTextNAValue();
        
        if (value != NULL)
        {
            // append the title-value pair to the arrays
            CFArrayAppendValue (titleArray, title);
            CFArrayAppendValue (valueArray, value);
            
            CFRelease (value);
        }
        CFRelease (title);
    }

    // Print Selection
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Print Selection"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Print Selection title (for summary)");
    if (title != NULL)
    {
        if (context->settings.mHaveSelection)
            value = GetSummaryTextBooleanValue(context->settings.mPrintSelection);
        else
            value = GetSummaryTextNAValue();

        if (value != NULL)
        {
            // append the title-value pair to the arrays
            CFArrayAppendValue (titleArray, title);
            CFArrayAppendValue (valueArray, value);

            CFRelease (value);
        }
        CFRelease (title);
    }

    // Shrink To Fit
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Shrink To Fit"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Shrink To Fit title (for summary)");
    if (title != NULL)
    {
        value = GetSummaryTextBooleanValue(context->settings.mShrinkToFit);
        if (value != NULL)
        {
            // append the title-value pair to the arrays
            CFArrayAppendValue (titleArray, title);
            CFArrayAppendValue (valueArray, value);

            CFRelease (value);
        }
        CFRelease (title);
    }

    // Print BG Colors
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Print BG Colors"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Print BG Colors title (for summary)");
    if (title != NULL)
    {
        value = GetSummaryTextBooleanValue(context->settings.mPrintBGColors);
        if (value != NULL)
        {
            // append the title-value pair to the arrays
            CFArrayAppendValue (titleArray, title);
            CFArrayAppendValue (valueArray, value);

            CFRelease (value);
        }
        CFRelease (title);
    }

    // Print BG Images
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Print BG Images"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Print BG Images title (for summary)");
    if (title != NULL)
    {
        value = GetSummaryTextBooleanValue(context->settings.mPrintBGImages);
        if (value != NULL)
        {
            // append the title-value pair to the arrays
            CFArrayAppendValue (titleArray, title);
            CFArrayAppendValue (valueArray, value);

            CFRelease (value);
        }
        CFRelease (title);
    }
 
    // Page Headers
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Page Headers"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Page Headers (for summary)");
    if (title != NULL)
    {
        format = CFCopyLocalizedStringFromTableInBundle(
                            CFSTR("%@, %@, %@"),
                            CFSTR("Localizable"),
                            MyGetBundle(),
                            "Page Heaader/Footer format (for summary)");

        if (format != NULL)
        {
            value = CFStringCreateWithFormat(NULL, NULL, format,
                            GetSummaryTextHeaderFooterValue(context->settings.mHeaderLeft),
                            GetSummaryTextHeaderFooterValue(context->settings.mHeaderCenter),
                            GetSummaryTextHeaderFooterValue(context->settings.mHeaderRight));
            if (value != NULL)
            {
                // append the title-value pair to the arrays
                CFArrayAppendValue (titleArray, title);
                CFArrayAppendValue (valueArray, value);

                CFRelease (value);
            }
            CFRelease(format);
        }
        CFRelease (title);
    }

    // Page Footers
    title = CFCopyLocalizedStringFromTableInBundle(
                        CFSTR("Page Footers"),
                        CFSTR("Localizable"),
                        MyGetBundle(),
                        "Page Footers (for summary)");
    if (title != NULL)
    {
        format = CFCopyLocalizedStringFromTableInBundle(
                            CFSTR("%@, %@, %@"),
                            CFSTR("Localizable"),
                            MyGetBundle(),
                            "Page Heaader/Footer format (for summary)");

        if (format != NULL)
        {
            value = CFStringCreateWithFormat(NULL, NULL, format,
                            GetSummaryTextHeaderFooterValue(context->settings.mFooterLeft),
                            GetSummaryTextHeaderFooterValue(context->settings.mFooterCenter),
                            GetSummaryTextHeaderFooterValue(context->settings.mFooterRight));
            if (value != NULL)
            {
                // append the title-value pair to the arrays
                CFArrayAppendValue (titleArray, title);
                CFArrayAppendValue (valueArray, value);

                CFRelease (value);
            }
            CFRelease(format);
        }
        CFRelease (title);
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file PDECustom.c.

{
    MyCFAssign(NULL, context->settings.mHeaderLeft);
    MyCFAssign(NULL, context->settings.mHeaderCenter);
    MyCFAssign(NULL, context->settings.mHeaderRight);
    MyCFAssign(NULL, context->settings.mFooterLeft);
    MyCFAssign(NULL, context->settings.mFooterCenter);
    MyCFAssign(NULL, context->settings.mFooterRight);
    
    free (context);
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MySyncPaneFromTicket ( MyCustomContext  ,
PMPrintSession   
)

Definition at line 520 of file PDECustom.c.

{
    OSStatus result = noErr;
    PMTicketRef ticket = NULL;

    result = MyGetTicket (session, kPDE_PMPrintSettingsRef, &ticket);
    if (result == noErr)
    {
        CFDataRef xmlData = NULL;
        CFDictionaryRef dict = NULL;

        result = PMTicketGetCFData (
            ticket, 
            kPMTopLevel, 
            kPMTopLevel, 
            kAppPrintDialogPDEOnlyKey, 
            &xmlData
        );
        if (result == noErr)
        {
            dict = CFPropertyListCreateFromXMLData (
                        kCFAllocatorDefault,
                        xmlData,
                        kCFPropertyListImmutable,
                        NULL
                        );
            if (dict)
            {
                InternSettings(dict, &context->settings);
                CFRelease(dict);
            }
            else
                result = kPMKeyNotFound;    // bad XML?
        }
        if (result == kPMKeyNotFound)
        {
            InitSettings(&context->settings);
            result = noErr;
        }
    }

    if (result == noErr)
        SyncPaneFromSettings(context);
    
    MyDebugMessage("MySyncPane", result);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MySyncTicketFromPane ( MyCustomContext  ,
PMPrintSession   
)

Definition at line 579 of file PDECustom.c.

{
    OSStatus result = noErr;
    PMTicketRef ticket = NULL;
    CFMutableDictionaryRef dict = NULL;
    CFDataRef xmlData = NULL;

    result = MyGetTicket (session, kPDE_PMPrintSettingsRef, &ticket);
    if (result == noErr)
    {
        // If our pane has never been shown, this will be a noop.
        SyncSettingsFromPane(context);
        
        dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
                    (const CFDictionaryKeyCallBacks *)&kCFTypeDictionaryKeyCallBacks,
                    (const CFDictionaryValueCallBacks *)&kCFTypeDictionaryValueCallBacks);
        if (dict)
        {
            ExternSettings(&context->settings, dict);
            xmlData = CFPropertyListCreateXMLData(kCFAllocatorDefault, dict);
            if (xmlData)
            {
                result = PMTicketSetCFData (
                    ticket, 
                    kMyBundleIdentifier, 
                    kAppPrintDialogPDEOnlyKey, 
                    xmlData, 
                    kPMUnlocked
                );
                CFRelease(xmlData);
            }
            CFRelease(dict);
        }
    }

    MyDebugMessage("MySyncTicket", result);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: