static pascal OSStatus InputRateTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl, slider; HIViewID cid; SInt32 value; char num[10]; err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl); if (err == noErr) { cid.signature = 'snd_'; cid.id = iNibSInputRate; HIViewFindByID(HIViewGetSuperview(ctl), cid, &slider); value = GetControl32BitValue(slider); value /= 50; value *= 50; if (value > 33000) value = 33000; if (value < 31000) value = 31000; SetControl32BitValue(slider, value); sprintf(num, "%ld", value); SetEditTextCStr(ctl, num, true); result = noErr; } return (result); }
static pascal OSStatus AspectRatioTextEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; HIViewRef ctl, slider; HIViewID cid; float w, h, v; int iw, ih; err = GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &ctl); if (err == noErr) { cid.signature = 'grap'; cid.id = iNibGAspectRatio; HIViewFindByID(HIViewGetSuperview(ctl), cid, &slider); GetGameDisplay(&iw, &ih); w = (float) iw; h = (float) ih; v = (float) SNES_WIDTH / (float) SNES_HEIGHT * h; macAspectRatio = (int) (((4.0f / 3.0f) * h - v) / (w - v) * 10000.0f); SetControl32BitValue(slider, macAspectRatio); result = noErr; } return (result); }
OSStatus TextViewDefaultSettings( HIViewRef textView ) { OSStatus status = paramErr; static const CFStringRef taskCFStr = CFSTR("TaskDefault"); WindowRef window; status = AddTextToTheTextView( textView ); check_noerr( status ); status = TextViewEditCommandSupport( textView, true ); check_noerr( status ); status = TextViewFontPanelSupport( textView, false ); check_noerr( status ); status = TextViewSpellingSupport( textView, false ); check_noerr( status ); status = TextViewScrollingOptions( textView, (UInt32)kTXNAutoScrollInsertionIntoView ); check_noerr( status ); status = TXNSetSelection(HITextViewGetTXNObject(textView), kTXNStartOffset, kTXNStartOffset); check_noerr( status ); status = HIScrollViewNavigate(HIViewGetSuperview(textView),kHIScrollViewScrollToTop) ; check_noerr( status ); status = SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr ); return status; }
static void SelectTabPane (HIViewRef tabControl, SInt16 index) { HIViewRef sup, userPane, selectedPane = NULL; HIViewID cid; lastTabIndex = index; sup = HIViewGetSuperview(tabControl); cid.signature = 'tabs'; for (int i = 1; i < tabList[0] + 1; i++) { cid.id = tabList[i]; HIViewFindByID(sup, cid, &userPane); if (i == index) selectedPane = userPane; else HIViewSetVisible(userPane, false); } if (selectedPane != NULL) HIViewSetVisible(selectedPane, true); HIViewSetNeedsDisplay(tabControl, true); }
void CAccountManagerInfoPage::CreateControls() { ////@begin CAccountManagerInfoPage content construction CAccountManagerInfoPage* itemWizardPage23 = this; wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); itemWizardPage23->SetSizer(itemBoxSizer24); m_pTitleStaticCtrl = new wxStaticText; m_pTitleStaticCtrl->Create( itemWizardPage23, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana"))); itemBoxSizer24->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5); m_pDescriptionStaticCtrl = new wxStaticText; m_pDescriptionStaticCtrl->Create( itemWizardPage23, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer24->Add(m_pDescriptionStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5); wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(2, 1, 0, 0); itemFlexGridSizer3->AddGrowableRow(0); itemFlexGridSizer3->AddGrowableCol(0); itemBoxSizer24->Add(itemFlexGridSizer3, 1, wxGROW|wxALL, 5); m_pProjectListCtrl = new CProjectListCtrl; m_pProjectListCtrl->Create( itemWizardPage23 ); itemFlexGridSizer3->Add(m_pProjectListCtrl, 0, wxGROW|wxRIGHT, 10); wxFlexGridSizer* itemFlexGridSizer11 = new wxFlexGridSizer(2, 1, 0, 0); itemFlexGridSizer11->AddGrowableRow(0); itemFlexGridSizer11->AddGrowableCol(0); itemBoxSizer24->Add(itemFlexGridSizer11, 0, wxGROW|wxALL, 0); wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL); itemFlexGridSizer11->Add(itemBoxSizer22, 0, wxGROW|wxALL, 0); wxFlexGridSizer* itemFlexGridSizer14 = new wxFlexGridSizer(1, 2, 0, 0); itemFlexGridSizer14->AddGrowableCol(1); itemBoxSizer24->Add(itemFlexGridSizer14, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxRIGHT, 10); m_pProjectUrlStaticCtrl = new wxStaticText; m_pProjectUrlStaticCtrl->Create( itemWizardPage23, ID_PROJECTURLSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer14->Add(m_pProjectUrlStaticCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pProjectUrlCtrl = new wxTextCtrl; m_pProjectUrlCtrl->Create( itemWizardPage23, ID_PROJECTURLCTRL, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0 ); itemFlexGridSizer14->Add(m_pProjectUrlCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); // Set validators m_pProjectUrlCtrl->SetValidator( CValidateURL( & m_strProjectURL ) ); #ifdef __WXMAC__ //Accessibility HIViewRef listView = (HIViewRef)m_pProjectListCtrl->GetHandle(); HIObjectRef theObject = (HIObjectRef)HIViewGetSuperview(listView); HIObjectSetAccessibilityIgnored(theObject, true); #endif ////@end CAccountManagerInfoPage content construction }
static void HIOpenGLViewSetContextWindowAndBounds (HIOpenGLViewData* inData) { if (inData == nil) return; if (inData->mControl == nil) return; if (inData->mContext == nil) return; // Determine the AGL_BUFFER_RECT for the control. The coordinate // system for this rectangle is relative to the owning window, with // the origin at the bottom left corner and the y-axis inverted. HIRect ctrlBounds, winBounds; HIViewGetBounds(inData->mControl, &ctrlBounds); WindowRef window = GetControlOwner(inData->mControl); ControlRef root = nil; GetRootControl(window, &root); HIViewGetBounds(root, &winBounds); HIViewConvertRect(&ctrlBounds, inData->mControl, root); GLint bufferRect[4] = { (int)ctrlBounds.origin.x, (int)((winBounds.size.height) - (ctrlBounds.origin.y + ctrlBounds.size.height)), (int)ctrlBounds.size.width, (int)ctrlBounds.size.height }; // Associate the OpenGL context with the control's window, and establish the buffer rect. aglSetDrawable(inData->mContext, GetWindowPort(window)); aglSetInteger(inData->mContext, AGL_BUFFER_RECT, bufferRect); aglEnable(inData->mContext, AGL_BUFFER_RECT); // Establish the clipping region for the OpenGL context. To properly handle clipping // within the view hierarchy, I'm walking the hierarchy to determine the intersection // of this view's bounds with its parents. Is there an easier way to do this? CGRect clipBounds = ctrlBounds; HIViewRef parent = HIViewGetSuperview(inData->mControl); while (parent != root) { CGRect parentBounds; HIViewGetBounds(parent, &parentBounds); HIViewConvertRect(&parentBounds, parent, root); clipBounds = CGRectIntersection(clipBounds, parentBounds); parent = HIViewGetSuperview(parent); } Rect rgnBounds = { (int)clipBounds.origin.y, (int)clipBounds.origin.x, (int)(clipBounds.origin.y + clipBounds.size.height), (int)(clipBounds.origin.x + clipBounds.size.width) }; RgnHandle rgn = NewRgn(); RectRgn(rgn, &rgnBounds); aglSetInteger(inData->mContext, AGL_CLIP_REGION, (const GLint*)rgn); aglEnable(inData->mContext, AGL_CLIP_REGION); }
IPopupMenu* IGraphicsCarbon::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect) { // Get the plugin gui frame rect within the host's window HIRect rct; HIViewGetFrame(this->mView, &rct); // Get the host's window rect within the screen Rect wrct; GetWindowBounds(this->mWindow, kWindowContentRgn, &wrct); #ifdef RTAS_API int xpos = wrct.left + this->GetLeftOffset() + pAreaRect->L; int ypos = wrct.top + this->GetTopOffset() + pAreaRect->B + 5; #else HIViewRef contentView; HIViewFindByID(HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView); HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView); int xpos = wrct.left + rct.origin.x + pAreaRect->L; int ypos = wrct.top + rct.origin.y + pAreaRect->B + 5; #endif MenuRef menuRef = CreateMenu(pMenu); if (menuRef) { int32_t popUpItem = 1; int32_t PopUpMenuItem = PopUpMenuSelect(menuRef, ypos, xpos, popUpItem); short result = LoWord(PopUpMenuItem) - 1; short menuIDResult = HiWord(PopUpMenuItem); IPopupMenu* resultMenu = 0; if (menuIDResult != 0) { MenuRef usedMenuRef = GetMenuHandle(menuIDResult); if (usedMenuRef) { if (GetMenuItemRefCon(usedMenuRef, 0, (URefCon*)&resultMenu) == noErr) { resultMenu->SetChosenItemIdx(result); } } } CFRelease(menuRef); return resultMenu; } else { return 0; } }
/**************************************************************************** Hacks to glue AGL to an HIView ***************************************************************************/ QRegion qt_mac_get_widget_rgn(const QWidget *widget) { if(!widget->isVisible() || widget->isMinimized()) return QRegion(); const QRect wrect = QRect(qt_mac_posInWindow(widget), widget->size()); if(!wrect.isValid()) return QRegion(); RgnHandle macr = qt_mac_get_rgn(); GetControlRegion((HIViewRef)widget->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, wrect.x(), wrect.y()); QRegion ret = qt_mac_convert_mac_region(macr); QPoint clip_pos = wrect.topLeft(); for(const QWidget *last_clip = 0, *clip = widget; clip; last_clip = clip, clip = clip->parentWidget()) { if(clip != widget) { GetControlRegion((HIViewRef)clip->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, clip_pos.x(), clip_pos.y()); ret &= qt_mac_convert_mac_region(macr); } const QObjectList &children = clip->children(); for(int i = children.size()-1; i >= 0; --i) { if(QWidget *child = qobject_cast<QWidget*>(children.at(i))) { if(child == last_clip) break; // This check may seem weird, but when we are using a unified toolbar // The widget is actually being owned by that toolbar and not by Qt. // This means that the geometry it reports will be wrong // and will accidentally cause problems when calculating the region // So, it is better to skip these widgets since they aren't the hierarchy // anyway. if (HIViewGetSuperview(HIViewRef(child->winId())) != HIViewRef(clip->winId())) continue; if(child->isVisible() && !child->isMinimized() && !child->isTopLevel()) { const QRect childRect = QRect(clip_pos+child->pos(), child->size()); if(childRect.isValid() && wrect.intersects(childRect)) { GetControlRegion((HIViewRef)child->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, childRect.x(), childRect.y()); ret -= qt_mac_convert_mac_region(macr); } } } } if(clip->isWindow()) break; clip_pos -= clip->pos(); } qt_mac_dispose_rgn(macr); return ret; }
static pascal void InputRateSliderActionProc (HIViewRef slider, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid; char num[10]; cid.signature = 'snd_'; cid.id = iNibSInputRateText; HIViewFindByID(HIViewGetSuperview(slider), cid, &ctl); sprintf(num, "%ld", GetControl32BitValue(slider)); SetStaticTextCStr(ctl, num, true); }
static pascal void AutofireSliderActionProc (HIViewRef slider, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid; char num[10]; GetControlID(slider, &cid); cid.signature = 'Num_'; HIViewFindByID(HIViewGetSuperview(slider), cid, &ctl); sprintf(num, "%ld", GetControl32BitValue(slider)); SetStaticTextCStr(ctl, num, true); }
static pascal void LittleArrowsActionProc (HIViewRef arrows, HIViewPartCode partCode) { HIViewRef ctl; HIViewID cid = { 'msc2', iNibMTurboSkipText }; char num[8]; if (partCode == kControlUpButtonPart) SetControl32BitValue(arrows, GetControl32BitValue(arrows) + 1); else if (partCode == kControlDownButtonPart) SetControl32BitValue(arrows, GetControl32BitValue(arrows) - 1); HIViewFindByID(HIViewGetSuperview(arrows), cid, &ctl); sprintf(num, "%ld", GetControl32BitValue(arrows)); SetStaticTextCStr(ctl, num, true); }
void SkOSWindow::updateSize() { Rect r; GetWindowBounds((WindowRef)fHWND, kWindowContentRgn, &r); this->resize(r.right - r.left, r.bottom - r.top); #if 0 HIRect frame; HIViewRef imageView = (HIViewRef)getHVIEW(); HIViewRef parent = HIViewGetSuperview(imageView); HIViewGetBounds(imageView, &frame); SkDebugf("------ %d bounds %g %g %g %g\n", r.right - r.left, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); #endif }
OSStatus TextViewFocusInWindow( WindowRef window ) { OSStatus status = paramErr; HIViewRef textView = NULL; HIViewRef scrollView = NULL; // Get the HITextView from the window status = GetTextViewFromWindow( window, textView ); require_action( textView != NULL, EXIT, status = paramErr ); scrollView = HIViewGetSuperview( textView ); require_action( scrollView != NULL, EXIT, status = paramErr ); HIViewSetFirstSubViewFocus( HIViewGetRoot(window), textView ); status = HIViewSetNextFocus( scrollView, NULL ); status = HIViewAdvanceFocus ( scrollView, 0 /*modifiers*/ ); EXIT: return status; }
// Each time a new window is first opened, call this one time function to set up // the text view OSStatus SetUpTheTextView( WindowRef window ) { OSStatus status = noErr; HIViewRef textView = NULL; HIViewRef scrollView = NULL; HIViewRef scrollParentView = NULL; CMLTEViewData* mlteData = NULL; // Get the HITextView from the window status = GetTextViewFromWindow( window, textView ); require_action( textView != NULL, EXIT, status = paramErr ); // make a new custom C++ object to hold MLTE related data mlteData = new CMLTEViewData(); // DON'T FORGET TO DISPOSE THIS WHEN HITextView destructs!!! // put the custom object in the HITextView for this window // as a control property so that we can retrieve it later when we need it. status = TextViewStoreMLTEInstanceData( textView, mlteData ); require_action( textView != NULL, EXIT, status = paramErr ); // Now set the text view as we like it status = TextViewDefaultSettings( textView ); check_noerr( status ); status = TextViewAddActionNameMapper( textView ); check_noerr( status ); status = TextViewSetMargins( textView, 0 /*top*/, 0 /*left*/, 0 /*right*/ ); check_noerr( status ); // get fancy - try to add a picture behind the textView scrollView = HIViewGetSuperview( textView ); scrollParentView = HIViewGetSuperview( scrollView ); if( scrollParentView != NULL ) { HIViewRef imageViewRef = AddImage( scrollParentView ); if( imageViewRef != NULL ) { HIRect scrollFrame; HIViewGetFrame( scrollView, &scrollFrame ); HIViewSetFrame( imageViewRef, &scrollFrame ); status = HIViewSetZOrder( scrollView, kHIViewZOrderAbove, imageViewRef ); check_noerr( status ); HIViewSetVisible(imageViewRef, true); status = TextViewSetBGAlpha( textView, 0.75 ); check_noerr( status ); } } // register for menu handing status = TextViewInstallMenuHandlers( textView ); EXIT: return status; }
void IGraphicsCarbon::CreateTextEntry(IControl* pControl, IText* pText, IRECT* pTextRect, const char* pString, IParam* pParam) { if (!pControl || mTextEntryView || !mIsComposited) return; // Only composited carbon supports text entry WindowRef window = mWindow; TXNFrameOptions txnFrameOptions = kTXNMonostyledTextMask | kTXNDisableDragAndDropMask | kTXNSingleLineOnlyMask; TXNObject txnObject = 0; TXNFrameID frameID = 0; TXNObjectRefcon txnObjectRefCon = 0; HIRect rct; HIViewGetFrame(this->mView, &rct); HIViewRef contentView; HIViewFindByID (HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView); HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView); Rect rect = { rct.origin.y + pTextRect->T, rct.origin.x + pTextRect->L, rct.origin.y + pTextRect->B + 1, rct.origin.x + pTextRect->R + 1 }; if (TXNNewObject(NULL, window, &rect, txnFrameOptions, kTXNTextEditStyleFrameType, kTXNSingleStylePerTextDocumentResType, kTXNMacOSEncoding, &txnObject, &frameID, txnObjectRefCon) == noErr) { TXNSetFrameBounds(txnObject, rect.top, rect.left, rect.bottom, rect.right, frameID); mTextEntryView = txnObject; // Set the text to display by defualt TXNSetData(mTextEntryView, kTXNTextData, pString, strlen(pString)/*+1*/, kTXNStartOffset, kTXNEndOffset); // center aligned text has problems with uneven string lengths RGBColor tc; tc.red = pText->mTextEntryFGColor.R * 257; tc.green = pText->mTextEntryFGColor.G * 257; tc.blue = pText->mTextEntryFGColor.B * 257; TXNBackground bg; bg.bgType = kTXNBackgroundTypeRGB; bg.bg.color.red = pText->mTextEntryBGColor.R * 257; bg.bg.color.green = pText->mTextEntryBGColor.G * 257; bg.bg.color.blue = pText->mTextEntryBGColor.B * 257; TXNSetBackground(mTextEntryView, &bg); // Set justification SInt16 justification; Fract flushness; switch ( pText->mAlign ) { case IText::kAlignCenter: justification = kTXNCenter; // seems to be buggy wrt dragging and alignement with uneven string lengths flushness = kATSUCenterAlignment; break; case IText::kAlignFar: justification = kTXNFlushRight; flushness = kATSUEndAlignment; break; case IText::kAlignNear: default: justification = kTXNFlushLeft; flushness = kATSUStartAlignment; break; } TXNControlTag controlTag[1]; TXNControlData controlData[1]; controlTag[0] = kTXNJustificationTag; controlData[0].sValue = justification; TXNSetTXNObjectControls(mTextEntryView, false, 1, controlTag, controlData); ATSUFontID fontid = kATSUInvalidFontID; if (pText->mFont && pText->mFont[0]) { ATSUFindFontFromName(pText->mFont, strlen(pText->mFont), kFontFullName /* kFontFamilyName? */ , (FontPlatformCode)kFontNoPlatform, kFontNoScriptCode, kFontNoLanguageCode, &fontid); } // font (NOT working) TXNTypeAttributes attributes[3]; attributes[0].tag = kATSUFontTag; attributes[0].size = sizeof(ATSUFontID); attributes[0].data.dataPtr = &fontid; // size attributes[1].tag = kTXNQDFontSizeAttribute; attributes[1].size = kTXNFontSizeAttributeSize; attributes[1].data.dataValue = pText->mSize << 16; // color attributes[2].tag = kTXNQDFontColorAttribute; attributes[2].size = kTXNQDFontColorAttributeSize; attributes[2].data.dataPtr = &tc; // Finally set the attributes TXNSetTypeAttributes(mTextEntryView, 3, attributes, kTXNStartOffset, kTXNEndOffset); // Ensure focus remains consistent SetUserFocusWindow(window); AdvanceKeyboardFocus(window); // Set the focus to the edit window TXNFocus(txnObject, true); TXNSelectAll(mTextEntryView); TXNShowSelection(mTextEntryView, true); // The event types const static EventTypeSpec eventTypes[] = { { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseDown }, { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseWheelMoved }, { kEventClassWindow, kEventWindowClosed }, { kEventClassWindow, kEventWindowDeactivated }, { kEventClassWindow, kEventWindowFocusRelinquish }, { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyRepeat } }; // Install the event handler InstallWindowEventHandler(window, TextEntryHandler, GetEventTypeCount(eventTypes), eventTypes, this, &mTextEntryHandler); mEdControl = pControl; mEdParam = pParam; mTextEntryRect = *pTextRect; } }
bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event) { #if !__LP64__ UInt32 eclass = GetEventClass(event); UInt32 ekind = GetEventKind(event); ControlRef control; switch (eclass) { case kEventClassControl: { switch (ekind) { case kEventControlClick: GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control); if (control == mCarbonPane) { ClearKeyboardFocus(mCarbonWindow); return true; } } } break; case kEventClassScrollable: { switch (ekind) { case kEventScrollableGetInfo: { // [1/4] /* <-- kEventParamImageSize (out, typeHISize) * On exit, contains the size of the entire scrollable view. */ HISize originalSize = { mBottomRight.h, mBottomRight.v }; verify_noerr(SetEventParameter(event, kEventParamImageSize, typeHISize, sizeof(HISize), &originalSize)); // [2/4] /* <-- kEventParamViewSize (out, typeHISize) * On exit, contains the amount of the scrollable view that is * visible. */ HIViewRef parentView = HIViewGetSuperview(mCarbonPane); HIRect parentBounds; verify_noerr(HIViewGetBounds(parentView, &parentBounds)); //HISize windowSize = { float(windowBounds.right - windowBounds.left), // float(windowBounds.bottom - windowBounds.top) }; verify_noerr(SetEventParameter(event, kEventParamViewSize, typeHISize, sizeof(HISize), &(parentBounds.size))); // [3/4] /* <-- kEventParamLineSize (out, typeHISize) * On exit, contains the amount that should be scrolled in * response to a single click on a scrollbar arrow. */ HISize scrollIncrementSize = { 16.0f, float(20) }; verify_noerr(SetEventParameter(event, kEventParamLineSize, typeHISize, sizeof(HISize), &scrollIncrementSize)); // [4/4] /* <-- kEventParamOrigin (out, typeHIPoint) * On exit, contains the scrollable viewÕs current origin (the * view-relative coordinate that is drawn at the top left * corner of its frame). These coordinates should always be * greater than or equal to zero. They should be less than or * equal to the viewÕs image size minus its view size. */ verify_noerr(SetEventParameter(event, kEventParamOrigin, typeHIPoint, sizeof(HIPoint), &mCurrentScrollPoint)); } return true; case kEventScrollableScrollTo: { /* * kEventClassScrollable / kEventScrollableScrollTo * * Summary: * Requests that an HIScrollViewÕs scrollable view should scroll to * a particular origin. */ /* --> kEventParamOrigin (in, typeHIPoint) * The new origin for the scrollable view. The origin * coordinates will vary from (0,0) to scrollable viewÕs image * size minus its view size. */ HIPoint pointToScrollTo; verify_noerr(GetEventParameter(event, kEventParamOrigin, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pointToScrollTo)); float xDelta = mCurrentScrollPoint.x - pointToScrollTo.x; float yDelta = mCurrentScrollPoint.y - pointToScrollTo.y; // move visible portion the appropriate amount verify_noerr(HIViewScrollRect(mCarbonPane, NULL, xDelta, yDelta)); // set new content to be drawn verify_noerr(HIViewSetBoundsOrigin(mCarbonPane, pointToScrollTo.x, pointToScrollTo.y)); mCurrentScrollPoint = pointToScrollTo; } return true; default: break; } } break; default: break; } #endif return false; }
static pascal OSStatus HandlePaneEvents(EventHandlerCallRef handlerRef, EventRef eventRef, void *data) { wxMacCarbonEvent event(eventRef); CustomData *dt = (CustomData *) data; OSStatus result = eventNotHandledErr; switch (event.GetClass()) { case kEventClassControl: { ControlRef control; ControlID cid; control = event.GetParameter<ControlRef>(kEventParamDirectObject, typeControlRef); if (control == NULL) { break; } GetControlID(control, &cid); if (cid.signature != kCustom) { break; } switch (cid.id) { case kChoice: { MenuRef menu = GetControlPopupMenuRef(control); UInt32 v = GetControl32BitValue(control) - 1; const size_t numFilters = dt->extensions.GetCount(); if (v < (UInt32) dt->extensions.GetCount()) { dt->currentfilter = v; NavCustomControl(dt->context, kNavCtlBrowserRedraw, NULL); } } break; case kButton: { dt->me->ClickButton(GetControl32BitValue(dt->choice) - 1); } break; } } break; case kEventClassAccessibility: { switch (event.GetKind()) { case kEventAccessibleGetNamedAttribute: { CFStringRef attr; require_noerr(event.GetParameter(kEventParamAccessibleAttributeName, typeCFTypeRef, sizeof(attr), &attr), ParameterError); if (false) { } else if (CFStringCompare(attr, kAXRoleAttribute, 0) == kCFCompareEqualTo) { CFStringRef role = kAXGroupRole; result = event.SetParameter(kEventParamAccessibleAttributeValue, typeCFStringRef, sizeof(role), &role); require_noerr(result, ParameterError); } else if (CFStringCompare(attr, kAXRoleDescriptionAttribute, 0) == kCFCompareEqualTo) { CFStringRef role = kAXGroupRole; CFStringRef desc; desc = HICopyAccessibilityRoleDescription(role, NULL); if (desc) { result = event.SetParameter(kEventParamAccessibleAttributeValue, typeCFStringRef, sizeof(desc), &desc); CFRelease(desc); require_noerr(result, ParameterError); } } else if (CFStringCompare(attr, kAXParentAttribute, 0) == kCFCompareEqualTo) { HIViewRef viewRef = HIViewGetSuperview(dt->userpane); if (viewRef) { result = SetElement(event, (HIObjectRef) viewRef, 0, kEventParamAccessibleAttributeValue); require_noerr(result, ParameterError); } } else if (CFStringCompare(attr, kAXWindowAttribute, 0) == kCFCompareEqualTo) { WindowRef winRef = HIViewGetWindow((HIViewRef) dt->userpane); if (winRef) { result = SetElement(event, (HIObjectRef) winRef, 0, kEventParamAccessibleAttributeValue); require_noerr(result, ParameterError); } } else if (CFStringCompare(attr, kAXTopLevelUIElementAttribute, 0) == kCFCompareEqualTo) { if (dt->window) { result = SetElement(event, (HIObjectRef) dt->window, 0, kEventParamAccessibleAttributeValue); require_noerr(result, ParameterError); } } else { result = eventNotHandledErr; } } break; } } break; } ParameterError: return result; }
/***************************************************** * * Handle_WindowCommandProcess(inHandlerCallRef, inEvent, inUserData) * * Purpose: called to handle of the events generated by the various controls of the HICustomView_Tester window * * Inputs: inHandlerCallRef - reference to the current handler call chain * inEvent - the event * inUserData - app-specified data you passed in the call to InstallEventHandler * * Returns: OSStatus - noErr indicates the event was handled * eventNotHandledErr indicates the event was not handled and the Toolbox should take over */ static pascal OSStatus Handle_WindowCommandProcess(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus status; HIViewRef customView = (HIViewRef)inUserData; // getting the command HICommandExtended aCommand; status = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(aCommand), NULL, &aCommand); require_noerr(status, ExitCommandProcess); status = eventNotHandledErr; // cheking that the command came from a control if ( ! (aCommand.attributes & kHICommandFromControl) ) goto ExitCommandProcess; switch (aCommand.commandID) { // // Asking for a refresh of the custom view // case 'SNDt': HIViewSetNeedsDisplay(customView, true); status = noErr; break; // // Setting the control value of the custom view // case 'SV00': SetControl32BitValue(customView, 0); status = noErr; break; case 'SV01': SetControl32BitValue(customView, 1); status = noErr; break; case 'SV17': SetControl32BitValue(customView, 17); status = noErr; break; case 'SVTH': SetControl32BitValue(customView, 1000); status = noErr; break; case 'SVet': { HIViewRef editText; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kSetValueEditID, &editText); char buffer[11]; Size actualSize; GetControlData(editText, kControlEntireControl, kControlEditTextTextTag, 10, buffer, &actualSize); if (actualSize > 10) actualSize = 10; buffer[actualSize] = 0; SetControl32BitValue(customView, atoi(buffer)); } status = noErr; break; // // Setting the state of the custom view // case 'CHlt': // setting the hilite to non-0 also stomps the previous hilite state if any // and we don't want that in our testing if (GetControl32BitValue(aCommand.source.control) == 1) HiliteControl(customView, 1); else HiliteControl(customView, 0); status = noErr; break; case 'CEnb': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) EnableControl(customView); else DisableControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; case 'CAct': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) ActivateControl(customView); else DeactivateControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; // // Testing the custom view in or as a scroller in a HIScrollView // case 'CTiS': case 'CTaS': if (GetControl32BitValue(aCommand.source.control) == 1) { // create a HIScrollView and install it where and as the custom view was HIViewRef scrollView; status = HIScrollViewCreate(kHIScrollViewValidOptions, &scrollView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(scrollView, &kBindToParentLayout); HIViewSetLayoutInfo(customView, &kNoBindLayout); status = HIViewAddSubview(HIViewGetSuperview(customView), scrollView); require_noerr(status, ExitCommandProcess); if (aCommand.commandID == 'CTiS') { // if we are testing the custom view in a scroller, we embed it in a scrolling User Pane // that we embed in the HIScrollView Rect boundsRect = {0, 0, 1000, 1000}; HIViewRef userPane; status = CreateUserPaneControl(NULL, &boundsRect, kControlSupportsEmbedding, &userPane); require_noerr(status, ExitCommandProcess); EventTypeSpec userPaneEvents[] = { {kEventClassScrollable, kEventScrollableGetInfo}, {kEventClassScrollable, kEventScrollableScrollTo} }; InstallControlEventHandler(userPane, UserPaneHandler, 2, userPaneEvents, userPane, NULL); status = HIViewAddSubview(scrollView, userPane); require_noerr(status, ExitCommandProcess); status = HIViewAddSubview(userPane, customView); require_noerr(status, ExitCommandProcess); HIViewSetVisible(userPane, true); } else { // else we just embed the custom view directly in the HIScrollView status = HIViewAddSubview(scrollView, customView); require_noerr(status, ExitCommandProcess); } HIViewSetVisible(scrollView, true); // the 2 modes are not compatible so we disable the other check box HIViewRef otherCheckToDisable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToDisable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToDisable); require_noerr(status, ExitCommandProcess); DisableControl(otherCheckToDisable); // if we reach here, status is already set to noErr so we don't set it again } else { // we remove the HIScrollView and set the custom view back to where and as it was HIViewRef scrollView; if (aCommand.commandID == 'CTiS') scrollView = HIViewGetSuperview(HIViewGetSuperview(customView)); else scrollView = HIViewGetSuperview(customView); status = HIViewAddSubview(HIViewGetSuperview(scrollView), customView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(customView, &kBindToParentLayout); // by releasing the HIScrollView, we also release the scrolling User Pane if any // which was embedded inside CFRelease(scrollView); // we renable the other check box HIViewRef otherCheckToEnable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToEnable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToEnable); require_noerr(status, ExitCommandProcess); EnableControl(otherCheckToEnable); // if we reach here, status is already set to noErr so we don't set it again } break; } ExitCommandProcess: return status; } // Handle_WindowCommandProcess
void CAccountInfoPage::CreateControls() { ////@begin CAccountInfoPage content construction CAccountInfoPage* itemWizardPage56 = this; wxBoxSizer* itemBoxSizer57 = new wxBoxSizer(wxVERTICAL); itemWizardPage56->SetSizer(itemBoxSizer57); m_pTitleStaticCtrl = new wxStaticText; m_pTitleStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_pTitleStaticCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana"))); itemBoxSizer57->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxGROW|wxALL, 5); m_pCookieDetectionFailedStaticCtrl = new wxStaticText; m_pCookieDetectionFailedStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_pCookieDetectionFailedStaticCtrl->Hide(); itemBoxSizer57->Add(m_pCookieDetectionFailedStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5); m_pCookieDetectionFailedCtrl = new wxHyperlinkCtrl; m_pCookieDetectionFailedCtrl->Create( itemWizardPage56, ID_ACCOUNTCOOKIEDETECTIONFAILEDCTRL, wxT(" "), wxT(" "), wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU ); m_pCookieDetectionFailedCtrl->Hide(); itemBoxSizer57->Add(m_pCookieDetectionFailedCtrl, 0, wxALIGN_LEFT|wxALL, 5); m_pAccountQuestionStaticCtrl = new wxStaticText; m_pAccountQuestionStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer57->Add(m_pAccountQuestionStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5); wxFlexGridSizer* itemFlexGridSizer61 = new wxFlexGridSizer(1, 2, 0, 0); itemFlexGridSizer61->AddGrowableCol(1); itemBoxSizer57->Add(itemFlexGridSizer61, 0, wxGROW|wxALL, 5); m_pAccountCreateCtrl = new wxRadioButton; m_pAccountCreateCtrl->Create( itemWizardPage56, ID_ACCOUNTCREATECTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_pAccountCreateCtrl->SetValue(TRUE); itemFlexGridSizer61->Add(m_pAccountCreateCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountUseExistingCtrl = new wxRadioButton; m_pAccountUseExistingCtrl->Create( itemWizardPage56, ID_ACCOUNTUSEEXISTINGCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_pAccountUseExistingCtrl->SetValue(FALSE); itemFlexGridSizer61->Add(m_pAccountUseExistingCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountInformationStaticCtrl = new wxStaticText; m_pAccountInformationStaticCtrl->Create( itemWizardPage56, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer57->Add(m_pAccountInformationStaticCtrl, 0, wxALIGN_LEFT|wxALL, 5); wxFlexGridSizer* itemFlexGridSizer64 = new wxFlexGridSizer(4, 2, 0, 0); itemFlexGridSizer64->AddGrowableCol(1); itemBoxSizer57->Add(itemFlexGridSizer64, 0, wxEXPAND|wxALL, 0); m_pAccountEmailAddressStaticCtrl = new wxStaticText; m_pAccountEmailAddressStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer64->Add(m_pAccountEmailAddressStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountEmailAddressCtrl = new wxTextCtrl; m_pAccountEmailAddressCtrl->Create( itemWizardPage56, ID_ACCOUNTEMAILADDRESSCTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 22), 0 ); itemFlexGridSizer64->Add(m_pAccountEmailAddressCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountUsernameStaticCtrl = new wxStaticText; m_pAccountUsernameStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTUSERNAMESTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer64->Add(m_pAccountUsernameStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountUsernameCtrl = new wxTextCtrl; m_pAccountUsernameCtrl->Create( itemWizardPage56, ID_ACCOUNTUSERNAMECTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 22), 0 ); itemFlexGridSizer64->Add(m_pAccountUsernameCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountPasswordStaticCtrl = new wxStaticText; m_pAccountPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer64->Add(m_pAccountPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountPasswordCtrl = new wxTextCtrl; m_pAccountPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); itemFlexGridSizer64->Add(m_pAccountPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountConfirmPasswordStaticCtrl = new wxStaticText; m_pAccountConfirmPasswordStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer64->Add(m_pAccountConfirmPasswordStaticCtrl, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountConfirmPasswordCtrl = new wxTextCtrl; m_pAccountConfirmPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTCONFIRMPASSWORDCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); itemFlexGridSizer64->Add(m_pAccountConfirmPasswordCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemFlexGridSizer64->Add( 0, 0 ); m_pAccountPasswordRequirmentsStaticCtrl = new wxStaticText; m_pAccountPasswordRequirmentsStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTREQUIREMENTSSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_pAccountPasswordRequirmentsStaticCtrl->SetFont(wxFont(7, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE)); itemFlexGridSizer64->Add(m_pAccountPasswordRequirmentsStaticCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountManagerLinkLabelStaticCtrl = new wxStaticText; m_pAccountManagerLinkLabelStaticCtrl->Create( itemWizardPage56, ID_ACCOUNTLINKLABELSTATICCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer57->Add(m_pAccountManagerLinkLabelStaticCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); m_pAccountForgotPasswordCtrl = new wxHyperlinkCtrl; m_pAccountForgotPasswordCtrl->Create( itemWizardPage56, ID_ACCOUNTFORGOTPASSWORDCTRL, wxT(" "), wxT(" "), wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_ALIGN_LEFT | wxHL_CONTEXTMENU ); itemBoxSizer57->Add(m_pAccountForgotPasswordCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); // Set validators // m_pAccountEmailAddressCtrl/m_pAccountUsernameCtrl is setup when the OnPageChange event is fired since // it can be a username or an email address. m_pAccountEmailAddressCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress) ); m_pAccountUsernameCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountUsername) ); m_pAccountPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountPassword) ); m_pAccountConfirmPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, &m_strAccountConfirmPassword) ); #ifdef __WXMAC__ //Accessibility HIViewRef buttonView = (HIViewRef)m_pAccountCreateCtrl->GetHandle(); HIObjectRef theObject = (HIObjectRef)HIViewGetSuperview(buttonView); HIObjectSetAccessibilityIgnored(theObject, true); #endif ////@end CAccountInfoPage content construction }
// --------------------------------------------------------------------------- // To make a TextView auto-size along with its parent view, use the following // code: HIViewRef textView; HILayoutInfo layoutInfo; HIRect parentFrame; //... // Bind the view to its parent on all sides (affects resize) layoutInfo.binding.left.kind = kHILayoutBindLeft; layoutInfo.binding.left.toView = NULL; layoutInfo.binding.left.offset = 0.0; layoutInfo.binding.top.kind = kHILayoutBindTop; layoutInfo.binding.top.toView = NULL; layoutInfo.binding.top.offset = 0.0; layoutInfo.binding.right.kind = kHILayoutBindRight; layoutInfo.binding.right.toView = NULL; layoutInfo.binding.right.offset = 0.0; layoutInfo.binding.bottom.kind = kHILayoutBindBottom; layoutInfo.binding.bottom.toView = NULL; layoutInfo.binding.bottom.offset = 0.0; status = HIViewSetLayoutInfo(textView, &layoutInfo); // Set the initial size to be the same as the parent status = HIViewGetFrame(HIViewGetSuperview(textView), &parentFrame); status = HIViewSetFrame(textView, &parentFrame);