SmallChange  1.0.0
A collection of extensions to Coin3D
Loading...
Searching...
No Matches
SmPopupMenuKit.h
1#ifndef SMALLCHANGE_SMPOPUPMENUKIT_H
2#define SMALLCHANGE_SMPOPUPMENUKIT_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/nodekits/SoSubKit.h>
37#include <Inventor/nodekits/SoBaseKit.h>
38#include <Inventor/fields/SoMFNode.h>
39#include <Inventor/fields/SoSFBool.h>
40#include <Inventor/fields/SoSFTime.h>
41#include <Inventor/fields/SoSFInt32.h>
42#include <Inventor/fields/SoSFFloat.h>
43#include <Inventor/fields/SoSFVec2s.h>
44#include <Inventor/fields/SoSFString.h>
45#include <Inventor/fields/SoMFString.h>
46#include <Inventor/fields/SoMFBool.h>
47#include <SmallChange/basic.h>
48
49class SmPopupMenuKitP;
50class SoSensor;
51class SoPickedPoint;
52class SbViewportRegion;
53class SbVec2f;
54
55class SMALLCHANGE_DLL_API SmPopupMenuKit : public SoBaseKit {
56 typedef SoBaseKit inherited;
57
58 SO_KIT_HEADER(SmPopupMenuKit);
59
60 SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
61 SO_KIT_CATALOG_ENTRY_HEADER(resetTransform);
62 SO_KIT_CATALOG_ENTRY_HEADER(transparencyType);
63 SO_KIT_CATALOG_ENTRY_HEADER(position);
64 SO_KIT_CATALOG_ENTRY_HEADER(depthBuffer);
65 SO_KIT_CATALOG_ENTRY_HEADER(lightModel);
66 SO_KIT_CATALOG_ENTRY_HEADER(camera);
67 SO_KIT_CATALOG_ENTRY_HEADER(texture);
68 SO_KIT_CATALOG_ENTRY_HEADER(shapeHints);
69 SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
70 SO_KIT_CATALOG_ENTRY_HEADER(materialBinding);
71 SO_KIT_CATALOG_ENTRY_HEADER(backgroundMaterial);
72 SO_KIT_CATALOG_ENTRY_HEADER(backgroundTexture);
73 SO_KIT_CATALOG_ENTRY_HEADER(justification);
74 SO_KIT_CATALOG_ENTRY_HEADER(backgroundShape);
75 SO_KIT_CATALOG_ENTRY_HEADER(textSeparator);
76 SO_KIT_CATALOG_ENTRY_HEADER(textFont);
77 SO_KIT_CATALOG_ENTRY_HEADER(textColor);
78 SO_KIT_CATALOG_ENTRY_HEADER(textPickStyle);
79 SO_KIT_CATALOG_ENTRY_HEADER(itemSeparator);
80 SO_KIT_CATALOG_ENTRY_HEADER(activeMaterial);
81 SO_KIT_CATALOG_ENTRY_HEADER(activeShape);
82 SO_KIT_CATALOG_ENTRY_HEADER(borderShape);
83 SO_KIT_CATALOG_ENTRY_HEADER(titleSeparator);
84
85
86public:
87 SmPopupMenuKit(void);
88 static void initClass(void);
89
90 virtual void GLRender(SoGLRenderAction * action);
91 virtual void handleEvent(SoHandleEventAction * action);
92 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
93 virtual void search(SoSearchAction * action);
94 virtual void callback(SoCallbackAction * action);
95 virtual void getMatrix(SoGetMatrixAction * action);
96 virtual void pick(SoPickAction * action);
97 virtual void rayPick(SoRayPickAction * action);
98 virtual void audioRender(SoAudioRenderAction * action);
99 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
100
101 static void setSchemeEvalFunctions(int (*scriptcb)(const char *),
102 void (*filecb)(const char *));
103
104protected:
105 virtual ~SmPopupMenuKit();
106 virtual SbBool affectsState(void) const;
107
108public:
109
110 void setTransparencies(float active, float inactive);
111 void setPickedPoint(const SoPickedPoint * pp, const SbViewportRegion & vp);
112 void setNormalizedPosition(const SbVec2f & npt);
113
114 void setViewportRegion(const SbViewportRegion & vp);
115
116 SoMFString itemList;
117 SoMFNode itemData;
118 SoMFString itemSchemeScript;
119 SoMFBool itemTagged;
120 SoMFBool itemDisabled;
121 SoSFString menuTitle;
122 SoSFBool visible;
123 SoSFBool isActive;
124
125 // signal
126 SoSFInt32 pickedItem;
127
128 SoSFInt32 frameSize;
129 SoSFVec2s offset;
130 SoSFFloat spacing;
131 SoSFBool closeParent;
132
133 void setParent(SmPopupMenuKit * kit);
134 void childFinished(SmPopupMenuKit * child);
135
136private:
137 void updateBackground(void);
138 void updateActiveItem(void);
139 void itemPicked(const int idx);
140
141 static void items_changed_cb(void * closure, SoSensor * s);
142 static void oneshot_cb(void * closure, SoSensor * s);
143 static void trigger_cb(void * closure, SoSensor * s);
144 static void activeitemchanged_cb(void * closure, SoSensor * s);
145 static void opensub_cb(void * closure, SoSensor * s);
146 static void isactive_cb(void * closure, SoSensor * s);
147 friend class SmPopupMenuKitP;
148 SmPopupMenuKitP * pimpl;
149};
150
151
152#endif // SMALLCHANGE_SMPOPUPMENUKIT_H
Definition misc/SbList.h:69
The SmPopupMenuKit class...
Definition SmPopupMenuKit.h:55
SoMFString itemList
Definition SmPopupMenuKit.h:116
SoSFInt32 frameSize
Definition SmPopupMenuKit.h:128
SoMFNode itemData
Definition SmPopupMenuKit.h:117
SoSFBool isActive
Definition SmPopupMenuKit.h:123