// -------------------------------------------------------------------------------------- static void changePanel(WindowRef window, short newPanel) { ControlRef rootControl, userPane; GetRootControl(window, &rootControl); GetIndexedSubControl(rootControl, gPanelNumber, &userPane); SetControlVisibility(userPane, false, false); // hide the currently active panel GetIndexedSubControl(rootControl, newPanel, &userPane); SetControlVisibility(userPane, true, true); // and show the newly selected panel gPanelNumber = newPanel; }
void TabbedWindow::DisableAllPanes( void ) { OSStatus status; ControlRef controlRef; ControlID controlID; controlID.signature = kTabPaneSignature; // loop through and disable all of the panes for ( int i = 1; i <= kTabPaneCount; i++ ) { controlID.id = gPaneArray[i]; status = GetControlByID( fWindowRef, &controlID, &controlRef ); check_noerr( status ); // disable the panes if ( status == noErr ) { SetControlVisibility( controlRef, false, false ); DisableControl( controlRef ); } } return; }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Name: MyPDEInitialize Input Parameters: context : The plugins context parentUserPane : the user pane to your your controls into ref : the reference to this PDE printSession : this holds the PM tickets Output Parameters: flags : feature flags that are supported by this PDE err : returns the error status Description: Initializes client interface. Creates controls and sets initial values Change History (most recent first): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ static OSStatus MyPDEInitialize( PMPDEContext context, PMPDEFlags* flags, PMPDERef ref, ControlRef parentUserPane, PMPrintSession printSession) { OSStatus err = noErr; PrintDialogPDEOnlyContextPtr myContext = NULL; // Pointer to our context data. DebugMessage("PrintDialogPDE MyPDEInitialize called\n"); myContext = (PrintDialogPDEOnlyContextPtr) context; if ((myContext != NULL) && (printSession != NULL)) { WindowRef theWindow = NULL; short savedResFile = CurResFile(); UseResFile(myContext->theResFile); theWindow = GetControlOwner(parentUserPane); // get the windowref from the user pane // the user panes rect is the rect we should use to draw our // controls into. The printing system calculates the user pane // size based on the maxh and maxv sizes returned from the // Prologue function // Note that we are using the AutoToggleProc variant of the Radio Button control // This allows a hit on this control to be automatically processed by the ControlMgr // get controls myContext->thePrintSelTextOnlyControlRef = GetNewControl(kPrintDialogPDEControlID, theWindow); // embed controls EmbedControl(myContext->thePrintSelTextOnlyControlRef, parentUserPane); // set controls as visible SetControlVisibility(myContext->thePrintSelTextOnlyControlRef, true, false); // Set default value SetControlValue(myContext->thePrintSelTextOnlyControlRef, 0); // Set flags *flags = kPMPDENoFlags; // Initialize this plugins controls based on the information in the // PageSetup or PrintSettings ticket. err = MyPDESync(context, printSession, kSyncDirectionSetUserInterface); if (err == kPMKeyNotFound) err = noErr; UseResFile(savedResFile); } else err = kPMInvalidPDEContext; DebugPrintErr(err, "PrintDialogPDE Error from MyPDEInitialize returned %d\n"); return (err); }
// -------------------------------------------------------------------------------------- pascal void IconDataBrowserItemSelectionCB(ControlRef browser, DataBrowserItemID item, DataBrowserItemNotification message) { #pragma unused (browser) IconDBItemDataRec *itemData; itemData = (IconDBItemDataRec *)item; switch (message) { case kDataBrowserItemSelected: SetControlVisibility(itemData->userPane, true, true); // this will draw over the break; // previously selected user pane case kDataBrowserItemDeselected: SetControlVisibility(itemData->userPane, false, false); // we've already been // drawn over so there's no need to update the display (which would flicker) break; } }
OSStatus TabbedWindow::SwitchTabPane( ControlRef tabControl ) { OSStatus status = noErr; ControlRef paneRef; // get the value of the control int tabIndex = GetControlValue( tabControl ); // make sure that the value of the control is within the current count, // so we don't step outside the bounds of the array paneRef = this->PaneAtIndex( tabIndex ); // check to see if the controlRef is the same as the one that's // currently activated if ( paneRef != fCurrentTabPane ) { // deactivate and disable the current pane, if we have one if ( fCurrentTabPane != NULL ) { SetControlVisibility( fCurrentTabPane, false, false ); DisableControl( fCurrentTabPane ); } // activate the current pane EnableControl( paneRef ); SetControlVisibility( paneRef, true, true ); // set the current pane to be the one that we just activated fCurrentTabPane = paneRef; } else { // set the error back to eventNotHandled error, since we're // not handling it for the same tab that's already activated status = eventNotHandledErr; } return status; }
// -------------------------------------------------------------------------------------- static void changePanel(DialogRef dialog, short newPanel) { ControlRef userPane; static const SInt16 panelIndexes[kNumberOfRows] = { iUserPane1, iUserPane2, iUserPane3, iUserPane4, iUserPane5, iUserPane6, iUserPane7, iUserPane8, iUserPane9, iUserPane10 }; GetDialogItemAsControl(dialog, panelIndexes[gPanelNumber], &userPane); SetControlVisibility(userPane, false, false); // hide the currently active panel GetDialogItemAsControl(dialog, panelIndexes[newPanel], &userPane); SetControlVisibility(userPane, true, true); // and show the newly selected panel gPanelNumber = newPanel; }
void TkpDisplayMenuButton( ClientData clientData) /* Information about widget. */ { TkMenuButton *butPtr = (TkMenuButton *) clientData; Tk_Window tkwin = butPtr->tkwin; TkWindow * winPtr; Pixmap pixmap; MacMenuButton * mbPtr = (MacMenuButton *) butPtr; GWorldPtr dstPort; CGrafPtr saveWorld; GDHandle saveDevice; int hasImageOrBitmap = 0; int width, height; int err; ControlButtonGraphicAlignment theAlignment; Rect paneRect, cntrRect; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = ( Pixmap )Tk_WindowId(tkwin); GetGWorld(&saveWorld, &saveDevice); dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); SetGWorld(dstPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); winPtr=(TkWindow *)butPtr->tkwin; paneRect.left=winPtr->privatePtr->xOff; paneRect.top=winPtr->privatePtr->yOff; paneRect.right=paneRect.left+Tk_Width(butPtr->tkwin)-1; paneRect.bottom=paneRect.top+Tk_Height(butPtr->tkwin)-1; cntrRect=paneRect; cntrRect.left+=butPtr->inset; cntrRect.top+=butPtr->inset; cntrRect.right-=butPtr->inset; cntrRect.bottom-=butPtr->inset; if (mbPtr->userPane) { MenuButtonControlParams params; bzero(¶ms, sizeof(params)); ComputeMenuButtonControlParams(butPtr, ¶ms ); if (bcmp(¶ms,&mbPtr->params,sizeof(params))) { if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } } } if (!mbPtr->userPane) { if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) { fprintf(stderr,"Init Control failed\n" ); return; } } SetControlBounds(mbPtr->userPane,&paneRect); SetControlBounds(mbPtr->control,&cntrRect); /* * We need to cache the title and its style */ if (!(mbPtr->flags&2)) { ControlTitleParams titleParams; int titleChanged; int styleChanged; ComputeControlTitleParams(butPtr,&titleParams); CompareControlTitleParams(&titleParams,&mbPtr->titleParams, &titleChanged,&styleChanged); if (titleChanged) { CFStringRef cf; cf = CFStringCreateWithCString(NULL, titleParams.title, kCFStringEncodingUTF8); if (hasImageOrBitmap) { SetControlTitleWithCFString(mbPtr->control, cf); } else { SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf); } CFRelease(cf); bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1); mbPtr->titleParams.len = titleParams.len; } if ((titleChanged||styleChanged) && titleParams .len) { if (hasImageOrBitmap) { if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) { fprintf(stderr,"SetControlFontStyle failed %d\n", err); return; } } bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style)); } } if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); hasImageOrBitmap = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); hasImageOrBitmap = 1; } if (hasImageOrBitmap) { mbPtr->picParams.srcRect.right = width; mbPtr->picParams.srcRect.bottom = height; /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ tkPictureIsOpen = 1; if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { fprintf(stderr,"OpenCPicture failed\n"); } /* * TO DO - There is one case where XCopyPlane calls CopyDeepMask, * which does not get recorded in the picture. So the bitmap code * will fail in that case. */ if (butPtr->image != NULL) { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0); } else { XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0, (unsigned int) width, (unsigned int) height, 0, 0, 1); } ClosePicture(); tkPictureIsOpen = 0; if ( (err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err ); } switch (butPtr->anchor) { case TK_ANCHOR_N: theAlignment = kControlBevelButtonAlignTop; break; case TK_ANCHOR_NE: theAlignment = kControlBevelButtonAlignTopRight; break; case TK_ANCHOR_E: theAlignment = kControlBevelButtonAlignRight; break; case TK_ANCHOR_SE: theAlignment = kControlBevelButtonAlignBottomRight; break; case TK_ANCHOR_S: theAlignment = kControlBevelButtonAlignBottom; break; case TK_ANCHOR_SW: theAlignment = kControlBevelButtonAlignBottomLeft; break; case TK_ANCHOR_W: theAlignment = kControlBevelButtonAlignLeft; break; case TK_ANCHOR_NW: theAlignment = kControlBevelButtonAlignTopLeft; break; case TK_ANCHOR_CENTER: theAlignment = kControlBevelButtonAlignCenter; break; } if ((err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err ); } } if (butPtr->flags & GOT_FOCUS) { HiliteControl(mbPtr->control,kControlButtonPart); } else { HiliteControl(mbPtr->control,kControlNoPart); } UpdateControlColors(mbPtr); if (mbPtr->flags&2) { ShowControl(mbPtr->control); ShowControl(mbPtr->userPane); mbPtr->flags ^= 2; } else { Draw1Control(mbPtr->userPane); SetControlVisibility(mbPtr->control, true, true); } if (hasImageOrBitmap) { KillPicture(mbPtr->bevelButtonContent.u.picture); } SetGWorld(saveWorld, saveDevice); }
CV_IMPL int cvCreateTrackbar (const char* trackbar_name, const char* window_name,int* val, int count, CvTrackbarCallback on_notify) { int result = 0; CV_FUNCNAME( "cvCreateTrackbar" ); __BEGIN__; /*char slider_name[32];*/ CvWindow* window = 0; CvTrackbar* trackbar = 0; Rect stboundsRect; ControlRef outControl; ControlRef stoutControl; Rect bounds; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); if( !trackbar ) { int len = strlen(trackbar_name); trackbar = (CvTrackbar*)cvAlloc(sizeof(CvTrackbar) + len + 1); memset( trackbar, 0, sizeof(*trackbar)); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->name = (char*)(trackbar+1); memcpy( trackbar->name, trackbar_name, len + 1 ); trackbar->parent = window; trackbar->next = window->toolbar.first; window->toolbar.first = trackbar; if( val ) { int value = *val; if( value < 0 ) value = 0; if( value > count ) value = count; trackbar->pos = value; trackbar->data = val; } trackbar->maxval = count; trackbar->notify = on_notify; int c = icvCountTrackbarInWindow(window); GetWindowBounds(window->window,kWindowContentRgn,&bounds); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = stboundsRect.left+LABELWIDTH; fprintf(stdout,"create trackabar bounds (%d %d %d %d)\n",stboundsRect.top,stboundsRect.left,stboundsRect.bottom,stboundsRect.right); CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,trackbar_name,kCFStringEncodingASCII),NULL,&stoutControl); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE*2+LABELWIDTH; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = bounds.right-INTERWIDGETSPACE; CreateSliderControl (window->window,&stboundsRect, trackbar->pos,0,trackbar->maxval,kControlSliderLiveFeedback,0,true,NewControlActionUPP(TrackbarActionProcPtr),&outControl); bounds.bottom += INTERWIDGETSPACE + WIDGETHEIGHT; SetControlVisibility (outControl,true,true); SetControlVisibility (stoutControl,true,true); trackbar->trackbar = outControl; trackbar->label = stoutControl; if (c == 1) window->trackbarheight = INTERWIDGETSPACE*2 + WIDGETHEIGHT; else window->trackbarheight += INTERWIDGETSPACE + WIDGETHEIGHT; icvUpdateWindowSize( window ); } __END__; return result; }
void TkpDisplayScale( ClientData clientData) /* Widget record for scale. */ { TkScale *scalePtr = (TkScale *) clientData; Tk_Window tkwin = scalePtr->tkwin; Tcl_Interp *interp = scalePtr->interp; int result; char string[TCL_DOUBLE_SPACE]; MacScale *macScalePtr = (MacScale *) clientData; Rect r; WindowRef windowRef; CGrafPtr destPort, savePort; Boolean portChanged; MacDrawable *macDraw; SInt32 initialValue, minValue, maxValue; UInt16 numTicks; #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("TkpDisplayScale"); #endif scalePtr->flags &= ~REDRAW_PENDING; if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { goto done; } /* * Invoke the scale's command if needed. */ Tcl_Preserve((ClientData) scalePtr); if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) { Tcl_Preserve((ClientData) interp); sprintf(string, scalePtr->format, scalePtr->value); result = Tcl_VarEval(interp, scalePtr->command, " ", string, NULL); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command executed by scale)"); Tcl_BackgroundError(interp); } Tcl_Release((ClientData) interp); } scalePtr->flags &= ~INVOKE_COMMAND; if (scalePtr->flags & SCALE_DELETED) { Tcl_Release((ClientData) scalePtr); return; } Tcl_Release((ClientData) scalePtr); /* * Now handle the part of redisplay that is the same for * horizontal and vertical scales: border and traversal * highlight. */ if (scalePtr->highlightWidth != 0) { GC gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, Tk_WindowId(tkwin)); } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scalePtr->bgBorder, scalePtr->highlightWidth, scalePtr->highlightWidth, Tk_Width(tkwin) - 2*scalePtr->highlightWidth, Tk_Height(tkwin) - 2*scalePtr->highlightWidth, scalePtr->borderWidth, scalePtr->relief); /* * Set up port for drawing Macintosh control. */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Create Macintosh control. */ #define MAC_OSX_SCROLL_WIDTH 10 if (scalePtr->orient == ORIENT_HORIZONTAL) { int offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH)/2; if (offset < 0) { offset = 0; } r.left = macDraw->xOff + scalePtr->inset; r.top = macDraw->yOff + offset; r.right = macDraw->xOff+Tk_Width(tkwin) - scalePtr->inset; r.bottom = macDraw->yOff + offset + MAC_OSX_SCROLL_WIDTH/2; } else { int offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH)/2; if (offset < 0) { offset = 0; } r.left = macDraw->xOff + offset; r.top = macDraw->yOff + scalePtr->inset; r.right = macDraw->xOff + offset + MAC_OSX_SCROLL_WIDTH/2; r.bottom = macDraw->yOff+Tk_Height(tkwin) - scalePtr->inset; } if (macScalePtr->scaleHandle == NULL) { #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("Initialising scale"); #endif initialValue = scalePtr->value; if (scalePtr->orient == ORIENT_HORIZONTAL) { minValue = scalePtr->fromValue; maxValue = scalePtr->toValue; } else { minValue = scalePtr->fromValue; maxValue = scalePtr->toValue; } if (scalePtr->tickInterval == 0) { numTicks = 0; } else { numTicks = (maxValue - minValue)/scalePtr->tickInterval; } CreateSliderControl(windowRef, &r, initialValue, minValue, maxValue, kControlSliderPointsDownOrRight, numTicks, 1, scaleActionProc, &(macScalePtr->scaleHandle)); SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr); if (IsWindowActive(windowRef)) { macScalePtr->flags |= ACTIVE; } } else { SetControlBounds(macScalePtr->scaleHandle, &r); SetControl32BitValue(macScalePtr->scaleHandle, scalePtr->value); SetControl32BitMinimum(macScalePtr->scaleHandle, scalePtr->fromValue); SetControl32BitMaximum(macScalePtr->scaleHandle, scalePtr->toValue); } /* * Finally draw the control. */ SetControlVisibility(macScalePtr->scaleHandle,true,true); HiliteControl(macScalePtr->scaleHandle,0); Draw1Control(macScalePtr->scaleHandle); if (portChanged) { QDSwapPort(savePort, NULL); } done: scalePtr->flags &= ~REDRAW_ALL; }
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name) { if ( !wxCheckListBoxBase::Create(parent, id, pos, size, n, choices, style, validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; m_checkBoxWidth = 12; m_checkBoxHeight= 10; long h = m_checkBoxHeight ; #if TARGET_CARBON GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif const wxFont& font = GetFont(); FontInfo finfo; FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; if (m_checkBoxHeight<h) { m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2; m_checkBoxHeight= h; } Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macCheckListDefUPP == NULL ) { macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition ); } listDef.u.userProc = macCheckListDefUPP ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true, m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lNoExtend ; } else if ( style & wxLB_EXTENDED ) { options += lExtendDrag ; } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); MacPostControlCreate() ; for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } LSetDrawingMode( true , (ListHandle) m_macList ) ; return TRUE; }
bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macListDefUPP == NULL ) { macListDefUPP = NewListDefUPP( wxMacListDefinition ); } listDef.u.userProc = macListDefUPP ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; #if TARGET_CARBON GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; #else GetFontName( kFontIDMonaco , fontName ) ; fontSize = 9 ; fontStyle = normal ; #endif SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, (style & wxLB_HSCROLL), true, kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , (style & wxLB_HSCROLL) ? kwxMacListWithVerticalAndHorizontalScrollbar : kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = kwxMacListItemHeight ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lExtendDrag + lUseSense ; } else if ( style & wxLB_EXTENDED ) { // default behaviour } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } MacPostControlCreate() ; LSetDrawingMode( true , (ListHandle)m_macList ) ; return true; }
static void TkMacOSXDrawControl( MacButton *mbPtr, /* Mac button. */ GWorldPtr destPort, /* Off screen GWorld. */ GC gc, /* The GC we are drawing into - needed for the * bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed for * the bevel button */ { TkButton *butPtr = (TkButton *) mbPtr; TkWindow *winPtr; Rect paneRect, cntrRect; int active, enabled; int rebuild; winPtr = (TkWindow *) butPtr->tkwin; paneRect.left = winPtr->privatePtr->xOff; paneRect.top = winPtr->privatePtr->yOff; paneRect.right = paneRect.left + Tk_Width(butPtr->tkwin); paneRect.bottom = paneRect.top + Tk_Height(butPtr->tkwin); cntrRect = paneRect; /* cntrRect.left += butPtr->inset; cntrRect.top += butPtr->inset; cntrRect.right -= butPtr->inset; cntrRect.bottom -= butPtr->inset; */ cntrRect.left += DEF_INSET_LEFT; cntrRect.top += DEF_INSET_TOP; cntrRect.right -= DEF_INSET_RIGHT; cntrRect.bottom -= DEF_INSET_BOTTOM; /* * The control has been previously initialised. * It may need to be re-initialised */ #if 0 rebuild = (winPtr->flags & TK_REBUILD_TOPLEVEL); winPtr->flags &= ~TK_REBUILD_TOPLEVEL; #else rebuild = 0; #endif if (mbPtr->flags) { MacControlParams params; TkMacOSXComputeControlParams(butPtr, ¶ms); if (rebuild || bcmp(¶ms, &mbPtr->params, sizeof(params))) { /* * The type of control has changed. * Clean it up and clear the flag. */ if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } mbPtr->flags = 0; } } if (!(mbPtr->flags & CONTROL_INITIALIZED)) { if (TkMacOSXInitControl(mbPtr, destPort, gc, pixmap, &paneRect, &cntrRect)) { return; } } SetControlBounds(mbPtr->userPane, &paneRect); SetControlBounds(mbPtr->control, &cntrRect); if (!mbPtr->useTkText) { Str255 controlTitle; ControlFontStyleRec fontStyle; Tk_Font font; int len; if (((mbPtr->info.image == NULL) && (mbPtr->info.bitmap == None)) || (mbPtr->info.compound != COMPOUND_NONE)) { len = TkFontGetFirstTextLayout(butPtr->textLayout, &font, (char*) controlTitle); controlTitle[len] = 0; } else { len = 0; controlTitle[0] = 0; } if (rebuild || bcmp(mbPtr->controlTitle, controlTitle, len+1)) { CFStringRef cf = CFStringCreateWithCString(NULL, (char*) controlTitle, kCFStringEncodingUTF8); if (cf != NULL) { SetControlTitleWithCFString(mbPtr->control, cf); CFRelease(cf); } bcopy(controlTitle, mbPtr->controlTitle, len+1); } if (len) { TkMacOSXInitControlFontStyle(font, &fontStyle); if (bcmp(&mbPtr->fontStyle, &fontStyle, sizeof(fontStyle)) ) { ChkErr(SetControlFontStyle, mbPtr->control, &fontStyle); bcopy(&fontStyle, &mbPtr->fontStyle, sizeof(fontStyle)); } } } if (mbPtr->params.isBevel) { /* * Initialiase the image/button parameters. */ SetupBevelButton(mbPtr, mbPtr->control, destPort, gc, pixmap); } if (butPtr->flags & SELECTED) { SetControlValue(mbPtr->control, 1); #if 0 } else if (butPtr->flags & TRISTATED) { SetControlValue(mbPtr->control, 2); #endif } else { SetControlValue(mbPtr->control, 0); } active = ((mbPtr->flags & ACTIVE) != 0); if (active != IsControlActive(mbPtr->control)) { if (active) { ChkErr(ActivateControl, mbPtr->control); } else { ChkErr(DeactivateControl, mbPtr->control); } } enabled = !(butPtr->state == STATE_DISABLED); if (enabled != IsControlEnabled(mbPtr->control)) { if (enabled) { ChkErr(EnableControl, mbPtr->control); } else { ChkErr(DisableControl, mbPtr->control); } } if (active && enabled) { if (butPtr->state == STATE_ACTIVE) { if (mbPtr->params.isBevel) { HiliteControl(mbPtr->control, kControlButtonPart); } else { switch (butPtr->type) { case TYPE_BUTTON: HiliteControl(mbPtr->control, kControlButtonPart); break; case TYPE_RADIO_BUTTON: HiliteControl(mbPtr->control, kControlRadioButtonPart); break; case TYPE_CHECK_BUTTON: HiliteControl(mbPtr->control, kControlCheckBoxPart); break; } } } else { HiliteControl(mbPtr->control, kControlNoPart); } } UpdateControlColors(mbPtr); if (butPtr->type == TYPE_BUTTON && !mbPtr->params.isBevel) { Boolean isDefault; if (butPtr->defaultState == STATE_ACTIVE) { isDefault = true; } else { isDefault = false; } ChkErr(SetControlData, mbPtr->control, kControlNoPart, kControlPushButtonDefaultTag, sizeof(isDefault), &isDefault); } if (mbPtr->flags & FIRST_DRAW) { ShowControl(mbPtr->userPane); ShowControl(mbPtr->control); mbPtr->flags ^= FIRST_DRAW; } else { SetControlVisibility(mbPtr->control, true, true); Draw1Control(mbPtr->userPane); } if (mbPtr->params.isBevel) { if (mbPtr->bevelButtonContent.contentType == kControlContentPictHandle) { KillPicture(mbPtr->bevelButtonContent.u.picture); } } }
static int icvCreateTrackbar (const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback on_notify, CvTrackbarCallback2 on_notify2, void* userdata) { int result = 0; CV_FUNCNAME( "icvCreateTrackbar" ); __BEGIN__; /*char slider_name[32];*/ CvWindow* window = 0; CvTrackbar* trackbar = 0; Rect stboundsRect; ControlRef outControl; ControlRef stoutControl; Rect bounds; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); if( !trackbar ) { int len = strlen(trackbar_name); trackbar = (CvTrackbar*)cvAlloc(sizeof(CvTrackbar) + len + 1); memset( trackbar, 0, sizeof(*trackbar)); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->name = (char*)(trackbar+1); memcpy( trackbar->name, trackbar_name, len + 1 ); trackbar->parent = window; trackbar->next = window->toolbar.first; window->toolbar.first = trackbar; if( val ) { int value = *val; if( value < 0 ) value = 0; if( value > count ) value = count; trackbar->pos = value; trackbar->data = val; } trackbar->maxval = count; //----------- YV ---------------------- //get nb of digits int nbDigit = 0; while((count/=10)>10){ nbDigit++; } //pad size maxvalue in pixel Point qdSize; char valueinchar[strlen(trackbar_name)+1 +1 +1+nbDigit+1];//length+\n +space +(+nbDigit+) sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->maxval); SInt16 baseline; CFStringRef text = CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII); GetThemeTextDimensions( text, kThemeCurrentPortFont, kThemeStateActive, false, &qdSize, &baseline ); trackbar->labelSize = qdSize.h; //-------------------------------------- int c = icvCountTrackbarInWindow(window); GetWindowBounds(window->window,kWindowContentRgn,&bounds); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = stboundsRect.left+LABELWIDTH; //fprintf(stdout,"create trackabar bounds (%d %d %d %d)\n",stboundsRect.top,stboundsRect.left,stboundsRect.bottom,stboundsRect.right); //----------- YV ---------------------- sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->pos); CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII),NULL,&stoutControl); //-------------------------------------- stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE*2+LABELWIDTH; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = bounds.right-INTERWIDGETSPACE; CreateSliderControl (window->window,&stboundsRect, trackbar->pos,0,trackbar->maxval,kControlSliderLiveFeedback,0,true,NewControlActionUPP(TrackbarActionProcPtr),&outControl); bounds.bottom += INTERWIDGETSPACE + WIDGETHEIGHT; SetControlVisibility (outControl,true,true); SetControlVisibility (stoutControl,true,true); trackbar->trackbar = outControl; trackbar->label = stoutControl; if (c == 1) window->trackbarheight = INTERWIDGETSPACE*2 + WIDGETHEIGHT; else window->trackbarheight += INTERWIDGETSPACE + WIDGETHEIGHT; icvUpdateWindowSize( window ); } trackbar->notify = on_notify; trackbar->notify2 = on_notify2; trackbar->userdata = userdata; result = 1; __END__; return result; }