Esempio n. 1
0
void OpenUserDataRec::EventProcCBEventMouseDown(NavCBRecPtr callBackParms)
{
    EventRecord *evt = callBackParms->eventData.eventDataParms.event;
    Point where = evt->where;
    QDGlobalToLocalPoint(GetWindowPort(callBackParms->window), &where);

    ControlRef whichControl = FindControlUnderMouse(where, callBackParms->window, NULL);
    if (whichControl != NULL)
    {
        ControlKind theKind;
        GetControlKind(whichControl, &theKind);

        // Moving the focus if we clicked in an focusable control
        if ((theKind.kind == kControlKindEditUnicodeText) ||
            (theKind.kind == kControlKindEditText) ||
            (theKind.kind == kControlKindDataBrowser) ||
            (theKind.kind == kControlKindListBox))
        {
            ControlRef currentlyFocusedControl;
            GetKeyboardFocus(callBackParms->window, &currentlyFocusedControl);
            if (currentlyFocusedControl != whichControl)
                SetKeyboardFocus(callBackParms->window, whichControl, kControlFocusNextPart);
        }
        HandleControlClick(whichControl, where, evt->modifiers, NULL);
    }
}
Esempio n. 2
0
// --------------------------------------------------------------------------------------
void  OpenPrefsDialog(void)
{
	DialogRef dialog;
	WindowRef dialogWindow;
	ControlRef control;
	ListHandle iconList;
	Cell theCell;
	
	dialog = GetNewDialog(rPrefsDialogPlatinum, NULL, kFirstWindowOfClass);
	if (dialog == NULL)
		ExitToShell();
	SetPortDialogPort(dialog);
	dialogWindow = GetDialogWindow(dialog);
	
	SetDialogDefaultItem(dialog, kStdOkItemIndex);
	SetDialogCancelItem(dialog, kStdCancelItemIndex);
	
	GetDialogItemAsControl(dialog, iIconList, &control);
	GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, 
					sizeof(ListHandle), &iconList, NULL);
 	
	AddRowsAndDataToIconList(iconList, rIconListIconBaseID);
	(*iconList)->selFlags = lOnlyOne;
	
	SetPt(&theCell, 0, 0);
	LSetSelect(true, theCell, iconList);
	SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart);
	gPanelNumber = 0;
		
	DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog);
	ShowWindow(dialogWindow);
} // OpenPrefsDialog
Esempio n. 3
0
void aui_Tab::MouseLGrabInside( aui_MouseEvent *mouseData )
{
	if ( IsDisabled() ) return;
	if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this )
	{
		SetWhichSeesMouse( this );

		PlaySound( AUI_SOUNDBASE_SOUND_EXECUTE );

		
		HideTipWindow();

		
		SetMouseOwnership();
		ReleaseMouseOwnership();
		SetKeyboardFocus();

		m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE;

		
		if ( !HandleGameSpecificLeftClick( this ) )
		if ( 0 < m_state && m_state < m_numStates - 1 )
			SetState( Mod(m_state+1,m_numStates) );
		else
			SetState( 1 );

		m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE;

		
		m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE;
	}
	else
		MouseLGrabOutside( mouseData );
}
Esempio n. 4
0
void CInitBrushNameDlg::InitGadgetText(String_32* pString, BOOL resizeDialog /*= TRUE*/)
{
	if (pString != NULL)
		m_strSuggest = *pString;
	SetStringGadgetValue(_R(IDC_EDITBRUSHNAME), *GetSuggestion(&m_strSuggest));

	// change the dialog title to "Enter brush name:"
	// Errr, NO!  This is very bad for translation!
//	String_256 Name = TEXT("Create new brush:");
//	SetTitlebarName(&Name);

	// Show the help button
	HideGadget(_R(ID_CC_HELP_BUTTON), FALSE);

	// show the group info text
	SetStringGadgetValue(_R(IDC_STATICBRUSHGROUP), _R(IDS_BRUSHGROUP));
	HideGadget(_R(IDC_STATICBRUSHGROUP), FALSE);

	
	
	HighlightText(_R(IDC_EDITBRUSHNAME));
	SetKeyboardFocus(_R(IDC_EDITBRUSHNAME));


}
Esempio n. 5
0
void WebAddressDlg::OnCreate()
{	
	//Set up the dialog in its initial state
	SetDialogInitialState();

	//And put the keyboard focus in the URL edit field
	SetKeyboardFocus(_R(IDC_WEBADDRESS_URL));
	HighlightText(_R(IDC_WEBADDRESS_URL));
}
// --------------------------------------------------------------------------------------
ControlRef CreateIconDataBrowser(WindowRef window, const Rect *dbRect, ControlRef *userPanes)
{
    ControlRef dataBrowserControl;
    DataBrowserListViewColumnDesc columnDesc;
    DataBrowserItemID firstItem;

    CreateDataBrowserControl(window, dbRect, kDataBrowserListView, &dataBrowserControl);

    SetDataBrowserHasScrollBars(dataBrowserControl, false, true);
    SetDataBrowserSelectionFlags(dataBrowserControl, kDataBrowserDragSelect |
                                 kDataBrowserSelectOnlyOne);
    SetDataBrowserListViewHeaderBtnHeight(dataBrowserControl, 0);	// no header button
    SetDataBrowserTableViewHiliteStyle(dataBrowserControl, kDataBrowserTableViewFillHilite);
    // because kDataBrowserTableViewMinimalHilite would require us to provide a hit test
    // callback which we would just return true from anyways

    columnDesc.propertyDesc.propertyID = kCategoryProperty;
    columnDesc.propertyDesc.propertyType = kDataBrowserCustomType;	// because
    // kDataBrowserIconAndTextType doesn't draw the way we want
    columnDesc.propertyDesc.propertyFlags = kDataBrowserDefaultPropertyFlags |
                                            kDataBrowserListViewSelectionColumn;
    columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
    columnDesc.headerBtnDesc.minimumWidth = kColumnWidth;
    columnDesc.headerBtnDesc.maximumWidth = kColumnWidth;
    columnDesc.headerBtnDesc.titleOffset = 0;
    columnDesc.headerBtnDesc.titleString = NULL;
    columnDesc.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing;
    columnDesc.headerBtnDesc.btnFontStyle.flags = 0;
    columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
    AddDataBrowserListViewColumn(dataBrowserControl, &columnDesc,
                                 kDataBrowserListViewAppendColumn);

    /* We need to wait to set the row height until here because
       AddDataBrowserListViewColumn will resize the row height. */
#if TARGET_API_MAC_OSX
    SetDataBrowserTableViewRowHeight(dataBrowserControl, kRowHeight);
#else		// Mac OS 8/9 under CarbonLib adds 1 to the row height you provide
    SetDataBrowserTableViewRowHeight(dataBrowserControl, kRowHeight - 1);
#endif

    SetDataBrowserListViewUsePlainBackground(dataBrowserControl, true);

    if (gCallbackRefCount == 0)
    {
        gIconDBCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(IconDataBrowserItemSelectionCB);
        gIconDBCustomCallbacks.u.v1.drawItemCallback = NewDataBrowserDrawItemUPP(DrawIconDataBrowserItemCB);
    }
    SetDataBrowserCallbacks(dataBrowserControl, &gIconDBCallbacks);
    SetDataBrowserCustomCallbacks(dataBrowserControl, &gIconDBCustomCallbacks);
    gCallbackRefCount++;

    firstItem = addItemsToIconDB(dataBrowserControl, userPanes);
    SetDataBrowserSelectedItems(dataBrowserControl, 1, &firstItem, kDataBrowserItemsAssign);
    SetKeyboardFocus(window, dataBrowserControl, kControlFocusNextPart);

    return dataBrowserControl;
}
Esempio n. 7
0
bool LLCrashLoggerMac::init(void)
{	
	bool ok = LLCrashLogger::init();
	if(!ok) return false;
	if(mCrashBehavior != CRASH_BEHAVIOR_ASK) return true;
	
	// Real UI...
	OSStatus err;
	
	err = CreateNibReference(CFSTR("CrashReporter"), &nib);
	
	if(err == noErr)
	{
		err = CreateWindowFromNib(nib, CFSTR("CrashReporter"), &gWindow);
	}

	if(err == noErr)
	{
		// Set focus to the edit text area
		ControlRef textField = NULL;
		ControlID id;

		id.signature = 'text';
		id.id = 0;
		
		// Don't set err if any of this fails, since it's non-critical.
		if(GetControlByID(gWindow, &id, &textField) == noErr)
		{
			SetKeyboardFocus(gWindow, textField, kControlFocusNextPart);
		}
	}
	
	if(err == noErr)
	{
		ShowWindow(gWindow);
	}
	
	if(err == noErr)
	{
		// Set up an event handler for the window.
		EventTypeSpec handlerEvents[] = 
		{
			{ kEventClassCommand, kEventCommandProcess }
		};

		InstallWindowEventHandler(
				gWindow, 
				NewEventHandlerUPP(dialogHandler), 
				GetEventTypeCount (handlerEvents), 
				handlerEvents, 
				0, 
				&gEventHandler);
	}
	return true;
}
Esempio n. 8
0
void ImagemapDlg::OnCreate()
{	
	//Set up the controls from our ImagemapFilterOptions member variables
	SetOptions(ms_Options);

	//Set up our internal member variables
	SetMemberVariables(ms_Options);

	//And put the keyboard focus in the Map Name field
	SetKeyboardFocus(_R(IDC_IMAGEMAP_MAPNAME));
}
Esempio n. 9
0
bool wxMacSearchFieldControl::SetFocus()
{
    // NB: We have to implement SetFocus a little differently because kControlFocusNextPart
    // leads to setting the focus on the search icon rather than the text area.
    // We get around this by explicitly telling the control to set focus to the
    // text area.

    OSStatus err = SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, kControlEditTextPart );
    if ( err == errCouldntSetFocus )
        return false ;
    SetUserFocusWindow(GetControlOwner( m_controlRef ) );
    return true;
}
Esempio n. 10
0
//-------------------------------------------------------------------------------------
//	Prompt
//-------------------------------------------------------------------------------------
//	Put up a modal panel and request some text.
//
CFStringRef
Prompt( CFStringRef inPrompt, CFStringRef inDefaultText )
{
    IBNibRef 			nibRef;
	OSStatus			err;
	WindowRef			window;
	EventTypeSpec		kEvents[] = { { kEventClassCommand, kEventCommandProcess } };
	PanelInfo			info;
	HIViewRef			view;
	
	info.window = window;
	info.string = NULL;

    err = CreateNibReference( CFSTR( "main" ), &nibRef );
    require_noerr( err, CantGetNibRef );
	
	err = CreateWindowFromNib( nibRef, CFSTR( "Prompt" ), &window );
	require_noerr( err, CantCreateWindow );
	
	DisposeNibReference( nibRef );

	if ( inPrompt )
	{
		HIViewFindByID( HIViewGetRoot( window ), kPromptLabelID, &view );
		SetControlData( view, 0, kControlStaticTextCFStringTag, sizeof( CFStringRef ), &inPrompt );
	}
	
	HIViewFindByID( HIViewGetRoot( window ), kTextFieldID, &view );

	if ( inDefaultText )
		SetControlData( view, 0, kControlEditTextCFStringTag, sizeof( CFStringRef ), &inDefaultText );	

	SetKeyboardFocus( window, view, kControlFocusNextPart );

	InstallWindowEventHandler( window, InputPanelHandler, GetEventTypeCount( kEvents ),
				kEvents, &info, NULL );	
	
	ShowWindow( window );
	
	info.window = window;

	RunAppModalLoopForWindow( window );

	DisposeWindow( window );

CantCreateWindow:
CantGetNibRef:
	return info.string;
}
Esempio n. 11
0
static void RunDialogTheMacOS8or9Way(DialogRef theDialog)
{
	SInt16 itemHit;
	ControlRef theControl;
	ControlRef  theTextControl;
	
	BringToFront(GetDialogWindow(theDialog));
	
	do {
		ModalDialog(MyMacOS8or9DialogFilter, &itemHit);
		switch (itemHit)
		{
			case 2:
			{
				// we still enable or disable the user pane depending on whether the box is checked or not
				GetDialogItemAsControl(theDialog, itemHit, &theControl);
				SInt32 enable = GetControl32BitValue(theControl);
				SetControl32BitValue(theControl, 1 - enable);
				GetDialogItemAsControl(theDialog, 13, &theControl);
				if (!enable)
					ActivateControl(theControl);
				else
					DeactivateControl(theControl);
			}
				break;
			case 9: case 10:
			{
				// we got a click in an edit text control, if didn't have the focus, let's set it
				GetDialogItemAsControl(theDialog, itemHit, &theTextControl);
				ControlRef currentFocus;
				GetKeyboardFocus(GetDialogWindow(theDialog), &currentFocus);
				if (currentFocus != theTextControl)
					SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart);
			}
				break;
		}
	} while (!(itemHit == ok));
	
	DisposeDialog(theDialog);
}
Esempio n. 12
0
void aui_Button::MouseLGrabInside( aui_MouseEvent *mouseData )
{
	if (IsDisabled()) {
		if (g_soundManager) {
			g_soundManager->AddSound(SOUNDTYPE_SFX, 0,
					gamesounds_GetGameSoundID(GAMESOUNDS_GENERALFAIL), 0, 0);
		}
		return;
	}

	if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this )
	{
		SetWhichSeesMouse( this );

		PlaySound( AUI_SOUNDBASE_SOUND_ENGAGE );

		HideTipWindow();

		SetMouseOwnership();
		SetKeyboardFocus();

		m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE;

		m_attributes |= k_CONTROL_ATTRIBUTE_DOWN;
		m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE;
		m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE;

		m_isRepeating = TRUE;
		m_repeatCount = 0;
		m_startWaitTime = mouseData->time;
		if ( m_ActionFunc )
			m_ActionFunc( this, AUI_BUTTON_ACTION_PRESS, 0, m_cookie );
		else if ( m_action )
			m_action->Execute( this, AUI_BUTTON_ACTION_PRESS, 0 );
	}
	else
		MouseLGrabOutside( mouseData );
}
Esempio n. 13
0
void IGraphicsCarbon::CreateTextEntry(IControl* pControl, IText* pText, IRECT* pTextRect, const char* pString, IParam* pParam)
{
  ControlRef control = 0;

  if (!pControl || mTextEntryView || !mIsComposited) return;

  Rect r = { pTextRect->T, pTextRect->L, pTextRect->B, pTextRect->R };

  // these adjustments should make it the same as the cocoa one, i.e. the same size as the pTextRect, but with the extra blue rim often this is too small
  //Rect r = { pTextRect->T+4, pTextRect->L+3, pTextRect->B-3, pTextRect->R -3 };

  if (CreateEditUnicodeTextControl(NULL, &r, NULL, false, NULL, &control) != noErr) return;

  HIViewAddSubview(mView, control);

  const EventTypeSpec events[] =
  {
    { kEventClassKeyboard, kEventRawKeyDown },
    { kEventClassKeyboard, kEventRawKeyRepeat }
  };

  InstallControlEventHandler(control, TextEntryHandler, GetEventTypeCount(events), events, this, &mTextEntryHandler);
  mTextEntryView = control;

  if (pString[0] != '\0')
  {
    CFStringRef str = CFStringCreateWithCString(NULL, pString, kCFStringEncodingUTF8);

    if (str)
    {
      SetControlData(mTextEntryView, kControlEditTextPart, kControlEditTextCFStringTag, sizeof(str), &str);
      CFRelease(str);
    }

    ControlEditTextSelectionRec sel;
    sel.selStart = 0;
    sel.selEnd = strlen(pString);
    SetControlData(mTextEntryView, kControlEditTextPart, kControlEditTextSelectionTag, sizeof(sel), &sel);
  }

  int just = 0;

  switch ( pText->mAlign )
  {
    case IText::kAlignNear:
      just = teJustLeft;
      break;
    case IText::kAlignCenter:
      just = teCenter;
      break;
    case IText::kAlignFar:
      just = teJustRight;
      break;
    default:
      just = teCenter;
      break;
  }

  ControlFontStyleRec font = { kControlUseJustMask | kControlUseSizeMask | kControlUseFontMask, 0, pText->mSize, 0, 0, just, 0, 0 };
  CFStringRef str = CFStringCreateWithCString(NULL, pText->mFont, kCFStringEncodingUTF8);
  font.font = ATSFontFamilyFindFromName(str, kATSOptionFlagsDefault);

  SetControlData(mTextEntryView, kControlEditTextPart, kControlFontStyleTag, sizeof(font), &font);
  CFRelease(str);

  Boolean singleLineStyle = true;
  SetControlData(mTextEntryView, kControlEditTextPart, kControlEditTextSingleLineTag, sizeof (Boolean), &singleLineStyle);

  HIViewSetVisible(mTextEntryView, true);
  HIViewAdvanceFocus(mTextEntryView, 0);
  SetKeyboardFocus(mWindow, mTextEntryView, kControlEditTextPart);
  SetUserFocusWindow(mWindow);

  mEdControl = pControl;
  mEdParam = pParam;
}
Esempio n. 14
0
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);
}
	/* YASTControlCarbonEventHandler defines the main entry point for all
	of the carbon event handlers installed for the YASTControl. */
static pascal OSStatus YASTControlCarbonEventHandler(
									EventHandlerCallRef myHandler,
									EventRef event,
									void* userData) {
	#pragma unused ( myHandler )
    OSStatus err, returnedResult;
	YASTControlVarsPtr varsp;
	UInt32 eclass, ekind;
		/* set up locals */
	eclass = GetEventClass(event);
	ekind = GetEventKind(event);
	varsp = (YASTControlVarsPtr) userData;
	returnedResult = eventNotHandledErr;
		/* dispatch the event by class*/
	switch (eclass) {
	
		case kEventClassWindow:
			if ( ekind == kEventWindowCursorChange ) {
				Point where;
				UInt32 modifiers;
				Boolean cursorWasSet;
					/* get the mouse position */
				err = GetEventParameter( event, kEventParamMouseLocation, 
						typeQDPoint,  NULL, sizeof(where), NULL, &where);
				if (err == noErr) {
					err = GetEventParameter( event, kEventParamKeyModifiers, 
							typeUInt32,  NULL, sizeof(modifiers), NULL, &modifiers);
					if (err == noErr) {
						SetPort(varsp->fGrafPtr);
						GlobalToLocal(&where);
						if (PtInRect(where, &varsp->fRBounds)) {
							err = HandleControlSetCursor( varsp->fControl, where, modifiers, &cursorWasSet);
							if (err != noErr) cursorWasSet = false;
							if ( ! cursorWasSet ) InitCursor();
							returnedResult = noErr;
						}
					}
				}
			}
			break;
	
		case kEventClassMouse:
				/* handle mouse downs in the control, but only if the
				control is in focus. */
			if ( ekind == kEventMouseDown ) {
				EventRecord outEvent;
				if ( varsp->fInFocus ) {
					if (ConvertEventRefToEventRecord( event, &outEvent)) {
						TXNClick( varsp->fTXNObject,  &outEvent);
					}
					returnedResult = noErr;
				}
			}
			break;

		case kEventClassTextInput:
			if ( ekind == kEventUnicodeForKeyEvent
			&& varsp->fTabMovesFocus) {
				UniChar mUnicodeText[8];
				UInt32 bytecount, nchars;
					/* get the character */
				err = GetEventParameter(event, kEventParamTextInputSendText, 
							typeUnicodeText, NULL, sizeof(mUnicodeText),
							&bytecount, (char*) mUnicodeText);
				if ((err == noErr)
				&& (bytecount >= sizeof(UniChar))) {
					nchars = ( bytecount / sizeof(UniChar) );
						/* if it's not the tab key, forget it... */
					if ( mUnicodeText[0] == '\t' ) {
						EventRef rawKeyEvent;
						Boolean shiftDown;
							/* is the shift key held down? */
						shiftDown = false;
						err = GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, 
									typeEventRef, NULL, sizeof(rawKeyEvent), NULL, &rawKeyEvent);
						if (err == noErr) {
							UInt32 modifiers;
							err = GetEventParameter(rawKeyEvent, kEventParamKeyModifiers, 
									typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
							if (err == noErr) {
								shiftDown = ( (modifiers & shiftKey) != 0 );
							}
						}
							/* advance the keyboard focus, backwards if shift is down */
						if (shiftDown)
							ReverseKeyboardFocus( varsp->fWindow );
						else AdvanceKeyboardFocus( varsp->fWindow );
							/* noErr lets the CEM know we handled the event */
						returnedResult = noErr;
					}
				}
			}
			break;

		case kEventClassControl:
			switch (ekind) {

				case kEventControlSetFocusPart:
					{	ControlPartCode thePart;
						err = GetEventParameter(event, kEventParamControlPart, 
							typeControlPartCode, NULL, sizeof(thePart), NULL, &thePart);
						if (err == noErr) {
							switch (thePart) {
								default:
								case kControlFocusNoPart: /* turn off focus */
									if ( varsp->fInFocus ) {
										TXNFocus( varsp->fTXNObject, false);
										varsp->fInFocus = false;
									}
									thePart = kControlFocusNoPart;
									break;
								case kYASTControlOnlyPart: /* turn on focus */
									if ( !  varsp->fInFocus ) {
										TXNFocus( varsp->fTXNObject, true);
										varsp->fInFocus = true;
									}
									thePart = kYASTControlOnlyPart;
									break;
								case kControlFocusPrevPart: /* toggle focus on/off */
								case kControlFocusNextPart:
									varsp->fInFocus = ! varsp->fInFocus;
									TXNFocus( varsp->fTXNObject, varsp->fInFocus);
									thePart = (varsp->fInFocus ? kYASTControlOnlyPart : kControlFocusNoPart);
									break;
							}
							SetPort(varsp->fGrafPtr);
								/* calculate the next highlight state */
							SetTextActivation(varsp, varsp->fIsActive && varsp->fInFocus);
								/* redraw the text fram and focus rectangle to indicate the
								new focus state */
							DrawThemeEditTextFrame(&varsp->fRTextOutline,
								varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
							RedrawFocusOutline(varsp);
						}
							/* pass back the foocus part code */
						err = SetEventParameter( event, kEventParamControlPart,
								typeControlPartCode, sizeof(thePart), &thePart);
						returnedResult = err;
					}
					break;

				case kEventControlHitTest:
						/* this event does not necessairly mean that a mouse click
						has occured.  Here we are simply testing to see if a particular
						point is located inside of the control.  More complicated controls
						would return different part codes for different parts of
						themselves;  but, since YASTControls only advertise one part, the
						hit test here is more or less a boolean test. */
					{	ControlPartCode thePart;
						Point where;
						err = GetEventParameter(event, kEventParamMouseLocation, 
							typeQDPoint, NULL, sizeof(where), NULL, &where);
						if (err == noErr) {
							if (PtInRect(where, &varsp->fRTextArea)) {
								thePart = kYASTControlOnlyPart;
							} else thePart = 0;
							err = SetEventParameter( event, kEventParamControlPart,
										typeControlPartCode, sizeof(thePart), &thePart);
						}
						returnedResult = err;
					}
					break;

				case kEventControlClick:
						/* here we handle focus switching on the control.  Actual tracking
						of mouse down events in the control is performed in the kEventClassMouse
						mouse down handler above. */
					if ( ! varsp->fInFocus ) {
						SetKeyboardFocus(varsp->fWindow, varsp->fControl, kYASTControlOnlyPart);
						returnedResult = noErr;
					}
					break;
					
				case kEventControlBoundsChanged:
						/* we moved, or switched size - recalculate our rectangles */
					{	Rect bounds;
						err = GetEventParameter(event, kEventParamCurrentBounds, 
							typeQDRectangle, NULL, sizeof(bounds), NULL, &bounds);
						if (err == noErr) {
							YASTControlCalculateBounds(varsp, &bounds);
							TXNSetFrameBounds( varsp->fTXNObject,
								varsp->fRTextArea.top, varsp->fRTextArea.left,
								varsp->fRTextArea.bottom, varsp->fRTextArea.right,
								varsp->fTXNFrameID);
						}
					}
					break;
						
				case kEventControlActivate:
				case kEventControlDeactivate:
					{	SetPort(varsp->fGrafPtr);
						varsp->fIsActive = (ekind == kEventControlActivate);
						SetTextActivation(varsp, varsp->fIsActive && varsp->fInFocus);
							/* redraw the frame */
						DrawThemeEditTextFrame(&varsp->fRTextOutline,
							varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
						RedrawFocusOutline(varsp);
						returnedResult = noErr;
					}
					break;
					
				case kEventControlDraw:
						/* redraw the control */
					SetPort(varsp->fGrafPtr);
						/* update the text region */
					TXNDraw(varsp->fTXNObject, NULL);
						/* restore the drawing environment */
						/* draw the text frame and focus frame (if necessary) */
					DrawThemeEditTextFrame(&varsp->fRTextOutline,
						varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
					RedrawFocusOutline(varsp);
					returnedResult = noErr;
					break;
					
				case kEventControlSetCursor:
						/* cursor adjustment */
					{	SetPortWindowPort(varsp->fWindow);
						TXNAdjustCursor( varsp->fTXNObject, varsp->fRTextOutlineRegion);
						returnedResult = noErr;
					}
					break;
					
				case kEventControlDispose:
						/* RemoveEventHandler(varsp->fControlEvents); -- this call has been
						left out on purpose because it will be called automatically when the
						control is disposed. */
					RemoveEventHandler(varsp->fWindowEvents);
					TXNDeleteObject(varsp->fTXNObject);
					DisposeRgn(varsp->fRTextOutlineRegion);
					free(varsp);
						/* returnedResult = noErr; -- this has been left out on purpose
						because we want the dispatching to continue and dispose of the control */
					break;
					
				case kEventControlSetData:
					{	ResType inTagName;
						Size inBufferSize;
						void * inBuffer;
						err = GetEventParameter( event, kEventParamControlDataTag, typeEnumeration, 
							NULL, sizeof(inTagName), NULL, &inTagName);
						if (err == noErr) {
							err = GetEventParameter( event, kEventParamControlDataBuffer, typePtr, 
								NULL, sizeof(inBuffer), NULL, &inBuffer);
							if (err == noErr) {
								err = GetEventParameter( event, kEventParamControlDataBufferSize, typeLongInteger, 
									NULL, sizeof(inBufferSize), NULL, &inBufferSize);
								if (err == noErr) {
									err = YASTControlSetData(varsp, inTagName, inBuffer, inBufferSize);
								}
							}
						}
						returnedResult = err;
					}
					break;
					
				case kEventControlGetData:
					{	ResType inTagName;
						Size inBufferSize, outBufferSize;
						void * inBuffer;
						err = GetEventParameter( event, kEventParamControlDataTag, typeEnumeration, 
							NULL, sizeof(inTagName), NULL, &inTagName);
						if (err == noErr) {
							err = GetEventParameter( event, kEventParamControlDataBuffer, typePtr, 
								NULL, sizeof(inBuffer), NULL, &inBuffer);
							if (err == noErr) {
								err = GetEventParameter( event, kEventParamControlDataBufferSize, typeLongInteger, 
									NULL, sizeof(inBufferSize), NULL, &inBufferSize);
								if (err == noErr) {
									err = YASTControlGetData(varsp, inTagName, inBuffer, inBufferSize, &outBufferSize);
									if (err == noErr) {
										err = SetEventParameter( event, kEventParamControlDataBufferSize,
													typeLongInteger, sizeof(outBufferSize), &outBufferSize);
									}
								}
							}
						}
						returnedResult = err;
					}
					break;
					
			}
			break;
		case kEventClassCommand:
			if ( ekind == kEventProcessCommand ) {
				HICommand command;
				err = GetEventParameter( event, kEventParamDirectObject,
										typeHICommand, NULL, sizeof(command), NULL, &command);
				if (err == noErr) {
					switch (command.commandID) {
						case kHICommandUndo:
							TXNUndo(varsp->fTXNObject);
							returnedResult = noErr;
							break;
						case kHICommandRedo:
							TXNRedo(varsp->fTXNObject);
							returnedResult = noErr;
							break;
						case kHICommandCut:
							ClearCurrentScrap();
							err = TXNCut(varsp->fTXNObject); 
							if (err == noErr)
								err = TXNConvertToPublicScrap();
							returnedResult = err;
							break;
						case kHICommandCopy:
							ClearCurrentScrap();
							err = TXNCopy(varsp->fTXNObject);
							if (err == noErr)
								err = TXNConvertToPublicScrap();
							returnedResult = err;
							break;
						case kHICommandPaste:
							err = TXNConvertFromPublicScrap();
							if (err == noErr)
								err = TXNPaste(varsp->fTXNObject);
							returnedResult = err;
							break;
						case kHICommandClear:
							err = TXNClear(varsp->fTXNObject);
							returnedResult = err;
							break;
						case kHICommandSelectAll:
							err = TXNSetSelection(varsp->fTXNObject, kTXNStartOffset, kTXNEndOffset);
							returnedResult = err;
							break;
					}
				}
			} else if ( ekind == kEventCommandUpdateStatus ) {
				HICommand command;
				TXNOffset oStartOffset, oEndOffset;
				TXNActionKey oActionKey;

				err = GetEventParameter( event, kEventParamDirectObject, typeHICommand, 
										NULL, sizeof(command), NULL, &command);
				
				if ((err == noErr)
				&& ((command.attributes & kHICommandFromMenu) != 0)) {
					switch (command.commandID) {
						case kHICommandUndo:
							if (TXNCanUndo(varsp->fTXNObject, &oActionKey)) {
								EnableMenuItem(command.menu.menuRef, 0); /* required pre OS 10.2 */
								EnableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							} else DisableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							returnedResult = noErr;
							break;
						case kHICommandRedo:
							if (TXNCanRedo(varsp->fTXNObject, &oActionKey)) {
								EnableMenuItem(command.menu.menuRef, 0); /* required pre OS 10.2 */
								EnableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							} else DisableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							returnedResult = noErr;
							break;
						case kHICommandCut:
						case kHICommandCopy:
						case kHICommandClear:
							TXNGetSelection(varsp->fTXNObject, &oStartOffset, &oEndOffset);
							if (oStartOffset != oEndOffset) {
								EnableMenuItem(command.menu.menuRef, 0); /* required pre OS 10.2 */
								EnableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							} else DisableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							returnedResult = noErr;
							break;
						case kHICommandPaste:
							if (TXNIsScrapPastable()) {
								EnableMenuItem(command.menu.menuRef, 0); /* required pre OS 10.2 */
								EnableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							} else DisableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							returnedResult = noErr;
							break;
						case kHICommandSelectAll:
							if(TXNDataSize(varsp->fTXNObject) > 0) {
								EnableMenuItem(command.menu.menuRef, 0); /* required pre OS 10.2 */
								EnableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							} else DisableMenuItem(command.menu.menuRef, command.menu.menuItemIndex);
							returnedResult = noErr;
							break;
					}
				}
			}
			break;
	}
    return returnedResult;
}
Esempio n. 16
0
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);
}
Esempio n. 17
0
void FilterWidget::activate(void)
{
	SetKeyboardFocus(HIViewGetWindow(searchField), searchField, kControlFocusNoPart);
	SetKeyboardFocus(HIViewGetWindow(searchField), searchField, kControlFocusNextPart);
	setText(text());
}
Esempio n. 18
0
void SetClientStateWithEventMask (ClientData *pCD, int newState, Time setTime, unsigned int event_mask)
{
    ClientData *pcdLeader;
    int currentState;
    WmScreenData *pSD = PSD_FOR_CLIENT(pCD);
#ifdef WSM
    Boolean notShowing = (newState & UNSEEN_STATE);
#endif /* WSM */

    currentState = pCD->clientState;
    if (currentState == newState)
    {
	/* no change in state */
	return;
    }


    /*
     * Undo the old state and setup the new state.  If this is a transient
     * window then insure that it is put in a state that is compatible
     * with its transient leader (e.g., it cannot be minimized separately).
     */

    pcdLeader = (pCD->transientLeader) ? FindTransientTreeLeader (pCD) : pCD;
#ifdef WSM
    SetClientWsIndex (pCD);
#endif /* WSM */

    if (pCD->transientLeader)
    {
	if ((pcdLeader->clientState == MINIMIZED_STATE) &&
	    (newState != WITHDRAWN_STATE))
	{
	    newState = MINIMIZED_STATE;
#ifdef WSM
	    if (notShowing)
	    {
		newState |= UNSEEN_STATE;
	    }
#endif /* WSM */
	}
	else if ((newState == MINIMIZED_STATE) &&
		 (pcdLeader->clientState != MINIMIZED_STATE))
	{
	    if (currentState == WITHDRAWN_STATE)
	    {
		newState = NORMAL_STATE;
#ifdef WSM
	    if (notShowing)
	    {
		newState |= UNSEEN_STATE;
	    }
#endif /* WSM */
	    }
	    else
	    {
		newState = currentState;
#ifdef WSM
	    if (notShowing)
	    {
		newState |= UNSEEN_STATE;
	    }
#endif /* WSM */
	    }
	}
	if (newState == currentState)
	{
	    return;
	}
    }

    switch (newState)
    {

#ifdef WSM
        case UNSEEN_STATE | WITHDRAWN_STATE:
#else
	case WITHDRAWN_STATE:
#endif /* WSM */
	{
	    /*
	     * Free window manager resources (frame and icon).  The
	     * WM_STATE property is set in WithdrawWindow.
	     */

	    UnManageWindow (pCD);
	    break;
	}

	case NORMAL_STATE:
	case MAXIMIZED_STATE:
	{
	    SetupWindowStateWithEventMask (pCD, newState, setTime, event_mask);
#ifdef WSM
	    XMapWindow (DISPLAY, pCD->client);
	    XMapWindow (DISPLAY, pCD->clientFrameWin);
#if defined(PANELIST)
            WmStopWaiting();   /* in WmIPC.c */
#endif /* PANELIST */
#endif /* WSM */
	    break;
	}

	case MINIMIZED_STATE:
	{
	    Boolean clientHasFocus;

	    /*
	     * Transient windows are minimized with the rest of the transient
	     * tree, including the transient leader.
	     */

	    if ((pCD->clientState == NORMAL_STATE) ||
		(pCD->clientState == MAXIMIZED_STATE))
	    {
		if ((wmGD.keyboardFocus == pCD) ||
		    (pCD->transientChildren && wmGD.keyboardFocus &&
		     (pCD == FindTransientTreeLeader (wmGD.keyboardFocus))))
		{
		    clientHasFocus = True;
		}
		else
		{
		    clientHasFocus = False;
		}

		if (clientHasFocus ||
		  ((wmGD.nextKeyboardFocus == pCD) ||
		   (pCD->transientChildren && wmGD.keyboardFocus &&
		    (pCD == FindTransientTreeLeader (wmGD.nextKeyboardFocus)))))
	    	{
		    /*
		     * Give up the keyboard focus when minimized (including
		     * the case in which an associated transient window has
		     * the focus).  Immediately remove the focus indication
		     * from the window being minimized.
		     */

		    if (wmGD.autoKeyFocus &&
			(wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT))
		    {
			AutoResetKeyFocus (pcdLeader, setTime);
		    }
		    else
		    {
		        Do_Focus_Key (NULL, setTime, 
				ALWAYS_SET_FOCUS | WORKSPACE_IF_NULL);
		    }

		    if (clientHasFocus)
		    {
			SetKeyboardFocus (NULL, 0);
		    }
		}

		/* unmap main client and all transients */
		UnmapClients (pCD, event_mask);
	    }

	    /*
	     * Display the icon for the minimized client.
	     */

	    if (ICON_FRAME_WIN(pCD)) 
	    {
#ifdef WSM
		if (pCD->clientState & UNSEEN_STATE)
		{
		    if (pCD->iconWindow)
		    {
			XMapWindow (DISPLAY, pCD->iconWindow);
		    }
		    XMapWindow (DISPLAY, ICON_FRAME_WIN(pCD));
		}

		ShowAllIconsForMinimizedClient (pCD);
#else /* WSM */
		ShowIconForMinimizedClient (pSD->pActiveWS, pCD);
#endif /* WSM */
	    }

	    SetClientWMState (pCD, IconicState, MINIMIZED_STATE);

	    if ((pSD->useIconBox) && P_ICON_BOX(pCD))
	    {
		if ((pCD->clientFlags & ICON_BOX) && ACTIVE_ICON_TEXT_WIN)
		{
		    /*
		     * Hide active icon text window and reparent it to
		     * root
		     */
		    HideActiveIconText((WmScreenData *)NULL);
		    pSD->activeLabelParent = ACTIVE_ROOT;
		    XReparentWindow(DISPLAY, ACTIVE_ICON_TEXT_WIN , 
				ACTIVE_ROOT, 0, 0 );
		}
		if (ICON_FRAME_WIN(pCD))
		{
		    /* 
		     * force icon appearance in icon box to change 
		     */
		    IconExposureProc (pCD, True);
		}
	    }
	    break;
	}

#ifdef WSM 

        case UNSEEN_STATE | NORMAL_STATE:
        case UNSEEN_STATE | MAXIMIZED_STATE:
        case UNSEEN_STATE | MINIMIZED_STATE:
	{
	    if (wmGD.keyboardFocus == pCD)
	    {
		/*
		 * Give up the keyboard focus 
		 */
		Do_Focus_Key ((ClientData *)NULL, 
			CurrentTime, ALWAYS_SET_FOCUS);
		SetKeyboardFocus (NULL, 0);
	    }

	    if (!(pCD->clientState & UNSEEN_STATE) &&
		 (((pCD->clientState & ~UNSEEN_STATE) == NORMAL_STATE) ||
		  ((pCD->clientState & ~UNSEEN_STATE) == MAXIMIZED_STATE)))
	    {
		/* unmap main client and all transients */
		UnmapClients (pcdLeader, event_mask);

	    }
      
	    if (pCD->clientFrameWin) 
	    {
		if (!P_ICON_BOX(pCD))
		{
		    if (ICON_FRAME_WIN(pCD))
		    {
			XUnmapWindow (DISPLAY, ICON_FRAME_WIN(pCD));
		    }
		    if (pCD->iconWindow)
			XUnmapWindow (DISPLAY, pCD->iconWindow);
		} 
	    }

	    switch (newState & ~UNSEEN_STATE)
	    {
	    case MINIMIZED_STATE:
		SetClientWMState (pCD, IconicState, newState);
		break;

	    case NORMAL_STATE:
	    case MAXIMIZED_STATE:
	    default:
		SetClientWMState (pCD, NormalState, newState);
		break;
	    }
        }
	break;
#endif /* WSM */
    }

} /* END OF FUNCTION SetClientStateWithEventMask */
Esempio n. 19
0
void ConfigureCheat (void)
{
	if (!cartOpen)
		return;

	OSStatus	err;
	IBNibRef	nibRef;

	err = CreateNibReference(kMacS9XCFString, &nibRef);
	if (err == noErr)
	{
		err = CreateWindowFromNib(nibRef, CFSTR("CheatEntry"), &wRef);
		if (err == noErr)
		{
			DataBrowserCallbacks	callbacks;
			EventHandlerRef			eref;
			EventHandlerUPP			eUPP;
			EventTypeSpec			events[] = { { kEventClassCommand, kEventCommandProcess      },
												 { kEventClassCommand, kEventCommandUpdateStatus },
												 { kEventClassWindow,  kEventWindowClose         } };
			HIViewRef				ctl, root;
			HIViewID				cid;

			root = HIViewGetRoot(wRef);
			cid.id = 0;
			cid.signature = kDataBrowser;
			HIViewFindByID(root, cid, &dbRef);

		#ifdef MAC_PANTHER_SUPPORT
			if (systemVersion < 0x1040)
			{
				HISize	minSize;
				Rect	rct;

				GetWindowBounds(wRef, kWindowContentRgn, &rct);
				minSize.width  = (float) (rct.right  - rct.left);
				minSize.height = (float) (rct.bottom - rct.top );
				err = SetWindowResizeLimits(wRef, &minSize, NULL);
			}
		#endif

			callbacks.version = kDataBrowserLatestCallbacks;
			err = InitDataBrowserCallbacks(&callbacks);
			callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DBClientDataCallback);
			callbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(DBCompareCallBack);
			callbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DBItemNotificationCallBack);
			err = SetDataBrowserCallbacks(dbRef, &callbacks);

			if (systemVersion >= 0x1040)
				err = DataBrowserChangeAttributes(dbRef, kDataBrowserAttributeListViewAlternatingRowColors, kDataBrowserAttributeNone);

			InitCheatItems();
			ImportCheatItems();

			DataBrowserItemID	*id;

			id = new DataBrowserItemID[MAC_MAX_CHEATS];
			if (!id)
				QuitWithFatalError(0, "cheat 01");

			numofcheats = 0;

			for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
			{
				if (citem[i].valid)
				{
					id[numofcheats] = citem[i].id;
					numofcheats++;
				}
			}

			if (numofcheats)
				err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, numofcheats, id, kDataBrowserItemNoProperty);

			delete [] id;

			cid.signature = kNewButton;
			HIViewFindByID(root, cid, &ctl);
			if (numofcheats == MAC_MAX_CHEATS)
				err = DeactivateControl(ctl);
			else
				err = ActivateControl(ctl);

			cid.signature = kAllButton;
			HIViewFindByID(root, cid, &ctl);
			if (numofcheats == 0)
				err = DeactivateControl(ctl);
			else
				err = ActivateControl(ctl);

			cid.signature = kDelButton;
			HIViewFindByID(root, cid, &ctl);
			err = DeactivateControl(ctl);

			eUPP = NewEventHandlerUPP(CheatEventHandler);
			err = InstallWindowEventHandler(wRef, eUPP, GetEventTypeCount(events), events, (void *) wRef, &eref);

			err = SetKeyboardFocus(wRef, dbRef, kControlFocusNextPart);

			MoveWindowPosition(wRef, kWindowCheatEntry, true);
			ShowWindow(wRef);
			err = RunAppModalLoopForWindow(wRef);
			HideWindow(wRef);
			SaveWindowPosition(wRef, kWindowCheatEntry);

			err = RemoveEventHandler(eref);
			DisposeEventHandlerUPP(eUPP);

			DisposeDataBrowserItemNotificationUPP(callbacks.u.v1.itemNotificationCallback);
			DisposeDataBrowserItemCompareUPP(callbacks.u.v1.itemCompareCallback);
			DisposeDataBrowserItemDataUPP(callbacks.u.v1.itemDataCallback);

			CFRelease(wRef);

			DetachCheatItems();
		}

		DisposeNibReference(nibRef);
	}
}
Esempio n. 20
0
void ctp2_HyperTextBox::MouseLGrabInside( aui_MouseEvent *mouseData )
{
	if (IsDisabled()) return;

	if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this )
	{
		SetWhichSeesMouse( this );

		PlaySound( AUI_SOUNDBASE_SOUND_ENGAGE );

		
		HideTipWindow();

		
		SetMouseOwnership();
		SetKeyboardFocus();

		m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE;

		
		m_attributes |= k_CONTROL_ATTRIBUTE_DOWN;
		m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE;
		m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE;

		POINT pos;
		pos.x = mouseData->position.x - m_x;
		pos.y = mouseData->position.y - m_y;

		
		pos.y += m_ranger->GetValueY();

		
		m_selectedHyperLink = NULL;

		ListPos lp = m_hyperLinkList->GetHeadPosition();
		for ( uint32 i = 0;i < m_hyperLinkList->L();i++ ) {
			ctp2_HyperLink *hl = m_hyperLinkList->GetNext( lp );
			RECT rect;
			rect.left = hl->m_static->X();
			rect.top = hl->m_static->Y();
			rect.right = rect.left + hl->m_static->Width();
			rect.bottom = rect.top + hl->m_static->Height();

			if ( PtInRect(&rect, pos) ) {
				hl->m_frame = TRUE;
				hl->m_static->SetTextColor( hl->m_selectColor );
				m_selectedHyperLink = hl;
			}
			else {
				hl->m_frame = FALSE;
				hl->m_static->SetTextColor( hl->m_oldColor );
			}
		}
		







	}
	else
		MouseLGrabOutside( mouseData );
}
Esempio n. 21
0
// --------------------------------------------------------------------------------------
void  OpenPrefsDialog(void)
{
	ListDefSpec listSpec;
	DialogRef dialog;
	WindowRef dialogWindow;
	EventTypeSpec dialogEvents[] = {
									{kEventClassControl, kEventControlHit}
	                               };
	ControlID controlID = {kAppSignature, 0};
	ControlRef control;
	EventTypeSpec listBoxControlEvents[] = {
											{kEventClassTextInput, 
												kEventTextInputUnicodeForKeyEvent}
	                                       };
	ListHandle iconList;
	Cell theCell;
	
	listSpec.defType = kListDefUserProcType;
	listSpec.u.userProc = NewListDefUPP(IconListDef);	// this is automatically disposed 
														// when the program exits
	RegisterListDefinition(kIconListLDEF, &listSpec);
	
	dialog = GetNewDialog(rPrefsDialog, NULL, kFirstWindowOfClass);
	if (dialog == NULL)
		ExitToShell();
	SetPortDialogPort(dialog);
	dialogWindow = GetDialogWindow(dialog);
																// install window handlers
	ChangeWindowAttributes(dialogWindow, kWindowStandardHandlerAttribute, kWindowNoAttributes);
	gDialogEventHandler = NewEventHandlerUPP(dialogEventHandler);
	InstallWindowEventHandler(dialogWindow, gDialogEventHandler, 
								GetEventTypeCount(dialogEvents), dialogEvents, (void *)dialog, 
								NULL);
	
	GetDialogItemAsControl(dialog, kStdOkItemIndex, &control);		// set control IDs to 
	controlID.id = kStdOkItemIndex;									// match dialog item 
	SetControlID(control, &controlID);								// indices which are 
	SetWindowDefaultButton(dialogWindow, control);					// not tracked by any 
																	// standard handlers
	GetDialogItemAsControl(dialog, kStdCancelItemIndex, &control);	// also set the default 
	controlID.id = kStdCancelItemIndex;				// and cancel buttons (because Mac OS 8/9 
	SetControlID(control, &controlID);				// under CarbonLib doesn't respect the 
	SetWindowCancelButton(dialogWindow, control);	// dialog's default and cancel buttons)
	
	GetDialogItemAsControl(dialog, iIconList, &control);
	controlID.id = iIconList;
	SetControlID(control, &controlID);
		/* We need to postprocess keyboard events on the icon list so that we can change 
		   panels after the user changes the selected cell by using the keyboard. */
	gListBoxControlEventHandler = NewEventHandlerUPP(listBoxControlEventHandler);
	InstallControlEventHandler(control, gListBoxControlEventHandler, 
								GetEventTypeCount(listBoxControlEvents), listBoxControlEvents, 
								(void *)dialog, NULL);
	
	GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, 
					sizeof(ListHandle), &iconList, NULL);
 	
	AddRowsAndDataToIconList(iconList, rIconListIconBaseID);
	SetListSelectionFlags(iconList, lOnlyOne);
	
	SetPt(&theCell, 0, 0);
	LSetSelect(true, theCell, iconList);
	SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart);
	gPanelNumber = 0;
	
	SetPrefsDialogHelpTags(dialog);
	
	DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog);
	ShowWindow(dialogWindow);
} // OpenPrefsDialog
Esempio n. 22
0
void CNameBrushDlg::InitGadgetText(String_32* pString, BOOL resizeDialog /*= TRUE*/)
{
	if (pString != NULL)
		m_strSuggest = *pString;
	SetStringGadgetValue(_R(IDC_EDITBRUSHNAME), *GetSuggestion(&m_strSuggest));
	HighlightText(_R(IDC_EDITBRUSHNAME));
	SetKeyboardFocus(_R(IDC_EDITBRUSHNAME));

	// change the dialog title to "Enter brush name:"
	String_256 Name = TEXT("Enter brush name:");
	SetTitlebarName(&Name);

	if (resizeDialog)
	{
		// what we want to do is shrink the dialog by the size of the label and then hide it
		RECT LabelRect;
		GetGadgetPosition(_R(IDC_STATICBRUSHGROUP), &LabelRect);
		
		// hide the label
		HideGadget(_R(IDC_STATICBRUSHGROUP), TRUE);

		// get the size of this dialog
		RECT DialogRect;
		GetWindowPosition(&DialogRect);
		
		// subtract the size of the label
		INT32 Subtract = LabelRect.bottom - LabelRect.top;
		DialogRect.bottom -= Subtract;

		// We want to move up the buttons
		RECT OkRect;
		if (GetGadgetPosition(_R(IDOK), &OkRect))
		{
			OkRect.top -= Subtract;
			OkRect.bottom -= Subtract;
			INT32 Width = OkRect.right - OkRect.left;
			Width = (Width * 2) / 3;
			OkRect.left += Width ;
			OkRect.right += Width;
			SetGadgetPosition(_R(IDOK), OkRect);
		}

		RECT CancelRect;
		if (GetGadgetPosition(_R(IDCANCEL), &CancelRect))
		{
			CancelRect.top -= Subtract;
			CancelRect.bottom -= Subtract;
			INT32 Width = CancelRect.right - CancelRect.left;
			Width = (Width * 2) / 3;
			CancelRect.left += Width;
			CancelRect.right += Width;
			SetGadgetPosition(_R(IDCANCEL), CancelRect);
		}

		// Reset the window
		SetWindowPosition(DialogRect);
		
		// Hide the help button
		HideGadget(_R(ID_CC_HELP_BUTTON), TRUE);
	}
}
Esempio n. 23
0
void URLImportDlg::OnCreate()
{	
	//Put the keyboard focus in the edit field
	SetKeyboardFocus(_R(IDC_URLIMPORT_URL));
}
Esempio n. 24
0
MsgResult ToolnameDlg::Message(Msg* Message)
{
	if (IS_OUR_DIALOG_MSG(Message))
	{

		DialogMsg* Msg = (DialogMsg*)Message; 
		BOOL EndDialog = FALSE; 
		switch (Msg->DlgMsg)
		{
			case DIM_CREATE:
			    SetKeyboardFocus (_R(IDC_EDITNEWBARNAME)) ;
				HighlightText    (_R(IDC_EDITNEWBARNAME)) ;
				break ;

			case DIM_COMMIT:
 			{
 				// Accept all changes that the user wants to make to toolbars...
 				BOOL VV;
 				String_32 NewBarName = GetStringGadgetValue(_R(IDC_EDITNEWBARNAME),&VV);
				if(NewBarName.Length()==0)
				{
				  	UINT32 Number = DialogBarOp::FindUniqueBarNumber();	
					NewBarName._MakeMsg(TEXT("Bar #1%ld"),Number); 
				}
				DialogBarOp* pNewBar = new DialogBarOp(NewBarName);
 				if (pNewBar)
 				{
 					pNewBar->SetDockBarType(DOCKBAR_FLOAT);
 					pNewBar->Create();
					// The Create function sends a message which we intercept to update
					// the list of bars in the Toolbars... dialog.
					// this is very dangerous in fact it blows up..
					// so I have removed it .. chris.
					/*	if (pNewBar)
					{
						// Find toolbar dialog and close it...
 						ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
						if (pToolbarDlg)
						{
							pToolbarDlg->Close();
							pToolbarDlg->End();
						}
					}
					*/
					ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
					pToolbarDlg->ShowToolbarList();
 				}
 				EndDialog = TRUE;
			
 			}
 			break;

 			case DIM_CANCEL:
 				// Cancel all changes the user wants to make to toolbars...
 				EndDialog = TRUE;
	 			break;

//			default:
		}

		if (EndDialog)	// Dialog communication over 
		{
			Close();	// Close the dialog 
			End();		// Destroy dialog 
	   	}

//		return (DLG_EAT_IF_HUNGRY(Msg)); 
	}

//	return OK; 

	// Pass everything on to the base-class . . .
	return DialogOp::Message(Message);
}