示例#1
0
void MPU98DialogProc(void) {

	DialogPtr		hDlg;
	int				done;
	short			item;
	ControlHandle	lst[2];
	UINT8			mpu;
	short			value;

	hDlg = GetNewDialog(IDD_MPU98II, NULL, (WindowPtr)-1);
	if (!hDlg) {
		return;
	}
	lst[0] = (ControlHandle)GetDlgItem(hDlg, IDC_MPUPORT);
	lst[1] = (ControlHandle)GetDlgItem(hDlg, IDC_MPUIRQ);

	mpu = np2cfg.mpuopt;
	SetControlValue(lst[0], ((mpu >> 4) & 15) + 1);
	SetControlValue(lst[1], (mpu & 3) + 1);

	SetDialogDefaultItem(hDlg, IDOK);

	done = 0;
	while(!done) {
		ModalDialog(NULL, &item);
		switch(item) {
			case IDOK:
				mpu = np2cfg.mpuopt;
				value = GetControlValue(lst[0]);
				if (value) {
					mpu &= ~0xf0;
					mpu |= (UINT8)((value - 1) << 4);
				}
				value = GetControlValue(lst[1]);
				if (value) {
					mpu &= ~0x03;
					mpu |= (UINT8)((value - 1) & 3);
				}
				if (np2cfg.mpuopt != mpu) {
					np2cfg.mpuopt = mpu;
					sysmng_update(SYS_UPDATEOSCFG);
				}
				done = IDOK;
				break;

			case IDCANCEL:
				done = IDCANCEL;
				break;

			case IDC_MPUDEF:
				SetControlValue(lst[0], ((0x82 >> 4) & 15) + 1);
				SetControlValue(lst[1], (0x82 & 3) + 1);
				break;
		}
	}
	DisposeDialog(hDlg);
}
示例#2
0
static void RunDialogTheSystem6or7Way(DialogRef theDialog)
{
	SInt16 itemHit;
	DialogItemType itemType;
	Handle itemHandle;
	Rect itemBox;
	
	BringToFront(GetDialogWindow(theDialog));
	
	do {
		ModalDialog(MySystem6or7DialogFilter, &itemHit);
		switch (itemHit)
		{
			case 2:
			{
				// we enable or disable the user item depending on whether the box is checked or not
				GetDialogItem(theDialog, itemHit, &itemType, &itemHandle, &itemBox);
				SInt16 enable = GetControlValue((ControlHandle)itemHandle);
				SetControlValue((ControlHandle)itemHandle, 1 - enable);
				GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox);
				SetDialogItem(theDialog, 13, enable?userItem+itemDisable:userItem, itemHandle, &itemBox);
				HideDialogItem(theDialog, 13);
				ShowDialogItem(theDialog, 13);
			}
				break;
			case 3: case 4: case 5: case 6: case 7:
			{
				// one radio button was chosen, let's adjust them all (we could also remember the last one...)
				int i;
				for (i = 3; i <= 7; i++)
				{
					GetDialogItem(theDialog, i, &itemType, &itemHandle, &itemBox);
					SetControlValue((ControlHandle)itemHandle, (i == itemHit)?1:0);
				}
			}
				break;
			case 14:
			{
				// the indicator of the scroll bar was moved so let's display the value in the first edit box
				// this is System 6 or 7 style so the controls can only handle 16 bits value (hence a max of 32767)
				GetDialogItem(theDialog, itemHit, &itemType, &itemHandle, &itemBox);
				SInt16 newValue = GetControlValue((ControlHandle)itemHandle);
				Str255 theStr;
				NumToString(newValue, theStr);
				GetDialogItem(theDialog, 9, &itemType, &itemHandle, &itemBox);
				SetDialogItemText(itemHandle, theStr);
				SelectDialogItemText(theDialog, 9, 0, 32767);
			}
				break;
		}
	} while (!(itemHit == ok));
	
	DisposeDialog(theDialog);
}
示例#3
0
/*! 
 *  \brief  按钮控件通知
 *  \details  当按钮状态改变(或调用GetControlValue)时,执行此函数
 *  \param screen_id 画面ID
 *  \param control_id 控件ID
 *  \param state 按钮状态:0弹起,1按下
 */
void NotifyButton(uint16 screen_id, uint16 control_id, uint8 state)
{
	//TODO: 添加用户代码
	if (screen_id == 1&& control_id == 1) //设置页面的保存按钮被按下
	{  
		if(0x01 == state)     //按钮被按下
		{
			//获取修正参数-斜率和截距
			GetControlValue(1,3);
			GetControlValue(1,4);
		} 

	}
	
	return;
}
示例#4
0
static void
MacScaleEventProc(
    ClientData clientData,	/* Information about window. */
    XEvent *eventPtr)		/* Information about event. */
{
    MacScale *macScalePtr = (MacScale *) clientData;
    Point where;
    Rect bounds;
    int part;
    CGrafPtr destPort, savePort;
    Boolean portChanged;

#ifdef TK_MAC_DEBUG_SCALE
    fprintf(stderr,"MacScaleEventProc\n" );
#endif

    /*
     * To call Macintosh control routines we must have the port
     * set to the window containing the control. We will then test
     * which part of the control was hit and act accordingly.
     */

    destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin));
    portChanged = QDSwapPort(destPort, &savePort);
    TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin));

    TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds);
    where.h = eventPtr->xbutton.x + bounds.left;
    where.v = eventPtr->xbutton.y + bounds.top;
#ifdef TK_MAC_DEBUG_SCALE
    TkMacOSXDbgMsg("calling TestControl");
#endif
    part = TestControl(macScalePtr->scaleHandle, where);
    if (part == 0) {
	return;
    }

    TkMacOSXTrackingLoop(1);
    part = HandleControlClick(macScalePtr->scaleHandle, where,
	    TkMacOSXModifierState(), scaleActionProc);
    TkMacOSXTrackingLoop(0);

    /*
     * Update the value for the widget.
     */

    macScalePtr->info.value = GetControlValue(macScalePtr->scaleHandle);
    /* TkScaleSetValue(&macScalePtr->info, macScalePtr->info.value, 1, 0); */

    /*
     * The HandleControlClick call will "eat" the ButtonUp event. We now
     * generate a ButtonUp event so Tk will unset implicit grabs etc.
     */

    TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin));

    if (portChanged) {
	QDSwapPort(savePort, NULL);
    }
}
示例#5
0
/*	GetPopMenu(theDialog,popupItemNumber,selItem,selStr)

 	Returns currently selected item number and string.
	Pass NULL for selStr if you don't care about it.

	Thread Safety: GetPopMenu is not thread-safe.
*/
void
GetPopMenu(DialogPtr theDialog, int popupItemNumber, int *selItem, char *selStr)
{
	ControlHandle controlH;
	MenuHandle mH;
	int err;
	
	*selItem = 1;
	if (selStr != NULL)
		*selStr = 0;

	if (err = XOPGetDialogItemAsControl(theDialog, popupItemNumber, &controlH))
		return;
	
	*selItem = GetControlValue(controlH);
	
	if (selStr != NULL) {
		mH = GetPopMenuHandle(theDialog, popupItemNumber);
		if (mH != NULL) {
			unsigned char temp[256];
			GetMenuItemText(mH, *selItem, temp);
			CopyPascalStringToC(temp, selStr);
		}
	}	
}
示例#6
0
OSStatus
OPL_LoginDialog::handleControlHit(ControlRef cntl)
{
    OSStatus err = eventNotHandledErr;

    if (!cntl)
        return err;

    if (cntl == tab_panel)
    {
        int tab_index;

        /* Search which tab is activated */
        tab_index = GetControlValue (tab_panel) - 1;
        DisplayTabControl (tab_index, tab_panel, 2, tabs);

        /* Is the panel has been changed */
        if (tab_number == tab_index)
            return noErr;

        tab_number = tab_index;
        ClearKeyboardFocus (getWindow());
        AdvanceKeyboardFocus (getWindow());
        return noErr;
    }

error:
    return err;
}
示例#7
0
void
GetServiceTypeToLookup(CFMutableStringRef * serviceString, UInt16 * serviceMenuItem)
{
    ControlID 		controlID = { kNSLSample, kServicesTypePopup };
    ControlRef		control;
    CFStringRef		outString;
    MenuRef		menu;
    SInt16		value;
    OSStatus		err;
    
    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        value = GetControlValue(control);
        if (serviceString)
        {
            menu = GetControlPopupMenuHandle(control);
            if (menu)
            {
                CopyMenuItemTextAsCFString(menu, value, &outString);
                if (serviceString)
                {
                    *serviceString = CFStringCreateMutableCopy(NULL, CFStringGetLength(outString), outString);
                    CFStringLowercase(*serviceString, NULL);
                }
                if (outString) CFRelease(outString);
            }
        }
        
        if (serviceMenuItem) *serviceMenuItem = value;
    }
}
UInt32 PreferencesDialog::getComboSelection()
{
	ControlHandle popupButtonControl;
	ControlID popupButtonControlID = {kAppSignature, 130};
	
	GetControlByID(preferencesWindow, &popupButtonControlID, &popupButtonControl);
	return (unsigned int)GetControlValue(popupButtonControl) - 1;
}
示例#9
0
/*	GetRadBut(theDialog, itemNumber)

 	Returns state of radio button.

	Thread Safety: GetRadBut is not thread-safe.
*/
int
GetRadBut(DialogPtr theDialog, int itemNumber)
{
	ControlHandle controlH;
	
	if (XOPGetDialogItemAsControl(theDialog, itemNumber, &controlH) == 0)
		return GetControlValue(controlH);
	
	return 0;
}
示例#10
0
文件: carbon_gui.cpp 项目: dyne/MuSE
static OSStatus MainWindowCommandHandler (
    EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    HICommand command; 
    OSStatus err = noErr;
	SInt16 val;
    CARBON_GUI *me = (CARBON_GUI *)userData;
	err = GetEventParameter (event, kEventParamDirectObject,
        typeHICommand, NULL, sizeof(HICommand), NULL, &command);
    if(err != noErr) me->msg->error("Can't get event parameter!!");
	switch (command.commandID)
    {
        case 'sndo':
			val = GetControlValue(mainControls[SNDOUT_BUT]);
            me->jmix->set_lineout(val?true:false);
            break;
		case 'sndi':
			val = GetControlValue(mainControls[SNDIN_BUT]);
			me->jmix->set_live(val?true:false);
			break;
		case 'newc':
			me->new_channel();
			break;
		case SHOW_STREAMS_CMD:
			me->showStreamWindow();
			break;
		case SHOW_VUMETERS_CMD:
			me->toggleVumeters();
			break;
		case SHOW_STATUS_CMD:
			me->toggleStatus();
			break;
		case ABOUT_CMD:
			me->credits();
			break;
		case BI_SHOW:
			me->toggleBufferInspector();
        default:
            err = eventNotHandledErr;
            break;
    }
    return err;
}
示例#11
0
/*	GetCheckBox(theDialog, itemNumber)

 	Returns state of check box.

	Thread Safety: GetCheckBox is not thread-safe.
*/
int
GetCheckBox(DialogPtr theDialog, int itemNumber)
{
	ControlHandle controlH;
	int val=0;
	
	if (XOPGetDialogItemAsControl(theDialog, itemNumber, &controlH) == 0)
		val = GetControlValue(controlH);
	return val;
}
示例#12
0
static void ScrollBarActionProc(ControlRef theControl, ControlPartCode partCode)
{
	SInt16 oldValue = GetControlValue(theControl);
	switch (partCode)
	{
		case kControlUpButtonPart:		SetControlValue(theControl, oldValue - 1); break;
		case kControlDownButtonPart:  SetControlValue(theControl, oldValue + 1); break;
		case kControlPageUpPart:		SetControlValue(theControl, oldValue - 10); break;
		case kControlPageDownPart:		SetControlValue(theControl, oldValue + 10); break;
	}
}
示例#13
0
/*	ToggleCheckBox(theDialog, itemNumber)

	Toggles state of check box and returns new value.

	Thread Safety: ToggleCheckBox is not thread-safe.
*/
int
ToggleCheckBox(DialogPtr theDialog, int itemNumber)
{
	ControlHandle controlH;
	int val=0;
	
	if (XOPGetDialogItemAsControl(theDialog, itemNumber, &controlH) == 0) {
		val = !GetControlValue(controlH);
		SetControlValue(controlH, val);
	}
	return val;
}
示例#14
0
bool structGuiRadioButton :: f_getValue () {
	bool value = false;
	#if gtk
		value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (d_widget));   // gtk_check_button inherits from gtk_toggle_button
	#elif cocoa
	#elif win
		value = (Button_GetState (d_widget -> window) & 0x0003) == BST_CHECKED;
	#elif mac
		value = GetControlValue (d_widget -> nat.control.handle);
	#endif
	return value;
}
示例#15
0
void 
CalcChange(ControlHandle theControl,	short *amount)
{
	short		value, max;
	
	value = GetControlValue(theControl);	// get current value
	max = GetControlMaximum(theControl);		// and maximum value
	*amount = value - *amount;
	if (*amount < 0)
		*amount = 0;
	else if (*amount > max)
		*amount = max;
	SetControlValue(theControl, *amount);
	*amount = value - *amount;			// calculate the change
}
示例#16
0
static OSErr BeginThumbTracking ( ControlRef theControl ) {

	OSErr theErr = noErr;
	Point thePoint;

	gControl = theControl;
	gStartValue = GetControlValue ( theControl );
	
	gValueSlop = 0;
	GetMouse ( &thePoint );
	
	if (flverticalscroll)
		lastpoint = thePoint.v;
	else
		lastpoint = thePoint.h;
	
	gValueSlop = GetControlValue ( theControl ) - CalcValueFromPoint ( theControl, thePoint );
		
	gSaveClip = NewRgn ( );

	DisableDrawing ( );
	
	return theErr;
	} /*BeginThumbTracking*/
示例#17
0
void tool_wind_magnify_action(ControlRef ctrl,ControlPartCode code)
{
	int				s;
	
	s=GetControlValue(ctrl);
	if (s==magnify_factor) return;
	
	magnify_factor=s;
	
	top_view_reset();
	portal_view_reset();
	site_path_view_reset();
	
    main_wind_draw();
}
示例#18
0
pascal OSStatus
keyval_ok_clicked (EventHandlerCallRef inHandlerRef,
    EventRef inEvent, void *inUserData)
{
  TKEYVAL *keyval_t = (TKEYVAL *) inUserData;
  char *cour;
  int i = 0, size = 1;
  char msg[1024], msg1[1024];

  if (keyval_t)
    {
      /* What is the size of the block to malloc */
      keyval_t->connstr = calloc(sizeof(char), 2);
      for (i = 0; i < KEYVAL_nrows; i++)
        {
          CFStringGetCString (KEYVAL_array[0][i], msg, sizeof (msg),
            kCFStringEncodingUTF8);
          CFStringGetCString (KEYVAL_array[1][i], msg1, sizeof (msg1),
            kCFStringEncodingUTF8);

          cour = (char *) keyval_t->connstr;
          keyval_t->connstr =
                (LPSTR) malloc (size + STRLEN (msg) + STRLEN (msg1) + 2);
          if (keyval_t->connstr)
            {
              memcpy (keyval_t->connstr, cour, size);
              sprintf (((char*)keyval_t->connstr) + size - 1, "%s=%s", msg, msg1);
              if (cour)
                free (cour);
              size += STRLEN (msg) + STRLEN (msg1) + 2;
            }
          else
            keyval_t->connstr = cour;
        }

      ((char*)keyval_t->connstr)[size - 1] = '\0';

      keyval_t->verify_conn = GetControlValue (keyval_t->verify_conn_cb) != 0;
      DisposeWindow (keyval_t->mainwnd);
      keyval_t->mainwnd = NULL;
      keyval_t->verify_conn_cb =  NULL;
      keyval_t->key_list = NULL;
      KEYVAL = NULL;
    }

  return noErr;
}
示例#19
0
static pascal void
ScaleActionProc(
    ControlRef theControl,	/* Handle to scrollbat control */
    ControlPartCode partCode)	/* Part of scrollbar that was "hit" */
{
    int value;
    TkScale *scalePtr = (TkScale *) GetControlReference(theControl);

#ifdef TK_MAC_DEBUG_SCALE
    TkMacOSXDbgMsg("ScaleActionProc");
#endif
    value = GetControlValue(theControl);
    TkScaleSetValue(scalePtr, value, 1, 1);
    Tcl_Preserve((ClientData) scalePtr);
    TkMacOSXRunTclEventLoop();
    Tcl_Release((ClientData) scalePtr);
}
示例#20
0
OSStatus
OPL_LoginDialog::handleCommandEvent(UInt32 commandID)
{
    UInt32 idx;
    CFStringRef str;
    char *dsn;
    char tmp_path[1024];

    switch (commandID) {
    case 'SDIR':
        ControlRef f_select;
        CFStringRef menuText;
        MenuRef menu;

        getControl(kLoginDIR, &f_select);
        menu = GetControlPopupMenuHandle(f_select);
        idx = GetControlValue (f_select);
        CopyMenuItemTextAsCFString(menu, idx, &menuText);
        CFStringGetCString(menuText, tmp_path, sizeof(tmp_path), kCFStringEncodingUTF8);
        CFRelease(menuText);

        loadFDSNList(tmp_path);
        return noErr;

    case 'SFDS':
        idx = fdsnlist->getSelectedItem();
        if (idx && !fdsnlist->getItemType(idx))
        {   // set DSN
            dsn = OPL_CFString_to_char(fdsnlist->getItem(idx));
            str = OPL_CFString_asprintf("%s/%s", cur_dir, dsn);
            setEditText(kLoginDSN, str);
            free(dsn);
        }
        return noErr;

    case 'SDS ':
        idx = dsnlist->getSelectedItem();
        if (idx)
            setEditText(kLoginDSN, CFStringCreateCopy(NULL, dsnlist->getItem(idx)));
        return noErr;

    default:
        return OPL_Dialog::handleCommandEvent(commandID);
    }
}
示例#21
0
OSStatus
TabbedWindow::SwitchTabPane( ControlRef tabControl )
{
    OSStatus status = noErr;
    ControlRef paneRef;

    // get the value of the control
    int tabIndex = GetControlValue( tabControl );
    
    // make sure that the value of the control is within the current count,
    // so we don't step outside the bounds of the array
    paneRef = this->PaneAtIndex( tabIndex );
    
    // check to see if the controlRef is the same as the one that's
    // currently activated
    if ( paneRef != fCurrentTabPane )
    {
        // deactivate and disable the current pane, if we have one
        if ( fCurrentTabPane != NULL )
        {
            SetControlVisibility( fCurrentTabPane, false, false );
            DisableControl( fCurrentTabPane );
        }
        
        // activate the current pane
        EnableControl( paneRef );
        SetControlVisibility( paneRef, true, true );
            
        // set the current pane to be the one that we just activated
        fCurrentTabPane = paneRef;
    }
    else
    {
        // set the error back to eventNotHandled error, since we're
        // not handling it for the same tab that's already activated
        status = eventNotHandledErr;
    }
    return status;

}
示例#22
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Name:	MyPDEGetSummaryText

	Input Parameters:
		context			:	The plugins context
		titleArray 		:	an array to store the title of the summary text
		summaryArray		:	an array to store the summary text
		
	Output Parameters:
		titleArray 		:	updated with this plugins summary text title
		summaryArray		:	updated with this plugins summary text
		err			:	returns the error status

	Description:
		Returns the status/state of the plugin in textual form

	Change History (most recent first):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static 
OSStatus MyPDEGetSummaryText(PMPDEContext	context, 
                        CFArrayRef 		*titleArray,
                        CFArrayRef		*summaryArray)
{
	OSStatus err = noErr;
        CFMutableArrayRef theTitleArray = NULL;		// Init CF strings
        CFMutableArrayRef theSummaryArray = NULL;
        CFStringRef titleStringRef = NULL;
        CFStringRef summaryStringRef = NULL;
	PageSetupPDEOnlyContextPtr myContext = NULL;	// Pointer to global data block.

        DebugMessage("PageSetupPDE MyPDEGetSummaryText called\n");
    
        myContext = (PageSetupPDEOnlyContextPtr) context;
	*titleArray = NULL;
        *summaryArray = NULL;

	if (myContext != NULL)
        {
		//  NOTE: if the second parameter to CFArrayCreateMutable 
		//		  is not 0 then the array is a FIXED size
		theTitleArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
		theSummaryArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
    
		if ((theTitleArray != NULL) && (theSummaryArray != NULL))
		{
		    SInt16	theControlValue = -1;
		    titleStringRef = CopyLocalizedStringFromPlugin(
					    CFSTR(" Print Title Text"),
					    CFSTR("Summary Title"),
					    myContext->theBundleRef);
		    theControlValue = GetControlValue(myContext->thePrintTitleControlRef);
		    switch (theControlValue)
		    {
			    case 0:
				    summaryStringRef = CopyLocalizedStringFromPlugin(
					    CFSTR(" No"),
					    CFSTR("Summary Text"),
					    myContext->theBundleRef);
				    break;
    
			    case 1:
				    summaryStringRef = CopyLocalizedStringFromPlugin(
					    CFSTR(" Yes"),
					    CFSTR("Summary Text"),
					    myContext->theBundleRef);
				    break;
		    }
		    if(titleStringRef && summaryStringRef){
			CFArrayAppendValue(theTitleArray, titleStringRef);
			CFArrayAppendValue(theSummaryArray, summaryStringRef);
		    }else
			err = memFullErr;
		}else{
			err = memFullErr;
		}
	}else
            err = kPMInvalidPDEContext;

        // we release these because we've added them already to the title and summary array
        // or we don't need them because there was an error
        if (titleStringRef)
                CFRelease(titleStringRef);
        if (summaryStringRef)
                CFRelease(summaryStringRef);
        
        // update the data passed in.
        if(!err){
            *titleArray = theTitleArray;
            *summaryArray = theSummaryArray;

        }else{
            if (theTitleArray)
                    CFRelease(theTitleArray);
            if (theSummaryArray)
                    CFRelease(theSummaryArray);
        }
        
	DebugPrintErr(err, "PageSetupPDE Error from MyPDEGetSummaryText returned %d\n");
	return (err);
}
示例#23
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Name:	MyPDESync

	Input Parameters: 	
		context			:	The plugins context
		printSession		:	this holds the tickets
		syncDirection		:	A boolean that tells the plugin that it needs to
                                                do one of two functions. 
                                                    If true the plugin
							fetches the values from the tickets and 
							sets the plugins control values.
                                                    if false the plugin
                                                        does the opposite, it takes the values out of the 
                                                        plugins' controls and sets them into the
                                                        tickets
			
	Output Parameters:
		err					returns the error status

	Description:
		Sets/Gets values in the PageFormat or PrintSettings tickets

	Change History (most recent first):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static 
OSStatus MyPDESync(	PMPDEContext	context,
                PMPrintSession	printSession,
                Boolean			syncDirection)
{
    OSStatus err = noErr;
    PageSetupPDEOnlyContextPtr myContext = NULL;		// Pointer to global data block.

    DebugMessage("PageSetupPDE MyPDESync called\n");
    
    myContext = (PageSetupPDEOnlyContextPtr) context;
    
    if ((myContext != NULL) && (printSession != NULL))
	{
	    PMTicketRef pageFormatContainer = NULL;

	    err = GetTicketRef(printSession, kPDE_PMPageFormatRef, &pageFormatContainer);
	    if (noErr == err)		
	    {
		CFDataRef ourPDEPageFormatDataRef;
		Boolean printTitles = false;
		SInt16 theControlValue = -1;

		switch (syncDirection)
		{
		    case kSyncDirectionSetUserInterface:
			err = PMTicketGetCFData(pageFormatContainer, kPMTopLevel, 
			    kPMTopLevel, kAppPageSetupPDEOnlyKey, &ourPDEPageFormatDataRef);
			if(!err){
			    if(CFDataGetLength(ourPDEPageFormatDataRef) == sizeof(printTitles)){
				printTitles = *(Boolean *)CFDataGetBytePtr(ourPDEPageFormatDataRef);
			    }else
				printTitles = kPrintTitlesDefault;	// default value
			    CFRelease(ourPDEPageFormatDataRef);
			}else{
			    // set to default value
			    printTitles = kPrintTitlesDefault;
			    err = noErr;
			}
						
			if (noErr == err)
			{
			    theControlValue = (printTitles) ? 1 : 0;
			    SetControlValue(myContext->thePrintTitleControlRef, theControlValue);
			}
			break;
    
		    case kSyncDirectionSetTickets:
			theControlValue = GetControlValue(myContext->thePrintTitleControlRef);
			printTitles = theControlValue != 0;
			ourPDEPageFormatDataRef = CFDataCreate(kCFAllocatorDefault, &printTitles,
										sizeof(printTitles));
			if(ourPDEPageFormatDataRef){
			    err = PMTicketSetCFData(pageFormatContainer, kPMPrintingManager, 
					    kAppPageSetupPDEOnlyKey, ourPDEPageFormatDataRef, kPMUnlocked);
			    CFRelease(ourPDEPageFormatDataRef);
			}else
			    err = memFullErr;
			    
			break;
		}
	    }
	}
    else
	err = kPMInvalidPDEContext;
    
    DebugPrintErr(err, "PageSetupPDE Error from MyPDESync returned %d\n");

    return (err);
}
示例#24
0
void draw_shop_graphics(bool pressed,Rect clip_area_rect)
// mode 1 - drawing dark for button press
{
	Rect area_rect,item_info_from = {11,42,24,56};
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {15,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	short faces[13] = {1,1,1,42,43, 1,1,1,1,1, 44,44,44};
	
	short i,what_chosen;
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	Rect shopper_name = {44,6,56,260};
	short current_pos;
	
	short cur_cost,what_magic_shop,what_magic_shop_item;
	char cur_name[60];
	char cur_info_str[60];
char *cost_strs[] = {"Extremely Cheap","Very Reasonable","Pretty Average","Somewhat Pricey",
	"Expensive","Exorbitant","Utterly Ridiculous"};
	GrafPtr old_port;
	cItemRec base_item;
	
	if (overall_mode != 21) {
		return;
		}
	
	
	GetPort(&old_port);
	SetPort(talk_gworld);
	TextFont(dungeon_font_num);
	TextSize(18);
	TextFace(0);

	if (pressed) {
		ClipRect(&clip_area_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	FrameRect(&shop_frame);
	
	// Place store icon
	if (!pressed) { 
		SetPort(GetWindowPort(mainPtr));
		i = faces[store_shop_type];
		draw_dialog_graphic( talk_gworld, face_rect, i, PICT_TALK, false,1);
		SetPort( talk_gworld);
	}


	// Place name of store and shopper name
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string(talk_gworld,dest_rect,store_store_name,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,store_store_name,2,18);	

	TextFont(geneva_font_num);
	TextSize(12);
	TextFace(bold);

	RGBForeColor(&c[3]);
	switch (store_shop_type) {
		case 3: sprintf(cur_name,"Healing for %s.",univ.party[current_pc].name.c_str()); break;
		case 10: sprintf(cur_name,"Mage Spells for %s.",univ.party[current_pc].name.c_str());break;
		case 11: sprintf(cur_name,"Priest Spells for %s.",univ.party[current_pc].name.c_str()); break;
		case 12: sprintf(cur_name,"Buying Alchemy.");break;
		case 4: sprintf(cur_name,"Buying Food.");break;
		default:sprintf(cur_name,"Shopping for %s.",univ.party[current_pc].name.c_str()); break;
		}
	char_port_draw_string( talk_gworld,shopper_name,cur_name,2,18);	

	// Place help and done buttons
	ForeColor(blackColor);
	GetPortBounds(dlg_buttons_gworld[3][0],&help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][pressed],help_from,talk_gworld,talk_help_rect);
	GetPortBounds(dlg_buttons_gworld[11][0],&help_from);
	//talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	//talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[11][pressed],help_from,talk_gworld,shop_done_rect);
	
	if (pressed)
		RGBForeColor(&c[4]);
	else ForeColor(blackColor);
		
	// Place all the items
	for (i = 0; i < 8; i++) {
		current_pos = i + GetControlValue(shop_sbar);
		if (store_shop_items[current_pos] < 0)
			break; // theoretically, this shouldn't happen
		cur_cost = store_shop_costs[current_pos];
		what_chosen = store_shop_items[current_pos];
		switch (what_chosen / 100) {
			case 0: case 1: case 2: case 3: case 4: 
				base_item = get_stored_item(what_chosen);
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			case 5:
				base_item = store_alchemy(what_chosen - 500);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],53,PICT_ITEM, false,1);//// all graphic nums
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			case 6:
				//base_item = food_types[what_chosen - 600];
				//draw_dialog_graphic( talk_gworld, shopping_rects[i][2],633, false,1);
				//strcpy(cur_name,base_item.full_name);
				//get_item_interesting_string(base_item,cur_info_str);
				break;
			case 7:
				what_chosen -= 700;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],99,PICT_ITEM, false,1);
				strcpy(cur_name,heal_types[what_chosen]);
				strcpy(cur_info_str,"");
				break;
			case 8:
				base_item = store_mage_spells(what_chosen - 800 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);

				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");		
				break;
			case 9:
				base_item = store_priest_spells(what_chosen - 900 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			default:
				what_magic_shop = (what_chosen / 1000) - 1;
				what_magic_shop_item = what_chosen % 1000;
				base_item = univ.party.magic_store_items[what_magic_shop][what_magic_shop_item];
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			}

		// Now draw item shopping_rects[i][7]
		// 0 - whole area, 1 - active area 2 - graphic 3 - item name
		// 4 - item cost 5 - item extra str  6 - item help button
		TextSize(12);
		char_port_draw_string( talk_gworld,shopping_rects[i][3],cur_name,0,12);
		sprintf(cur_name,"Cost: %d",cur_cost);
		char_port_draw_string( talk_gworld,shopping_rects[i][4],cur_name,0,12);
		TextSize(10);
		char_port_draw_string( talk_gworld,shopping_rects[i][5],cur_info_str,0,12);
		if ((store_shop_type != 3) && (store_shop_type != 4))
			rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],pressed ? srcCopy : transparent);

		}

	// Finally, cost info and help strs
	TextSize(12);
	sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]);
	TextSize(10);
	char_port_draw_string( talk_gworld,bottom_help_rects[0],cur_name,0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",0,12);
	if ((store_shop_type != 3) && (store_shop_type != 4))
		char_port_draw_string( talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,12);
	
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	ClipRect(&area_rect);
	SetPort(old_port);

	refresh_shopping();
	ShowControl(shop_sbar);
	Draw1Control(shop_sbar);
}
pascal OSStatus PreferencesDialog::WindowEventHandler(EventHandlerCallRef myHandler, EventRef event, void* userData)
{
    OSStatus	result = eventNotHandledErr;    
    UInt32		eventClass, eventKind;
    
    eventClass	= GetEventClass(event);
    eventKind	= GetEventKind(event);

	PreferencesDialog* prefDlg = reinterpret_cast<PreferencesDialog*>(userData);
	
    switch (eventClass) 
	{
        case kEventClassControl: 
		{
			ControlRef	targetControl = NULL;
			ControlID	targetControlID;

			GetEventParameter(event, kEventParamDirectObject, typeControlRef, 
							  NULL, sizeof(targetControl), NULL, &targetControl);
			if (targetControl)
				GetControlID(targetControl, &targetControlID);

			switch (eventKind) 
			{
				case kEventControlHit: 
				{					
					switch (targetControlID.id)
					{
						// simulate insert key with ctrl+up
						case 131:
							prefDlg->setFakeInsertKey(GetControl32BitValue(targetControl)-1);
							result = noErr;
							break;

						// 15 bit color toggle
						case 132:
							prefDlg->toggleUse15BitColorDepth();
							result = noErr;
							break;
					
						// Enable MIDI device
						case 129:
							prefDlg->toggleUseMidiDevice();
							result = noErr;
							break;
							
						// Save MIDI preferences
						case 128:
							prefDlg->toggleSavePreferences();
							result = noErr;
							break;

						// Record key velocity
						case 127:
							prefDlg->toggleRecordVelocity();
							result = noErr;
							break;

						// velocity amplify slider
						case 125:
						{
							prefDlg->storeVelocityAmplify(GetControlValue(targetControl));
							result = noErr;
							break;
						}
					}
					
					break;
				}
			}
			
			break;
		}
		
		// Handle window close event (= discard)
		case kEventClassWindow:
		{
			switch (eventKind) 
			{
				case kEventWindowClose: 
				{
					prefDlg->restoreDataBase();
					prefDlg->hide();
					result = noErr;
					break;
				}
			}
			
			break;
		}

        case kEventClassCommand: 
		{
			switch (eventKind) 
			{
				case kEventCommandProcess: 
				{
					HICommand command;
					GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &command);
					
					switch (command.commandID)
					{
						case kDiscardPreferences:
							prefDlg->restoreDataBase();
							
						case kConfirmPreferences:
						{
							// These two events are better off when sent to the main window
							SendEventToWindow(event, prefDlg->mainWindow);
							break;
						}
						
						default:
							// Handle MIDI device selection from pop-up menu
							if (command.commandID >= kMIDIDeviceBaseCommand && 
								command.commandID <= kMIDIDeviceBaseCommand + prefDlg->getNumMidiDevices())
							{
								prefDlg->storeMidiDeviceName(command.commandID - kMIDIDeviceBaseCommand);
								result = noErr;
							}
					}
					
					break;
				}
			}
			break;
		}
	}

	return result;
}
示例#26
0
bool XGPopControl::DoMouseDown(Point where, short flags)
{
#if OPT_MACOS || OPT_XWIN
	#pragma unused(flags)
#endif

#if OPT_MACOS
	if (fControl) {
		XGDraw draw(this,false);
		if (fFont) {
			fFont->Attach();
			draw.SetFont(fFont);
		}
		ViewToGlobal(&where);
		if (::TrackControl(fControl,where,NULL)) {
			fValue = GetControlValue(fControl) - 1;
			DoDispatch(KXGPopValue,GetViewID(),NULL);
		}
		return false;
	}
#endif

#if OPT_WINOS
	if (fControl) {
		SetFocus();
		return XGControl::DoMouseDown(where, flags);
	}
	return false;
#endif

#if OPT_XWIN || OPT_MACOS
	/*
	 *	If we get here, simulating popup. Happens when we dont' have
	 *	an appearance manager
	 */
	
	XRect r,s;
	XGDraw draw(this);
	fFont->Attach();
	draw.SetFont(fFont);
	
	/*
	 *	Capture focus
	 */
	
#if OPT_WINOS || OPT_XWIN
	SetFocus();
#endif
	
	/*
	 *	Draw the gadget down
	 */
	
	r = GetContentRect();
	draw.Draw3DRect(r,KXGEInButton);
	s = r;
	s.left = s.right - (s.bottom - s.top);
	InsetRect(&s,2,2);
	draw.Draw3DRect(s,KXGEInset);
	
	/*
	 *	Pop up the list
	 */
	
	r = GetContentRect();
	fPop = XGInlinePopup::Create(this,r,fFontID,&fList,fValue);
	SetCapture(fPop);

	return true;
#endif
}
示例#27
0
pascal OSStatus
gensetup_ok_clicked (EventHandlerCallRef inHandlerRef,
    EventRef inEvent, void *inUserData)
{
  TGENSETUP *gensetup_t = (TGENSETUP *) inUserData;
  char *cour, *curr;
  int i = 0, size = 0;
  char msg[1024], msg1[1024];
  Size len;

  if (gensetup_t)
    {
      /* What is the size of the block to malloc */
      GetControlDataSize (gensetup_t->dsn_entry, 0, kControlEditTextTextTag,
        &len);
      size += len + STRLEN ("DSN=") + 1;
      size += STRLEN ("Description=") + 1;
      /* Malloc it */
      if ((gensetup_t->connstr = (char *) malloc (++size)))
        {
          for (curr = STRCONN, cour = gensetup_t->connstr;
            i < STRCONN_NB_TOKENS; i++, curr += (STRLEN (curr) + 1))
            switch (i)
              {
                case 0:
                  GetControlData (gensetup_t->dsn_entry, 0,
                    kControlEditTextTextTag, sizeof (msg), msg, &len);
                  msg[len] = '\0';
                  sprintf ((char*)cour, (char*)curr, msg);
                  cour += (STRLEN (cour) + 1);
                  break;
                case 1:
                  msg[0] = '\0';
                  sprintf ((char*)cour, (char*)curr, msg);
                  cour += (STRLEN (cour) + 1);
                  break;
                };

              for (i = 0; i < DSNSETUP_nrows; i++)
                {
                  CFStringGetCString (DSNSETUP_array[0][i], msg, sizeof (msg),
                    kCFStringEncodingUTF8);
                  CFStringGetCString (DSNSETUP_array[1][i], msg1, sizeof (msg1),
                    kCFStringEncodingUTF8);

                  cour = (char *) gensetup_t->connstr;
                  gensetup_t->connstr =
                    (LPSTR) malloc (size + STRLEN (msg) + STRLEN (msg1) + 2);
                  if (gensetup_t->connstr)
                    {
                      memcpy (gensetup_t->connstr, cour, size);
                      sprintf (((char*)gensetup_t->connstr) + size - 1, "%s=%s", msg,
                        msg1);
                      free (cour);
                      size += STRLEN (msg) + STRLEN (msg1) + 2;
                    }
                  else
                    gensetup_t->connstr = cour;
                }

              ((char*)gensetup_t->connstr)[size - 1] = '\0';
            }

      gensetup_t->verify_conn = GetControlValue (gensetup_t->verify_conn_cb) != 0;
      DisposeWindow (gensetup_t->mainwnd);
	  gensetup_t->mainwnd = NULL;
      gensetup_t->dsn_entry = gensetup_t->verify_conn_cb =  NULL;
      gensetup_t->key_list = NULL;
      DSNSETUP = NULL;
    }

  return noErr;
}
static pascal void AddNavEvent(
	NavEventCallbackMessage callBackSelector, 
	NavCBRecPtr 			callBackParms, 
	void *					callBackUD
)
	// Called by Navigation Services when interesting things happen 
	// in our Nav dialog (which is displayed when the user clicks 
	// the "Add" button).  In this case we're primarily interested 
	// in two events: the user action of the user clicking the Choose 
	// button of the Nav dialog, and the dialog being torn down.
{
	#pragma unused(callBackUD)
	OSStatus		err;
	OSStatus		junk;
	NavDialogRef 	navDialog;
	
	navDialog = callBackParms->context;
	assert(navDialog != NULL);
	
	switch (callBackSelector) {
		case kNavCBUserAction:
			switch ( NavDialogGetUserAction(navDialog) ) {
				case kNavUserActionChoose:
					{
						NavReplyRecord 	reply;
						AEKeyword 		junkKeyword;
						DescType		junkType;
						Size			junkSize;
						
						err = NavDialogGetReply(navDialog, &reply);
						if (err == noErr) {
							FSRef	chosenItem;
							
							// In the debug build, verify that only one items is 
							// selected.
							
							#if ! defined(NDEBUG)
								{
									long selectionCount;
									
									assert( 
										   (AECountItems( &reply.selection, &selectionCount) == noErr)
										&& (selectionCount == 1)
									);
								}
							#endif

							// Get the selected item.
							
							err = AEGetNthPtr(
								&reply.selection, 
								1, 
								typeFSRef, 
								&junkKeyword, 
								&junkType, 
								&chosenItem, 
								sizeof(chosenItem), 
								&junkSize
							);
							
							// Use LoginItemsAE to add it to the list.
							
							if (err == noErr) {
								err = LIAEAddRefAtEnd(
									&chosenItem, 
									GetControlValue(gAddHiddenControl) != 0
								);
							}
						
							junk = NavDisposeReply(&reply);
							assert(junk == noErr);
							
							if (err == noErr) {
								DoRefresh();
							} else {
								DisplayError(err);
							}						
						}
					}
					break;
				default:
					// do nothing
					break;
			}
			break;
		case kNavCBTerminate:
			NavDialogDispose(navDialog);
			break;
		default:
			// do nothing
			break;
	}
}
示例#29
0
short TActiveScroller::GetScrollBarValue()
{
	return GetControlValue(scrollBar);
}
示例#30
0
pascal void ScrollThumbActionProc (void) {

	SInt32 theValue;
    hdlscrollbar hscrollbar;
    Point thePoint;
    Rect theRect;
    long ctscroll;
	tydirection dir;
	long currvalue;
	hdlwindowinfo h = shellwindowinfo;
	short baselineoffset;

    if (h == nil) /*defensive driving*/
    	return;

	hscrollbar = (**h).vertscrollbar;
	
	if (!flverticalscroll)
		hscrollbar = (**h).horizscrollbar;
	
	zerorect (&theRect);
	
	GetBestControlRect (hscrollbar, &theRect, &baselineoffset);
 	//theRect = (**hscrollbar).contrlRect;
 	
 	if (flverticalscroll)
		
		insetrect (&theRect, -kThumbTrackLengthSlop, -kThumbTrackWidthSlop);
		
 	else
		
		insetrect (&theRect, -kThumbTrackWidthSlop, -kThumbTrackLengthSlop);
	
    GetMouse (&thePoint);
        
    if (pointinrect (thePoint, theRect))
		
		theValue = CalcValueFromPoint (hscrollbar, thePoint);
		
	else
		
		theValue = gStartValue;
		
	currvalue = (**h).vertscrollinfo.cur;
	
	if (theValue != GetControlValue (hscrollbar)) {	// if we scrolled
		
		EnableDrawing ();

		ctscroll = theValue - GetControlValue (hscrollbar);
		
		dir = scrolldirection (flverticalscroll, ctscroll > 0);	
		
	 	(*shellglobals.scrollroutine) (dir, false, abs (ctscroll));
	 	
		(**h).vertscrollinfo.cur = theValue;

		DisableDrawing ();
		} /*if*/
	
	return;
	} /*ScrollThumbActionProc*/