/* * An EntityStrBrowser is a deriviation of LStringBrowser for browsing entities * by name. There are two of these puppies in the browser interface -- one for * objects and the other for operations. Clicking on one of the contained * strings causes the current browser state to change. This includes, among * other things, the entity name to change and current text browser to scroll * to the selected entity. See rslbrowser.h for a more detailed discussion of * browser state change. */ #ifndef estrbrowserIncluded #define estrbrowserIncluded #include #include #include "lstrbrowser.h" #include "std-macros++.h" #include "entity.h" #include "esymtab.h" #include "browser.h" class EntityStrBrowser : public LStringBrowser { public: EntityStrBrowser(RSLBrowser* browser, int rows, int cols, EntityStructList* sl = 0); /* * Construct and call InstallNames with the given list if non-null. */ EntityStrBrowser* InstallNames(EntityStructList* el); /* * Stick the strings in the given list into this. */ EntityStrBrowser* ScrollToName(EntityStruct* es); /* * Scroll to the name of the given entity struct. This call should be a * noop if we're being called from UpdateBrowserState after having * initiated the update ourself. I.e., when the user clicks on this, * we'll call UpdateBrowserState, which will in turn call ScrollToName, * which we should ignore. On the other hand, if someone else (i.e., a * pulldown menu selection) initiated the call to UpdateBrowserState, * then the call to ScrolltoName should do its thing. * * Bottom line -- we tell if we need to do anything here by checking if * this->es->GetSym == es->GetSym(). */ void Handle(Event& e); /* * Custom event handler. For left click on the ith string, call * browser->UpdateCurEntity with the ith elem of the attached entity * list. */ bool HandleDownEvent(Event& e); bool HandleKeyEvent (Event& e); EntitySymtab* EntityStrBrowser::GetSymtab(); void Resize(); private: RSLBrowser* browser; /* The Big Cheese above */ EntityStructList* el; /* The list of what's displayed. */ EntityStruct* es; /* Where we are in the list */ EntitySymtab* symtab; /* Lookup tab of elem's in el */ }; /* * EnityStrBrowserPair is just the clumping of the two entity browsers. We * mostly have this so that we can remain functional. Viz., it's what * RSLBrowser::UpdateStrBrowsers returns. OK, I know -- who cares? */ class EntityStrBrowserPair { public: EntityStrBrowserPair(RSLBrowser* browser, int rows, int cols); EntityStrBrowser* InstallObjs(EntityStructList* el); EntityStrBrowser* InstallOps(EntityStructList* el); EntityStrBrowserPair* ScrollToName(EntityStruct *es); EntityStrBrowser* GetObjs(); EntityStrBrowser* GetOps(); EntityStruct* Lookup(const char* ename); EntityStrBrowserPair* Unselect(); Box* Layout(); Box* Layout(int distanceInInchesToOpsBrowser); private: EntityStrBrowser* objs; EntityStrBrowser* ops; RSLBrowser* browser; }; #endif