pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) { OSStatus status = noErr ; switch( iMessage ) { case kControlMsgSetUpBackground : { wxControl* wx = (wxControl*) GetControlReference( iControl ) ; if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) { wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; #if TARGET_CARBON // under classic this would lead to partial redraws RgnHandle clip = NewRgn() ; int x = 0 , y = 0; wx->MacWindowToRootWindow( &x,&y ) ; CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; OffsetRgn( clip , x , y ) ; SetClip( clip ) ; DisposeRgn( clip ) ; #endif } else { status = paramErr ; } } break ; default : status = paramErr ; break ; } return status ; }
// --------------------------------------------------------------------------- // // ----------- pascal OSStatus bToolGeomWithJoin::dtb_proc( ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue){ bToolGeomWithJoin* t=(bToolGeomWithJoin*)GetControlReference(browser); CFStringRef cfs; bGenericMacMapApp* gapp=(bGenericMacMapApp*)t->getapp(); bGenericType* tp=NULL; char name[256]; Boolean b; switch(property){ case kToolGeomWithJoinTypesCheckProperty: if(!changeValue){ if(!t->_tp_use.get(itemID,&tp)){ } SetDataBrowserItemDataBooleanValue(itemData,(tp!=NULL)); } else{ GetDataBrowserItemDataBooleanValue(itemData,&b); if(b){ tp=gapp->typesMgr()->get(itemID); } else{ tp=NULL; } t->_tp_use.put(itemID,&tp); } break; case kToolGeomWithJoinTypesNameProperty: if(!changeValue){ tp=gapp->typesMgr()->get(itemID); tp->name(name); cfs=CFStringCreateWithCString(kCFAllocatorDefault,name,CFStringGetSystemEncoding()); SetDataBrowserItemDataText(itemData,cfs); CFRelease(cfs); } break; case kDataBrowserItemIsEditableProperty: if(SetDataBrowserItemDataBooleanValue(itemData,true)){ } break; case kDataBrowserItemIsSelectableProperty: if(SetDataBrowserItemDataBooleanValue(itemData,true)){ } break; default: break; } return(noErr); }
/** * @brief Generates the message for controller references. * * @param Cbuff[out] Pointer to the circular buffer to put the data in. * @return HAL_FAILED if the message didn't fit or HAL_SUCCESS * if it did fit. */ static bool GenerateGetControllerReferences(circular_buffer_t *Cbuff) { static control_reference_save_t temp; GetControlReference(&temp); return GenerateGenericCommand(Cmd_GetControllerReferences, (uint8_t *)&temp, sizeof(control_reference_save_t), Cbuff); }
pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) { if ( partCode != 0) { wxControl* wx = (wxControl*) GetControlReference( control ) ; if ( wx ) { wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ; } } }
void UserPaneBackgroundProc( ControlHandle control, ControlBackgroundPtr info) { MacButton * mbPtr = (MacButton *)(intptr_t)GetControlReference(control); if (info->colorDevice) { CGrafPtr port; GetPort(&port); TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); } }
void UserPaneDraw( ControlRef control, ControlPartCode cpc) { MacButton *mbPtr = (MacButton *)(intptr_t)GetControlReference(control); Rect contrlRect; CGrafPtr port; GetPort(&port); GetControlBounds(control,&contrlRect); TkMacOSXSetColorInPort(mbPtr->userPaneBackground, 0, NULL, port); EraseRect(&contrlRect); }
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID, DataBrowserItemNotification message) #endif { long ref = GetControlReference( browser ) ; if ( ref ) { wxCheckListBox* list = wxDynamicCast( (wxObject*) ref , wxCheckListBox ) ; int i = itemID - 1 ; if (i >= 0 && i < list->GetCount() ) { bool trigger = false ; wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() ); switch( message ) { case kDataBrowserItemDeselected : if ( list->HasMultipleSelection() ) trigger = true ; break ; case kDataBrowserItemSelected : trigger = true ; break ; case kDataBrowserItemDoubleClicked : event.SetEventType(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED) ; trigger = true ; break ; default : break ; } if ( trigger ) { event.SetEventObject( list ); if ( list->HasClientObjectData() ) event.SetClientObject( list->GetClientObject(i) ); else if ( list->HasClientUntypedData() ) event.SetClientData( list->GetClientData(i) ); event.SetString( list->GetString(i) ); event.SetInt(i) ; event.SetExtraLong( list->HasMultipleSelection() ? message == kDataBrowserItemSelected : TRUE ); wxPostEvent( list->GetEventHandler() , event ) ; // direct notification is not always having the listbox GetSelection() having in synch with event // list->GetEventHandler()->ProcessEvent(event) ; } } } }
static pascal void ScaleActionProc( ControlRef theControl, /* Handle to scrollbat control */ ControlPartCode partCode) /* Part of scrollbar that was "hit" */ { int value; TkScale *scalePtr = (TkScale *) GetControlReference(theControl); #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("ScaleActionProc"); #endif value = GetControlValue(theControl); TkScaleSetValue(scalePtr, value, 1, 1); Tcl_Preserve((ClientData) scalePtr); TkMacOSXRunTclEventLoop(); Tcl_Release((ClientData) scalePtr); }
pascal ControlKeyFilterResult AUCarbonViewControl::StdKeyFilterCallback(ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers) { #if !__LP64__ SInt16 c = *charCode; if (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; }
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]); }
static pascal OSStatus ListBoxGetSetItemData(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue) { OSStatus err = errDataBrowserPropertyNotSupported; if ( ! changeValue ) { switch (property) { case kTextColumnId: { long ref = GetControlReference( browser ) ; if ( ref ) { wxListBox* list = wxDynamicCast( (wxObject*) ref , wxListBox ) ; int i = itemID - 1 ; if (i >= 0 && i < list->GetCount() ) { wxMacCFStringHolder cf( list->GetString(i) , list->GetFont().GetEncoding() ) ; verify_noerr( ::SetDataBrowserItemDataText( itemData , cf ) ) ; err = noErr ; } } } break; default: break; } } return err; }
static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect, Cell cell, short dataOffset, short dataLength, ListHandle listHandle ) { wxCheckListBox* list; list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); if ( list == NULL ) return ; GrafPtr savePort; GrafPtr grafPtr; RgnHandle savedClipRegion; SInt32 savedPenMode; GetPort(&savePort); SetPort((**listHandle).port); grafPtr = (**listHandle).port ; // typecast our refCon // Calculate the cell rect. switch( message ) { case lInitMsg: break; case lCloseMsg: break; case lDrawMsg: { const wxString text = list->m_stringArray[cell.v] ; int checked = list->m_checks[cell.v] ; // Save the current clip region, and set the clip region to the area we are about // to draw. savedClipRegion = NewRgn(); GetClip( savedClipRegion ); ClipRect( drawRect ); EraseRect( drawRect ); const wxFont& font = list->GetFont(); if ( font.Ok() ) { ::TextFont( font.GetMacFontNum() ) ; ::TextSize( font.GetMacFontSize()) ; ::TextFace( font.GetMacFontStyle() ) ; } ThemeButtonDrawInfo info ; info.state = kThemeStateActive ; info.value = checked ? kThemeButtonOn : kThemeButtonOff ; info.adornment = kThemeAdornmentNone ; Rect checkRect = *drawRect ; checkRect.left +=0 ; checkRect.top +=0 ; checkRect.right = checkRect.left + list->m_checkBoxWidth ; checkRect.bottom = checkRect.top + list->m_checkBoxHeight ; DrawThemeButton(&checkRect,kThemeCheckBox, &info,NULL,NULL, NULL,0); MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); DrawText(text, 0 , text.Length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. if( isSelected ) { savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode ); } // Restore the saved clip region. SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); } break; case lHiliteMsg: // Hilite or unhilite the cell. Paint the cell contents with the // appropriate QuickDraw transform mode. GetPort( &grafPtr ); savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode ); break; default : break ; } SetPort(savePort); }
static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect, Cell cell, short dataOffset, short dataLength, ListHandle listHandle ) { wxListBox* list; list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); if ( list == NULL ) return ; GrafPtr savePort; GrafPtr grafPtr; RgnHandle savedClipRegion; SInt32 savedPenMode; GetPort(&savePort); SetPort((**listHandle).port); grafPtr = (**listHandle).port ; // typecast our refCon // Calculate the cell rect. switch( message ) { case lInitMsg: break; case lCloseMsg: break; case lDrawMsg: { const wxString linetext = list->m_stringArray[cell.v] ; // Save the current clip region, and set the clip region to the area we are about // to draw. savedClipRegion = NewRgn(); GetClip( savedClipRegion ); ClipRect( drawRect ); EraseRect( drawRect ); const wxFont& font = list->GetFont(); if ( font.Ok() ) { ::TextFont( font.GetMacFontNum() ) ; ::TextSize( font.GetMacFontSize() ) ; ::TextFace( font.GetMacFontStyle() ) ; } else { ::TextFont( kFontIDMonaco ) ; ::TextSize( 9 ); ::TextFace( 0 ) ; } #if TARGET_CARBON { Rect frame = { drawRect->top, drawRect->left + 4, drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext , list->GetFont().GetEncoding()) ) ; ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, false, &frame, teJustLeft, nil ); CFRelease( mString ) ; } #else { wxCharBuffer text = linetext.mb_str( wxConvLocal) ; MoveTo(drawRect->left + 4 , drawRect->top + 10 ); DrawText(text, 0 , strlen(text) ); } #endif // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. if( isSelected ) { savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); } // Restore the saved clip region. SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); } break; case lHiliteMsg: // Hilite or unhilite the cell. Paint the cell contents with the // appropriate QuickDraw transform mode. GetPort( &grafPtr ); savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr ); SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); break; default : break ; } SetPort(savePort); }
static pascal OSStatus ListBoxGetSetItemData(ControlRef browser, DataBrowserItemID itemID, DataBrowserPropertyID property, DataBrowserItemDataRef itemData, Boolean changeValue) { OSStatus err = errDataBrowserPropertyNotSupported; if ( ! changeValue ) { switch (property) { case kTextColumnId: { long ref = GetControlReference( browser ) ; if ( ref ) { wxCheckListBox* list = wxDynamicCast( (wxObject*) ref , wxCheckListBox ) ; int i = itemID - 1 ; if (i >= 0 && i < list->GetCount() ) { wxMacCFStringHolder cf( list->GetString(i) , list->GetFont().GetEncoding() ) ; verify_noerr( ::SetDataBrowserItemDataText( itemData , cf ) ) ; err = noErr ; } } } break; case kCheckboxColumnId : { long ref = GetControlReference( browser ) ; if ( ref ) { wxCheckListBox* list = wxDynamicCast( (wxObject*) ref , wxCheckListBox ) ; int i = itemID - 1 ; if (i >= 0 && i < list->GetCount() ) { verify_noerr( ::SetDataBrowserItemDataButtonValue( itemData , list->IsChecked( i ) ? kThemeButtonOn : kThemeButtonOff ) ) ; err = noErr ; } } } break ; case kDataBrowserItemIsEditableProperty: { err = ::SetDataBrowserItemDataBooleanValue(itemData, true); } break; default: break; } } else { switch( property ) { case kCheckboxColumnId : { long ref = GetControlReference( browser ) ; if ( ref ) { wxCheckListBox* list = wxDynamicCast( (wxObject*) ref , wxCheckListBox ) ; int i = itemID - 1 ; if (i >= 0 && i < list->GetCount() ) { // we have to change this behind the back, since Check() would be triggering another update round bool newVal = !list->IsChecked( i ) ; verify_noerr( ::SetDataBrowserItemDataButtonValue( itemData , newVal ? kThemeButtonOn : kThemeButtonOff ) ) ; err = noErr ; list->m_checks[ i ] = newVal ; wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, list->GetId()); event.SetInt(i); event.SetEventObject(list); list->GetEventHandler()->ProcessEvent(event); } } } break ; default : break ; } } return err; }