Re: Dynamic Menus


Subject: Re: Dynamic Menus
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Sat Sep 15 2001 - 10:19:08 CDT


On Sat, 15 Sep 2001, Joaquin Cuenca Abela wrote:

> Martin wrote:
> >
> >
> > On Thu, 13 Sep 2001, Joaquin Cuenca Abela wrote:
> >
> > > Jared wrote:
> > > > Hrmn. I'm still pretty confused. Let me see if I can get some more
> > > info...
> > > >
> > > > > The way to get a unused XAP_Menu_Id is to
> > > > > ask EV_Menu_LayoutSet for a new one.
> > > > >
> > > > > Let's assume that you know:
> > > > >
> > > > > * The label that this item will carry (for instance: "Thesaurus")
> <- I
> > > > > will call it "stLabel"
> > > > > * A position to put your item <- I will call it "nPos"
> > > > > * A function to callback (to simplify, let's assume that we only
> need
> > > a
> > > > > string with the name of the method to call back). <- I will call
> it
> > > > > "stCallback"
> > > > > You start creating a new menu item doing:
> > > > >
> > > > > XAP_Menu_Id id = m_pLayout->addLayoutItem(nPos, EV_MLF_Normal);
> > > >
> > > > Ok, right here I need a time out. What is m_pLayout? How do I get to
> it?
> > >
> > > Fair enough.
> > >
> > > The m_pLayout name is a fictive one. I was only trying to explain how
> to
> > > add a menu item *when* you have a pointer to the right EV_Menu_Layout,
> etc.
> > >
> > > To your question about how can you get a
> > > EV_Menu_{Layout,ActionSet,LabelSet}, I replied saying that right now
> it's
> > > *not* possible (if you're outside XAP_UnixFrame)
> >
> > Actually it is possible:
> >
> > XAP_App * pApp = XAP_App::getApp();
> > XAP_Frame * pFrame = pApp->getLastFocussedFrame();
> > XAP_UnixFrame * pUFrame = static_cast<XAP_UnixFrame *>(pFrame);
>
> If my memory still serves me right, it's not possible.
> This downcast has several disavantages, and still it doesn't achieves our
> goal (to be able to change the EV_Menu_Layout)
>
> * This code will only work on unix specific code, when really it should be
> perfectly xp.
> * If I remember right, there is no accesor to the layout & labels *even* in
> a UnixFrame (I will check that later)
> * Even with one accesor in UnixFrame, this way we will only change the menu
> of the last focussed frame, and that's hardly desired behaviour (I guess
> that we want to change the menu of *all* the frames).
>

Not a problem!

Simply use the pApp pointer to get all the xp info you want. ie from the
XAP_App.h file there are...

        UT_Bool updateClones(XAP_Frame * pFrame);

        UT_uint32 getFrameCount(void) const;
        XAP_Frame * getFrame(UT_uint32 ndx) const;
        UT_sint32 findFrame(XAP_Frame * pFrame);
        UT_sint32 findFrame(const char * szFilename);
        
        EV_EditMethodContainer * getEditMethodContainer(void) const;
        EV_EditBindingMap * getBindingMap(const char * szName);
        const EV_Menu_ActionSet * getMenuActionSet(void) const;
        const EV_Toolbar_ActionSet * getToolbarActionSet(void) const;

Want to update all the frames? Just loop through them :-)
 
Cheers

Martin



This archive was generated by hypermail 2b25 : Sat Sep 15 2001 - 10:19:25 CDT