Statistics
| Branch: | Revision:

root / src / tkenv / inspector.h @ e1750c09

History | View | Annotate | Download (3.77 KB)

1 01873262 Georg Kunz
//==========================================================================
2
//  INSPECTOR.H - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
//==========================================================================
8
9
/*--------------------------------------------------------------*
10
  Copyright (C) 1992-2008 Andras Varga
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16
17
#ifndef __INSPECTOR_H
18
#define __INSPECTOR_H
19
20
#include <tk.h>
21
#include "tkutil.h"
22
#include "envirbase.h"
23
24
NAMESPACE_BEGIN
25
26
/**
27
 * Inspector types
28
 */
29
enum {
30
    INSP_DEFAULT,
31
    INSP_OBJECT,
32
    INSP_GRAPHICAL,
33
    INSP_MODULEOUTPUT,
34
    NUM_INSPECTORTYPES   // this must be the last one
35
};
36
37
38
// utility functions
39
const char *insptypeNameFromCode( int code );
40
int insptypeCodeFromName(const char *namestr);
41
void splitInspectorName(const char *namestr, cObject *&object, int& type);
42
43
44
45
/**
46
 * Virtual base class for all inspectors.
47
 */
48
class TKENV_API TInspector
49
{
50
   protected:
51
      cObject *object;        // the inspected object
52
      int type;               // INSP_OBJECT, etc.
53
      void *data;
54
      char windowname[24];    // Tk inspector window variable
55
      char windowtitle[128];  // window title string
56
      char geometry[64];      // X-window geometry string (window pos + size)
57
      bool toBeDeleted;       // "mark for deletion" flag (set if user wants to close inspector during animation)
58
   public:
59
      TInspector(cObject *obj, int typ, const char *geom, void *dat=NULL);
60
      virtual ~TInspector();
61
62
      virtual cObject *getObject() {return object;}
63
      virtual int getType() {return type;}
64
      virtual const char *windowName() {return windowname;}
65
66
      virtual void hostObjectDeleted();
67
      virtual void markForDeletion() {toBeDeleted=true;}
68
      virtual bool isMarkedForDeletion() {return toBeDeleted;}
69
70
      /** @name Virtual functions to be redefined in subclasses */
71
      //@{
72
      virtual void createWindow();
73
      bool windowExists();
74
      void showWindow();
75
76
      virtual void update();
77
      virtual void writeBack() {}
78
79
      virtual int inspectorCommand(Tcl_Interp *interp, int, const char **) {return TCL_ERROR;}
80
81
      virtual void objectDeleted(cObject *) {}
82
      //@}
83
84
      /** @name Utility functions */
85
      //@{
86
      void setEntry(const char *entry, const char *val);
87
      void setEntry(const char *entry, long l);
88
      void setEntry(const char *entry, double d);
89
      void setLabel(const char *label, const char *val);
90
      void setLabel(const char *label, long l);
91
      void setLabel(const char *label, double d);
92
      void setText(const char *entry, const char *val);
93
      void setReadonlyText(const char *entry, const char *val);
94
      const char *getEntry(const char *entry);
95
      void setInspectButton(const char *button, cObject *object, bool displayfullpath, int inspectortype);
96
      void setToolbarInspectButton(const char *button, cObject *object, int inspectortype);
97
98
      void deleteInspectorListbox(const char *listbox);
99
      void fillInspectorListbox(const char *listbox, cObject *object, bool deep);
100
      void fillListboxWithSubmodules(const char *listbox, cModule *parent);
101
      //@}
102
};
103
104
/**
105
 * Defines a panel that can be inserted into any inspector
106
 */
107
class TInspectorPanel
108
{
109
   protected:
110
      char widgetname[80];
111
      cObject *object;
112
   public:
113
      TInspectorPanel(const char *widgetname, cObject *obj);
114
      virtual ~TInspectorPanel() {}
115
      virtual void setObject(cObject *obj);
116
      virtual void update() = 0;
117
      virtual void writeBack() = 0;
118
      virtual int inspectorCommand(Tcl_Interp *, int, const char **) = 0;
119
};
120
121
NAMESPACE_END
122
123
124
#endif
125