Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
PDEUtilities.c File Reference
#include <Carbon/Carbon.h>
#include <Print/PMPrintingDialogExtensions.h>
#include "PDECore.h"
#include "PDECustom.h"
#include "PDEUtilities.h"

Go to the source code of this file.

Defines

#define kMyNumberOfEventTypes   1

Functions

static OSStatus MyHandleHelpEvent (EventHandlerCallRef, EventRef, void *userData)
void MyDebugMessage (char *msg, SInt32 value)
CFTypeRef MyCFAssign (CFTypeRef srcRef, CFTypeRef dstRef)
static CFBundleRef _MyGetBundle (Boolean stillNeeded)
CFBundleRef MyGetBundle ()
void MyFreeBundle ()
CFStringRef MyGetTitle ()
void MyFreeTitle ()
OSStatus MyGetTicket (PMPrintSession session, CFStringRef ticketID, PMTicketRef *ticketPtr)
OSStatus MyEmbedControl (WindowRef nibWindow, ControlRef userPane, const ControlID *controlID, ControlRef *outControl)
void MyReleaseContext (MyContext context)
OSStatus MyInstallHelpEventHandler (WindowRef inWindow, EventHandlerRef *outHandler, EventHandlerUPP *outHandlerUPP)
OSStatus MyRemoveHelpEventHandler (EventHandlerRef *helpHandlerP, EventHandlerUPP *helpHandlerUPP)

Define Documentation

Definition at line 316 of file PDEUtilities.c.


Function Documentation

static CFBundleRef _MyGetBundle ( Boolean  stillNeeded) [static]

Definition at line 105 of file PDEUtilities.c.

{
    static CFBundleRef sBundle = NULL;
    
    if (stillNeeded)
    {
        if (sBundle == NULL)
        {
            sBundle = CFBundleGetBundleWithIdentifier (kMyBundleIdentifier);
            CFRetain (sBundle);
        }
    }
    else
    {
        if (sBundle != NULL)
        {
            CFRelease (sBundle);
            sBundle = NULL;
        }
    }

    return sBundle;
}

Here is the caller graph for this function:

CFTypeRef MyCFAssign ( CFTypeRef  srcRef,
CFTypeRef  dstRef 
)

Definition at line 89 of file PDEUtilities.c.

{
    if (srcRef)
        CFRetain(srcRef);
    if (dstRef)
        CFRelease(dstRef);
    dstRef = srcRef;
    return dstRef;
}

Here is the caller graph for this function:

void MyDebugMessage ( char *  msg,
SInt32  value 
)

Definition at line 73 of file PDEUtilities.c.

{
    char *debug = getenv ("PDEDebug");
    if (debug != NULL)
    {
        fprintf (stdout, "%s (%d)\n", msg, (int) value);
        fflush (stdout);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MyEmbedControl ( WindowRef  nibWindow,
ControlRef  userPane,
const ControlID *  controlID,
ControlRef *  outControl 
)

Definition at line 225 of file PDEUtilities.c.

{
    ControlRef control = NULL;
    OSStatus result = noErr;

    *outControl = NULL;

    result = GetControlByID (nibWindow, controlID, &control);
    if (result == noErr)
    {
        SInt16 dh, dv;
        Rect nibFrame, controlFrame, paneFrame;

        (void) GetWindowBounds (nibWindow, kWindowContentRgn, &nibFrame);
        (void) GetControlBounds (userPane, &paneFrame);
        (void) GetControlBounds (control, &controlFrame);
        
        // find vertical and horizontal deltas needed to position the control
        // such that the nib-based interface is centered inside the dialog pane

        dh = ((paneFrame.right - paneFrame.left) - 
                (nibFrame.right - nibFrame.left))/2;

        if (dh < 0) dh = 0;

        dv = ((paneFrame.bottom - paneFrame.top) - 
                (nibFrame.bottom - nibFrame.top))/2;

        if (dv < 0) dv = 0;
                
        OffsetRect (
            &controlFrame, 
            paneFrame.left + dh, 
            paneFrame.top + dv
        );
 
        (void) SetControlBounds (control, &controlFrame);

        // make visible
        result = SetControlVisibility (control, TRUE, FALSE);

        if (result == noErr) 
        {
            result = EmbedControl (control, userPane);
            if (result == noErr)
            {
                // return the control only if everything worked
                *outControl = control;
            }
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 148 of file PDEUtilities.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 174 of file PDEUtilities.c.

Here is the call graph for this function:

Here is the caller graph for this function:

CFBundleRef MyGetBundle ( )

Definition at line 136 of file PDEUtilities.c.

{
    return _MyGetBundle (TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MyGetTicket ( PMPrintSession  session,
CFStringRef  ticketID,
PMTicketRef *  ticketPtr 
)

Definition at line 188 of file PDEUtilities.c.

{
    OSStatus result = noErr;
    CFTypeRef type = NULL;
    PMTicketRef ticket = NULL;
    
    *ticketPtr = NULL;

    result = PMSessionGetDataFromSession (session, ticketID, &type);

    if (result == noErr)
    {    
        if (CFNumberGetValue (
            (CFNumberRef) type, kCFNumberSInt32Type, (void*) &ticket))
        {
            *ticketPtr = ticket;
        }
        else {
            result = kPMInvalidValue;
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CFStringRef MyGetTitle ( )

Definition at line 162 of file PDEUtilities.c.

{
    return MyGetCustomTitle (TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static OSStatus MyHandleHelpEvent ( EventHandlerCallRef  call,
EventRef  event,
void userData 
) [static]

Definition at line 389 of file PDEUtilities.c.

{
    HICommand   commandStruct;
    OSStatus    result = eventNotHandledErr;

    GetEventParameter (
        event, kEventParamDirectObject,
        typeHICommand, NULL, sizeof(HICommand), 
        NULL, &commandStruct
    );

    if (commandStruct.commandID == 'help')
    {
        // result = MyDisplayHelp();
        // MyDebugMessage("handled help event", result);
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MyInstallHelpEventHandler ( WindowRef  inWindow,
EventHandlerRef *  outHandler,
EventHandlerUPP *  outHandlerUPP 
)

Definition at line 318 of file PDEUtilities.c.

{
    static const EventTypeSpec sEventTypes [kMyNumberOfEventTypes] =
    {
        { kEventClassCommand, kEventCommandProcess }
    };

    OSStatus result = noErr;
    EventHandlerRef handler = NULL;
    EventHandlerUPP handlerUPP = NewEventHandlerUPP (MyHandleHelpEvent);

    result = InstallWindowEventHandler (
        inWindow,
        handlerUPP,
        kMyNumberOfEventTypes,
        sEventTypes,
        NULL, 
        &handler
    );

    *outHandler = handler;
    *outHandlerUPP = handlerUPP;
    
    MyDebugMessage("InstallEventHandler", result);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 295 of file PDEUtilities.c.

{
    if (context != NULL)
    {
        if (context->customContext != NULL) {
            MyReleaseCustomContext (context->customContext);
        }

        free (context);
    }
}

Here is the call graph for this function:

OSStatus MyRemoveHelpEventHandler ( EventHandlerRef *  helpHandlerP,
EventHandlerUPP *  helpHandlerUPP 
)

Definition at line 357 of file PDEUtilities.c.

{
    OSStatus result = noErr;
    
    // we remove the help handler if there is still one present
    if (*helpHandlerP != NULL)
    {
        MyDebugMessage("Removing event handler", result);
        result = RemoveEventHandler (*helpHandlerP);
        *helpHandlerP = NULL;
    }

    if (*helpHandlerUPP != NULL)
    {
        DisposeEventHandlerUPP (*helpHandlerUPP);
        *helpHandlerUPP = NULL;
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: