Example #1
0
// --------------------------------------------------------------------------------------
void SetPrefsWindowHelpTags(WindowRef prefsWindow)
{
	CFBundleRef mainBundle;
	CFStringRef dataBrowserString, userPaneString, staticTextString;
	HMHelpContentRec dataBrowserContent, userPaneContent, staticTextContent;
	ControlID dataBrowserID = {kAppSignature, kIconDataBrowserID};
	ControlRef dataBrowser, rootControl, userPane, staticText;
	UInt16 panelIndex;
	
	mainBundle = CFBundleGetMainBundle();
	
		// set the help tag for the data browser
	dataBrowserString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Window Data Browser"), 
																NULL, mainBundle, NULL);
	
	dataBrowserContent.version = kMacHelpVersion;
	SetRect(&dataBrowserContent.absHotRect, 0, 0, 0, 0);
	dataBrowserContent.tagSide = kHMDefaultSide;
	dataBrowserContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	dataBrowserContent.content[kHMMinimumContentIndex].u.tagCFString = dataBrowserString;
	dataBrowserContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
	GetControlByID(prefsWindow, &dataBrowserID, &dataBrowser);
	HMSetControlHelpContent(dataBrowser, &dataBrowserContent);
	CFRelease(dataBrowserString);
	
		// set the help tags for the user panes
	userPaneString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, 
															mainBundle, NULL);
	
	userPaneContent.version = kMacHelpVersion;
	SetRect(&userPaneContent.absHotRect, 0, 0, 0, 0);
	userPaneContent.tagSide = kHMDefaultSide;
	userPaneContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	userPaneContent.content[kHMMinimumContentIndex].u.tagCFString = userPaneString;
	userPaneContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
		// set the help tags for the static texts
	staticTextString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, 
																mainBundle, NULL);
	
	staticTextContent.version = kMacHelpVersion;
	SetRect(&staticTextContent.absHotRect, 0, 0, 0, 0);
	staticTextContent.tagSide = kHMDefaultSide;
	staticTextContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent;
	staticTextContent.content[kHMMinimumContentIndex].u.tagCFString = staticTextString;
	staticTextContent.content[kHMMaximumContentIndex].contentType = kHMNoContent;
	
	GetRootControl(prefsWindow, &rootControl);
	for (panelIndex = 1; panelIndex <=  kNumberOfRows; panelIndex++)
	{
		GetIndexedSubControl(rootControl, panelIndex, &userPane);
		HMSetControlHelpContent(userPane, &userPaneContent);
		
		GetIndexedSubControl(userPane, 1, &staticText);
		HMSetControlHelpContent(staticText, &staticTextContent);
	}
	CFRelease(userPaneString);
	CFRelease(staticTextString);
}
Example #2
0
// --------------------------------------------------------------------------------------
static void changePanel(WindowRef window, short newPanel)
{
    ControlRef rootControl, userPane;

    GetRootControl(window, &rootControl);

    GetIndexedSubControl(rootControl, gPanelNumber, &userPane);
    SetControlVisibility(userPane, false, false);	// hide the currently active panel

    GetIndexedSubControl(rootControl, newPanel, &userPane);
    SetControlVisibility(userPane, true, true);		// and show the newly selected panel
    gPanelNumber = newPanel;
}
Example #3
0
// --------------------------------------------------------------------------------------
void CalculateBalloonHelpRects(WindowRef prefsWindow)
{
	GrafPtr savedPort;
	ListHandle iconList;
	Point tips[3];
	Rect hotRects[3], userPaneBounds;
	ControlRef rootControl, userPane;
	
	GetPort(&savedPort);
	SetPortWindowPort(prefsWindow);
	
	GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, 
						&iconList);
	SetPt(&tips[0], kPlatinumWindowEdgeSpacing + kListWidth, kPlatinumWindowEdgeSpacing + 10);
	SetRect(&hotRects[0], (*iconList)->rView.left, (*iconList)->rView.top, 
			(*iconList)->rView.right, (*iconList)->rView.bottom);	// set the icon list tip 
																	// and hot rectangle
	
	SetPt(&tips[1], 203, 219);			// set the static text tip and hot rectangle
	SetRect(&hotRects[1], 149, 213, 213, 229);	// these coordinates are all arbitrary
	
	GetRootControl(prefsWindow, &rootControl);			// the only thing embedded in the 
	GetIndexedSubControl(rootControl, 1, &userPane);	// root control is the user panes and 
	SetRect(&userPaneBounds, (*userPane)->contrlRect.left, (*userPane)->contrlRect.top, 
			(*userPane)->contrlRect.right, (*userPane)->contrlRect.bottom);		// they're 
																		// all the same size
	SetPt(&tips[2], userPaneBounds.right - 10, userPaneBounds.top + 10);
	SetRect(&hotRects[2], userPaneBounds.left, userPaneBounds.top, userPaneBounds.right, 
			userPaneBounds.bottom);		// set the user pane tip and hot rectangle
	
	SetWindowProperty(prefsWindow, kAppSignature, kBalloonTipsTag, 3 * sizeof(Point), tips);
	SetWindowProperty(prefsWindow, kAppSignature, kHotRectsTag, 3 * sizeof(Rect), hotRects);
	
	SetPort(savedPort);
}
Example #4
0
// MW-2011-09-11: [[ Redraw ]] Force an immediate update of the window within the given
//   region but using the pixmap given.
void MCStack::updatewindowwithbuffer(Pixmap p_pixmap, MCRegionRef p_region)
{
	HIViewRef t_root;
	GetRootControl((WindowPtr)window -> handle . window, &t_root);
	
	HIViewRef t_view;
	GetIndexedSubControl(t_root, 1, &t_view);
	HIViewSetNeedsDisplayInRegion(t_view, (RgnHandle)p_region, TRUE);
		
	// Set the file-local static to the pixmap to use (stacksurface picks this up!)
	s_update_pixmap = p_pixmap;
	HIViewRender(t_view);
	// Unset the file-local static.
	s_update_pixmap = nil;
	
	// MW-2011-10-18: [[ Bug 9798 ]] Make sure we force a screen update after every
	//   update.
	// MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
	// HIWindowFlush((WindowPtr)window -> handle . window);
	
	// Update the shadow, if required.
	if (getextendedstate(ECS_MASK_CHANGED))
	{
		// MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
		HIWindowFlush((WindowPtr)window -> handle . window);
		
		HIWindowInvalidateShadow((WindowPtr)window -> handle . window);
		
		EnableScreenUpdates();
		
		setextendedstate(False, ECS_MASK_CHANGED);
	}
}
Example #5
0
void MCRevolutionStackViewRelink(WindowRef p_window, MCStack *p_new_stack)
{
	EventRef t_event;
	CreateEvent(NULL, 'revo', 'rlnk', GetCurrentEventTime(), 0, &t_event);
	SetEventParameter(t_event, 'Stak', typeVoidPtr, sizeof(void *), &p_new_stack);
	
	HIViewRef t_root;
	GetRootControl(p_window, &t_root);
	
	HIViewRef t_view;
	GetIndexedSubControl(t_root, 1, &t_view);
	SendEventToEventTarget(t_event, GetControlEventTarget(t_view));
	ReleaseEvent(t_event);
}
Example #6
0
// MW-2011-09-11: [[ Redraw ]] Force an immediate update of the window within the given
//   region. The actual rendering is done by deferring to the 'redrawwindow' method.
void MCStack::updatewindow(MCRegionRef p_region)
{
	HIViewRef t_root;
	GetRootControl((WindowPtr)window -> handle . window, &t_root);
	
	HIViewRef t_view;
	GetIndexedSubControl(t_root, 1, &t_view);
	
	// MW-2011-10-07: [[ Bug 9792 ]] If the mask hasn't changed, use the update region,
	//   else redraw the whole view.
	if (!getextendedstate(ECS_MASK_CHANGED))
		HIViewSetNeedsDisplayInRegion(t_view, (RgnHandle)p_region, TRUE);
	else
	{
		HIViewSetNeedsDisplay(t_view, TRUE);
		DisableScreenUpdates();
	}
	
	HIViewRender(t_view);
	
	// MW-2012-09-04: [[ Bug 10333 ]] Flush the window immediately to make sure
	//   we see every update.
	// MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
	// HIWindowFlush((WindowPtr)window -> handle . window);
	
	// Update the shadow, if required.
	if (getextendedstate(ECS_MASK_CHANGED))
	{
		// MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved.
		HIWindowFlush((WindowPtr)window -> handle . window);
	
		HIWindowInvalidateShadow((WindowPtr)window -> handle . window);
		
		EnableScreenUpdates();
		
		setextendedstate(False, ECS_MASK_CHANGED);
	}
}
Example #7
0
void MCStack::syncscroll(void)
{
	// If we have no window, no need to adjust the HIView.
	if (window == nil)
		return;
	
	// And tweak the HIView's location...
	ControlRef t_root_control;
	GetRootControl((WindowPtr)window -> handle . window, &t_root_control);
	ControlRef t_subcontrol;
	if (GetIndexedSubControl(t_root_control, 1, &t_subcontrol) == noErr)
	{
		Rect t_bounds;
		t_bounds . left = 0;
		t_bounds . top = -m_scroll;
		t_bounds . right = rect . width;
		t_bounds . bottom = rect . height;
		SetControlBounds(t_subcontrol, &t_bounds);
	}
	
	// MW-2011-11-30: [[ Bug 9887 ]] Make sure all the player objects on this
	//   stack are adjusted as appropriate.
	for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
		if (!t_player -> isbuffering() && t_player -> getstack() == this)
			t_player -> setrect(t_player -> getrect());
			
	// MW-2012-10-08: [[ Bug 10442 ]] Set the scroll window property so revBrowser
	//   works properly.
	SetWindowProperty((WindowPtr)window -> handle . window, 'revo', 'scrl', 4, &m_scroll);
	
	// Now send a sync event so revBrowser picks it up.
	EventRef t_event;
	CreateEvent(NULL, 'revo', 'sync', GetCurrentEventTime(), 0, &t_event);
	SendEventToEventTarget(t_event, GetWindowEventTarget((WindowPtr)window -> handle . window));
	ReleaseEvent(t_event);
}
static void SyncPaneFromSettings(MyCustomContext context)
{
    if (context->controls.frameRadioGroup)
    {
        if (context->settings.mHaveFrames)
        {
            EnableControl(context->controls.frameRadioGroup);

            if (context->settings.mPrintSelectedFrame &&
                    context->settings.mHaveFrameSelected)
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesSelectedIndex);
            else if (context->settings.mPrintFramesSeparately)
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesEachSeparatelyIndex);
            else /* (context->settings.mPrintFrameAsIs) */
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesAsLaidOutIndex);
            
            if (!context->settings.mHaveFrameSelected)
            {
                ControlRef radioControl;
                if (GetIndexedSubControl(context->controls.frameRadioGroup,
                                          kFramesSelectedIndex, &radioControl) == noErr)
                    DisableControl(radioControl);
            }
        }
        else
        {
            DisableControl(context->controls.frameRadioGroup);
            SetControl32BitValue(context->controls.frameRadioGroup, 0);
        }
    }
    
    if (context->controls.printSelCheck)
    {
        if (context->settings.mHaveSelection)
        {
            EnableControl(context->controls.printSelCheck);
            SetControl32BitValue(context->controls.printSelCheck,
                            context->settings.mPrintSelection);
        }
        else
        {
            DisableControl(context->controls.printSelCheck);
            SetControl32BitValue(context->controls.printSelCheck, 0);
        }
    }
    if (context->controls.shrinkToFitCheck)
        SetControl32BitValue(context->controls.shrinkToFitCheck,
                        context->settings.mShrinkToFit);
    if (context->controls.printBGColorsCheck)
        SetControl32BitValue(context->controls.printBGColorsCheck,
                        context->settings.mPrintBGColors);
    if (context->controls.printBGImagesCheck)
        SetControl32BitValue(context->controls.printBGImagesCheck,
                        context->settings.mPrintBGImages);
                        
    if (context->controls.headerLeftPopup)
      SetControl32BitValue(context->controls.headerLeftPopup,
                        GetIndexForPrintString(context->settings.mHeaderLeft));
    if (context->controls.headerCenterPopup)
      SetControl32BitValue(context->controls.headerCenterPopup,
                        GetIndexForPrintString(context->settings.mHeaderCenter));
    if (context->controls.headerRightPopup)
      SetControl32BitValue(context->controls.headerRightPopup,
                        GetIndexForPrintString(context->settings.mHeaderRight));

    if (context->controls.footerLeftPopup)
      SetControl32BitValue(context->controls.footerLeftPopup,
                        GetIndexForPrintString(context->settings.mFooterLeft));
    if (context->controls.footerCenterPopup)
      SetControl32BitValue(context->controls.footerCenterPopup,
                        GetIndexForPrintString(context->settings.mFooterCenter));
    if (context->controls.footerRightPopup)
      SetControl32BitValue(context->controls.footerRightPopup,
                         GetIndexForPrintString(context->settings.mFooterRight));

}
extern OSStatus MyEmbedCustomControls (
    MyCustomContext context,
    WindowRef nibWindow,
    ControlRef userPane
)

{
    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;
}
Example #10
0
// --------------------------------------------------------------------------------------
void AdjustControls(WindowRef prefsWindow)
{
    Rect contentRect, listViewRect;
    ControlRef rootControl, userPane;
    SInt16 userPaneWidth, userPaneHeight;
    UInt16 panelIndex;
    ListHandle iconList;
    short oldListHeight, newListHeight;

    GetWindowBounds(prefsWindow, kWindowContentRgn, &contentRect);

    userPaneWidth = (contentRect.right - contentRect.left) -
                    (gWindowEdgeSpacing + kListWidth + kScrollBarWidth + kControlSpacing) -
                    (kSizeBoxWidth + gMinimumSpacing);
    userPaneHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing -
                     (kSizeBoxWidth + gMinimumSpacing);

    GetRootControl(prefsWindow, &rootControl);
    for (panelIndex = 1; panelIndex <= kNumberOfRows; panelIndex++)
    {
        GetIndexedSubControl(rootControl, panelIndex, &userPane);
        SizeControl(userPane, userPaneWidth, userPaneHeight);
    }

    GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL,
                      &iconList);

    GetListViewBounds(iconList, &listViewRect);
    oldListHeight = listViewRect.bottom - listViewRect.top;

    newListHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing -
                    gWindowEdgeSpacing;
    newListHeight -= newListHeight % kCellHeight;	// make the list height a multiple
    if (newListHeight > kMaxListHeight)				// of the cell height and don't make
        newListHeight = kMaxListHeight;				// it bigger than we have cells for

    if (newListHeight != oldListHeight)
    {
        Rect invalRect;

        listViewRect.right += kScrollBarWidth;	// we will need to redraw the scroll bar as well
        // we need to invalidate the area where a cell will be drawn or erased
        if (newListHeight > oldListHeight)
            SetRect(&invalRect, listViewRect.left - 5, listViewRect.bottom - 5,
                    listViewRect.right + 5, contentRect.bottom);	// the extra 5 pixels are
        // to cause the bottom of the list box frame to get erased
        else
            SetRect(&invalRect, listViewRect.left - 5, gWindowEdgeSpacing + newListHeight - 5,
                    listViewRect.right + 5, contentRect.bottom);

        // the drawing section is as far down as possible to avoid any screen flickering
        DrawThemeFocusRect(&listViewRect, false);			// erase the focus rectangle
        LSize(kListWidth, newListHeight, iconList);			// resize the List
        drawFrameAndFocus(iconList, true, prefsWindow);		// draw the focus rectangle back
        InvalWindowRect(prefsWindow, &invalRect);
    }

#if TARGET_API_MAC_OS8
    CalculateBalloonHelpRects(prefsWindow);
#endif
} // AdjustControls