1 /**************************************************************************\ 2 * 3 * This file is part of the Coin 3D visualization library. 4 * Copyright (C) by Kongsberg Oil & Gas Technologies. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * ("GPL") version 2 as published by the Free Software Foundation. 9 * See the file LICENSE.GPL at the root directory of this source 10 * distribution for additional information about the GNU GPL. 11 * 12 * For using Coin with software that can not be combined with the GNU 13 * GPL, and for taking advantage of the additional benefits of our 14 * support services, please contact Kongsberg Oil & Gas Technologies 15 * about acquiring a Coin Professional Edition License. 16 * 17 * See http://www.coin3d.org/ for more information. 18 * 19 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY. 20 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 21 * 22 \**************************************************************************/ 23 24 // $Id$ 25 26 #ifndef SOXT_XTNATIVEPOPUPMENU_H 27 #define SOXT_XTNATIVEPOPUPMENU_H 28 29 #include <X11/Intrinsic.h> 30 31 #include <Inventor/SoLists.h> 32 33 #include <Inventor/Xt/SoXtBasic.h> 34 #include <Inventor/Xt/widgets/SoXtPopupMenu.h> 35 36 // ************************************************************************* 37 38 struct MenuRecord; 39 struct ItemRecord; 40 41 class XtNativePopupMenu : public SoXtPopupMenu { 42 typedef SoXtPopupMenu inherited; 43 44 public: 45 XtNativePopupMenu(void); 46 virtual ~XtNativePopupMenu(void); 47 48 virtual int newMenu(const char * name, int menuid = -1); 49 virtual int getMenu(const char * name); 50 virtual void setMenuTitle(int id, const char * title); 51 virtual const char * getMenuTitle(int id); 52 53 virtual int newMenuItem(const char * name, int itemid = -1); 54 virtual int getMenuItem(const char * name); 55 virtual void setMenuItemTitle(int itemid, const char * title); 56 virtual const char * getMenuItemTitle(int itemid); 57 virtual void setMenuItemEnabled(int itemid, SbBool enabled); 58 virtual SbBool getMenuItemEnabled(int itemid); 59 virtual SbBool getMenuItemMarked(int itemid); 60 61 virtual void addMenu(int menuid, int submenuid, int pos = -1); 62 virtual void addMenuItem(int menuid, int itemid, int pos = -1); 63 virtual void addSeparator(int menuid, int pos = -1); 64 virtual void removeMenu(int menuid); 65 virtual void removeMenuItem(int itemid); 66 67 virtual void popUp(Widget inside, int x, int y); 68 69 protected: 70 virtual void _setMenuItemMarked(int itemid, SbBool marked); 71 72 MenuRecord * getMenuRecord(int menuid); 73 ItemRecord * getItemRecord(int itemid); 74 MenuRecord * createMenuRecord(const char * name); 75 ItemRecord * createItemRecord(const char * name); 76 77 Widget build(Widget parent); 78 Widget traverseBuild(Widget parent, MenuRecord * menu, int indent); 79 80 void itemSelection(Widget w, XtPointer call); 81 static void itemSelectionCallback(Widget, XtPointer client, XtPointer call); 82 83 private: 84 SbPList * menus; 85 SbPList * items; 86 Widget popup; 87 SbBool dirty; 88 89 }; // class XtNativePopupMenu 90 91 // ************************************************************************* 92 93 #endif // ! SOXT_XTNATIVEPOPUPMENU_H 94