本文整理汇总了C++中ChkErr函数的典型用法代码示例。如果您正苦于以下问题:C++ ChkErr函数的具体用法?C++ ChkErr怎么用?C++ ChkErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ChkErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MenuEventHandlerProc
static OSStatus
MenuEventHandlerProc(
EventHandlerCallRef callRef,
EventRef event,
void *userData)
{
OSStatus result = eventNotHandledErr, err;
int menuContext;
err = ChkErr(GetEventParameter, event, kEventParamMenuContext, typeUInt32,
NULL, sizeof(menuContext), NULL, &menuContext);
if (err == noErr && (menuContext & kMenuContextMenuBarTracking)) {
if (gInterp) {
Tcl_Obj *path = GetWidgetDemoPath(gInterp);
if (path) {
Tcl_IncrRefCount(path);
if (Tcl_FSAccess(path, R_OK) == 0) {
EnableMenuItem(tkFileMenu, kDemoItem);
}
Tcl_DecrRefCount(path);
}
}
ChkErr(RemoveEventHandler, menuEventHandlerRef);
menuEventHandlerRef = NULL;
result = noErr;
}
return result;
}
示例2: InstallStandardApplicationEventHandler
static OSStatus
InstallStandardApplicationEventHandler(void)
{
OSStatus err = memFullErr;
TK_IF_HI_TOOLBOX(5,
/*
* The approach below does not work correctly in Leopard, it leads to
* crashes in [NSView unlockFocus] whenever HIToolbox uses Cocoa (Help
* menu, Nav Services, Color Picker). While it is now possible to
* install the standard app handler with InstallStandardEventHandler(),
* to fully replicate RAEL the standard menubar event handler also needs
* to be installed. Unfortunately there appears to be no public API to
* obtain the menubar event target. As a workaround, for now we resort
* to calling the HIToolbox-internal GetMenuBarEventTarget() directly
* (symbol acquired via TkMacOSXInitNamedSymbol() from HIToolbox
* version 343, may not exist in later versions).
*/
err = ChkErr(InstallStandardEventHandler, GetApplicationEventTarget());
TkMacOSXInitNamedSymbol(HIToolbox, EventTargetRef,
GetMenuBarEventTarget, void);
if (GetMenuBarEventTarget) {
ChkErr(InstallStandardEventHandler, GetMenuBarEventTarget());
} else {
TkMacOSXDbgMsg("Unable to install standard menubar event handler");
}
) TK_ELSE_HI_TOOLBOX (5,
示例3: DisclosureElementSize
static void DisclosureElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
*widthPtr = s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
*heightPtr = s;
}
示例4: SpinButtonElementSize
static void SpinButtonElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
*widthPtr = s + Ttk_PaddingWidth(SpinbuttonMargins);
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
*heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins);
}
示例5: Tk_MacOSXIsAppInFront
int
Tk_MacOSXIsAppInFront(void)
{
OSStatus err;
ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
Boolean isFrontProcess = true;
err = ChkErr(GetFrontProcess, &frontPsn);
if (err == noErr) {
ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess);
}
return (isFrontProcess == true);
}
示例6: TreeHeaderElementDraw
static void TreeHeaderElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
ThemeButtonParams *params = clientData;
CGRect bounds = BoxToRect(d, b);
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = params->kind,
.value = Ttk_StateTableLookup(TreeHeaderValueTable, state),
.adornment = Ttk_StateTableLookup(TreeHeaderAdornmentTable, state),
};
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
END_DRAWING
}
static Ttk_ElementSpec TreeHeaderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
ButtonElementSizeNoPadding,
TreeHeaderElementDraw
};
/*
* Disclosure triangle:
*/
#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1
#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2
static Ttk_StateTable DisclosureValueTable[] = {
{ kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0 },
{ kThemeDisclosureRight, 0, 0 },
};
static void DisclosureElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
*widthPtr = s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
*heightPtr = s;
}
示例7: TkMacOSXSetWithNativeRegion
void
TkMacOSXSetWithNativeRegion(
TkRegion r,
HIShapeRef rgn)
{
ChkErr(TkMacOSXHIShapeSetWithShape, (HIMutableShapeRef) r, rgn);
}
示例8: ButtonElementSize
static void ButtonElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
ThemeButtonParams *params = clientData;
const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0);
static const CGRect scratchBounds = {{0, 0}, {100, 100}};
CGRect contentBounds;
ButtonElementSizeNoPadding(
clientData, elementRecord, tkwin,
widthPtr, heightPtr, paddingPtr);
/*
* To compute internal padding, query the appearance manager
* for the content bounds of a dummy rectangle, then use
* the difference as the padding.
*/
ChkErr(HIThemeGetButtonContentBounds,
&scratchBounds, &info, &contentBounds);
paddingPtr->left = CGRectGetMinX(contentBounds);
paddingPtr->top = CGRectGetMinY(contentBounds);
paddingPtr->right = CGRectGetMaxX(scratchBounds) - CGRectGetMaxX(contentBounds) + 1;
paddingPtr->bottom = CGRectGetMaxY(scratchBounds) - CGRectGetMaxY(contentBounds);
/*
* Now add a little extra padding to account for drop shadows.
* @@@ SHOULD: call GetThemeButtonBackgroundBounds() instead.
*/
*paddingPtr = Ttk_AddPadding(*paddingPtr, ButtonMargins);
*widthPtr += Ttk_PaddingWidth(ButtonMargins);
*heightPtr += Ttk_PaddingHeight(ButtonMargins);
}
示例9: computeButtonDrawInfo
/*
* computeButtonDrawInfo --
* Fill in an appearance manager HIThemeButtonDrawInfo record.
*/
static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
ThemeButtonParams *params, Ttk_State state)
{
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = params ? params->kind : 0,
.value = Ttk_StateTableLookup(ButtonValueTable, state),
.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
};
return info;
}
static void ButtonElementSizeNoPadding(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
ThemeButtonParams *params = clientData;
if (params->heightMetric != NoThemeMetric) {
SInt32 height;
ChkErr(GetThemeMetric, params->heightMetric, &height);
*heightPtr = height;
}
}
示例10: ComboboxElementDraw
static void ComboboxElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ComboboxMargins));
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = kThemeComboBox,
.value = Ttk_StateTableLookup(ButtonValueTable, state),
.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
};
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
END_DRAWING
}
static Ttk_ElementSpec ComboboxElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
ComboboxElementSize,
ComboboxElementDraw
};
/*----------------------------------------------------------------------
* +++ Spinbuttons.
*
* From Apple HIG, part III, section "Controls", "The Stepper Control":
* there should be 2 pixels of space between the stepper control
* (AKA IncDecButton, AKA "little arrows") and the text field it modifies.
*/
static Ttk_Padding SpinbuttonMargins = {2,0,2,0};
static void SpinButtonElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
*widthPtr = s + Ttk_PaddingWidth(SpinbuttonMargins);
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
*heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins);
}
示例11: TkMacOSXOffsetRegion
void
TkMacOSXOffsetRegion(
TkRegion r,
short dx,
short dy)
{
ChkErr(HIShapeOffset, (HIMutableShapeRef) r, dx, dy);
}
示例12: EntryElementDraw
static void EntryElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
EntryElement *e = elementRecord;
Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,e->backgroundObj);
Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(3));
CGRect bounds = BoxToRect(d, inner);
const HIThemeFrameDrawInfo info = {
.version = 0,
.kind = kHIThemeFrameTextFieldSquare,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.isFocused = state & TTK_STATE_FOCUS,
};
/*
* Erase w/background color:
*/
XFillRectangle(Tk_Display(tkwin), d,
Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
inner.x,inner.y, inner.width, inner.height);
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
/*if (state & TTK_STATE_FOCUS) {
ChkErr(DrawThemeFocusRect, &bounds, 1);
}*/
END_DRAWING
}
static Ttk_ElementSpec EntryElementSpec = {
TK_STYLE_VERSION_2,
sizeof(EntryElement),
EntryElementOptions,
EntryElementSize,
EntryElementDraw
};
/*----------------------------------------------------------------------
* +++ Combobox:
*
* NOTES:
* kThemeMetricComboBoxLargeDisclosureWidth -> 17
* Padding and margins guesstimated by trial-and-error.
*/
static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 };
static Ttk_Padding ComboboxMargins = { 3, 3, 4, 4 };
static void ComboboxElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
*widthPtr = 0;
*heightPtr = 0;
*paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding);
}
示例13: TkSubtractRegion
void
TkSubtractRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
ChkErr(HIShapeDifference, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
}
示例14: TkIntersectRegion
void
TkIntersectRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
ChkErr(HIShapeIntersect, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
}
示例15: TkUnionRectWithRegion
void
TkUnionRectWithRegion(
XRectangle* rectangle,
TkRegion src_region,
TkRegion dest_region_return)
{
const CGRect r = CGRectMake(rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
if (src_region == dest_region_return) {
ChkErr(TkMacOSHIShapeUnionWithRect,
(HIMutableShapeRef) dest_region_return, &r);
} else {
HIShapeRef rectRgn = HIShapeCreateWithRect(&r);
ChkErr(TkMacOSHIShapeUnion, rectRgn, (HIShapeRef) src_region,
(HIMutableShapeRef) dest_region_return);
CFRelease(rectRgn);
}
}