How to convert XmFontList to XmRenderTable? - Motif

This is a discussion on How to convert XmFontList to XmRenderTable? - Motif ; Hi alltogether, I want to convert the obsolete XmFontList (Motif 1.2) to an XmRenderTable (Motif 2.0). The reason for this is, that we need to define tab positions now, which can only be done with RenderTables. But I cannot find ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to convert XmFontList to XmRenderTable?

  1. How to convert XmFontList to XmRenderTable?

    Hi alltogether,

    I want to convert the obsolete XmFontList (Motif 1.2) to an
    XmRenderTable (Motif 2.0).

    The reason for this is, that we need to define tab positions now,
    which can only be done with RenderTables.

    But I cannot find an instruction how to convert a given XmFontList to
    an XmRenderTable. Can someone provide this information for me?

    Thanks, Sven


  2. Re: How to convert XmFontList to XmRenderTable?

    Sven wrote:
    > I want to convert the obsolete XmFontList (Motif 1.2) to an
    > XmRenderTable (Motif 2.0).
    >
    > The reason for this is, that we need to define tab positions now,
    > which can only be done with RenderTables.
    >
    > But I cannot find an instruction how to convert a given XmFontList to
    > an XmRenderTable. Can someone provide this information for me?


    I was able to do this based on the following information:
    http://www.motifdeveloper.com/tips/tip2.html

    Let me know if this helps you or you need a piece
    of my code.

    Best regards,

    DuĊĦan Peterc
    http://www.arahne.si

  3. Re: How to convert XmFontList to XmRenderTable?

    > I was able to do this based on the following information:http://www.motifdeveloper.com/tips/tip2.html
    >

    "For backwards compatibility, the XmFontList has been internally re-
    implemented as a Render Table (although the render table it creates
    only contains font data)."

    Does this mean, that I do not have to convert XmFontList to
    XmRenderTable, because it already is one? If this is right, then I do
    not understand why my program crashes then:

    void StringDraw( HDC hDC, XmFontList fontlist, XmString string,
    int x, int y, int width, unsigned alignment,
    unsigned dir, XRectangle *clip )
    {
    Widget w = hDC->w;
    GC gc = hDC->gc;
    Display *display = XtDisplay( w );
    Drawable d = hDC->drw;
    Dimension wh, h;
    XRectangle rc;

    #ifndef __osf__
    motif_cpp:efaultTabRenderTable rendertable( w, fontlist );
    const XmFontList& fonts = rendertable.get();
    #else
    XmFontList& fonts = fontlist;
    #endif
    if (IsZoomed( hDC, False ))
    {
    XmStringExtent( fontlist, string, &wh, &h );
    rc.x = x;
    rc.y = y;
    rc.width = wh;
    rc.height = h;
    LRtoDR( hDC, &rc );
    if (rc.height >= nTextLimit)
    XmStringDraw( display, d, fonts, string, gc, rc.x, rc.y, rc.width,
    alignment, dir, clip );
    else if (bShowSmallText)
    {
    XSetForeground( display, gc, colors[CLR_GREY] );
    FillRectangle( hDC, x, y, wh, h );
    }
    }
    else
    {
    LCtoDC( hDC, &x, &y );
    XmStringDraw( display, d, fonts, string, gc, x, y, width,
    alignment, dir, clip );
    }
    }

    Thanks, Sven

  4. Re: How to convert XmFontList to XmRenderTable?

    Here is the essence of the code of the class:

    template class TabRenderTable {
    public: // --- public methods ---
    TabRenderTable( Widget pParent_, XmRenderTable copy_ = 0 )
    : m_pParent( pParent_ ), m_rendertable( copy_ ) {
    this->add_tab_rendition( 1000.0 );
    } // *** TabRenderTable() ***
    ~TabRenderTable() {
    if ( this->m_rendertable ) {
    XmRenderTableFree( this->m_rendertable );
    }
    }
    XmRenderTable get() const {
    return this->m_rendertable;
    }
    void add_tab_rendition( float fontunits_ = 1000.0 ) {
    // 1.create an XmTab object
    XmTab tabs[MAX_TABS];
    for ( size_t i=0; i < MAX_TABS; i++ ) {
    tabs[i] = XmTabCreate ( (float) fontunits_,
    Xm100TH_FONT_UNITS,
    ( (i==0) ? XmABSOLUTE : XmRELATIVE ),
    XmALIGNMENT_BEGINNING, "." );
    }

    // 2.create TabList. TabLists can be changed, copied etc. in many
    ways, see manual.
    // Alternativ mit XmStringTableProposeTablist()
    XmTabList tablist = XmTabListInsertTabs ( NULL, tabs,
    XtNumber(tabs), 0 );

    // 3.create a rendition that uses the tab list
    Arg args[20];
    size_t argc=0;
    XtSetArg ( args[argc], XmNtabList, tablist ); ++argc;
    XmRendition rendition = XmRenditionCreate ( m_pParent,
    XmFONTLIST_DEFAULT_TAG, args, argc );
    for ( size_t i=0; i < MAX_TABS; ++i ) {
    XmTabFree( tabs[i] );
    }
    XmTabListFree( tablist );
    // 4.create a render table which uses the rendition objects
    this->m_rendertable = XmRenderTableAddRenditions ( this-
    >m_rendertable, &rendition, 1, XmMERGE_NEW );

    XmRenditionFree( rendition );
    }
    void add_font_rendition( const char* pFontname_ ) {
    Arg args[20];
    size_t argc=0;
    XtSetArg ( args[argc], XmNfontName, pFontname_ ); ++argc;
    XtSetArg ( args[argc], XmNfontType, XmFONT_IS_FONT ); ++argc;
    XmRendition rendition = XmRenditionCreate ( m_pParent,
    XmFONTLIST_DEFAULT_TAG, args, argc );
    this->m_rendertable = XmRenderTableAddRenditions ( this-
    >m_rendertable, &rendition, 1, XmMERGE_NEW );

    XmRenditionFree( rendition );
    }
    private: // --- private attributes ---
    Widget m_pParent; //!< widget above in hierarchy
    XmRenderTable m_rendertable; //!< Motif representation
    }; // ### class TabRenderTable ###

    typedef TabRenderTable<10> DefaultTabRenderTable;

+ Reply to Thread