Menu

#6 public visability request

open
None
5
2009-05-08
2009-05-08
No

I would like to use the following types and function:

ItctObject
ItclClass
Itcl_GetContext()

I use the object context to associate to a C++ instance. It is still invisible to me without the itclInt.h header file and friends. Those components are not installed and still many years later I have to still build from source.

Discussion

  • David Gravereaux

    Just for fun, this is the the code I use in the base class:

    int GetItclObj (ItclObject **contextObj, Tcl_Obj *cmd)
    {
    ItclClass *contextClass;

    // Get the object context we are in
    if \(Itcl\_GetContext\(interp, &contextClass, contextObj\) \!= TCL\_OK
        || \!contextObj\) \{
        char \*token = Tcl\_GetString\(cmd\);
        Tcl\_ResetResult\(interp\);
        Tcl\_AppendStringsToObj\(Tcl\_GetObjResult\(interp\),
        "cannot use \"", token, "\" without an object context",
        0L\);
        return TCL\_ERROR;
    \}
    return TCL\_OK;
    

    }

    And this is an example of my use of it. And looks like I use Itcl_FindObject() as well.

    int
    GdiplusAdapter::GraphicsDrawArcCmd (int objc, struct Tcl_Obj * CONST objv[])
    {
    ItclObject *GraphicsItclObj;
    ItclObject *PenItclObj;
    Gdiplus::Graphics *graphicsPtr;
    Gdiplus::Pen *penPtr;
    Gdiplus::Status result;
    double x, y, width, height, startAngle, sweepAngle;

    if (objc != 8) {
    Tcl_WrongNumArgs(interp, 1, objv, "pen x y width height startAngle sweepAngle");
    return TCL_ERROR;
    }

    if (GetItclObj(&GraphicsItclObj, objv[0]) != TCL_OK) {
    return TCL_ERROR;
    }

    if (GraphicsHash.Find(GraphicsItclObj, &graphicsPtr) != TCL_OK) {
    Tcl_SetObjResult(interp,
    Tcl_NewStringObj("Gdiplus::Graphics instance lost!", -1));
    return TCL_ERROR;
    }

    // Dissect and disseminate all the arguments.

    // look for the pen ItclObject* from the commandname
    Itcl_FindObject(interp, Tcl_GetString(objv[1]), &PenItclObj);
    if (PenItclObj == 0L) {
    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "\"",
    Tcl_GetString(objv[1]), "\"",
    " was not a Gdiplus::Pen instance.", 0L);
    return TCL_ERROR;
    }

    // Get the Gdiplus::Pen* from the Itcl object context.
    if (PenHash.Find(PenItclObj, &penPtr) != TCL_OK) {
    Tcl_SetObjResult(interp,
    Tcl_NewStringObj("Gdiplus::Pen instance lost!", -1));
    return TCL_ERROR;
    }

    if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK) {
    return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK) {
    return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[4], &width) != TCL_OK) {
    return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[5], &height) != TCL_OK) {
    return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[6], &startAngle) != TCL_OK) {
    return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[7], &sweepAngle) != TCL_OK) {
    return TCL_ERROR;
    }

    result = graphicsPtr->DrawArc(
    penPtr,
    Gdiplus::RectF(
    static_cast<Gdiplus::REAL>(x),
    static_cast<Gdiplus::REAL>(y),
    static_cast<Gdiplus::REAL>(width),
    static_cast<Gdiplus::REAL>(height)
    ),
    static_cast<Gdiplus::REAL>(startAngle),
    static_cast<Gdiplus::REAL>(sweepAngle)
    );

    if (result != Gdiplus::Ok) {
    SetTclErrorMsg(result);
    return TCL_ERROR;
    }

    return TCL_OK;
    }

     
  • David Gravereaux

    • labels: 325545 -->
    • assigned_to: wiede --> nobody
     
  • David Gravereaux

    • assigned_to: nobody --> wiede
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.