cmGrPlot.h/c Added default plot obj callback function to mgr.
This commit is contained in:
parent
41a33a0333
commit
9d4c82ae37
21
cmGrPlot.c
21
cmGrPlot.c
@ -62,10 +62,12 @@ typedef struct cmGrPlotObj_str
|
||||
|
||||
typedef struct cmGrPl_str
|
||||
{
|
||||
cmCtx_t* ctx; //
|
||||
cmErr_t err; //
|
||||
cmGrPlotObj_t* list; // plot object linked list
|
||||
cmGrPlotObj_t* fop; // focused object ptr
|
||||
cmCtx_t* ctx; //
|
||||
cmErr_t err; //
|
||||
cmGrPlotObj_t* list; // plot object linked list
|
||||
cmGrPlotObj_t* fop; // focused object ptr
|
||||
cmGrPlotCbFunc_t cbFunc; // dflt callback function
|
||||
void* cbArg; // dflt callback function arg.
|
||||
} cmGrPl_t;
|
||||
|
||||
cmGrPlH_t cmGrPlNullHandle = cmSTATIC_NULL_HANDLE;
|
||||
@ -196,7 +198,7 @@ bool _cmGrPlotObjCb( cmGrPlotObj_t* op, cmGrPlCbSelId_t selId, unsigned deltaFla
|
||||
{
|
||||
cmGrPlotCbArg_t a;
|
||||
|
||||
_cmGrPlotObjSetupCbArg(&a,op,kPreEventCbSelGrPlId);
|
||||
_cmGrPlotObjSetupCbArg(&a,op,selId);
|
||||
a.deltaFlags = deltaFlags;
|
||||
return op->cbFunc(&a);
|
||||
}
|
||||
@ -743,6 +745,8 @@ cmGrPlRC_t cmGrPlotObjCreate(
|
||||
op->fontId = kHelveticaFfGrId;
|
||||
op->fontSize = 12;
|
||||
op->fontStyle = kNormalFsGrFl;
|
||||
op->cbFunc = p->cbFunc;
|
||||
op->cbArg = p->cbArg;
|
||||
|
||||
if( cmIsFlag(op->cfgFlags,kSymbolGrPlFl) )
|
||||
{
|
||||
@ -1232,3 +1236,10 @@ void cmGrPlotKeyEvent( cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKey
|
||||
_cmGrPlotObjEvent(&a, eventFlags, keycode, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg )
|
||||
{
|
||||
cmGrPl_t* p = _cmGrPlHandleToPtr(h);
|
||||
p->cbFunc = func;
|
||||
p->cbArg = arg;
|
||||
}
|
||||
|
13
cmGrPlot.h
13
cmGrPlot.h
@ -94,7 +94,7 @@ extern "C" {
|
||||
cmGrKeyCodeId_t eventKey; // Event keys (See the cmGrEvent() keys)
|
||||
int eventX; // Mouse X,Y location when event was generated (Same as cmGrEvent())
|
||||
int eventY; //
|
||||
unsigned deltaFlags; // Event caused an object state change (See kXXXGrPlFl flags)
|
||||
unsigned deltaFlags; // Event which caused an object state change (See kXXXGrPlFl flags)
|
||||
} cmGrPlotCbArg_t;
|
||||
|
||||
|
||||
@ -104,7 +104,8 @@ extern "C" {
|
||||
// the object has not yet been changed. This may be confusing because if
|
||||
// the state of the object is queried inside the callback it will have the
|
||||
// pre-change state - but this state will be automatically toggled when the
|
||||
// callback returns 'true'.
|
||||
// callback returns 'true'. Examine the arg->deltaFlags to determine the
|
||||
// state attribute which is changing.
|
||||
typedef bool (*cmGrPlotCbFunc_t)( cmGrPlotCbArg_t* arg );
|
||||
|
||||
extern cmGrPlH_t cmGrPlNullHandle;
|
||||
@ -201,13 +202,21 @@ extern "C" {
|
||||
cmGrPlRC_t cmGrPlotClear( cmGrPlH_t h ); // destroy all objects
|
||||
cmErr_t* cmGrPlotErr( cmGrPlH_t h );
|
||||
cmRpt_t* cmGrPlotRpt( cmGrPlH_t h );
|
||||
|
||||
// Return the count of plot objects.
|
||||
unsigned cmGrPlotObjectCount( cmGrPlH_t h );
|
||||
|
||||
// Return the handle of the ith object (0<=index<cmGrPlotObjectCount())
|
||||
cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
|
||||
|
||||
// Given a plot object id return the associated object handle.
|
||||
cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
|
||||
|
||||
// Pass a keyboard event to the plot system.
|
||||
void cmGrPlotKeyEvent( cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
|
||||
|
||||
// Set the default object callback and arg.
|
||||
void cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user