Ejemplo n.º 1
0
Archivo: ugView.c Proyecto: rolk/ug
static void DisposeApplicationWindow (AWindowRecord *wr)
{
  DisposeControl(wr->vScrollBar);
  DisposeControl(wr->hScrollBar);
  CloseWindow(wr->theWindow);
  return;
}
Ejemplo n.º 2
0
void
ClearDownloadSettings(void)
{
    GrafPtr oldPort;
    
    GetPort(&oldPort);
    if (gWPtr)
    {
        SetPort(gWPtr);
        
        if (gControls->tw->dlSettingsGB)
            DisposeControl(gControls->tw->dlSettingsGB);
            
    	if (gControls->tw->startMsg)
            EraseRect(&gControls->tw->startMsgBox);
            
    	if (gControls->tw->siteSelector)
    		DisposeControl(gControls->tw->siteSelector);	  
        if (gControls->tw->siteSelMsg)
            DisposeControl(gControls->tw->siteSelMsg);
                    	
        if (gControls->tw->saveBitsMsg)
            EraseRect(&gControls->tw->saveBitsMsgBox);
        if (gControls->tw->saveBitsCheckbox)
            DisposeControl(gControls->tw->saveBitsCheckbox);
            
        if (gControls->tw->proxySettingsBtn)
            DisposeControl(gControls->tw->proxySettingsBtn);
    }
    
    SetPort(oldPort);            
}
Ejemplo n.º 3
0
void tool_wind_fill_group_combo(void)
{
	int					n,group_idx;
	char				str[256];
	CFStringRef			cf_str;
	HMHelpContentRec	tag;
	
		// old settings
		
	group_idx=GetControl32BitValue(group_combo);
	
		// delete old control and menu
		
	DisposeControl(group_combo);
	
	DeleteMenu(160);
	DisposeMenu(group_menu);
	
		// recreate the menu
		
	CreateNewMenu(group_combo_menu_id,0,&group_menu);
	
	cf_str=CFStringCreateWithCString(kCFAllocatorDefault,"No Group",kCFStringEncodingMacRoman);
	AppendMenuItemTextWithCFString(group_menu,cf_str,0,FOUR_CHAR_CODE('gp01'),NULL);
	CFRelease(cf_str);
	
	AppendMenuItemTextWithCFString(group_menu,NULL,kMenuItemAttrSeparator,0,NULL);
	
	for (n=0;n<map.ngroup;n++) {
		sprintf(str,"%s (%d)",map.groups[n].name,group_count(n));
		cf_str=CFStringCreateWithCString(kCFAllocatorDefault,str,kCFStringEncodingMacRoman);
		AppendMenuItemTextWithCFString(group_menu,cf_str,0,FOUR_CHAR_CODE('gp03'),NULL);
		CFRelease(cf_str);
	}
	
	InsertMenu(group_menu,kInsertHierarchicalMenu);
	
		// recreate the contorl
		
	CreatePopupButtonControl(toolwind,&group_box,NULL,group_combo_menu_id,FALSE,0,0,0,&group_combo);
	Draw1Control(group_combo);
	
		// build the help
	
	tag.version=kMacHelpVersion;
	tag.tagSide=kHMDefaultSide;
	SetRect(&tag.absHotRect,0,0,0,0);
	tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent;
	tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,"Segment Groups",kCFStringEncodingMacRoman);
	tag.content[kHMMaximumContentIndex].contentType=kHMNoContent;
		
	HMSetControlHelpContent(group_combo,&tag);
	
		// reset the control
		
	SetControl32BitValue(group_combo,group_idx);
}
Ejemplo n.º 4
0
void tool_wind_close(void)
{
	int			t;
	
	for ((t=0);(t!=maxtool);t++) {
		DisposeControl(tool_ctrl[t]);
	}
	
	DisposeControl(magnify_icon);
	DisposeControl(magnify_slider);
	DisposeControlActionUPP(magnify_proc);
	
	DisposeControl(group_combo);
	DisposeMenu(group_menu);

	RemoveEventHandler(tool_wind_event);
	DisposeEventHandlerUPP(tool_wind_upp);
	
	DisposeWindow(toolwind);
}
Ejemplo n.º 5
0
void
TkpDestroyButton(
    TkButton *butPtr)
{
    MacButton *mbPtr = (MacButton *) butPtr; /* Mac button. */

    if (mbPtr->userPane) {
	DisposeControl(mbPtr->userPane);
	mbPtr->userPane = NULL;
    }
}
Ejemplo n.º 6
0
P1(PUBLIC pascal trap, void, LDispose, ListHandle, list)	/* IMIV-271 */
{
  if (list)
    {
      LISTDECL();
      LISTBEGIN(list);
      LISTCALL(lCloseMsg, FALSE, (Rect *)0, * (Cell *) &HxX(list, clikLoc), 0,
	       0, list);
      LISTEND(list);

      DisposHandle((Handle) HxP(list, cells));
      if (HxP(list, hScroll))
	DisposeControl(HxP(list, hScroll));
      if (HxP(list, vScroll))
	DisposeControl(HxP(list, vScroll));
    }
#if defined (LIST_DEBUG)
  delete_list (list);
#endif  
}
Ejemplo n.º 7
0
void
TkpDestroyScale(
    TkScale *scalePtr)
{
    MacScale *macScalePtr = (MacScale *) scalePtr;

    /*
     * Free Macintosh control.
     */

    if (macScalePtr->scaleHandle != NULL) {
	DisposeControl(macScalePtr->scaleHandle);
    }
}
Ejemplo n.º 8
0
AUCarbonViewBase::~AUCarbonViewBase()
{
    if (mCarbonPane)
        DisposeControl(mCarbonPane);

    for (ControlList::iterator it = mControlList.begin(); it != mControlList.end(); ++it) {
        AUCarbonViewControl *ctl = *it;
        delete ctl;
    }
    AUListenerDispose(mParameterListener);

    if (mTimerRef)
        ::RemoveEventLoopTimer (mTimerRef);

    if (mTimerUPP)
        ::DisposeEventLoopTimerUPP (mTimerUPP);
}
Ejemplo n.º 9
0
void
TkpDestroyMenuButton(
    TkMenuButton *mbPtr)
{
    MacMenuButton * macMbPtr = (MacMenuButton *)mbPtr;
    if (macMbPtr->userPane) {
        DisposeControl(macMbPtr->userPane);
        macMbPtr->userPane = NULL;
    }
    if (macMbPtr->menuRef) {
        short menuID;
        menuID = GetMenuID(macMbPtr->menuRef);
        TkMacOSXFreeMenuID(menuID);
        DisposeMenu(macMbPtr->menuRef);
        macMbPtr->menuRef = NULL;
    }
}
OSStatus CreateYASTControl(WindowRef theWindow, Rect *bounds, ControlRef *theControl) {
	UInt32 featurSet;
	ControlRef theNewControl;
	OSStatus err;
	
		/* feature flags for our control. */
	featurSet = kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle
			| kControlWantsActivate | kControlHasSpecialBackground
			| kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
			
		/* create the control */
	err = CreateUserPaneControl( theWindow,  bounds, featurSet, &theNewControl);
	if (err == noErr) {
			/* set up the txn features */
		err = YASTControlAttachToExistingControl(theNewControl);
		if (err == noErr) {
			*theControl = theNewControl;
		} else {
			DisposeControl(theNewControl);
		}
	}
		/* all done.... */
	return err;
}
Ejemplo n.º 11
0
void
TkpDisplayMenuButton(
    ClientData clientData)        /* Information about widget. */
{
    TkMenuButton *butPtr = (TkMenuButton *) clientData;
    Tk_Window tkwin = butPtr->tkwin;
    TkWindow *  winPtr;
    Pixmap      pixmap;
    MacMenuButton * mbPtr = (MacMenuButton *) butPtr;
    GWorldPtr dstPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    int      hasImageOrBitmap = 0;
    int      width, height;
    int      err;
    ControlButtonGraphicAlignment theAlignment;

    Rect paneRect, cntrRect;

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

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

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

    /*
     * We need to cache the title and its style
     */
    if (!(mbPtr->flags&2)) {
        ControlTitleParams titleParams;
        int                titleChanged;
        int                styleChanged;
        ComputeControlTitleParams(butPtr,&titleParams);
        CompareControlTitleParams(&titleParams,&mbPtr->titleParams,
            &titleChanged,&styleChanged);
        if (titleChanged) {
            CFStringRef cf;    	    
            cf = CFStringCreateWithCString(NULL,
                  titleParams.title, kCFStringEncodingUTF8);
            if (hasImageOrBitmap) {
                SetControlTitleWithCFString(mbPtr->control, cf);
            } else {
                SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf);
            }
            CFRelease(cf);
            bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1);
            mbPtr->titleParams.len = titleParams.len;
        }
        if ((titleChanged||styleChanged) && titleParams .len) {
            if (hasImageOrBitmap) {
                if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) {
                    fprintf(stderr,"SetControlFontStyle failed %d\n", err);
                    return;
                }
            }
            bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style));
        }
    }
    if (butPtr->image != None) {
        Tk_SizeOfImage(butPtr->image, &width, &height);
        hasImageOrBitmap = 1;
    } else if (butPtr->bitmap != None) {
        Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
        hasImageOrBitmap = 1;
    }
    if (hasImageOrBitmap) {
        mbPtr->picParams.srcRect.right = width;
        mbPtr->picParams.srcRect.bottom = height; 
        /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */
        tkPictureIsOpen = 1;
        if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) {
            fprintf(stderr,"OpenCPicture failed\n");
        }
        /*
         * TO DO - There is one case where XCopyPlane calls CopyDeepMask,
         * which does not get recorded in the picture.  So the bitmap code
         * will fail in that case.
         */
        if (butPtr->image != NULL) {
            Tk_RedrawImage(butPtr->image, 0, 0, width,
                height, pixmap, 0, 0);
        } else {   
            XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0,
                (unsigned int) width, (unsigned int) height, 0, 0, 1);
        }
        ClosePicture();
        
        tkPictureIsOpen = 0;
        if ( (err=SetControlData(mbPtr->control, kControlButtonPart,
                    kControlBevelButtonContentTag,
                    sizeof(ControlButtonContentInfo),
                    (char *) &mbPtr->bevelButtonContent)) != noErr ) {
                fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err );
        }
        switch (butPtr->anchor) {
            case TK_ANCHOR_N:
                theAlignment = kControlBevelButtonAlignTop;
                break;
            case TK_ANCHOR_NE:
                theAlignment = kControlBevelButtonAlignTopRight;
                break;
            case TK_ANCHOR_E:
                theAlignment = kControlBevelButtonAlignRight;
                break;
            case TK_ANCHOR_SE:
                theAlignment = kControlBevelButtonAlignBottomRight;
                break;
            case TK_ANCHOR_S:
                theAlignment = kControlBevelButtonAlignBottom;
                break;
            case TK_ANCHOR_SW:
                theAlignment = kControlBevelButtonAlignBottomLeft;
                break;
            case TK_ANCHOR_W:
                theAlignment = kControlBevelButtonAlignLeft;
                break;
            case TK_ANCHOR_NW:
                theAlignment = kControlBevelButtonAlignTopLeft;
                break;
            case TK_ANCHOR_CENTER:
                theAlignment = kControlBevelButtonAlignCenter;
                break;
        }
    
        if ((err=SetControlData(mbPtr->control, kControlButtonPart,
                kControlBevelButtonGraphicAlignTag,
                sizeof(ControlButtonGraphicAlignment),
                (char *) &theAlignment)) != noErr ) {
            fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err );
        }
    }
    if (butPtr->flags & GOT_FOCUS) {
        HiliteControl(mbPtr->control,kControlButtonPart);
    } else {
        HiliteControl(mbPtr->control,kControlNoPart);
    }
    UpdateControlColors(mbPtr);
    if (mbPtr->flags&2) {
        ShowControl(mbPtr->control);
        ShowControl(mbPtr->userPane);
        mbPtr->flags ^= 2;
    } else {
        Draw1Control(mbPtr->userPane);
        SetControlVisibility(mbPtr->control, true, true);
    }
    if (hasImageOrBitmap) {
        KillPicture(mbPtr->bevelButtonContent.u.picture);
    }
    SetGWorld(saveWorld, saveDevice);
}
Ejemplo n.º 12
0
void Separator::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}
Ejemplo n.º 13
0
OSStatus
InitDataBrowserControl()
{
    DataBrowserCallbacks 	myCallbacks;
    ControlID 			controlID = { kNSLSample, kUserPaneControl };
    ControlRef			control;
    Rect			outRect;
    OSStatus			err;
    int				i;

    err = GetControlByID(gMainWindow, &controlID, &control);
    if (err == noErr)
    {
        GetControlBounds(control, &outRect);
        DisposeControl(control);
    }
    else
    {
        return err;
    }
    
    if (gDataBrowserControl == NULL)
    {
        err = CreateDataBrowserControl(gMainWindow, &outRect, kDataBrowserListView, &gDataBrowserControl);
        if (err == noErr)
        {
            AdvanceKeyboardFocus(gMainWindow);
            SetDataBrowserHasScrollBars(gDataBrowserControl, false, true);
            SetDataBrowserTableViewRowHeight(gDataBrowserControl, kDataBrowserRowHeight);
            SetDataBrowserSortOrder(gDataBrowserControl, kDataBrowserOrderIncreasing);
            SetDataBrowserSelectionFlags(gDataBrowserControl, kDataBrowserSelectOnlyOne);
            SetDataBrowserListViewUsePlainBackground(gDataBrowserControl, false);
    
            myCallbacks.version = kDataBrowserLatestCallbacks;
            InitDataBrowserCallbacks(&myCallbacks);
    
        #if USE_OLD_DATA_BROWSER_STRUCTS    
            myCallbacks.u.v1.clientDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.compareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #else
            myCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP((DataBrowserItemDataProcPtr)MySimpleDataCallback);
            myCallbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP((DataBrowserItemCompareProcPtr)MyDataBrowserItemCompareUPP);
        #endif
            
            myCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP((DataBrowserItemNotificationProcPtr)MySimpleNotificationCallback);

            err = SetDataBrowserCallbacks(gDataBrowserControl, &myCallbacks);
            if (err != noErr) return err;
        }
        else
        {
            return err;
        }
    }
    
    err = AddNameColumnToList();
    if (err == noErr)
    {        
        SetDataBrowserListViewDisclosureColumn(gDataBrowserControl, kNameColumn, false);
        SetDataBrowserSortProperty(gDataBrowserControl, kNameColumn);        
        
        for (i = 0; i < kMaxNeighborhoods; i++)
        {
            gNeighborhoodInfo.neighborhoodSize[i] = 0;
            gNeighborhoodInfo.isNeighborhoodOpen[i] = false;
            gNeighborhoodInfo.isDefaultNeighborhood[i] = false;
            gNeighborhoodInfo.isNeighborhoodVisible[i] = false;
            gLookupInfo[i + 1].sLookupActive = false;
            gLookupInfo[i + 1].nLookupActive = false;
        }
        
        gNeighborhoodInfo.neighborhoodCount = 0;
        gSelectedItem = 0;
        
        DoNeighborhoodLookup(kDefaultNeighborhoods);
    }
    
    return err;
}
Ejemplo n.º 14
0
void Placard::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}
Ejemplo n.º 15
0
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, &params);
	if (rebuild || bcmp(&params, &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);
	}
    }
}
Ejemplo n.º 16
0
void
TkpDisplayButton(
    ClientData clientData)	/* Information about widget. */
{
    MacButton *macButtonPtr = (MacButton *) clientData;
    TkButton *butPtr = (TkButton *) clientData;
    Tk_Window tkwin = butPtr->tkwin;
    CGrafPtr destPort, savePort;
    Boolean portChanged;
    Pixmap pixmap;
    int width, height, fullWidth, fullHeight, textXOffset, textYOffset;
    int borderWidth, wasUsingControl;
    int haveImage = 0, haveText = 0, imageWidth = 0, imageHeight = 0;
    int imageXOffset = 0, imageYOffset = 0; /* image information that will
					     * be used to restrict disabled
					     * pixmap as well */
    DrawParams drawParams, *dpPtr = &drawParams;

    butPtr->flags &= ~REDRAW_PENDING;
    if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
	return;
    }
    pixmap = (Pixmap) Tk_WindowId(tkwin);
    wasUsingControl = macButtonPtr->usingControl;

    if (TkMacOSXComputeDrawParams(butPtr, &drawParams) ) {
	macButtonPtr->usingControl = 1;
	if (butPtr->type == TYPE_BUTTON) {
	    macButtonPtr->useTkText = 0;
	} else {
	    macButtonPtr->useTkText = 1;
	}
    } else {
	macButtonPtr->usingControl = 0;
	macButtonPtr->useTkText = 1;
    }

    /*
     * See the comment in UpdateControlColors as to why we use the
     * highlightbackground for the border of Macintosh buttons.
     */

    if (macButtonPtr->useTkText) {
	if (butPtr->type == TYPE_BUTTON) {
	    Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
		    Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
	} else {
	    Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
		    Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
	}
    }

    /*
     * Set up clipping region. Make sure the we are using the port
     * for this button, or we will set the wrong window's clip.
     */

    destPort = TkMacOSXGetDrawablePort(pixmap);
    portChanged = QDSwapPort(destPort, &savePort);
    TkMacOSXSetUpClippingRgn(pixmap);

    /*
     * Draw the native portion of the buttons. Start by creating the control
     * if it doesn't already exist. Then configure the Macintosh control from
     * the Tk info. Finally, we call Draw1Control to draw to the screen.
     */

    if (macButtonPtr->usingControl) {
	borderWidth = 0;
	TkMacOSXDrawControl(macButtonPtr, destPort, dpPtr->gc, pixmap);
    } else if (wasUsingControl && macButtonPtr->userPane) {
	DisposeControl(macButtonPtr->userPane);
	macButtonPtr->userPane = NULL;
	macButtonPtr->control = NULL;
	macButtonPtr->flags = 0;
    }

    if ((dpPtr->drawType == DRAW_CUSTOM) || (dpPtr->drawType == DRAW_LABEL)) {
	borderWidth = butPtr->borderWidth;
    }

    /*
     * Display image or bitmap or text for button. This has
     * already been done under Appearance with the Bevel
     * button types.
     */

    if (dpPtr->drawType == DRAW_BEVEL) {
	goto applyStipple;
    }

    if (butPtr->image != None) {
	Tk_SizeOfImage(butPtr->image, &width, &height);
	haveImage = 1;
    } else if (butPtr->bitmap != None) {
	Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
	haveImage = 1;
    }
    imageWidth = width;
    imageHeight = height;

    haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
    if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
	int x, y;

	textXOffset = 0;
	textYOffset = 0;
	fullWidth = 0;
	fullHeight = 0;

	switch ((enum compound) butPtr->compound) {
	    case COMPOUND_TOP:
	    case COMPOUND_BOTTOM:
		/*
		 * Image is above or below text.
		 */
		if (butPtr->compound == COMPOUND_TOP) {
		    textYOffset = height + butPtr->padY;
		} else {
		    imageYOffset = butPtr->textHeight + butPtr->padY;
		}
		fullHeight = height + butPtr->textHeight + butPtr->padY;
		fullWidth = (width > butPtr->textWidth ? width :
			butPtr->textWidth);
		textXOffset = (fullWidth - butPtr->textWidth)/2;
		imageXOffset = (fullWidth - width)/2;
		break;

	    case COMPOUND_LEFT:
	    case COMPOUND_RIGHT:
		/*
		 * Image is left or right of text.
		 */

		if (butPtr->compound == COMPOUND_LEFT) {
		    textXOffset = width + butPtr->padX;
		} else {
		    imageXOffset = butPtr->textWidth + butPtr->padX;
		}
		fullWidth = butPtr->textWidth + butPtr->padX + width;
		fullHeight = (height > butPtr->textHeight ? height :
			butPtr->textHeight);
		textYOffset = (fullHeight - butPtr->textHeight)/2;
		imageYOffset = (fullHeight - height)/2;
		break;

	    case COMPOUND_CENTER:
		/*
		 * Image and text are superimposed.
		 */

		fullWidth = (width > butPtr->textWidth ? width :
			butPtr->textWidth);
		fullHeight = (height > butPtr->textHeight ? height :
			butPtr->textHeight);
		textXOffset = (fullWidth - butPtr->textWidth)/2;
		imageXOffset = (fullWidth - width)/2;
		textYOffset = (fullHeight - butPtr->textHeight)/2;
		imageYOffset = (fullHeight - height)/2;
		break;

	    case COMPOUND_NONE:
		break;
	}

	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);

	x += butPtr->indicatorSpace;

	x += dpPtr->offset;
	y += dpPtr->offset;
	if (dpPtr->relief == TK_RELIEF_RAISED) {
	    x -= dpPtr->offset;
	    y -= dpPtr->offset;
	} else if (dpPtr->relief == TK_RELIEF_SUNKEN) {
	    x += dpPtr->offset;
	    y += dpPtr->offset;
	}
	imageXOffset += x;
	imageYOffset += y;
	if (butPtr->image != NULL) {
	    if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
		Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
#if 0
	    } else if ((butPtr->tristateImage != NULL) &&
		    (butPtr->flags & TRISTATED)) {
		Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
#endif
	    } else {
		Tk_RedrawImage(butPtr->image, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
	    }
	} else {
	    XSetClipOrigin(butPtr->display, dpPtr->gc, imageXOffset,
		    imageYOffset);
	    XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
		    0, 0, width, height, imageXOffset, imageYOffset, 1);
	    XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
	}

	if (macButtonPtr->useTkText) {
	    Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
		    butPtr->textLayout, x + textXOffset, y + textYOffset, 0,
		    -1);
	    Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc,
		    butPtr->textLayout, x + textXOffset, y + textYOffset,
		    butPtr->underline);
	}
	y += fullHeight/2;
    } else if (haveImage) {
	int x = 0, y;

	TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
		butPtr->indicatorSpace + width, height, &x, &y);
	x += butPtr->indicatorSpace;

	x += dpPtr->offset;
	y += dpPtr->offset;
	if (dpPtr->relief == TK_RELIEF_RAISED) {
	    x -= dpPtr->offset;
	    y -= dpPtr->offset;
	} else if (dpPtr->relief == TK_RELIEF_SUNKEN) {
	    x += dpPtr->offset;
	    y += dpPtr->offset;
	}
	imageXOffset += x;
	imageYOffset += y;
	if (butPtr->image != NULL) {
	    if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
		Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
#if 0
	    } else if ((butPtr->tristateImage != NULL) &&
		    (butPtr->flags & TRISTATED)) {
		Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
#endif
	    } else {
		Tk_RedrawImage(butPtr->image, 0, 0, width, height,
			pixmap, imageXOffset, imageYOffset);
	    }
	} else {
	    XSetClipOrigin(butPtr->display, dpPtr->gc, x, y);
	    XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
		    0, 0, width, height, x, y, 1);
	    XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
	}
	y += height/2;
    } else if (macButtonPtr->useTkText) {
	int x = 0, y;

	TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
		butPtr->indicatorSpace + butPtr->textWidth,
		butPtr->textHeight, &x, &y);
	x += butPtr->indicatorSpace;
	Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
		butPtr->textLayout, x, y, 0, -1);
    }

    /*
     * If the button is disabled with a stipple rather than a special
     * foreground color, generate the stippled effect. If the widget
     * is selected and we use a different background color when selected,
     * must temporarily modify the GC so the stippling is the right color.
     */

  applyStipple:
    if (macButtonPtr->useTkText) {
	if ((butPtr->state == STATE_DISABLED)
		&& ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) {
	    if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
		    && (butPtr->selectBorder != NULL)) {
		XSetForeground(butPtr->display, butPtr->stippleGC,
			Tk_3DBorderColor(butPtr->selectBorder)->pixel);
	    }

	    /*
	     * Stipple the whole button if no disabledFg was specified,
	     * otherwise restrict stippling only to displayed image
	     */

	    if (butPtr->disabledFg == NULL) {
		XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
			0, 0, (unsigned) Tk_Width(tkwin),
			(unsigned) Tk_Height(tkwin));
	    } else {
		XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC,
			imageXOffset, imageYOffset,
			(unsigned) imageWidth, (unsigned) imageHeight);
	    }
	    if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn
		    && (butPtr->selectBorder != NULL)) {
		XSetForeground(butPtr->display, butPtr->stippleGC,
			Tk_3DBorderColor(butPtr->normalBorder)->pixel);
	    }
	}

	/*
	 * Draw the border and traversal highlight last. This way, if the
	 * button's contents overflow they'll be covered up by the border.
	 */

	if (dpPtr->relief != TK_RELIEF_FLAT) {
	    int inset = butPtr->highlightWidth;

	    Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset,
		    Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
		    butPtr->borderWidth, dpPtr->relief);
	}
    }
    if (portChanged) {
	QDSwapPort(savePort, NULL);
    }
}
Ejemplo n.º 17
0
void RelevanceBar::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}
Ejemplo n.º 18
0
 ~wxToolBarTool()
 {
     if ( m_controlHandle )
         DisposeControl( m_controlHandle ) ;
 }
Ejemplo n.º 19
0
void SearchField::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}
Ejemplo n.º 20
0
void ProgressBar::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}
Ejemplo n.º 21
0
void PopUpButton::dispose()
{
  cleanup();
  DisposeControl(getControlRef());
}