コード例 #1
0
ファイル: SrLvlnView.cpp プロジェクト: Vuher/skyedit
/*===========================================================================
 *
 * Class CSrLvlnView Event - void OnInitialUpdate (void);
 *
 *=========================================================================*/
void CSrLvlnView::OnInitialUpdate (void) 
{
	CSrRecordDialog::OnInitialUpdate();

		/* Setup the list */
	m_ItemList.SetListName("LvlnList");
	m_ItemList.DefaultSettings();
	m_ItemList.SetupCustomList(s_LevelListInit, &CSrLvlnRecord::s_FieldMap, s_LevelListFields);
	m_ItemList.SetOwner(this);
	m_ItemList.SetDragType(SR_RLDRAG_CUSTOM | SR_RLDRAG_RECORD);
	m_ItemList.SetSortEnable(false);

	m_pRecordHandler->GetEventHandler().AddListener(this);

	SaveSubrecords();
	SetControlData();
}
コード例 #2
0
ファイル: mac_updater.cpp プロジェクト: Xara/Astra-Viewer-2
OSStatus setProgressText(CFStringRef text)
{
	OSStatus err;
	ControlRef progressText = NULL;
	ControlID id;

	id.signature = 'what';
	id.id = 0;

	err = GetControlByID(gWindow, &id, &progressText);
	if(err == noErr)
	{
		err = SetControlData(progressText, kControlEntireControl, kControlStaticTextCFStringTag, sizeof(CFStringRef), (Ptr)&text);
		Draw1Control(progressText);
	}

	return(err);
}
コード例 #3
0
ファイル: AUCarbonViewControl.cpp プロジェクト: kdridi/acau
pascal ControlKeyFilterResult	AUCarbonViewControl::NumericKeyFilterCallback(ControlRef theControl, 
												SInt16 *keyCode, SInt16 *charCode, 
												EventModifiers *modifiers)
{
#if !__LP64__
	SInt16 c = *charCode;
	if (isdigit(c) || c == '+' || c == '-' || c == '.' || c == '\b' || c == 0x7F || (c >= 0x1c && c <= 0x1f)
	|| c == '\t')
		return kControlKeyFilterPassKey;
	if (c == '\r' || c == 3) {	// return or Enter
		AUCarbonViewControl *This = (AUCarbonViewControl *)GetControlReference(theControl);
		ControlEditTextSelectionRec sel = { 0, 32767 };
		SetControlData(This->mControl, 0, kControlEditTextSelectionTag, sizeof(sel), &sel);
		This->ControlToParameter();
	}
#endif
	return kControlKeyFilterBlockKey;
}
コード例 #4
0
//
// set our static text control to be the name of the movie
//
static OSStatus SetControlTextToMovieName()
{
	CFStringRef stringRef = CFURLCopyLastPathComponent (mMovieFileURLref);

	CFIndex size = CFStringGetLength (stringRef);
	CFRange range = CFRangeMake(0, size);
	UniChar *buffer = (UniChar *)malloc(range.length  * sizeof(UniChar));
	if (buffer)
	{
		CFStringGetCharacters(stringRef, range, buffer);
		
		SetControlData (mMovNameRef, kControlNoPart, kControlStaticTextTextTag, size * 2, buffer);
        
		free((void *)buffer);
		CFRelease(stringRef);
	}

}
コード例 #5
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static void ScrollBar32BitActionProc(ControlRef theControl, ControlPartCode partCode)
{
	// this is Mac OS 8 or 9 style so the controls can now handle 32 bits value (hence a max of 2147483647)
	SInt32 oldValue = GetControl32BitValue(theControl);
	switch (partCode)
	{
		case kControlUpButtonPart:		SetControl32BitValue(theControl, oldValue - 1); break;
		case kControlDownButtonPart:  SetControl32BitValue(theControl, oldValue + 1); break;
		case kControlPageUpPart:		SetControl32BitValue(theControl, oldValue - 10); break;
		case kControlPageDownPart:		SetControl32BitValue(theControl, oldValue + 10); break;
	}
	SInt32 newValue = GetControl32BitValue(theControl);
	
	// let's display the value in the edit text control associated with this control
	theControl = (ControlRef)GetControlReference(theControl);
	Str255 theStr;
	NumToString(newValue, theStr);
	SetControlData(theControl, kControlEntireControl, kControlEditTextTextTag, theStr[0], &theStr[1]);
}
コード例 #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AUDiskStreamingCheckbox::AUDiskStreamingCheckbox
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, 
				Point 					inLocation,  
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top;
	r.left = inLocation.h;		r.right = r.left;
	
    // localize as necessary
    if (!sLocalized) {
		sLocalized = true;
        CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
        if (mainBundle) {
            kStringStreamFromDisk =	CFCopyLocalizedStringFromTableInBundle(
                                        kAUViewLocalizedStringKey_StreamFromDisk, kLocalizedStringTable_AUView,
                                        mainBundle, CFSTR("'Stream From Disk' checkbox title string"));
        }
    }
    
	verify_noerr(CreateCheckBoxControl(	GetCarbonWindow(), 
										&r, 
										kStringStreamFromDisk, 
										0, 
										true, 
										&mControl));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	ControlSize smallSize = kControlSizeSmall;
	verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize));

	AUCarbonViewControl::SizeControlToFit(mControl, NULL, &mHeight);
	if (mHeight < 0) mHeight = 0;
	
	EmbedControl(mControl);
	
	UInt32 value = 0;
	UInt32 size = sizeof(value);
	verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size));
	
	HandlePropertyChange (value);
	
	RegisterEvents();
}
コード例 #7
0
void CEsmSpellDlg::OnInitialUpdate() {

    int Index;



    CEsmRecDialog::OnInitialUpdate();

    UpdateTitle(NULL);



    /* Initialize the armor record */

    ASSERT(GetRecInfo() != NULL);

    m_pSpell = (CEsmSpell *) GetRecInfo()->pRecord;

    FillEsmSpellTypeCombo(m_TypeList);



    for (Index = 0; Index < MWESM_ENCHANT_NUMENCHANTS; Index++) {

        FillEsmEffectsCombo(m_EffectList[Index], false);

        FillEsmEnchantRangeCombo(m_RangeList[Index]);

        m_DurationText[Index].SetLimitText(5);	/* Are shorts so only need 5 digits at most */

        m_Magnitude1Text[Index].SetLimitText(5);

        m_Magnitude2Text[Index].SetLimitText(5);

        m_AreaText[Index].SetLimitText(5);

    }



    SetControlData();

}
コード例 #8
0
ファイル: AppearanceHelpers.c プロジェクト: arnelh/Examples
OSStatus
SetStaticTextCFString( ControlRef control, CFStringRef text, Boolean draw )
{
	OSStatus	err;
	
	if ( control == nil )
		return paramErr;

	if ( text == nil )
		return paramErr;

	err = SetControlData( control, 0, kControlStaticTextCFStringTag, sizeof( CFStringRef ),
			&text );
			
	if ( (err == noErr) && draw )
		DrawOneControl( control );
	
	return err;
}
コード例 #9
0
ファイル: SrLighView.cpp プロジェクト: Vuher/skyedit
/*===========================================================================
 *
 * Class CSrLighView Event - void OnInitialUpdate (void);
 *
 *=========================================================================*/
void CSrLighView::OnInitialUpdate (void) 
{
	CSrRecordDialog::OnInitialUpdate();

	SrFillComboList(m_FlickerType, s_SrLightTypes, SRE_FILLCOMBO_NODUPLICATES);

	m_RedSpin.SetRange(0, 255);
	m_GreenSpin.SetRange(0, 255);
	m_BlueSpin.SetRange(0, 255);

	SetControlData();

	m_ColorBox.SetColor(RGB(m_RedSpin.GetPos(), m_GreenSpin.GetPos(), m_BlueSpin.GetPos()));
	m_ColorBox.RedrawWindow();

	OnCarried();

	m_Initialized = true;
}
コード例 #10
0
ファイル: gensetup.c プロジェクト: EvilMcJerkface/iODBC
static void
parse_attribute_line (TGENSETUP * gensetup_t,
    LPCSTR dsn,
    LPCSTR attrs,
    BOOL add)
{
  if (dsn)
    {
      SetControlData (gensetup_t->dsn_entry, 0, kControlEditTextTextTag,
        STRLEN (dsn), (UInt8 *) dsn);
      if (add)
	ActivateControl (gensetup_t->dsn_entry);
      else
	DeactivateControl (gensetup_t->dsn_entry);
      DrawOneControl (gensetup_t->dsn_entry);
    }

  addkeywords_to_list (gensetup_t->key_list, attrs, gensetup_t);
}
コード例 #11
0
ファイル: AppearanceHelpers.c プロジェクト: arnelh/Examples
//-----------------------------------------------------------------------------
//	¥ SetEditTextSelection
//-----------------------------------------------------------------------------
//	Sets the selection of an edit text control and redraws it.
//
OSStatus
SetEditTextSelection( ControlHandle control, SInt16 selStart, SInt16 selEnd )
{
	ControlEditTextSelectionRec	selection;
	OSStatus	err;

	if ( control == nil )
		return paramErr;
		
	selection.selStart = selStart;
	selection.selEnd = selEnd;
	
	err = SetControlData( control, 0, kControlEditTextSelectionTag,
			sizeof( selection ), (Ptr)&selection );
	
	if ( err == noErr )
		DrawOneControl( control );
	
	return err;
}
コード例 #12
0
ファイル: XPInstallGlue.c プロジェクト: rn10950/RetroZilla
OSErr
RunXPI(FSSpec& aXPI, XPI_InstallProc *xpi_installProc)
{	
	nsresult	rv;
	OSErr	 	err = noErr;
	long		flags = 0x1000; /* XPI_NO_NEW_THREAD = 0x1000 from nsISoftwareUpdate.h */
	Boolean		indeterminateFlag = true;
	
	XPI_ERR_CHECK((*xpi_installProc)( aXPI, "", flags ));
	
	/* reset progress bar to barber poll */
	bMaxDiscovered = false;
	if (gControls->tw->xpiProgressBar)
		SetControlData(gControls->tw->xpiProgressBar, kControlNoPart, kControlProgressBarIndeterminateTag,
						sizeof(indeterminateFlag), (Ptr) &indeterminateFlag);
	if (NS_FAILED(rv))
		return -1;


	return err;
}
コード例 #13
0
void CEsmBodyPartDlg::OnInitialUpdate() {
  CEsmRecDialog::OnInitialUpdate();
  UpdateTitle(NULL);
  
	/* Initialize the record */
  ASSERT(GetRecInfo() != NULL);
  m_pBodyPart = (CEsmBodyPart *) GetRecInfo()->pRecord;

	/* Set text limits */
  m_IDText.SetLimitText(MWESM_ID_MAXSIZE);

	/* Disable controls */
  m_PlayableCheck.EnableWindow(FALSE);

	/* Fill the various lists */
  FillEsmBodyPartCombo(m_PartList);
  FillEsmBodyPartTypeCombo(m_PartTypeList);
  FillEsmRaceCombo(m_RaceList);

  SetControlData();
 }
コード例 #14
0
void CEsmArmorDlg::OnInitialUpdate() {
  int Index;

  CEsmRecDialog::OnInitialUpdate();
  UpdateTitle(NULL);

  //HICON hIcon;
  //hIcon = AfxGetApp()->LoadIcon(IDI_ARMOR);
  //GetParentFrame()->SetIcon(hIcon, FALSE);
  //SetIcon(hIcon, FALSE);

  //CMenu Menu;
  //Menu.LoadMenu(IDR_LIST_MENU);
  //((CChildFrameFix *)GetParentFrame())->SetSharedMenu(Menu.GetSafeHmenu());
  //((CFrameWnd*)AfxGetMainWnd())->OnUpdateFrameMenu(Menu.GetSafeHmenu());
  //((CFrameWnd*)AfxGetMainWnd())>OnUpdateFrameMenu(NULL) ;
  //((CFrameWnd*)AfxGetMainWnd())->DrawMenuBar();
  
	/* Initialize the armor record */
  ASSERT(GetRecInfo() != NULL);
  m_pArmor = (CEsmArmor *) GetRecInfo()->pRecord;

	/* Initialize the ui controls/lists */
  FillEsmArmorTypeCombo(m_TypeList);
  FillEsmScriptCombo(m_ScriptList);
  FillEsmEnchantCombo(m_EnchantList);
  m_IDText.SetLimitText(MWESM_ID_MAXSIZE);
  m_NameText.SetLimitText(MWESM_ID_MAXSIZE);
  m_EnchantText.SetLimitText(16);
  m_WeightText.SetLimitText(16);
  m_RatingText.SetLimitText(16);
  m_HealthText.SetLimitText(16);
  m_ValueText.SetLimitText(16);

  for (Index = 0; Index < MWESM_ARMOR_MAXBODYPARTS; Index++) {
    FillEsmBodyPartsCombo(m_BipedList[Index]);
   }

  SetControlData();
 }
コード例 #15
0
void CEsmRegionDlg::OnInitialUpdate() {
  CEsmRecDialog::OnInitialUpdate();
  UpdateTitle(NULL);

	/* Initialize the armor record */
  ASSERT(GetRecInfo() != NULL);
  m_pRegion = (CEsmRegion *) GetRecInfo()->pRecord;

	/* Sound List */
  m_SoundList.OnInitCtrl();
  m_SoundList.SetDlgHandler(m_pParent);
  m_SoundList.SetEnableDrag(true);
  m_SoundList.SetAcceptDrag(true);
  m_SoundList.SetWantKeys(true);
  m_SoundList.InitObjectList(&l_SoundColData[0]);

	/* Initialize the text controls */
  m_IDText.SetLimitText(MWESM_ID_MAXSIZE);
  m_NameText.SetLimitText(MWESM_ID_MAXSIZE);
  m_ThunderText.SetLimitText(8);
  m_RainText.SetLimitText(8);
  m_BlightText.SetLimitText(4);
  m_AshText.SetLimitText(4);
  m_OvercastText.SetLimitText(4);
  m_FoggyText.SetLimitText(4);
  m_ClearText.SetLimitText(4);
  m_CloudyText.SetLimitText(4);
  m_RedText.SetLimitText(4);
  m_BlueText.SetLimitText(4);
  m_GreenText.SetLimitText(4);
  m_RSpin.SetRange32(0, 255);
  m_GSpin.SetRange32(0, 255);
  m_BSpin.SetRange32(0, 255);
   
	/* Fill creature list */
  FillEsmCreatureCombo(m_CreatureList, true, true);

	/* Update the UI data */
  SetControlData();
 }
コード例 #16
0
ファイル: XGProgress.cpp プロジェクト: ElusiveMind/ballistic
void
XGProgress::SetIndeterminate (bool indet)
{
	if (fIndeterminate == indet) 
		return;
	fIndeterminate = indet;
	
#if OPT_MACOS
	if (fControl) {
		char indon = fIndeterminate;
		SetControlData(fControl, 0, kControlProgressBarIndeterminateTag, 1, &indon);
		return;
	}
#endif
#if OPT_WINOS
	if (fControl) {
		/* not supported */
		return;
	}
#endif
	InvalView();
}
コード例 #17
0
void TrackbarActionProcPtr (ControlRef theControl, ControlPartCode partCode)
{
    CvTrackbar * trackbar = icvTrackbarByHandle (theControl);

    if (trackbar == NULL)
    {
        fprintf(stderr,"Error getting trackbar\n");
        return;
    }
    else
    {
        int pos = GetControl32BitValue (theControl);
        if ( trackbar->data )
            *trackbar->data = pos;
        if ( trackbar->notify )
            trackbar->notify(pos);
        else if ( trackbar->notify2 )
            trackbar->notify2(pos, trackbar->userdata);

        //--------YV---------------------------
        CFStringEncoding encoding = kCFStringEncodingASCII;
        CFAllocatorRef alloc_default = kCFAllocatorDefault;  // = NULL;

        char valueinchar[20];
        sprintf(valueinchar, " (%d)",  *trackbar->data);

        // create an empty CFMutableString
        CFIndex maxLength = 256;
        CFMutableStringRef cfstring = CFStringCreateMutable(alloc_default,maxLength);

        // append some c strings into it.
        CFStringAppendCString(cfstring,trackbar->name,encoding);
        CFStringAppendCString(cfstring,valueinchar,encoding);

        SetControlData(trackbar->label, kControlEntireControl,kControlStaticTextCFStringTag, sizeof(cfstring), &cfstring);
        DrawControls(trackbar->parent->window);
        //-----------------------------------------
    }
}
コード例 #18
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AUDiskStreamingCheckbox::AUDiskStreamingCheckbox
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, 
				Point 					inLocation, 
				int 					inRightEdge, 
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top + 16;
	r.left = inLocation.h;		r.right = r.left + inRightEdge;
	
	verify_noerr(CreateCheckBoxControl(mView->GetCarbonWindow(), 
										&r, 
										CFSTR("Disk Streaming"), 
										0, 
										true, 
										&mControl));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	ControlSize smallSize = kControlSizeSmall;
	verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize));

	SInt16 baseLineOffset;
	verify_noerr (GetBestControlRect (mControl, &r, &baseLineOffset));
	r.bottom += baseLineOffset;
	SInt16 difference = (r.left + inRightEdge) - r.right;
	r.right += difference;
	r.left += difference;
	SetControlBounds (mControl, &r);
	EmbedControl(mControl);
	verify_noerr (AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, DiskStreamingListener, this));
	UInt32 value;
	UInt32 size = sizeof(value);
	verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size));
	
	HandlePropertyChange (value);
	
	RegisterEvents();

}
コード例 #19
0
static void add_message(const char *str, ...)
{
    carbon_debug("add_message()\n");

	//static int line = 0;
    va_list ap;
    char buf[BUFSIZ];
	//GList *items = NULL;
	//GtkWidget *item;

    va_start(ap, str);
    vsnprintf(buf, sizeof(buf), str, ap);
    va_end(ap);

    strcat(CurMessage, buf);
    strcat(CurMessage, "\r");
    printf("add_message() - CurMessage = '%s'\n", CurMessage);
    printf("add_message() - Length = %d\n", strlen(CurMessage));
    //STUPSetText(Res->InstalledFilesLabel, CurMessage, strlen(CurMessage));
    CFStringRef CFMessage = CFStringCreateWithCString(NULL, CurMessage, kCFStringEncodingMacRoman);
    SetControlData(Res->InstalledFilesLabel, kControlEntireControl, kYASTControlAllUnicodeTextTag, sizeof(CFMessage), &CFMessage);
    CFRelease(CFMessage);
}
コード例 #20
0
ファイル: AUCarbonViewControl.cpp プロジェクト: kdridi/acau
Boolean	AUCarbonViewControl::SizeControlToFit(ControlRef inControl, SInt16 *outWidth, SInt16 *outHeight)
{
#if !__LP64__
	if (inControl == 0) return false;
	
	Boolean bValue = false;
	// this only works on text controls -- returns an error for other controls, but doesn't do anything,
	// so the error is irrelevant
	SetControlData(inControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
	
	SInt16 baseLineOffset;
	Rect bestRect;
	OSErr err = GetBestControlRect(inControl, &bestRect, &baseLineOffset);  
	if (err != noErr) return false;
	
	int width = (bestRect.right - bestRect.left) + 1;
	int height = (bestRect.bottom - bestRect.top) + 1;
	
	Rect boundsRect;
	GetControlBounds (inControl, &boundsRect);
	
	Rect newRect;
	newRect.top = boundsRect.top;
	newRect.bottom = newRect.top + height;
	newRect.left = boundsRect.left;
	newRect.right = newRect.left + width;
	
	SetControlBounds (inControl, &newRect);
	
	if (outWidth)
		*outWidth = width;
	
	if (outHeight)
		*outHeight = height;
#endif	
	return true;
}
コード例 #21
0
void CEsmBirthSignDlg::OnInitialUpdate() {
  CEsmRecDialog::OnInitialUpdate();
  UpdateTitle(NULL);

	/* Initialize the armor record */
  ASSERT(GetRecInfo() != NULL);
  m_pBirthSign = (CEsmBirthSign *) GetRecInfo()->pRecord;

	/* Spell List */
  m_SpellList.OnInitCtrl();
  m_SpellList.SetDlgHandler(m_pParent);
  m_SpellList.SetEnableDrag(true);
  m_SpellList.SetAcceptDrag(true);
  m_SpellList.SetWantKeys(true);
  m_SpellList.InitObjectList(&l_SpellColData[0]);

	/* Initialize the text controls */
  m_IDText.SetLimitText(MWESM_ID_MAXSIZE);
  m_NameText.SetLimitText(MWESM_ID_MAXSIZE);
  m_DescText.SetLimitText(256);
  
	/* Update the UI data */
  SetControlData();
 }
コード例 #22
0
ファイル: AUCarbonViewControl.cpp プロジェクト: kdridi/acau
void	AUCarbonViewControl::Bind()
{
#if !__LP64__
	mInControlInitialization = 1;   // true
	AUListenerAddParameter(mListener, this, &mParam);
		// will cause an almost-immediate callback
	
	EventTypeSpec events[] = {
		{ kEventClassControl, kEventControlValueFieldChanged }	// N.B. OS X only
	};
	
	WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events);

	if (mType == kTypeContinuous || mType == kTypeText || mType == kTypeDiscrete) {
		EventTypeSpec events[] = {
			{ kEventClassControl, kEventControlHit },
			{ kEventClassControl, kEventControlClick },
		    { kEventClassControl, kEventControlTrack }
		};
		WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events);
	} 

	if (mType == kTypeText) {
		EventTypeSpec events[] = {
			{ kEventClassControl, kEventControlSetFocusPart }
		};
		WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); 
		ControlKeyFilterUPP proc = mParam.ValuesHaveStrings() ? StdKeyFilterCallback : NumericKeyFilterCallback;
			// this will fail for a static text field
		SetControlData(mControl, 0, kControlEditTextKeyFilterTag, sizeof(proc), &proc);
	}
	
	Update(true);
	mInControlInitialization = 0;   // false
#endif
}
コード例 #23
0
void CEsmWeaponDlg::OnInitialUpdate() {

  CEsmRecDialog::OnInitialUpdate();
  UpdateTitle(NULL);
  
	/* Initialize the Weapon record */
  ASSERT(GetRecInfo() != NULL);
  m_pWeapon = (CEsmWeapon *) GetRecInfo()->pRecord;

	/* Initialize the ui controls/lists */
  FillEsmWeaponTypeCombo(m_TypeList);
  FillEsmScriptCombo(m_ScriptList);
  FillEsmEnchantCombo(m_EnchantList);
  m_IDText.SetLimitText(MWESM_ID_MAXSIZE);
  m_NameText.SetLimitText(MWESM_ID_MAXSIZE);
  m_EnchantText.SetLimitText(16);
  m_WeightText.SetLimitText(16);
  m_SpeedText.SetLimitText(16);
  m_ReachText.SetLimitText(16);
  m_HealthText.SetLimitText(16);
  m_ValueText.SetLimitText(16);

  SetControlData();
 }
コード例 #24
0
void	AUControlGroup::CreateLabelledSlider(
										AUCarbonViewBase *			auView,
										const CAAUParameter &		auvp,
										const Rect &				area,
										Point 						labelSize,
										const ControlFontStyleRec &	inFontStyle)
{
#if !__LP64__
	ControlFontStyleRec fontStyle = inFontStyle;
	Rect minValRect, maxValRect, sliderRect;
	ControlRef newControl;
	int width = area.right - area.left, height = area.bottom - area.top;
	CFStringRef cfstr;
	int sliderValueMax, sliderValueMin, sliderValueDefault;
	AUCarbonViewControl::ControlType sliderType;

	bool horizontal = (width > height);

	if (horizontal) {
		maxValRect.top = minValRect.top = area.top + (height - labelSize.v) / 2;
		minValRect.left = area.left;
		maxValRect.left = area.right - labelSize.h;

		minValRect.bottom = minValRect.top + labelSize.v;
		minValRect.right = minValRect.left + labelSize.h;
		maxValRect.bottom = maxValRect.top + labelSize.v;
		maxValRect.right = maxValRect.left + labelSize.h;

		sliderRect.left = minValRect.right + kLabelAndSliderSpacing;
		sliderRect.right = maxValRect.left - kLabelAndSliderSpacing;
		sliderRect.top = area.top + (height - kSliderThinDimension) / 2;
		sliderRect.bottom = sliderRect.top + kSliderThinDimension + 4;

		if (auvp.IsIndexedParam ()) {
			sliderValueMin = sliderValueDefault = int(auvp.ParamInfo().minValue);
			sliderValueMax = int(auvp.ParamInfo().maxValue);
			sliderType = AUCarbonViewControl::kTypeDiscrete;
		} else {
			sliderValueMin = sliderValueDefault = 0;
			sliderValueMax = sliderRect.right - sliderRect.left;
			sliderType = AUCarbonViewControl::kTypeContinuous;
		}
	} else {
		maxValRect.left = minValRect.left = area.left + (width - labelSize.h) / 2;
		maxValRect.top = area.top;
		minValRect.top = area.bottom - labelSize.v;

		minValRect.bottom = minValRect.top + labelSize.v;
		minValRect.right = minValRect.left + labelSize.h;
		maxValRect.bottom = maxValRect.top + labelSize.v;
		maxValRect.right = maxValRect.left + labelSize.h;

		sliderRect.left = area.left + (width - kSliderThinDimension) / 2;
		sliderRect.right = sliderRect.left + kSliderThinDimension + 4;
		sliderRect.top = maxValRect.bottom + kLabelAndSliderSpacing;
		sliderRect.bottom = minValRect.top - kLabelAndSliderSpacing;

		if (auvp.IsIndexedParam ()) {
			sliderValueMin = sliderValueDefault = int(auvp.ParamInfo().minValue);
			sliderValueMax = int(auvp.ParamInfo().maxValue);
			sliderType = AUCarbonViewControl::kTypeDiscrete;
		} else {
			sliderValueMin = sliderValueDefault = 0;
			sliderValueMax = sliderRect.bottom - sliderRect.top;
			sliderType = AUCarbonViewControl::kTypeContinuous;
		}
	}

	// minimum value label
	if (labelSize.v > 0 && labelSize.h > 0) {
		// check to see if the minimum value has a label
		cfstr = auvp.GetStringFromValueCopy(&auvp.ParamInfo().minValue);
		fontStyle.just = horizontal ? teFlushRight : teCenter;
		verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &minValRect, cfstr, &fontStyle, &newControl));
		CFRelease(cfstr);
		verify_noerr(auView->EmbedControl(newControl));

		// maximum value label
		cfstr = auvp.GetStringFromValueCopy(&auvp.ParamInfo().maxValue);
		fontStyle.just = horizontal ? teFlushLeft : teCenter;
		verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &maxValRect, cfstr, &fontStyle, &newControl));
		CFRelease(cfstr);
		verify_noerr(auView->EmbedControl(newControl));
	}

	// slider
	verify_noerr(CreateSliderControl(auView->GetCarbonWindow(), &sliderRect, sliderValueDefault, sliderValueMin, sliderValueMax, kControlSliderDoesNotPoint, 0, true, AUCarbonViewControl::SliderTrackProc, &newControl));


	ControlSize small = kControlSizeSmall;
	SetControlData(newControl, kControlEntireControl, kControlSizeTag, sizeof(ControlSize), &small);
	auView->AddCarbonControl(sliderType, auvp, newControl);
#endif
}
コード例 #25
0
void	AUControlGroup::AddAUInfo (		AUCarbonViewBase *			auView,
										const Point &				inLocation,
										const SInt16 				inRightOffset,
										const SInt16				inTotalWidth)
{
#if !__LP64__
   // get component info
	ComponentDescription desc;
    Handle h1 = NewHandleClear(4);
	OSStatus err = GetComponentInfo ((Component)auView->GetEditAudioUnit(), &desc, h1, 0, 0);

    if (err == noErr) {
        // Get the manufacturer's name... look for the ':' character convention
        HLock(h1);
        char* ptr1 = *h1;
        int len = *ptr1++;
        char* displayStr = 0;

        for (int i = 0; i < len; ++i) {
            if (ptr1[i] == ':') { // found the name
                ptr1[i++] = 0;
                displayStr = ptr1;
                break;
            }
        }

        // localize as necessary:
        if (!sLocalized) {
            CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
            if (mainBundle) {
                kStringManufacturer = CFCopyLocalizedStringFromTableInBundle(
                                            kAUViewLocalizedStringKey_Manufacturer, kLocalizedStringTable_AUView,
                                            mainBundle, CFSTR("Manufacturer title string"));
                sLocalized = true;
            }
        }

        // display strings
        ControlRef newControl;
        Rect r;
        r.top = SInt16(inLocation.v);		r.bottom = SInt16(inLocation.v) + 16;
        ControlFontStyleRec fontStyle;
        fontStyle.flags = kControlUseFontMask | kControlUseJustMask;
        fontStyle.font = kControlFontSmallBoldSystemFont;

        // display manufacturer string
        if (displayStr) {
            CFMutableStringRef mfrstring = CFStringCreateMutable(NULL, 0);
            CFStringAppend(mfrstring, kStringManufacturer);		// "Manufacturer"
            CFStringAppend(mfrstring, kAUViewUnlocalizedString_TitleSeparator);
                                                                // "Manufacturer: "
            CFStringRef mfrname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
            if (mfrname) {
                CFStringAppend(mfrstring, mfrname);	// "Manufacturer: MFRName"
                CFRelease (mfrname);
            }

            r.left = inLocation.h + inRightOffset;
			r.right = inLocation.h + inTotalWidth - 28;
			fontStyle.just = teFlushRight;

            verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, mfrstring, &fontStyle, &newControl));
            verify_noerr(auView->EmbedControl(newControl));
            CFRelease (mfrstring);

            //move displayStr ptr past the manu, to the name
            // we move the characters down an index, because the handle doesn't have any room
            // at the end for the \0
			int i = strlen(displayStr), j = 0;
			while (displayStr[++i] == ' ' && i < len)
				;
			while (i < len)
				displayStr[j++] = displayStr[i++];
			displayStr[j] = 0;
        } else {
			displayStr = ptr1;
			int i = 0, j = 0;
			do {
				displayStr[j] = displayStr[i];
				++j; ++i;
			} while (i < len);

			displayStr[j] = 0;
        }

        // display AudioUnit string
        r.left = inLocation.h;	r.right = r.left + inRightOffset;
        fontStyle.just = 0;

        CFMutableStringRef cfstr = CFStringCreateMutable(NULL, 0);
        CFStringAppend(cfstr, kAUViewLocalizedStringKey_AudioUnit);		// "Audio Unit"
        CFStringAppend(cfstr, kAUViewUnlocalizedString_TitleSeparator);
                                                        // "Audio Unit: "

		CFStringRef auname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
		CFStringAppend(cfstr, auname);				// "Audio Unit: AUName"
		CFRelease (auname);

        verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, cfstr, &fontStyle, &newControl));

		// size text control correctly
		Boolean bValue = false;
		SetControlData(newControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
		SInt16 baseLineOffset;
		Rect bestRect;
		err = GetBestControlRect(newControl, &bestRect, &baseLineOffset);
		if (err == noErr)
		{
			int width = (bestRect.right - bestRect.left) + 1;
			int height = (bestRect.bottom - bestRect.top) + 1;
			SizeControl (newControl, width, height);
		}

        verify_noerr(auView->EmbedControl(newControl));
        CFRelease (cfstr);
    }

	DisposeHandle (h1);
#endif
}
コード例 #26
0
void
TkpDisplayMenuButton(
    ClientData clientData)        /* Information about widget. */
{
    TkMenuButton *butPtr = (TkMenuButton *) clientData;
    Tk_Window tkwin = butPtr->tkwin;
    TkWindow *  winPtr;
    Pixmap      pixmap;
    MacMenuButton * mbPtr = (MacMenuButton *) butPtr;
    GWorldPtr dstPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    int      hasImageOrBitmap = 0;
    int      width, height;
    int      err;
    ControlButtonGraphicAlignment theAlignment;

    Rect paneRect, cntrRect;

    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
        return;
    }
    pixmap = ( Pixmap )Tk_WindowId(tkwin);
    GetGWorld(&saveWorld, &saveDevice);
    dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
    SetGWorld(dstPort, NULL);
    TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));

    winPtr=(TkWindow *)butPtr->tkwin;
    paneRect.left=winPtr->privatePtr->xOff;
    paneRect.top=winPtr->privatePtr->yOff;
    paneRect.right=paneRect.left+Tk_Width(butPtr->tkwin)-1;
    paneRect.bottom=paneRect.top+Tk_Height(butPtr->tkwin)-1;
    
    cntrRect=paneRect;
        
    cntrRect.left+=butPtr->inset;
    cntrRect.top+=butPtr->inset;
    cntrRect.right-=butPtr->inset;
    cntrRect.bottom-=butPtr->inset;

    if (mbPtr->userPane) {
        MenuButtonControlParams params;
        bzero(&params, sizeof(params));
        ComputeMenuButtonControlParams(butPtr, &params );
        if (bcmp(&params,&mbPtr->params,sizeof(params))) {
            if (mbPtr->userPane) {
                DisposeControl(mbPtr->userPane);
                mbPtr->userPane = NULL;
                mbPtr->control = NULL;
            }
        }
     }
     if (!mbPtr->userPane) {
         if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) {
             fprintf(stderr,"Init Control failed\n" );
             return;
         }
     }
    SetControlBounds(mbPtr->userPane,&paneRect);
    SetControlBounds(mbPtr->control,&cntrRect); 

    /*
     * We need to cache the title and its style
     */
    if (!(mbPtr->flags&2)) {
        ControlTitleParams titleParams;
        int                titleChanged;
        int                styleChanged;
        ComputeControlTitleParams(butPtr,&titleParams);
        CompareControlTitleParams(&titleParams,&mbPtr->titleParams,
            &titleChanged,&styleChanged);
        if (titleChanged) {
            CFStringRef cf;    	    
            cf = CFStringCreateWithCString(NULL,
                  titleParams.title, kCFStringEncodingUTF8);
            if (hasImageOrBitmap) {
                SetControlTitleWithCFString(mbPtr->control, cf);
            } else {
                SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf);
            }
            CFRelease(cf);
            bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1);
            mbPtr->titleParams.len = titleParams.len;
        }
        if ((titleChanged||styleChanged) && titleParams .len) {
            if (hasImageOrBitmap) {
                if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) {
                    fprintf(stderr,"SetControlFontStyle failed %d\n", err);
                    return;
                }
            }
            bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style));
        }
    }
    if (butPtr->image != None) {
        Tk_SizeOfImage(butPtr->image, &width, &height);
        hasImageOrBitmap = 1;
    } else if (butPtr->bitmap != None) {
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        hasImageOrBitmap = 1;
    }
    if (hasImageOrBitmap) {
        mbPtr->picParams.srcRect.right = width;
        mbPtr->picParams.srcRect.bottom = height; 
        /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */
        tkPictureIsOpen = 1;
        if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) {
            fprintf(stderr,"OpenCPicture failed\n");
        }
        /*
         * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
         * which does not get recorded in the picture.  So the bitmap code
         * will fail in that case.
         */
        if (butPtr->image != NULL) {
            Tk_RedrawImage(butPtr->image, 0, 0, width,
                height, pixmap, 0, 0);
        } else {   
            XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0,
                (unsigned int) width, (unsigned int) height, 0, 0, 1);
        }
        ClosePicture();
        
        tkPictureIsOpen = 0;
        if ( (err=SetControlData(mbPtr->control, kControlButtonPart,
                    kControlBevelButtonContentTag,
                    sizeof(ControlButtonContentInfo),
                    (char *) &mbPtr->bevelButtonContent)) != noErr ) {
                fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err );
        }
        switch (butPtr->anchor) {
            case TK_ANCHOR_N:
                theAlignment = kControlBevelButtonAlignTop;
                break;
            case TK_ANCHOR_NE:
                theAlignment = kControlBevelButtonAlignTopRight;
                break;
            case TK_ANCHOR_E:
                theAlignment = kControlBevelButtonAlignRight;
                break;
            case TK_ANCHOR_SE:
                theAlignment = kControlBevelButtonAlignBottomRight;
                break;
            case TK_ANCHOR_S:
                theAlignment = kControlBevelButtonAlignBottom;
                break;
            case TK_ANCHOR_SW:
                theAlignment = kControlBevelButtonAlignBottomLeft;
                break;
            case TK_ANCHOR_W:
                theAlignment = kControlBevelButtonAlignLeft;
                break;
            case TK_ANCHOR_NW:
                theAlignment = kControlBevelButtonAlignTopLeft;
                break;
            case TK_ANCHOR_CENTER:
                theAlignment = kControlBevelButtonAlignCenter;
                break;
        }
    
        if ((err=SetControlData(mbPtr->control, kControlButtonPart,
                kControlBevelButtonGraphicAlignTag,
                sizeof(ControlButtonGraphicAlignment),
                (char *) &theAlignment)) != noErr ) {
            fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err );
        }
    }
    if (butPtr->flags & GOT_FOCUS) {
        HiliteControl(mbPtr->control,kControlButtonPart);
    } else {
        HiliteControl(mbPtr->control,kControlNoPart);
    }
    UpdateControlColors(mbPtr);
    if (mbPtr->flags&2) {
        ShowControl(mbPtr->control);
        ShowControl(mbPtr->userPane);
        mbPtr->flags ^= 2;
    } else {
        Draw1Control(mbPtr->userPane);
        SetControlVisibility(mbPtr->control, true, true);
    }
    if (hasImageOrBitmap) {
        KillPicture(mbPtr->bevelButtonContent.u.picture);
    }
    SetGWorld(saveWorld, saveDevice);
}
コード例 #27
0
ファイル: loginbox.c プロジェクト: Spacetracker/iODBC
void
create_login (HWND hwnd,
    LPCSTR username,
    LPCSTR password,
    LPCSTR dsn,
    TLOGIN * log_t)
{
  EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit };
  RgnHandle cursorRgn = NULL;
  WindowRef wlogin;
  ControlRef control;
  ControlID controlID;
  EventRecord event;
  IBNibRef nibRef;
  OSStatus err;
  char msg[1024];

  if (hwnd == NULL)
    return;

  /* Search the bundle for a .nib file named 'odbcadmin'. */
  err =
      CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier (CFSTR
	("org.iodbc.drvproxy")), CFSTR ("login"), &nibRef);
  if (err == noErr)
    {
      /* Nib found ... so create the window */
      CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wlogin);
      DisposeNibReference (nibRef);
      /* Set the title with the DSN */
      if (dsn)
        {
          msg[0] = STRLEN ("Login for ") + STRLEN(dsn);
          sprintf (msg+1, "Login for %s", (char*)dsn);
          SetWTitle (wlogin, msg);
	}
      /* Set the control into the structure */
      GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBUSER_CNTL, wlogin,
	  log_t->username);
      GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBPASS_CNTL, wlogin,
          log_t->password);
      log_t->user = log_t->pwd = NULL;
      log_t->mainwnd = wlogin;
      /* Install handlers for the finish button, the cancel */
      GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBOK_CNTL, wlogin, control);
      InstallEventHandler (GetControlEventTarget (control),
	  NewEventHandlerUPP (login_ok_clicked), 1, &controlSpec, log_t,
	  NULL);
      GETCONTROLBYID (controlID, CNTL_SIGNATURE, LBCANCEL_CNTL, wlogin,
	  control);
      InstallEventHandler (GetControlEventTarget (control),
	  NewEventHandlerUPP (login_cancel_clicked), 1, &controlSpec, log_t,
	  NULL);

      SetControlData (log_t->username, 0, kControlEditTextTextTag,
        username ? STRLEN (username) : STRLEN(""),
        (UInt8 *) username ? username : "");
      SetControlData (log_t->password, 0, kControlEditTextPasswordTag,
        password ? STRLEN (password) : STRLEN(""),
        (UInt8 *) password ? password : "");

      /* Show the window and run the loop */
      AdvanceKeyboardFocus (wlogin);
      ShowWindow (wlogin);
      /* The main loop */
      while (log_t->mainwnd)
	{
	  switch (WaitNextEvent (everyEvent, &event, 60L, cursorRgn))
	    {
	    };
	}
    }
  else
    goto error;

  return;

error:
  fprintf (stderr, "Can't load Window. Err: %d\n", (int) err);
  return;
}
コード例 #28
0
OSStatus _Growl_ShowUpdatePromptForVersion(CFStringRef updateVersion) {
	OSStatus err = noErr;

	if (_checkOSXVersion()) {
		CFBundleRef bundle = CFBundleGetBundleWithIdentifier(GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
		if (!bundle)
			NSLog(CFSTR("GrowlInstallationPrompt: could not locate framework bundle (forget about installing Growl); had looked for bundle with identifier '%@'"), GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
		else {
			IBNibRef nib = NULL;
			err = CreateNibReferenceWithCFBundle(bundle, CFSTR("GrowlInstallationPrompt-Carbon"), &nib);
			if (err != noErr) {
				NSLog(CFSTR("GrowlInstallationPrompt: could not obtain nib: CreateNibReferenceWithCFBundle(%@, %@) returned %li"), bundle, CFSTR("GrowlInstallationPrompt-Carbon"), (long)err);
			} else {
				WindowRef window = NULL;

				err = CreateWindowFromNib(nib, CFSTR("Installation prompt"), &window);
				DisposeNibReference(nib);

				if (err != noErr) {
					NSLog(CFSTR("GrowlInstallationPrompt: could not obtain window from nib: CreateWindowFromNib(%p, %@) returned %li"), nib, CFSTR("Installation prompt"), (long)err);
				} else {
					OSStatus fillOutTextErr = _fillOutTextInWindow(window, (updateVersion != nil));
					OSStatus fillOutIconErr = _fillOutIconInWindow(window);

					err = (fillOutTextErr != noErr) ? fillOutTextErr : (fillOutIconErr != noErr) ? fillOutIconErr : noErr;
					if (err == noErr) {
						if (updateVersion) {
							//store the update version on the window.
							updateVersion = CFRetain(updateVersion);
							err = SetWindowProperty(window,
													GROWL_SIGNATURE,
													GIPC_UPDATE_VERSION,
													sizeof(updateVersion),
													&updateVersion);
							if (err != noErr)
								NSLog(CFSTR("GrowlInstallationPrompt: SetWindowProperty returned %li"), (long)err);
						}

						EventHandlerUPP handlerUPP = NewEventHandlerUPP(_handleCommandInWindow);

						struct EventTypeSpec types[] = {
							{ .eventClass = kEventClassCommand, .eventKind = kEventCommandProcess },
						};

						EventHandlerRef handler = NULL;
						err = InstallWindowEventHandler(window,
														handlerUPP,
														GetEventTypeCount(types),
														types,
														/*refcon*/ window,
														&handler);
						if (err != noErr)
							NSLog(CFSTR("GrowlInstallationPrompt: InstallWindowEventHandler returned %li"), (long)err);
						else {
							HIViewID chasingArrowsID = { GROWL_SIGNATURE, chasingArrowsIDNumber };
							HIViewRef chasingArrows = NULL;

							//stop and hide the chasing arrows, until the user clicks Install.
							OSStatus chasingArrowsErr = HIViewFindByID(HIViewGetRoot(window), chasingArrowsID, &chasingArrows);
							if (chasingArrowsErr == noErr) {
								Boolean truth = false;
								SetControlData(chasingArrows,
											   kControlEntireControl,
											   kControlChasingArrowsAnimatingTag,
											   sizeof(truth),
											   &truth);
								HIViewSetVisible(chasingArrows, false);
							}

							SelectWindow(window);
							ShowWindow(window);

							err = RunAppModalLoopForWindow(window);
							if (err != noErr)
								NSLog(CFSTR("GrowlInstallationPrompt: RunAppModalLoopForWindow(%p) returned %li"), window, (long)err);

							RemoveEventHandler(handler);
						}
						DisposeEventHandlerUPP(handlerUPP);
					}

					ReleaseWindow(window);
				}
			}
		}
	}
コード例 #29
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static WindowRef DrawDialogTheMacOSXWay(void)
{
	// Create a window. "DLOG:257" is the name of the window object. This name is set in 
	// InterfaceBuilder when the resource file is imported.
	
	OSStatus status = noErr;
	IBNibRef nibRef;
	WindowRef window  = NULL;
	
	static HIObjectClassRef	theClass;
	if (theClass == NULL)
	{
		static EventTypeSpec kFactoryEvents[] =
	{
				{ kEventClassHIObject, kEventHIObjectConstruct },
				{ kEventClassHIObject, kEventHIObjectInitialize },
				{ kEventClassHIObject, kEventHIObjectDestruct },
				{ kEventClassControl, kEventControlHitTest },
				{ kEventClassControl, kEventControlTrack },
				{ kEventClassControl, kEventControlBoundsChanged },
				{ kEventClassControl, kEventControlDraw }
	};
		HIObjectRegisterSubclass(kCustomSpotViewClassID, kHIViewClassID, 0, CustomSpotViewHandler, GetEventTypeCount(kFactoryEvents), kFactoryEvents, 0, &theClass);
	}
	
	status = CreateNibReference(CFSTR("main"), &nibRef);
	require_noerr(status, CantGetNibRef);
	
	status = CreateWindowFromNib(nibRef, CFSTR("DLOG:257"), &window);
	require_noerr(status, CantCreateWindow);
	
	// Let's react to User's commands.
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	InstallEventHandler(GetWindowEventTarget(window), MacOSXDialogCommandProcess, 1, &eventTypeCP, window, NULL);
	
	// we still assign the key filter on our edit text box so that only digits can be entered
	HIViewID hidnst = {0, 9};
	HIViewRef numEditText;
	HIViewFindByID(HIViewGetRoot(window), hidnst, &numEditText);
	ControlKeyFilterUPP keyFilter = MyEditKeyFilter;
	SetControlData(numEditText, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter);
	SetKeyboardFocus(window, numEditText, kControlFocusNextPart);
	
	// we still set the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work
	// and still associate the previous edit text box with the scroll bar so it gets updated
	HIViewID hidsb = {0, 14};
	HIViewRef scrollBar;
	HIViewFindByID(HIViewGetRoot(window), hidsb, &scrollBar);
	SetControlAction(scrollBar, ScrollBar32BitActionProc);
	SetControlReference(scrollBar, (SInt32)numEditText);
	
	// Move it!
	MoveWindow(window, 854, 271, false);
	
	// and use the replacement for ModalDialog
	// one good thing is that our behaviors are no longer half-done at the dialog level
	// and half-done at the control level, they are all handled by the view handlers
	ShowWindow(window);
	
CantCreateWindow:
CantGetNibRef:
		return (window);
}
コード例 #30
0
ファイル: main.c プロジェクト: fruitsamples/DialogsToHIViews
static DialogRef DrawDialogTheMacOS8or9Way(void)
{
	short		i;
	ControlRef theControl;
	
	DialogRef theDialog = GetNewDialog(257, NULL, (WindowRef)-1L);
	if (theDialog == NULL) return(NULL);
	
	// Let's get a pulsing blue default button!
	GetDialogItemAsControl(theDialog, 1, &theControl);
	SetWindowDefaultButton(GetDialogWindow(theDialog), theControl);
	
	// Setting the check box
	GetDialogItemAsControl(theDialog, 2, &theControl);
	SetControl32BitValue(theControl, 1);
	
	// We need to autoembed our radio buttons in the radio group
	// so that they work automatically
	for (i = 4; i <= 8; i++)
	{
		GetDialogItemAsControl(theDialog, i, &theControl);
		AutoEmbedControl(theControl, GetDialogWindow(theDialog));
	}
	
	// we assign a key filter on our edit text box so that only digits can be entered
	ControlRef theTextControl;
	ControlKeyFilterUPP keyFilter = MyEditKeyFilter;
	GetDialogItemAsControl(theDialog, 9, &theTextControl);
	SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart);
	SetControlData(theTextControl, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter);
	
	// Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work
	// We also associate the previous edit text box with the scroll bar so it gets updated
	GetDialogItemAsControl(theDialog, 14, &theControl);
	SetControlAction(theControl, ScrollBar32BitActionProc);
	SetControl32BitMaximum(theControl, 0x7fffffff);
	SetControlReference(theControl, (SInt32)theTextControl);
	
	// The static text control is created as a resource but we could only set its title and
	// not its content. We set the content now!
	GetDialogItemAsControl(theDialog, 15, &theControl);
	Str255 theTitle;
	GetControlTitle(theControl, theTitle);
	SetControlData(theControl, kControlEntireControl, kControlStaticTextTextTag, theTitle[0], &theTitle[1]);
	
	// We set up our User Pane Control with the draw, hit test, and track (actually action) procs
	GetDialogItemAsControl(theDialog, 13, &theControl);
	Rect bounds;
	GetControlBounds(theControl, &bounds);
	gUserH = (bounds.left + bounds.right) / 2;
	gUserV = (bounds.top + bounds.bottom) / 2;	
	ControlUserPaneDrawUPP userPaneDraw = MyUserPaneDrawProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(userPaneDraw), &userPaneDraw);
	ControlUserPaneHitTestUPP userPaneHitTest = MyUserPaneHitTestProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(userPaneHitTest), &userPaneHitTest);
	SetControlAction(theControl, MoveSpotActionProc);
	
	ShowWindow(GetDialogWindow(theDialog));
	
	return(theDialog);
}