Browse Source

Add tlCtl and libcmpp to this repo.

master
kevin 1 year ago
parent
commit
f2ea644147

+ 0
- 2
.gitignore View File

@@ -1,7 +1,5 @@
1 1
 # directories to ignore
2 2
 libcm
3
-libcmpp
4
-tlCtl
5 3
 
6 4
 .deps
7 5
 autom4te.cache

+ 2
- 2
Makefile.am View File

@@ -55,8 +55,8 @@ endif
55 55
 endif
56 56
 
57 57
 if OS_OSX
58
- AM_CPPFLAGS +=  -I/opt/local/include	
59
- AM_LDFLAGS  +=  -L/opt/local/lib
58
+ AM_CPPFLAGS +=  -I/opt/local/include	# Search macports directory for fftw headers
59
+ AM_LDFLAGS  +=  -L/opt/local/lib       # and libraries.
60 60
  AM_LDFLAGS  +=  -framework Cocoa -framework CoreAudio -framework CoreMIDI -framework Carbon -framework Accelerate
61 61
 endif
62 62
 

+ 1
- 0
src/libcmpp/.gitignore View File

@@ -0,0 +1 @@
1
+Makefile.in

+ 18
- 0
src/libcmpp/Makefile.am View File

@@ -0,0 +1,18 @@
1
+
2
+
3
+cmppSRC  = src/libcmpp/fltk/Fl_CbLinker.cpp src/libcmpp/fltk/Fl_Splitter.cpp
4
+cmppHDR  = src/libcmpp/fltk/Fl_CbLinker.h   src/libcmpp/fltk/Fl_Splitter.h
5
+
6
+cmppSRC += src/libcmpp/fltk/cmGrFltk.cpp
7
+cmppHDR += src/libcmpp/fltk/cmGrFltk.h
8
+
9
+cmppHDR += src/libcmpp/fltk/Fl_File_Btn.h    src/libcmpp/fltk/Fl_Vert_Progress.h
10
+cmppSRC += src/libcmpp/fltk/Fl_File_Btn.cpp  src/libcmpp/fltk/Fl_Vert_Progress.cpp
11
+
12
+cmppHDR += src/libcmpp/fltk/Fl_DevCfgGroup.h 
13
+cmppSRC += src/libcmpp/fltk/Fl_DevCfgGroup.cpp
14
+
15
+cmppHDR += src/libcmpp/fltk/cmUiDrvrFltk.h
16
+cmppSRC += src/libcmpp/fltk/cmUiDrvrFltk.cpp
17
+
18
+

+ 82
- 0
src/libcmpp/fltk/Fl_CbLinker.cpp View File

@@ -0,0 +1,82 @@
1
+#include <FL/Fl.H>
2
+#include <FL/Fl_Widget.H>
3
+#include <FL/Fl_Button.H>
4
+#include <FL/Fl_Scrollbar.H>
5
+#include <FL/Fl_Menu_Button.H>
6
+#include <FL/Fl_Menu_Item.H>
7
+
8
+#include <vector>
9
+#include <assert.h>
10
+#include "Fl_CbLinker.h"
11
+
12
+
13
+Fl_CbLinker::Fl_CbLinker()
14
+{}
15
+
16
+Fl_CbLinker::~Fl_CbLinker()
17
+{
18
+  unsigned i;
19
+  for(i=0; i<_ctlV.size(); ++i)
20
+    delete _ctlV[i];
21
+}
22
+
23
+void Fl_CbLinker::registerCtl( Fl_Button* c, unsigned id )
24
+{ 
25
+  ctl_t* r;
26
+  _ctlV.push_back( r = new ctl_t(this,c,id) ); 
27
+  c->callback(_s_callback,r);
28
+}
29
+
30
+void Fl_CbLinker::registerCtl( Fl_Scrollbar* c, unsigned id ) 
31
+{ 
32
+  ctl_t* r;
33
+  _ctlV.push_back( r = new ctl_t(this,c,id) ); 
34
+  c->callback(_s_callback,r);
35
+}
36
+
37
+void Fl_CbLinker::registerCtl( Fl_Menu_Button* c, unsigned id ) 
38
+{ 
39
+  ctl_t* r;
40
+  _ctlV.push_back( r = new ctl_t(this,c,id) ); 
41
+  c->callback(_s_callback,r);
42
+}
43
+
44
+void Fl_CbLinker::registerCtl( Fl_Menu_Item* c, unsigned id ) 
45
+{ 
46
+  ctl_t* r;
47
+  _ctlV.push_back( r = new ctl_t(this,c,id) ); 
48
+  c->callback(_s_callback,r);
49
+}
50
+
51
+void Fl_CbLinker::onButton( Fl_Button* c, unsigned id )
52
+{}
53
+
54
+void Fl_CbLinker::onScrollbar( Fl_Scrollbar* c, unsigned id )
55
+{}
56
+
57
+void Fl_CbLinker::onMenuBtn( Fl_Menu_Button* c, unsigned id )
58
+{}
59
+
60
+void Fl_CbLinker::onMenuItem( Fl_Menu_Item* c, unsigned id )
61
+{}
62
+
63
+
64
+void Fl_CbLinker::_s_callback( Fl_Widget* w, void* arg )
65
+{
66
+  ctl_t* r =  static_cast<ctl_t*>(arg);
67
+
68
+  unsigned i;
69
+  for(i=0; i<r->thisPtr->_ctlV.size(); ++i)
70
+    if( r->thisPtr->_ctlV[i] == arg )
71
+    {
72
+      switch( r->typeId )
73
+      {
74
+        case kButtonTId:    r->thisPtr->onButton(    r->u.btn,   r->ctlId); break;
75
+        case kScrollbarTId: r->thisPtr->onScrollbar( r->u.sb,    r->ctlId); break;
76
+        case kMenuBtnTId:   r->thisPtr->onMenuBtn(   r->u.mbtn,  r->ctlId); break;
77
+        case kMenuItemTId:  r->thisPtr->onMenuItem(  r->u.mitem, r->ctlId); break;
78
+        default:
79
+          { assert(0); }
80
+      }
81
+    }
82
+}

+ 72
- 0
src/libcmpp/fltk/Fl_CbLinker.h View File

@@ -0,0 +1,72 @@
1
+#ifndef Fl_CbLinker_h
2
+#define Fl_CbLinker_h
3
+
4
+class Fl_Widget;
5
+class Fl_Button;
6
+class Fl_Scrollbar;
7
+class Fl_Menu_Button;
8
+struct Fl_Menu_Item;
9
+
10
+/* 
11
+This class solves the problem of linking static control callback functions
12
+to an object instance. 
13
+
14
+registerCtl() creates a record which links a control to an instance
15
+of a Fl_CbLinker. The control is then given a static callback function:
16
+_s_callback().  When _s_callback() is called from the control event
17
+handler it links locates the controls link record an calls the
18
+appropriate handler (e.g. onButton(), onScrollBar(), etc.)
19
+*/
20
+
21
+class Fl_CbLinker
22
+{
23
+ public:
24
+  Fl_CbLinker();
25
+  virtual ~Fl_CbLinker();
26
+
27
+  void registerCtl( Fl_Button*      c, unsigned id );
28
+  void registerCtl( Fl_Scrollbar*   c, unsigned id ); 
29
+  void registerCtl( Fl_Menu_Button* c, unsigned id );
30
+  void registerCtl( Fl_Menu_Item*   c, unsigned id );
31
+
32
+  virtual void onButton(    Fl_Button*      c, unsigned id );
33
+  virtual void onScrollbar( Fl_Scrollbar*   c, unsigned id );
34
+  virtual void onMenuBtn(   Fl_Menu_Button* c, unsigned id );
35
+  virtual void onMenuItem(  Fl_Menu_Item*   c, unsigned id );
36
+
37
+ private:
38
+  enum
39
+  {
40
+    kButtonTId,
41
+    kScrollbarTId,
42
+    kMenuBtnTId,
43
+    kMenuItemTId
44
+  };
45
+
46
+  typedef struct ctl_str
47
+  {
48
+    Fl_CbLinker* thisPtr;
49
+    unsigned     typeId;
50
+    unsigned     ctlId;
51
+    union
52
+    {
53
+      Fl_Button*      btn;
54
+      Fl_Scrollbar*   sb;
55
+      Fl_Menu_Button* mbtn;
56
+      Fl_Menu_Item*   mitem;
57
+      Fl_Widget*      w;
58
+    } u;
59
+
60
+  ctl_str( Fl_CbLinker* t, Fl_Button*      c, unsigned id)  : thisPtr(t), typeId(kButtonTId),   ctlId(id) { u.btn=c; }
61
+  ctl_str( Fl_CbLinker* t, Fl_Scrollbar*   c, unsigned id ) : thisPtr(t), typeId(kScrollbarTId),ctlId(id) { u.sb=c; }
62
+  ctl_str( Fl_CbLinker* t, Fl_Menu_Button* c, unsigned id ) : thisPtr(t), typeId(kMenuBtnTId),  ctlId(id) { u.mbtn=c; }
63
+  ctl_str( Fl_CbLinker* t, Fl_Menu_Item*   c, unsigned id ) : thisPtr(t), typeId(kMenuItemTId), ctlId(id) { u.mitem=c; }
64
+
65
+  } ctl_t;
66
+
67
+  std::vector< ctl_t* > _ctlV;
68
+
69
+  static void _s_callback( Fl_Widget* w, void* arg );
70
+};
71
+
72
+#endif

+ 1135
- 0
src/libcmpp/fltk/Fl_DevCfgGroup.cpp
File diff suppressed because it is too large
View File


+ 168
- 0
src/libcmpp/fltk/Fl_DevCfgGroup.h View File

@@ -0,0 +1,168 @@
1
+#ifndef Fl_DevCfgGroup_h
2
+#define Fl_DevCfgGroup_h
3
+
4
+#include <vector>
5
+
6
+class Fl_DevCfgGroup : public Fl_Group
7
+{
8
+public:
9
+  Fl_DevCfgGroup(cmDevCfgH_t dcH, int x, int y, int w, int h, const char* label );
10
+  virtual ~Fl_DevCfgGroup();
11
+
12
+  void onEnableAudio(bool enableFl );
13
+
14
+private:
15
+  enum
16
+  {
17
+    kInvalidCId,
18
+    kLocLabelCId,
19
+    kLocMenuCId,
20
+    kLocStringCId,
21
+    kLocStoreBtnCId,
22
+    kLocDeleteBtnCId,
23
+
24
+    kMidiLabelCId,
25
+    kMidiCfgMenuCId,
26
+    kMidiDeleteBtnCId,
27
+    kMidiCfgStringCId,
28
+    kMidiApplyBtnCId,
29
+    kMidiCfgDescCId,
30
+    kMidiDevMenuCId,
31
+    kMidiDevLabelCId,
32
+    kMidiPortMenuCId,
33
+    kMidiPortLabelCId,
34
+    kMidiInputCheckCId,
35
+
36
+    kAudioLabelCId,
37
+    kAudioCfgMenuCId,
38
+    kAudioDeleteBtnCId,
39
+    kAudioCfgDescCId,
40
+    kAudioCfgStringCId,
41
+    kAudioApplyBtnCId,
42
+    kAudioInDevMenuCId,
43
+    kAudioInDevLabelCId,
44
+    kAudioOutDevMenuCId,
45
+    kAudioOutDevLabelCId,
46
+    kAudioMsgQueSizeValCId,
47
+    kAudioDevFpCValCId,
48
+    kAudioDspFpCValCId,
49
+    kAudioBufCntValCId,
50
+    kAudioSrateMenuCId,
51
+    kAudioSyncInCheckCId,
52
+    kAudioNetNodeStringCId,
53
+    kAudioBcastAddrStringCId,
54
+    kAudioIpAddrStringCId,
55
+    kAudioIpPortValCId,
56
+    kAudioActiveCheckCId,
57
+
58
+    /*
59
+    kNetLabelCId,
60
+    kNetCfgMenuCId,
61
+    kNetDeleteBtnCId,
62
+    kNetCfgDescCId,
63
+    kNetCfgStringCId,
64
+    kNetApplyBtnCId,
65
+    kNetSockAddrStringCId,
66
+    kNetPortNumbValCId,
67
+    kNetLocalCheckCId,
68
+    kNetActiveCheckCId
69
+    */
70
+
71
+  };
72
+
73
+  typedef struct
74
+  {
75
+    unsigned        id;
76
+    Fl_DevCfgGroup* p;
77
+    union
78
+    {
79
+      Fl_Button*       btn;
80
+      Fl_Check_Button* chk;
81
+      Fl_Box*          box;
82
+      Fl_Menu_Button*  mbt;
83
+      Fl_Input*        inp;
84
+      Fl_Value_Input*  val;
85
+    } u;
86
+    
87
+  } ctl_t;
88
+
89
+  cmDevCfgH_t           _dcH;
90
+  std::vector< ctl_t* > _ctlV;
91
+  
92
+  bool     _loadLocBtn();
93
+  void     _recallLoc();
94
+  void     _storeLoc();
95
+  void     _deleteLoc();
96
+
97
+  void     _loadMidiDevBtn();
98
+  void     _loadMidiPortBtn();
99
+  void     _loadAudioDevBtn( unsigned id, unsigned devIdx );
100
+  void     _loadAudioSrateBtn();
101
+  void     _loadCfgMenu(cmTypeDcmId_t typeId, unsigned menuCtlId, unsigned deleteCtlId );
102
+  void     _syncLoc();
103
+  void     _createMidiCfg();
104
+  void     _createAudioCfg();
105
+  //void     _createNetCfg();
106
+  void     _deleteCfg( cmTypeDcmId_t typeId, unsigned menuCtlId, unsigned inpCtlCId, unsigned descCtlId, unsigned storeCtlId, unsigned deleteCtlId );
107
+  void     _recallCfg( cmTypeDcmId_t typeId, unsigned menuCtlId, unsigned strCtlId, unsigned descCtlId, unsigned storeCtlId );
108
+
109
+  // Attempt to set the menu to index 'val' otherwise attempt to set it to 'dfltVal'
110
+  // Finish by updating the label.
111
+  void     _restoreMenuValue( unsigned menuCtlId, int val, int dfltVal=0 );
112
+
113
+  // Get the current string value of the menu btn.
114
+  const char* _menuBtnValueStr( unsigned menuCtlId );
115
+
116
+  // Copy the menu btn's current string value to the label (and the input control)
117
+  void        _setMenuBtnLabel( unsigned menuCtlId, unsigned inpCtlId = cmInvalidId );
118
+
119
+  // Set the menu buttons value to 'string' and update the menu btn's label
120
+  void        _setMenuBtnWithString( unsigned menuCtlId, const char* string );
121
+  void        _setCheckCtl( unsigned ctlId, int val );
122
+  void        _setValueCtl( unsigned ctlId, double val );
123
+  void        _setInputCtl( unsigned ctlId, const cmChar_t* val );
124
+
125
+  const cmChar_t* _getMenuCtl(  unsigned ctlId );
126
+  const cmChar_t* _getInputCtl( unsigned ctlId );
127
+  double          _getValueCtl( unsigned ctlId );
128
+  bool            _getCheckCtl( unsigned ctlId );
129
+
130
+  double      _getSrate();
131
+  void        _setSrate( double srate );
132
+
133
+  void        _enableStoreBtn( unsigned ctlId );
134
+
135
+  ctl_t*   _idToCtl(unsigned id);
136
+  
137
+  
138
+  static void _s_ctl_cb( Fl_Widget* w, void* arg );
139
+  
140
+};
141
+
142
+// Init:
143
+//   1) Load all menu X btns and set to first entry.
144
+//   2) set cfg string X to string value of cfg menu
145
+//   3) update desc and X fields.
146
+//
147
+// Cfg:
148
+// Store:
149
+//   1) call cmDevCfgNameX( cfg_label ) successfully
150
+//   2) reload cfg menu
151
+//   3) set cfg menu label to new cfg_label
152
+// 
153
+// Recall:
154
+//   1) set cfg menu X label
155
+//   2) set cfg string X to string value of cfg menu
156
+//   3) update desc and X fields
157
+//
158
+// Delete:
159
+//   1) call cmDevDeleteX( cfg_label ) sucessfuly.
160
+//   2) reload cfg menu and set to first entry
161
+//   3) set cfg string X to string value of cfg menu
162
+//   4) update desc and X fields
163
+//
164
+// 
165
+
166
+
167
+
168
+#endif

+ 105
- 0
src/libcmpp/fltk/Fl_File_Btn.cpp View File

@@ -0,0 +1,105 @@
1
+#include <Fl/Fl.H>
2
+#include <Fl/Fl_Button.H>
3
+#include <Fl/Fl_File_Chooser.H>
4
+#include <Fl/Fl_Output.H>
5
+#include <Fl/Fl_Group.H>
6
+#include "Fl_File_Btn.h"
7
+
8
+Fl_File_Btn::Fl_File_Btn( int xx, int yy, int ww, int hh, const char* l )
9
+  : Fl_Group(xx,yy,ww,hh,l),
10
+    _patStr(NULL),_typeId(kFile_Type_Id),_btn(NULL),_out(NULL)
11
+{
12
+  _init();
13
+  end();
14
+}
15
+
16
+Fl_File_Btn::Fl_File_Btn( unsigned typeId, const char* patStr, int xx, int yy, int ww, int hh, const char* l )
17
+  : Fl_Group(xx,yy,ww,hh,l),
18
+    _patStr(NULL),_typeId(typeId),_btn(NULL),_out(NULL)
19
+{
20
+  _init();
21
+  type(typeId);
22
+  pattern_string(patStr);
23
+  end();
24
+}
25
+
26
+Fl_File_Btn::~Fl_File_Btn()
27
+{ delete[] _patStr; }
28
+
29
+unsigned    Fl_File_Btn::type()
30
+{ return _typeId; }
31
+
32
+void        Fl_File_Btn::type( unsigned typeId )
33
+{
34
+  switch(typeId)
35
+  {
36
+    case kFile_Type_Id:
37
+      _btn->label("File");
38
+      _typeId = typeId;
39
+      break;
40
+
41
+    case kDir_Type_Id:
42
+      _btn->label("Dir");
43
+      _typeId = typeId;
44
+      break;
45
+  }
46
+
47
+  
48
+}
49
+
50
+const char* Fl_File_Btn::pattern_string()
51
+{ return _patStr;  }
52
+
53
+void        Fl_File_Btn::pattern_string( const char* pat)
54
+{
55
+  delete[] _patStr;
56
+  if( pat != NULL )
57
+  {
58
+    _patStr = new char[ strlen(pat) + 1];
59
+    strcpy(_patStr,pat);
60
+  }
61
+}
62
+
63
+void        Fl_File_Btn::btn_width( int ww )
64
+{ 
65
+  _btn->resize(_btn->x(),_btn->y(),ww,_btn->h());
66
+  _out->resize(_btn->x() + _btn->w() + 2, _out->y(), w() - _btn->w() - 2, _out->h());
67
+}
68
+
69
+int         Fl_File_Btn::btn_width()
70
+{ return _btn->w(); }
71
+
72
+void        Fl_File_Btn::filename( const char* fn )
73
+{ _out->value(fn); _out->redraw(); }
74
+
75
+const char* Fl_File_Btn::filename() const
76
+{ return _out->value(); }
77
+
78
+
79
+void Fl_File_Btn::_s_btn_cb(Fl_Widget* w, void* data)
80
+{ ((Fl_File_Btn*)data)->_btn_cb(); }
81
+
82
+void Fl_File_Btn::_btn_cb()
83
+{
84
+  char* fn;
85
+  if( _typeId == kFile_Type_Id )
86
+    fn = fl_file_chooser("Select a file",_patStr,_out->value(),0);
87
+  else
88
+    fn = fl_dir_chooser("Select a directory",_out->value(),0);
89
+
90
+  if( fn != NULL )
91
+  {
92
+    _out->value(fn);
93
+    do_callback(this,user_data());
94
+  }
95
+
96
+}
97
+
98
+void Fl_File_Btn::_init()
99
+{
100
+  _btn = new Fl_Button(x(),y(),40,h(),_typeId==kFile_Type_Id ? "File" : "Dir");
101
+  _btn->callback(_s_btn_cb,this);
102
+
103
+  _out = new Fl_Output(x() + _btn->w() + 2, y(), w() - _btn->w(), h());
104
+
105
+}

+ 47
- 0
src/libcmpp/fltk/Fl_File_Btn.h View File

@@ -0,0 +1,47 @@
1
+#ifndef Fl_File_Btn_h
2
+#define Fl_File_Btn_h
3
+
4
+class Fl_Button;
5
+class Fl_Output;
6
+
7
+class Fl_File_Btn : public Fl_Group
8
+{
9
+public:
10
+  enum
11
+  {
12
+    kFile_Type_Id,
13
+    kDir_Type_Id
14
+  };
15
+
16
+  Fl_File_Btn( int x, int y, int w, int h, const char* l = 0 );
17
+
18
+  Fl_File_Btn( unsigned typeId, const char* patStr, int x, int y, int w, int h, const char* l = 0 );
19
+  virtual ~Fl_File_Btn();
20
+
21
+  unsigned    type();
22
+  void        type( unsigned typeId );
23
+
24
+  const char* pattern_string();
25
+  void        pattern_string( const char* pat);
26
+
27
+  void        btn_width( int w );
28
+  int         btn_width();
29
+
30
+  void        filename( const char* fn );
31
+  const char* filename() const;
32
+
33
+private:
34
+  char*       _patStr;
35
+  unsigned    _typeId;
36
+  Fl_Button*  _btn;
37
+  Fl_Output*  _out;
38
+
39
+  static void _s_btn_cb(Fl_Widget* w, void* data);
40
+  void _btn_cb();
41
+
42
+  void _init();
43
+
44
+};
45
+
46
+
47
+#endif

+ 273
- 0
src/libcmpp/fltk/Fl_Splitter.cpp View File

@@ -0,0 +1,273 @@
1
+// Code based on: http://www.mail-archive.com/fltk@easysw.com/msg04573.html
2
+// Lucas Sanner/Ian MacArthur
3
+
4
+#include "Fl_Splitter.h"
5
+
6
+void Fl_HSplitter::draw()
7
+{
8
+  Fl_Group::draw();
9
+  Fl_Color c = fl_color();
10
+  fl_color(FL_BLACK);
11
+  fl_line_style( FL_DOT, 1);
12
+
13
+  if(splitFl && Fl::event_button1() != 0)
14
+  {
15
+    fl_push_clip(x(), y(), w(), h());
16
+
17
+    yPos = Fl::event_y();
18
+
19
+    if(Fl::event_y() > h() - (border * 2))
20
+      yPos = h() - (border * 2);
21
+
22
+    if(Fl::event_y() < y() + (border * 2))
23
+      yPos = y() + (border * 2);
24
+
25
+    fl_line( x() + border, yPos - 1, x() + w() - (border*2), yPos - 1 );
26
+    fl_line( x() + border, yPos    , x() + w() - (border*2), yPos     );
27
+    fl_line( x() + border, yPos + 1, x() + w() - (border*2), yPos + 1 );
28
+
29
+    /*
30
+    fl_line(
31
+      x() + border,
32
+      yPos,
33
+      x() + w() - (border*2),
34
+      yPos );
35
+
36
+    fl_line(
37
+      x() + border,
38
+      yPos + 1,
39
+      x() + w() - (border*2),
40
+      yPos + 1 );
41
+    */  
42
+
43
+    fl_pop_clip();
44
+  }
45
+  else
46
+  {
47
+    fl_push_clip(x(), y(), w(), h());
48
+    fl_pop_clip();
49
+  }
50
+
51
+  fl_color(c);
52
+  fl_line_style(0);
53
+}
54
+
55
+int Fl_HSplitter::handle(int e)
56
+{
57
+  int ret = Fl_Group::handle(e);
58
+
59
+  switch(e)
60
+  {
61
+    case FL_MOVE:
62
+
63
+      if(hCtnl - border < Fl::event_y() && Fl::event_y() < hCtnl + border)
64
+      {
65
+        fl_cursor(FL_CURSOR_NS);
66
+        splitFl = true;
67
+      }
68
+      else
69
+      {
70
+        fl_cursor(FL_CURSOR_DEFAULT);
71
+        splitFl = false;
72
+      }
73
+
74
+      return 1;
75
+
76
+    case FL_PUSH:
77
+
78
+      if(Fl::event_button() == FL_LEFT_MOUSE && splitFl)
79
+      {
80
+        redraw();
81
+      }
82
+
83
+      return 1;
84
+
85
+    case FL_RELEASE:
86
+
87
+      if(Fl::event_button() == FL_LEFT_MOUSE && splitFl)
88
+      {
89
+        c0->resize(x(), y(), w(), yPos - y());
90
+        hCtnl = yPos;
91
+        c1->resize(x(),hCtnl, w(), h() - (yPos - y()));
92
+        
93
+        if( stretchTopFl )
94
+          init_sizes();
95
+
96
+        splitFl = false;
97
+        redraw();
98
+      }
99
+
100
+      return 1;
101
+
102
+    case FL_DRAG:
103
+
104
+      if(splitFl && Fl::event_state(FL_BUTTON1) != 0)
105
+        redraw();
106
+
107
+      return 1;
108
+  }
109
+
110
+  return(ret);
111
+}
112
+
113
+
114
+Fl_HSplitter::Fl_HSplitter(int x, int y, int w, int h, int h1, const char *l, bool stretchBotFl)
115
+  : Fl_Group(x, y, w, h, l)
116
+{
117
+  int h2 = h - h1;
118
+
119
+  begin();
120
+  c0 = new Splitter_Container(x, y, w, h1);
121
+  //c0->color((Fl_Color) FL_RED);
122
+  end();
123
+
124
+  begin();
125
+  c1 = new Splitter_Container(x, y + h1, w, h2);
126
+  //c1->color((Fl_Color) FL_BLUE);
127
+  end();
128
+
129
+  hCtnl        =  y + h1;
130
+  splitFl       = false;
131
+  stretchTopFl = !stretchBotFl;
132
+  border        = Fl::box_dy(FL_DOWN_BOX);
133
+
134
+  if( stretchTopFl )
135
+    resizable(c0);
136
+}
137
+
138
+void Fl_HSplitter::resize(int x, int y, int w, int h)
139
+{
140
+  Fl_Group::resize(x, y, w, h);
141
+
142
+  if( stretchTopFl )
143
+  {
144
+    hCtnl  = c0->h() + y;
145
+    yPos   = hCtnl;
146
+    //printf("hCtnl:%i\n",hCtnl);
147
+  }
148
+  else
149
+  {
150
+    c0->resize(x, y,     w,     hCtnl - y);
151
+    c1->resize(x, hCtnl, w, h - (hCtnl - y));
152
+  }
153
+
154
+}
155
+
156
+
157
+
158
+void Fl_VSplitter::draw()
159
+{
160
+  Fl_Group::draw();
161
+  Fl_Color c = fl_color();
162
+  fl_color(FL_BLACK);
163
+  fl_line_style( FL_DOT, 1);
164
+
165
+  if(splitFl && Fl::event_button1() != 0)
166
+  {
167
+    fl_push_clip(x(), y(), w(), h());
168
+
169
+    xPos = Fl::event_x();
170
+
171
+    if(Fl::event_x() > w() - (border * 2))
172
+      xPos = w() - (border * 2);
173
+
174
+    if(Fl::event_x() < x() + (border * 2))
175
+      xPos = x() + (border * 2);
176
+
177
+    fl_line(xPos - 1, y() + border, xPos - 1, y() + h() - (border * 2));
178
+    fl_line(xPos, y() + border, xPos, y() + h() - (border * 2));
179
+    fl_line(xPos + 1, y() + border, xPos + 1, y() + h() - (border * 2));
180
+
181
+    fl_pop_clip();
182
+  }
183
+  else
184
+  {
185
+    fl_push_clip(x(), y(), w(), h());
186
+    fl_pop_clip();
187
+  }
188
+
189
+  fl_color(c);
190
+  fl_line_style(0); // restore line style to defaults
191
+}
192
+
193
+int Fl_VSplitter::handle(int e)
194
+{
195
+  int ret = Fl_Group::handle(e);
196
+
197
+  switch(e)
198
+  {
199
+    case FL_MOVE:
200
+
201
+      if(Fl::event_x() > wCtn1 - border && Fl::event_x() < wCtn1 + border)
202
+      {
203
+        fl_cursor(FL_CURSOR_WE);
204
+        splitFl = true;
205
+      }
206
+      else
207
+      {
208
+        fl_cursor(FL_CURSOR_DEFAULT);
209
+        splitFl = false;
210
+      }
211
+
212
+      return 1;
213
+
214
+    case FL_PUSH:
215
+
216
+      if(Fl::event_button() == FL_LEFT_MOUSE && splitFl)
217
+      {
218
+        redraw();
219
+      }
220
+
221
+      return 1;
222
+
223
+    case FL_RELEASE:
224
+
225
+      if(Fl::event_button() == FL_LEFT_MOUSE && splitFl)
226
+      {
227
+        c0->resize(x(), y(), xPos, h());
228
+        wCtn1 = xPos;
229
+        c1->resize(wCtn1, y(), w() - wCtn1, h());
230
+        splitFl = false;
231
+        redraw();
232
+      }
233
+
234
+      return 1;
235
+
236
+    case FL_DRAG:
237
+
238
+      if(splitFl && Fl::event_state(FL_BUTTON1) != 0)
239
+        redraw();
240
+
241
+      return 1;
242
+  }
243
+
244
+  return(ret);
245
+}
246
+
247
+Fl_VSplitter::Fl_VSplitter(int x, int y, int w, int h, const char *l)
248
+  : Fl_Group(x, y, w, h, l)
249
+{
250
+  begin();
251
+  c0 = new Splitter_Container(x, y, w / 2, h);
252
+  //c0->color((Fl_Color) FL_RED);
253
+  end();
254
+
255
+  begin();
256
+  c1 = new Splitter_Container(x + (w / 2), y, w / 2, h);
257
+  //c1->color((Fl_Color) FL_BLUE);
258
+  end();
259
+
260
+  wCtn1 = w / 2;
261
+  splitFl = false;
262
+
263
+  border = Fl::box_dx(FL_DOWN_BOX);
264
+
265
+}
266
+
267
+void Fl_VSplitter::resize_splitter(int x, int y, int w, int h)
268
+{
269
+  resize(x, y, w, h);
270
+  c0->resize(x, y, wCtn1, h);
271
+  c1->resize(wCtn1, y, w - wCtn1, h);
272
+}
273
+

+ 70
- 0
src/libcmpp/fltk/Fl_Splitter.h View File

@@ -0,0 +1,70 @@
1
+// Code based on: http://www.mail-archive.com/fltk@easysw.com/msg04573.html
2
+// Lucas Sanner/Ian MacArthur
3
+
4
+#ifndef Fl_Splitter_h
5
+#define Fl_Splitter_h
6
+
7
+#include <FL/Fl.H>
8
+#include <FL/Fl_Group.H>
9
+#include <FL/Fl_Box.H>
10
+#include <FL/fl_draw.H>
11
+
12
+
13
+class Splitter_Container : public Fl_Group
14
+{
15
+
16
+  public:
17
+
18
+    Splitter_Container(int x, int y, int w, int h, char *l = NULL)
19
+    : Fl_Group(x, y, w, h, l)
20
+    {
21
+      box(FL_NO_BOX); // do not draw the background
22
+    }
23
+};
24
+
25
+class Fl_HSplitter : public Fl_Group
26
+{
27
+  int  hCtnl;    // window coord's of the horzontal splitter 
28
+  int  border;   // splitter divider height
29
+  int  yPos;     // window posn where divider was last draw 
30
+  bool splitFl;  // set if split cursor is enabled
31
+  bool stretchTopFl;  // set to make top container stretch when splitter is resized
32
+  //int  hh2;
33
+
34
+  virtual void draw();
35
+
36
+  int handle(int e);
37
+
38
+  public:
39
+
40
+  Splitter_Container *c0, *c1;
41
+
42
+  Fl_HSplitter(int x, int y, int w, int h, int h1, const char *l=NULL, bool stretchBotFl=false);
43
+
44
+  virtual void resize(int x, int y, int w, int h);
45
+
46
+};
47
+
48
+
49
+class Fl_VSplitter : public Fl_Group
50
+{
51
+
52
+  int wCtn1, border, xPos;
53
+  bool splitFl;
54
+
55
+  void draw();
56
+  int handle(int e);
57
+
58
+  public:
59
+
60
+  Splitter_Container *c0, *c1;
61
+
62
+  Fl_VSplitter(int x, int y, int w, int h, const char *l = NULL);
63
+
64
+  void resize_splitter(int x, int y, int w, int h);
65
+
66
+
67
+
68
+};
69
+
70
+#endif

+ 66
- 0
src/libcmpp/fltk/Fl_Vert_Progress.cpp View File

@@ -0,0 +1,66 @@
1
+#include <FL/Fl.H>
2
+#include <FL/fl_draw.H>
3
+#include <Fl/Fl_Progress.H>
4
+#include "Fl_Vert_Progress.h"
5
+
6
+Fl_Vert_Progress::Fl_Vert_Progress(int x, int y, int w, int h, const char* l)
7
+  : Fl_Progress(x,y,w,h)
8
+{
9
+}
10
+
11
+// This member function is a slight variation on a verbatim
12
+// copy of Fl_Progress.cxx from the FLTK source library.
13
+void Fl_Vert_Progress::draw()
14
+{
15
+  int	progress;                 // Size of progress bar...
16
+  int	bx, by, bw, bh;           // Box areas...
17
+  int	tx, tw;                   // Temporary X + width
18
+
19
+  // Get the box borders...
20
+  bx = Fl::box_dx(box());
21
+  by = Fl::box_dy(box());
22
+  bw = Fl::box_dw(box());
23
+  bh = Fl::box_dh(box());
24
+
25
+  tx = x() + bx;
26
+  tw = w() - bw;
27
+
28
+  // Draw the progress bar...
29
+  if (maximum() > minimum())
30
+    progress = (int)(h() * (value() - minimum()) / (maximum() - minimum()) + 0.5f);
31
+  else
32
+    progress = 0;
33
+
34
+  // Draw the box and label...
35
+  if (progress > 0) 
36
+  {
37
+    Fl_Color c = labelcolor();
38
+    labelcolor(fl_contrast(labelcolor(), selection_color()));
39
+
40
+    fl_push_clip(x(), y() + h() - (progress + by), w(), progress + by);
41
+
42
+    draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color()));
43
+
44
+    draw_label(tx, y() + by, tw, h() - bh);
45
+
46
+    fl_pop_clip();
47
+
48
+    labelcolor(c);
49
+
50
+    if (progress<h()) 
51
+    {
52
+      fl_push_clip(x(), y(), w(), h()-progress);
53
+
54
+      draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
55
+
56
+      draw_label(tx, y() + by, tw, h() - bh);
57
+
58
+      fl_pop_clip();
59
+    }
60
+  } 
61
+  else 
62
+  {
63
+    draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
64
+    draw_label(tx, y() + by, tw, h() - bh);
65
+  }
66
+}

+ 14
- 0
src/libcmpp/fltk/Fl_Vert_Progress.h View File

@@ -0,0 +1,14 @@
1
+#ifndef Fl_Vert_Progress_h
2
+#define Fl_Vert_Progress_h
3
+
4
+class Fl_Vert_Progress : public Fl_Progress
5
+{
6
+ protected:
7
+  virtual void draw();
8
+ public:
9
+  Fl_Vert_Progress(int x, int y, int w, int h, const char* l=0);
10
+  
11
+};
12
+
13
+
14
+#endif

+ 1546
- 0
src/libcmpp/fltk/cmGrFltk.cpp
File diff suppressed because it is too large
View File


+ 242
- 0
src/libcmpp/fltk/cmGrFltk.h View File

@@ -0,0 +1,242 @@
1
+#ifndef cmGrFltk_h
2
+#define cmGrFltk_h
3
+
4
+class Fl_Group;
5
+class Fl_Output;
6
+class Fl_Scrollbar;
7
+
8
+class cmGrDevDrvFltk
9
+{
10
+ public:
11
+
12
+  cmGrDevDrvFltk();
13
+  virtual ~cmGrDevDrvFltk(){}
14
+
15
+
16
+  static bool     create( void* user, unsigned w, unsigned h );
17
+  static void     destroy( void* user );
18
+
19
+  static void     begin_draw( void* arg );
20
+  static void     end_draw(   void* arg );
21
+  static void     draw(       void* arg, int x, int y );
22
+
23
+  static void     set_color( void* user, const cmGrColor_t  c );  
24
+  static void     get_color( void* user,       cmGrColor_t* c );  
25
+
26
+  static void     set_font_family( void* user, unsigned fontId );
27
+  static unsigned get_font_family( void* user );
28
+
29
+  static void     set_font_style( void* user, unsigned style );
30
+  static unsigned get_font_style( void* user );
31
+
32
+  static void     set_font_size( void* user, unsigned size );
33
+  static unsigned get_font_size( void* user );
34
+
35
+  static void     set_pen_style( void* user, unsigned styleFlags );
36
+  static unsigned get_pen_style( void* user );
37
+
38
+  static void     set_pen_width( void* user, unsigned w );  
39
+  static unsigned get_pen_width( void* user );
40
+
41
+  static void draw_line(     void* user, int x0, int y0, int x1, int y1 );
42
+  static void draw_rect(     void* user, int x0, int y0, unsigned w, unsigned h );
43
+  static void fill_rect(     void* user, int x0, int y0, unsigned w, unsigned h );
44
+  static void draw_ellipse(  void* user, int x0, int y0, unsigned w, unsigned h );
45
+  static void fill_ellipse(  void* user, int x0, int y0, unsigned w, unsigned h );
46
+  static void draw_diamond(  void* user, int x0, int y0, unsigned w, unsigned h );
47
+  static void fill_diamond(  void* user, int x0, int y0, unsigned w, unsigned h );
48
+  static void draw_triangle( void* user, int x0, int y0, unsigned w, unsigned h, unsigned dirFlag );
49
+  static void fill_triangle( void* user, int x0, int y0, unsigned w, unsigned h, unsigned dirFlag );
50
+
51
+  static void draw_text(     void* user, const char* text, int x, int y );
52
+  static void draw_text_rot( void* user, const char* text, int x, int y, int angle );
53
+  static void measure_text(  void* user, const char* text, unsigned* w, unsigned* h );
54
+
55
+  static void read_image( void* user,       unsigned char* p, int x, int y, unsigned w, unsigned h );
56
+  static void draw_image( void* user, const unsigned char* p, int x, int y, unsigned w, unsigned h );
57
+
58
+  bool is_initialized() const;
59
+
60
+  cmGrDev_t    d;
61
+
62
+ private:  
63
+
64
+  unsigned _fltk_pen_width;
65
+  unsigned _fltk_pen_style; 
66
+  unsigned _fltk_font_size;
67
+  unsigned _w;
68
+  unsigned _h;
69
+
70
+  static void _get_font_family_style(             unsigned* fontId, unsigned* style );
71
+  static void _set_font_family_style( void* user, unsigned  fontId, unsigned  style );
72
+};
73
+
74
+//--------------------------------------------------------------------------------------
75
+// Canvas Object 
76
+
77
+class cmGrViewFltk : public Fl_Widget
78
+{
79
+ public:
80
+  cmGrViewFltk( cmCtx_t* ctx, cmGrH_t grH, int x, int y, int w, int h );
81
+  virtual ~cmGrViewFltk();
82
+
83
+  virtual int  handle(int event);
84
+  virtual void resize(int x, int y, int w, int h );
85
+          void setGrH( cmGrH_t grH );
86
+
87
+ private:
88
+  virtual void draw();
89
+
90
+  typedef struct 
91
+  {
92
+    unsigned idx;
93
+    unsigned fltk_code;
94
+    char     ch;
95
+    cmGrKeyCodeId_t gr_code;
96
+  } keyMap_t;
97
+
98
+  cmGrH_t         _grH;
99
+  cmGrDevDrvFltk  _dd;
100
+  cmGrDcH_t       _dcH;
101
+  static keyMap_t _keymap[];
102
+
103
+  const keyMap_t* _getGrKeyCode( unsigned fltk_code );
104
+  cmGrKeyCodeId_t _eventKeyCode( );
105
+
106
+};
107
+
108
+
109
+//--------------------------------------------------------------------------------------
110
+// Container for multiple plots
111
+
112
+class cmGrPageFltk : public Fl_Group 
113
+{
114
+ public:
115
+  cmGrPageFltk( cmCtx_t* ctx, cmGrPgH_t pgH,  int x, int y, int w, int h );
116
+  virtual ~cmGrPageFltk();
117
+  
118
+  virtual void             createView( unsigned vwIdx );
119
+
120
+  virtual void             destroyView( unsigned vwIdx );
121
+
122
+  virtual cmGrDcH_t        devCtxHandle();
123
+
124
+  virtual cmGrViewFltk*   viewWidget( unsigned vwIdx );
125
+
126
+  virtual void resize(int x, int y, int w, int h );
127
+  
128
+ private:
129
+  virtual void draw();
130
+
131
+  cmGrDevDrvFltk _dd;
132
+  cmCtx_t*       _ctx;
133
+  cmGrPgH_t      _pgH;
134
+  cmGrDcH_t      _dcH;
135
+  cmGrViewFltk** _vwV;
136
+  unsigned       _vwN;
137
+  
138
+};
139
+
140
+//--------------------------------------------------------------------------------------
141
+// Contains a single cmGrPageFltk and a control panel
142
+
143
+class cmGrPlotFltk : public Fl_Group
144
+{
145
+ public:
146
+  cmGrPlotFltk( cmCtx_t* ctx, int x, int y, int w, int h, int rn=1, int cn=1, int textSz=10 );
147
+  virtual ~cmGrPlotFltk();
148
+
149
+  virtual void resize(int x, int y, int w, int h );
150
+
151
+  cmGrPgH_t pageHandle();
152
+  cmGrPlH_t plotHandle();
153
+  cmGrDcH_t dcHandle();
154
+
155
+  virtual void initViews( int rn, int cn );
156
+  virtual void setStatusText( const cmChar_t* s );
157
+  
158
+  virtual void on_button( unsigned id );
159
+  virtual void on_scroll( Fl_Scrollbar* sb, unsigned id );
160
+  virtual void on_view_create(   unsigned viewIdx );
161
+  virtual void on_view_destroy(  unsigned viewIdx );
162
+  virtual void rpt_local_pt(     cmGrH_t grH );
163
+  virtual void rpt_global_pt(    cmGrH_t grH );
164
+  virtual void on_phys_change(   cmGrH_t grH );
165
+  virtual void on_view_change(   cmGrH_t grH );
166
+  virtual void on_select_change( cmGrH_t grH );
167
+  virtual void on_focused_plot(  cmGrH_t grH );
168
+  virtual void on_key_event(     cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
169
+  virtual bool on_plot_object(   cmGrPlotCbArg_t* arg );
170
+
171
+ private:
172
+  enum
173
+  {
174
+    kHBord = 0,     // dist between vertical elements (cols)
175
+    kVBord = 0,     // dist between horz elements (rows)
176
+    kBtnH  = 20,    // control height
177
+    kBtnW  = 50,    // button width
178
+    kOutW  = 100,   // output width
179
+    kLblW  = 20,    // output label width,
180
+    kScrD  = 20     // scroll bar thickness
181
+  };
182
+
183
+  enum
184
+  {
185
+    kHScrollId,
186
+    kVScrollId,
187
+    kShowAllId,
188
+    kReportId,
189
+    kZoomInId,
190
+    kZoomOutId,
191
+    kZoomInXId,
192
+    kZoomInYId,
193
+    kZoomOutXId,
194
+    kZoomOutYId,
195
+  };
196
+
197
+
198
+  cmGrPgH_t      _pgH;
199
+  cmGrPlH_t      _plH;
200
+  
201
+  cmGrPageFltk* _pg;
202
+  Fl_Group*     _ctl_grp;
203
+  Fl_Group*     _usr_grp;
204
+  Fl_Output*    _status;        // status text output
205
+ 
206
+  Fl_Scrollbar* _hsb;           // scroll bars
207
+  Fl_Scrollbar* _vsb;
208
+
209
+  Fl_Output*    _gx;            // current global coord display
210
+  Fl_Output*    _gy;
211
+
212
+  Fl_Output*    _lx;            // current local coord display
213
+  Fl_Output*    _ly;
214
+
215
+  Fl_Output*    _s0x;           // seletion point
216
+  Fl_Output*    _s0y;
217
+  Fl_Output*    _s1x;  
218
+  Fl_Output*    _s1y;
219
+  Fl_Output*    _sdx;
220
+  Fl_Output*    _sdy;
221
+ 
222
+  int            _textSz;
223
+
224
+  void      _layout();
225
+  Fl_Group* _create_ctls();
226
+  void      _create_scroll_bars();
227
+  void      _showHideScrollBars();
228
+  cmGrH_t   _getFocusedView();
229
+
230
+  // controls callback
231
+  static void _s_ctl_cb(Fl_Widget* w, long id );
232
+
233
+  // plot page callbacks
234
+  static void _s_cmGrCallback( void* arg, cmGrH_t grH, cmGrCbId_t id, unsigned eventFlags, cmGrKeyCodeId_t keycode );
235
+
236
+  // plot object callbacks
237
+  static bool _s_cmGrPlotObjCbFunc( cmGrPlotCbArg_t* arg );
238
+  
239
+};
240
+
241
+
242
+#endif

+ 865
- 0
src/libcmpp/fltk/cmUiDrvrFltk.cpp View File

@@ -0,0 +1,865 @@
1
+#include <FL/Fl.H>
2
+#include <FL/Fl_Widget.H>
3
+#include <FL/Fl_Group.H>
4
+#include <FL/Fl_Tabs.H>
5
+#include <FL/Fl_Button.H>
6
+#include <FL/Fl_Check_Button.H>
7
+#include <FL/Fl_Box.H>
8
+#include <Fl/Fl_Input.H>
9
+#include <Fl/Fl_Value_Input.H>
10
+#include <Fl/Fl_Value_Slider.H>
11
+#include <Fl/Fl_Progress.H>
12
+#include <Fl/Fl_Menu_Button.H>
13
+#include <Fl/Fl_Select_Browser.H>
14
+#include <Fl/Fl_Text_Display.H>
15
+#include <FL/fl_draw.H>
16
+
17
+#include "Fl_File_Btn.h"
18
+#include "Fl_Vert_Progress.h"
19
+
20
+#include "cmGlobal.h"
21
+#include "cmRpt.h"
22
+#include "cmErr.h"
23
+#include "cmCtx.h"
24
+#include "cmMem.h"
25
+#include "cmMallocDebug.h"
26
+
27
+#include "cmRtSysMsg.h"
28
+#include "cmUiDrvr.h"
29
+#include "cmUiDrvrFltk.h"
30
+
31
+
32
+cmUiDrvrFltk::cmUiDrvrFltk(cmCtx_t* ctx, Fl_Tabs* tabs, cmUiDriverFunc_t cbFunc, void* cbArg)
33
+  : _tabs(NULL),_cbFunc(NULL),_cbArgs(NULL),_panels(NULL)
34
+{
35
+  cmErrSetup(&_err,&ctx->rpt,"cmUiDrvrFltk");
36
+  setBaseWindow(tabs);
37
+  setCallback(cbFunc,cbArg);
38
+}
39
+
40
+void cmUiDrvrFltk::setBaseWindow( Fl_Tabs* tabs )
41
+{ 
42
+  _tabs  = tabs; 
43
+  if( _tabs != NULL )
44
+    _tabs->callback(_s_tab_cb,this);
45
+}
46
+
47
+void cmUiDrvrFltk::setCallback( cmUiDriverFunc_t cbFunc, void* cbArg )
48
+{
49
+  _cbFunc = cbFunc;
50
+  _cbArgs = cbArg;  
51
+}
52
+
53
+cmUiDrvrFltk::~cmUiDrvrFltk()
54
+{ 
55
+  _destroyAllPanels(false); 
56
+}
57
+  
58
+cmUiRC_t cmUiDrvrFltk::cmUiDriverFunc( void* cbArg, const cmUiDriverArg_t* args )
59
+{
60
+  cmUiDrvrFltk* p = (cmUiDrvrFltk*)cbArg;
61
+  cmUiRC_t rc = kOkUiRC;
62
+  switch(args->dId)
63
+  {
64
+    case kInvalidDId:
65
+      break;
66
+
67
+    case kCreateCtlDId:
68
+      rc = p->_createCtl(args);
69
+      break;
70
+
71
+    case kDestroyCtlDId:
72
+      rc = p->_destroyCtl(args->appId,args->panelId,args->usrId,true);
73
+      break;
74
+
75
+    case kSetValDId:
76
+      rc = p->_setValueCtl(args);
77
+      break;
78
+
79
+    case kEnableDId:
80
+      rc = p->_enableCtl(args);
81
+      break;
82
+
83
+      //case kDestroyAllDId:
84
+      //rc = p->_destroyAllPanels(true);
85
+      //break;
86
+
87
+    case kMaxDId:
88
+      assert(0);
89
+      break;
90
+      
91
+  }
92
+  return rc;
93
+}
94
+
95
+void cmUiDrvrFltk::_insertNewCtl( panel_t* pp, ctl_t* ctl, Fl_Widget* wp, unsigned flags )
96
+{
97
+  ctl->wdgt = wp;
98
+
99
+  if( ctl->usrId != cmInvalidId )
100
+  {
101
+    ctl->link = pp->ctls;
102
+    pp->ctls  = ctl;
103
+    wp->callback( _s_ctl_cb, ctl );
104
+  }
105
+
106
+  pp->grp->add(wp);
107
+  
108
+
109
+  int align_flags = 0;
110
+  if( cmIsFlag(flags,kLeftUiFl))   align_flags |= FL_ALIGN_LEFT; 
111
+  if( cmIsFlag(flags,kTopUiFl))    align_flags |= FL_ALIGN_TOP; 
112
+  if( cmIsFlag(flags,kRightUiFl))  align_flags |= FL_ALIGN_RIGHT; 
113
+  if( cmIsFlag(flags,kBottomUiFl)) align_flags |= FL_ALIGN_BOTTOM; 
114
+  if( cmIsFlag(flags,kHCtrUiFl))   align_flags |= FL_ALIGN_CENTER; 
115
+  if( cmIsFlag(flags,kInsideUiFl)) align_flags |= FL_ALIGN_INSIDE; 
116
+  if( cmIsFlag(flags,kVCtrUiFl))   align_flags =  cmClrFlag(align_flags,FL_ALIGN_TOP | FL_ALIGN_BOTTOM); 
117
+
118
+
119
+  wp->align(align_flags);
120
+
121
+
122
+  int when_flags = 0;
123
+  if( cmIsFlag(flags,kSendChangeFl))   when_flags |= FL_WHEN_CHANGED;
124
+  if( cmIsFlag(flags,kSendEnterFl))    when_flags |= FL_WHEN_ENTER_KEY;
125
+  if( cmIsFlag(flags,kSendFocusFl))    when_flags |= FL_WHEN_RELEASE;
126
+  if( cmIsFlag(flags,kSendNoChangeFl)) when_flags |= FL_WHEN_NOT_CHANGED;
127
+    
128
+  if( when_flags != 0 )
129
+    wp->when(when_flags);
130
+}
131
+
132
+bool cmUiDrvrFltk::_hasNoAlignFlags( unsigned flags ) const
133
+{ 
134
+  return !cmIsFlag(flags, kLeftUiFl | kTopUiFl | kRightUiFl | kBottomUiFl | kVCtrUiFl | kHCtrUiFl );
135
+}
136
+
137
+cmUiRC_t cmUiDrvrFltk::_createCtl( const cmUiDriverArg_t* a )
138
+{
139
+  cmUiRC_t rc;
140
+  panel_t* pp;
141
+  panel_t* prvPnl;
142
+
143
+  // if this is a panel create request
144
+  if( a->cId == kPanelUiCId  )
145
+    return _createPanel(a);
146
+
147
+  // locate the new control's panel
148
+  if((rc = _findPanel(a->appId,a->panelId,pp,prvPnl)) != kOkUiRC )
149
+    return rc;
150
+
151
+  // allocate the control record
152
+  ctl_t* ctl ;
153
+  if( a->usrId == cmInvalidId )
154
+    ctl = &_dummy;
155
+  else
156
+    ctl = cmMemAllocZ(ctl_t,1);
157
+
158
+  ctl->cId   = a->cId;
159
+  ctl->pnl   = pp;
160
+  ctl->usrId = a->usrId;
161
+  ctl->flags = a->flags;
162
+
163
+  int x = a->x + pp->x_offs;
164
+  int y = a->y + pp->y_offs;
165
+
166
+  // cache the event callback arg record so that it 
167
+  // does not have to be filled on every callback.
168
+  cmUiDriverArgSetup(&ctl->cbArg,a->hdr.rtSubIdx,kUiDrvrSelRtId,kInvalidDId,pp->appId,a->usrId,pp->usrId,a->cId,0,0,0,NULL,x,y,a->w,a->h);
169
+
170
+  //printf("%i %i %i %i\n",x,y,a->w,a->h);
171
+
172
+  switch(a->cId)
173
+  {
174
+    case kInvalidUiCId:
175
+      assert(0);
176
+      break;
177
+
178
+    case kPanelUiCId:
179
+      break;
180
+
181
+    case kBtnUiCId:
182
+      ctl->u.btn = new Fl_Button(x,y,a->w,a->h,a->sval);
183
+      _insertNewCtl(pp,ctl,ctl->u.btn,a->flags);
184
+      ctl->cbArg.flags |= kIvalUiFl;
185
+      break;
186
+
187
+    case kCheckUiCId:
188
+      ctl->u.chk = new Fl_Check_Button(x,y,a->w,a->h,a->sval);
189
+      _insertNewCtl(pp,ctl,ctl->u.chk,a->flags);
190
+      ctl->cbArg.flags |= kIvalUiFl;
191
+      ctl->u.chk->value(a->ival);
192
+      break;
193
+
194
+    case kMenuBtnUiCId:
195
+      ctl->u.mbt = new Fl_Menu_Button(x,y,a->w,a->h,a->sval!=NULL ? a->sval : NULL);
196
+      _insertNewCtl(pp,ctl,ctl->u.mbt,a->flags);
197
+      ctl->cbArg.flags |= kIvalUiFl;
198
+      ctl->u.mbt->value(0);
199
+      break;
200
+
201
+    case kListUiCId:
202
+      ctl->u.lst = new Fl_Select_Browser(x,y,a->w,a->h);      
203
+      _insertNewCtl(pp,ctl,ctl->u.lst,a->flags);
204
+      ctl->cbArg.flags |= kIvalUiFl;
205
+      break;
206
+
207
+    case kLabelUiCId:
208
+      {
209
+        unsigned flags = a->flags;
210
+        ctl->u.lbl = new Fl_Box(x,y,a->w,a->h);
211
+        ctl->u.lbl->copy_label(a->sval);
212
+        if( _hasNoAlignFlags(flags) )
213
+          flags |= kHCtrUiFl | kInsideUiFl;
214
+        _insertNewCtl(pp,ctl,ctl->u.lbl,flags);
215
+      }
216
+      break;
217
+
218
+    case kStringUiCId:
219
+      {
220
+        unsigned flags = a->flags;
221
+        ctl->u.str = new Fl_Input(x,y,a->w/2,a->h);
222
+        ctl->u.str->copy_label(a->sval);
223
+        if( _hasNoAlignFlags(flags) )
224
+          flags |= kRightUiFl;
225
+        _insertNewCtl(pp,ctl,ctl->u.str,flags);
226
+        ctl->cbArg.flags |= kSvalUiFl;
227
+      }
228
+      break;
229
+
230
+    case kConsoleUiCId:
231
+      {
232
+        unsigned flags = a->flags;
233
+        ctl->u.con = new Fl_Text_Display(x,y,a->w,a->h);
234
+        ctl->u.con->buffer(new Fl_Text_Buffer());
235
+        ctl->u.con->textsize(12);
236
+        ctl->u.con->textfont(FL_COURIER);
237
+        ctl->u.con->copy_label(a->sval);
238
+        if( _hasNoAlignFlags(flags) )
239
+          flags |= kRightUiFl;
240
+        _insertNewCtl(pp,ctl,ctl->u.con,flags);
241
+        ctl->cbArg.flags |= kSvalUiFl;
242
+      }
243
+      break;
244
+
245
+    case kSliderUiCId:
246
+      {
247
+        unsigned flags = a->flags;
248
+        int      w = a->w;
249
+        int      h = a->h;
250
+
251
+        if( cmIsFlag(flags,kHorzUiFl) )
252
+        {
253
+          if( _hasNoAlignFlags(flags) )
254
+            flags |= kRightUiFl;
255
+
256
+          w /= 2;
257
+
258
+        }
259
+
260
+        if( cmIsFlag(flags,kVertUiFl) )
261
+        {
262
+          if( _hasNoAlignFlags(flags) )
263
+            flags |= kTopUiFl | kHCtrUiFl;
264
+
265
+          if( a->sval != NULL )
266
+          {
267
+            int hh,ww;
268
+            fl_measure(a->sval,ww,hh);
269
+
270
+            if( flags & kTopUiFl )
271
+            {
272
+              y += hh;
273
+              h -= hh;
274
+            }
275
+        
276
+            if( flags & kBottomUiFl)
277
+              h -= hh;
278
+
279
+          }
280
+        }
281
+
282
+        ctl->u.sld = new Fl_Value_Slider(x,y,w,h);
283
+        ctl->u.sld->copy_label(a->sval);
284
+
285
+
286
+        if( cmIsFlag(flags,kHorzUiFl) )
287
+          ctl->u.sld->type(FL_HOR_NICE_SLIDER);
288
+
289
+        if( cmIsFlag(flags,kVertUiFl) )
290
+          ctl->u.sld->type(FL_VERT_NICE_SLIDER);
291
+
292
+        _insertNewCtl(pp,ctl,ctl->u.sld,flags);
293
+
294
+        ctl->cbArg.flags |= kFvalUiFl;
295
+
296
+      }
297
+      break;
298
+
299
+    case kNumberUiCId:
300
+      {
301
+        unsigned flags = a->flags;
302
+        ctl->u.num = new Fl_Value_Input(x,y,a->w/2,a->h);
303
+        ctl->u.num->copy_label(a->sval);
304
+        if( _hasNoAlignFlags(flags) )
305
+          flags |= kRightUiFl;
306
+
307
+        _insertNewCtl(pp,ctl,ctl->u.num,flags);
308
+        ctl->cbArg.flags |= kFvalUiFl;
309
+        ctl->u.num->when(FL_WHEN_ENTER_KEY | FL_WHEN_NOT_CHANGED ); 
310
+      }
311
+      break;
312
+
313
+    case kProgressUiCId:
314
+      {
315
+        unsigned flags = a->flags;
316
+        ctl->u.prg = new Fl_Progress(x,y,a->w/2,a->h);
317
+        ctl->u.prg->copy_label(a->sval);
318
+        if( _hasNoAlignFlags(flags) )
319
+          flags |= kRightUiFl;
320
+        _insertNewCtl(pp,ctl,ctl->u.prg,flags);
321
+        ctl->u.prg->color( fl_rgb_color((unsigned char)256),fl_rgb_color((unsigned char)128));
322
+      }
323
+      break;
324
+
325
+    case kMeterUiCId:
326
+      {
327
+        unsigned flags = a->flags;
328
+        if( cmIsFlag(flags,kVertUiFl) )
329
+        {
330
+          ctl->u.mtr = new Fl_Vert_Progress(x,y,a->w/2,a->h);
331
+          ctl->u.mtr->color( fl_rgb_color((unsigned char)256),fl_rgb_color((unsigned char)128));
332
+        }
333
+        else
334
+        {
335
+          ctl->u.mtr = new Fl_Progress(x,y,a->w,a->h);
336
+          ctl->u.mtr->color( fl_rgb_color((unsigned char)256),fl_rgb_color((unsigned char)128));
337
+        }
338
+
339
+        ctl->u.mtr->copy_label(a->sval);
340
+
341
+        if( _hasNoAlignFlags(flags) )
342
+          flags |= kRightUiFl;
343
+        _insertNewCtl(pp,ctl,ctl->u.mtr,flags);
344
+      }
345
+      break;
346
+
347
+    case kFilenameUiCId:
348
+    case kDirUiCId:
349
+      {
350
+        unsigned flags = a->cId==kDirUiCId ? Fl_File_Btn::kDir_Type_Id : Fl_File_Btn::kFile_Type_Id;
351
+        ctl->u.fnb = new Fl_File_Btn(flags,"",x,y,a->w,a->h,a->sval);
352
+        flags = a->flags;
353
+        if( _hasNoAlignFlags(flags) )
354
+          flags |= kRightUiFl;
355
+        _insertNewCtl(pp,ctl,ctl->u.fnb,flags);
356
+        ctl->cbArg.flags |= kSvalUiFl;
357
+      }
358
+      break;
359
+
360
+    case kMaxUiCId:
361
+      assert(0);
362
+      break;
363
+
364
+  }
365
+
366
+  pp->grp->redraw();
367
+
368
+  return rc;
369
+}
370
+
371
+cmUiRC_t cmUiDrvrFltk::_setValueCtl( const cmUiDriverArg_t* a )
372
+{
373
+  cmUiRC_t rc;
374
+  panel_t* pp     = NULL;
375
+  panel_t* prvPnl = NULL;
376
+  ctl_t*   ctl    = NULL;
377
+  ctl_t*   prvCtl = NULL;
378
+
379
+  if((rc = _findPanel(a->appId,a->panelId,pp,prvPnl)) != kOkUiRC )
380
+    return rc;
381
+
382
+  if((rc= _findCtl(pp, a->usrId, ctl, prvCtl )) != kOkUiRC )
383
+    return rc;
384
+
385
+
386
+  switch( a->cId )
387
+  {
388
+    case kInvalidUiCId:
389
+      break;
390
+
391
+    case kPanelUiCId:
392
+      break;
393
+
394
+    case kBtnUiCId:
395
+      if( cmIsFlag(a->flags,kLblUiFl) )
396
+        ctl->u.btn->copy_label(a->sval);
397
+      break;
398
+
399
+    case kCheckUiCId:
400
+      switch( a->flags & (kLblUiFl | kValUiFl) )
401
+      {
402
+        case kValUiFl: ctl->u.chk->value(a->ival); break;
403
+        case kLblUiFl: ctl->u.chk->copy_label(a->sval); break;
404
+      }
405
+      break;
406
+
407
+    case kMenuBtnUiCId:
408
+      switch( a->flags & (kAppendUiFl | kClearUiFl | kValUiFl) )
409
+      {
410
+        case kValUiFl: 
411
+          if( a->ival < ctl->u.mbt->size() )
412
+          {
413
+            ctl->u.mbt->value(a->ival); 
414
+            if( ctl->u.mbt->mvalue() != NULL)
415
+              ctl->u.mbt->copy_label( ctl->u.mbt->mvalue()->label());
416
+          }
417
+          break;
418
+
419
+        case kClearUiFl: 
420
+          ctl->u.mbt->clear(); 
421
+          ctl->u.mbt->copy_label("");
422
+          break;
423
+
424
+        case kAppendUiFl: 
425
+          {
426
+            int n;
427
+            ctl->u.mbt->add( a->sval,0,ctl->u.mbt->callback(),ctl->u.mbt->user_data(),0); 
428
+            n = ctl->u.mbt->size();
429
+            if( (n) == 2 )
430
+            {
431
+              
432
+              ctl->u.mbt->value(0);
433
+              if( ctl->u.mbt->mvalue() != NULL)
434
+              {
435
+                const char* s = ctl->u.mbt->mvalue()->label();
436
+                ctl->u.mbt->copy_label( s);
437
+              }
438
+            }
439
+          }
440
+          break;
441
+      }
442
+      break;
443
+
444
+    case kListUiCId:
445
+      switch( a->flags & (kAppendUiFl | kClearUiFl | kValUiFl) )
446
+      {
447
+        case kValUiFl:    ctl->u.lst->value(a->ival);  break;
448
+        case kAppendUiFl: ctl->u.lst->add( a->sval ); break;
449
+        case kClearUiFl:  ctl->u.lst->clear(); break;
450
+      }
451
+      break;
452
+
453
+    case kLabelUiCId:
454
+      ctl->u.str->value(a->sval); 
455
+      break;
456
+
457
+    case kStringUiCId:
458
+      switch( a->flags & (kLblUiFl | kValUiFl) )
459
+      {
460
+        case kValUiFl: ctl->u.str->value(a->sval); break;
461
+        case kLblUiFl: ctl->u.str->copy_label(a->sval); break;
462
+      }
463
+      break;
464
+
465
+    case kConsoleUiCId:
466
+      switch( a->flags & (kLblUiFl | kValUiFl) )
467
+      {
468
+        case kValUiFl: if(a->sval!=NULL) ctl->u.con->insert(a->sval); break;
469
+        case kLblUiFl: ctl->u.str->copy_label(a->sval); break;
470
+      }
471
+      break;
472
+
473
+    case kSliderUiCId:
474
+    case kNumberUiCId:
475
+      {
476
+        Fl_Valuator* vp = static_cast<Fl_Valuator*>(ctl->wdgt);
477
+
478
+        // Correct for problem where the vertical slider values go up as the
479
+        // slider knob is dragged down.
480
+        bool invertFl =  a->cId == kSliderUiCId && cmIsFlag(ctl->flags,kVertUiFl);
481
+
482
+        switch(a->flags & (kNumMask | kLblUiFl | kMinUiFl | kMaxUiFl))
483
+        {
484
+          case kLblUiFl: ctl->u.num->copy_label(a->sval); break;
485
+          case kValUiFl: vp->value(a->fval);   break;
486
+          case kIncUiFl: vp->step(a->fval);    break;
487
+          case kMinUiFl: invertFl ? vp->maximum(a->fval) : vp->minimum(a->fval); break;
488
+          case kMaxUiFl: invertFl ? vp->minimum(a->fval) : vp->maximum(a->fval); break;
489
+        }
490
+      }
491
+      break;
492
+
493
+    case kProgressUiCId:
494
+      switch( a->flags & (kLblUiFl | kValUiFl | kMinUiFl | kMaxUiFl) )
495
+      {
496
+        case kValUiFl: ctl->u.prg->value(a->ival); break;
497
+        case kLblUiFl: ctl->u.prg->copy_label(a->sval); break;
498
+        case kMinUiFl: ctl->u.prg->minimum(a->ival); break;
499
+        case kMaxUiFl: ctl->u.prg->maximum(a->ival); break;
500
+      }
501
+      break;
502
+
503
+    case kMeterUiCId:
504
+      switch( a->flags & (kLblUiFl | kValUiFl | kMinUiFl | kMaxUiFl) )
505
+      {
506
+        case kValUiFl: ctl->u.mtr->value(a->ival); ctl->u.mtr->redraw(); break;
507
+        case kLblUiFl: ctl->u.mtr->copy_label(a->sval); break;
508
+        case kMinUiFl: ctl->u.prg->minimum(a->ival); break;
509
+        case kMaxUiFl: ctl->u.prg->maximum(a->ival); break;
510
+      }
511
+      break;
512
+
513
+    case kFilenameUiCId:
514
+    case kDirUiCId:
515
+      switch(a->flags & (kFnMask | kValUiFl | kFnPatUiFl | kFnDirUiFl) )
516
+      {
517
+        case kValUiFl:   
518
+          ctl->u.fnb->filename(a->sval); 
519
+          break;
520
+        case kFnPatUiFl: ctl->u.fnb->pattern_string(a->sval); break;
521
+        case kFnDirUiFl: 
522
+          ctl->u.fnb->type( ctl->u.fnb->type()==Fl_File_Btn::kFile_Type_Id ? Fl_File_Btn::kDir_Type_Id : Fl_File_Btn::kFile_Type_Id );
523
+          break;
524
+      }
525
+      break;
526
+
527
+    case kMaxUiCId:
528
+      assert(0);
529
+      break;
530
+  }
531
+
532
+  // echo the result back to the UI
533
+  //if( cmIsFlag(a->flags,kValUiFl|kAppendUiFl) )
534
+  //  _cbFunc(_cbArgs,a);
535
+
536
+  return rc;
537
+}
538
+
539
+cmUiRC_t cmUiDrvrFltk::_enableCtl( const cmUiDriverArg_t* a )
540
+{
541
+  cmUiRC_t rc;
542
+  panel_t* pp     = NULL;
543
+  panel_t* prvPnl = NULL;
544
+  ctl_t*   ctl    = NULL;
545
+  ctl_t*   prvCtl = NULL;
546
+
547
+  if((rc = _findPanel(a->appId,a->panelId,pp,prvPnl)) != kOkUiRC )
548
+    return rc;
549
+
550
+  if((rc= _findCtl(pp, a->usrId, ctl, prvCtl )) != kOkUiRC )
551
+    return rc;
552
+
553
+  if( a->ival )
554
+    ctl->wdgt->activate();
555
+  else
556
+    ctl->wdgt->deactivate();
557
+
558
+  _doCb(ctl,kEnableDId,0);
559
+
560
+  return rc;
561
+}
562
+
563
+cmUiRC_t   cmUiDrvrFltk::_destroyCtl( unsigned appId, unsigned panelId, unsigned usrId, bool deleteWindowEleFlag )
564
+{
565
+  cmUiRC_t rc     = kOkUiRC;
566
+
567
+  panel_t* pp     = NULL;
568
+  panel_t* prvPnl = NULL;
569
+
570
+  // locate the panel assoc'd with the ctl
571
+  if((rc = _findPanel(appId,panelId,pp,prvPnl,true)) != kOkUiRC )
572
+    return rc;
573
+
574
+  // if the panel is the ctl to delete ...
575
+  if( usrId == pp->usrId )
576
+  {
577
+    // ... unlink the panel
578
+    if( prvPnl!=NULL)
579
+      prvPnl->link = pp->link;
580
+    else
581
+    {
582
+      assert(_panels == pp );
583
+      _panels = pp->link;
584
+    }
585
+  }
586
+
587
+  return _destroyCtl(pp,usrId,deleteWindowEleFlag);
588
+}
589
+
590
+cmUiRC_t   cmUiDrvrFltk::_destroyCtl( panel_t* pp, unsigned usrId, bool deleteWindowEleFlag )
591
+{
592
+  cmUiRC_t rc     = kOkUiRC;
593
+  ctl_t*   ctl    = NULL;
594
+  ctl_t*   prvCtl = NULL;
595
+
596
+  // if the panel is the ctl to delete
597
+  if( usrId == pp->usrId )
598
+  {
599
+    return _destroyPanel(pp,deleteWindowEleFlag);
600
+  }
601
+
602
+  // locate the control on the panel
603
+  if((rc = _findCtl(pp,usrId,ctl,prvCtl,true)) != kOkUiRC )
604
+    return rc;
605
+
606
+  // unlink the control
607
+  if( prvCtl!=NULL)
608
+    prvCtl->link = ctl->link;
609
+  else
610
+  {
611
+    assert( pp->ctls == ctl );
612
+    pp->ctls = ctl->link;
613
+  }
614
+  
615
+  // delete the window element
616
+  if( deleteWindowEleFlag)
617
+    delete ctl->wdgt;
618
+
619
+  // release the control recd
620
+  cmMemFree(ctl);
621
+
622
+  return rc;
623
+}
624
+
625
+cmUiRC_t cmUiDrvrFltk::_createPanel( const cmUiDriverArg_t* a )
626
+{
627
+  int tx,ty,tw,th;
628
+  _tabs->client_area(tx,ty,tw,th);
629
+  panel_t* pnl = cmMemAllocZ(panel_t,1);
630
+  
631
+  pnl->drvr   = this;
632
+  pnl->grp    = new Fl_Group(tx,ty,tw,th,a->sval);
633
+  pnl->grp->user_data(pnl);
634
+  pnl->appId  = a->appId;
635
+  pnl->usrId  = a->usrId;
636
+  pnl->x_offs = tx + 2;
637
+  pnl->y_offs = ty + 2;
638
+  pnl->link   = _panels;
639
+  _panels     = pnl;
640
+
641
+  pnl->grp->end();
642
+
643
+  if( cmIsFlag(a->flags,kPrependUiFl) )
644
+    _tabs->insert(*pnl->grp,0);
645
+  else
646
+    _tabs->add(pnl->grp);
647
+
648
+  // cache the event callback arg record so that it 
649
+  // does not have to be filled on every callback.
650
+  cmUiDriverArgSetup(&pnl->cbArg,a->hdr.rtSubIdx,kUiDrvrSelRtId,kSetValDId,a->appId,a->usrId,a->usrId,kPanelUiCId,kIvalUiFl,0,0,NULL,tx,ty,tw,th);
651
+
652
+
653
+  _tabs->redraw();
654
+
655
+  return kOkUiRC;
656
+}
657
+
658
+cmUiRC_t  cmUiDrvrFltk::_destroyAllPanels( bool deleteWindowEleFlag )
659
+{
660
+  cmUiRC_t rc = kOkUiRC;
661
+
662
+  while( _panels != NULL )
663
+  {
664
+    cmUiRC_t rc0;
665
+    if((rc0 = _destroyCtl(_panels->appId,_panels->usrId,_panels->usrId,deleteWindowEleFlag)) != kOkUiRC )
666
+      rc = rc0;
667
+  }
668
+
669
+  return rc;
670
+}
671
+
672
+cmUiRC_t cmUiDrvrFltk::_destroyPanel(panel_t* pp, bool deleteWindowEleFlag)
673
+{
674
+  cmUiRC_t rc = kOkUiRC;
675
+
676
+  // delete the FLTK panel itself
677
+  if( deleteWindowEleFlag )
678
+  {
679
+    delete pp->grp;
680
+    deleteWindowEleFlag = false;
681
+  }
682
+
683
+  while( pp->ctls != NULL )
684
+  {
685
+    cmUiRC_t rc0;
686
+
687
+    if((rc0 = _destroyCtl(pp,pp->ctls->usrId,deleteWindowEleFlag)) != kOkUiRC )
688
+      rc = rc0;
689
+  }
690
+
691
+  cmMemFree(pp);
692
+
693
+  return rc;
694
+}
695
+
696
+cmUiRC_t cmUiDrvrFltk::_findPanel( unsigned appId, unsigned usrId, panel_t*& ppRef, panel_t*& prvPnl, bool errFl )
697
+{
698
+  ppRef  = NULL;
699
+  prvPnl = NULL;
700
+
701
+  panel_t* pp = _panels;
702
+  for(; pp!=NULL; pp=pp->link)
703
+  {
704
+    if(pp->appId==appId && pp->usrId==usrId )
705
+    {
706
+      ppRef = pp;
707
+      return kOkUiRC;
708
+    }
709
+    prvPnl = pp;
710
+  }
711
+  if( errFl )
712
+    cmErrMsg(&_err,kPanelNotFoundUiRC,"Panel not found for id=%i.",usrId);
713
+
714
+  return kPanelNotFoundUiRC;
715
+}
716
+
717
+cmUiRC_t cmUiDrvrFltk::_findCtl( panel_t* pp, unsigned usrId, ctl_t*& ctlRef, ctl_t*& prvCtlRef, bool errFl )
718
+{
719
+  ctlRef    = NULL;
720
+  prvCtlRef = NULL;
721
+  ctl_t* cp = pp->ctls;
722
+  for(; cp!=NULL; cp=cp->link)
723
+  {
724
+    if( cp->usrId == usrId )
725
+    {
726
+      ctlRef = cp;
727
+      return kOkUiRC;
728
+    }
729
+
730
+    prvCtlRef = cp;
731
+  }   
732
+  if( errFl )
733
+    cmErrMsg(&_err,kCtlNotFoundUiRC,"Control %i not found in panel %i.",usrId,pp->usrId);
734
+
735
+  return kCtlNotFoundUiRC;
736
+}
737
+
738
+void    cmUiDrvrFltk::_doCb( ctl_t* ctl, cmUiDId_t dId, unsigned flags )
739
+{
740
+  cmUiDriverArg_t* a = &ctl->cbArg;
741
+  unsigned orgFlags = a->flags;
742
+  a->flags |= flags;
743
+  a->dId    = dId;
744
+
745
+  _cbFunc(_cbArgs,&ctl->cbArg);
746
+
747
+  a->flags = orgFlags;
748
+  a->dId   = kInvalidDId;
749
+}
750
+
751
+void cmUiDrvrFltk::_s_ctl_cb(Fl_Widget* wp, void* arg )
752
+{
753
+  ctl_t*           ctl        = (ctl_t*)arg;
754
+  cmUiDrvrFltk*    p          = ctl->pnl->drvr;
755
+  cmUiDriverArg_t* a          = &ctl->cbArg;
756
+  bool             callbackFl = true;
757
+  unsigned         flags      = kValUiFl;
758
+
759
+  switch( ctl->cId )
760
+  {
761
+    case kInvalidUiCId:
762
+      assert(0);
763
+      callbackFl = false;
764
+      break;
765
+
766
+    case kPanelUiCId:
767
+      callbackFl = false;
768
+      break;
769
+
770
+    case kBtnUiCId:
771
+      break;
772
+
773
+    case kCheckUiCId:
774
+      a->ival = ctl->u.chk->value();
775
+      flags |= kIvalUiFl;
776
+      break;
777
+
778
+    case kMenuBtnUiCId:
779
+      if( ctl->u.mbt->mvalue() != NULL && ctl->u.mbt->mvalue()->label() != NULL )
780
+        ctl->u.mbt->copy_label(ctl->u.mbt->mvalue()->label());
781
+      a->ival = ctl->u.mbt->value();
782
+      flags |= kIvalUiFl;
783
+      break;
784
+
785
+    case kListUiCId:
786
+      a->ival = ctl->u.lst->value() - 1;
787
+      flags |= kIvalUiFl;
788
+      break;
789
+
790
+    case kLabelUiCId:
791
+      callbackFl = false;
792
+      break;
793
+
794
+    case kStringUiCId:
795
+      a->sval = ctl->u.str->value();
796
+      flags |= kSvalUiFl;
797
+      break;
798
+
799
+    case kConsoleUiCId:
800
+      callbackFl = false;
801
+      break;
802
+
803
+    case kSliderUiCId:
804
+      a->fval = ctl->u.sld->value();
805
+      flags |= kFvalUiFl;
806
+      break;
807
+
808
+    case kNumberUiCId:
809
+      a->fval = ctl->u.num->value();
810
+      flags |= kFvalUiFl;
811
+      break;
812
+
813
+    case kProgressUiCId:
814
+      callbackFl = false;
815
+      break;
816
+
817
+    case kMeterUiCId:
818
+      callbackFl = false;
819
+      break;
820
+
821
+    case kFilenameUiCId:
822
+      a->sval = ctl->u.fnb->filename();
823
+      flags |= kSvalUiFl;
824
+      break;
825
+
826
+    case kDirUiCId:
827
+      a->sval = ctl->u.fnb->filename();
828
+      flags |= kSvalUiFl;
829
+      break;
830
+
831
+    case kMaxUiCId:
832
+      callbackFl = false;
833
+      assert(0);
834
+      break;
835
+  }
836
+
837
+  if( callbackFl )
838
+    p->_doCb(ctl,kSetValDId,flags);
839
+  
840
+}
841
+
842
+void cmUiDrvrFltk::_s_tab_cb(Fl_Widget* wp, void* arg )
843
+{
844
+  cmUiDrvrFltk*   p   = (cmUiDrvrFltk*)arg;
845
+  Fl_Widget*      w   = p->_tabs->value();
846
+  
847
+  panel_t* pp = p->_panels;
848
+  for(; pp!=NULL; pp=pp->link)    
849
+  {
850
+    // if this is the panel being selected then send a 1 otherwise send a 0.
851
+    pp->cbArg.flags = cmSetFlag(pp->cbArg.flags, kIvalUiFl );
852
+    pp->cbArg.dId   = kSetValDId;
853
+    pp->cbArg.ival  = w->user_data() == pp->grp->user_data();
854
+
855
+    p->_cbFunc(p->_cbArgs,&pp->cbArg);
856
+
857
+    pp->cbArg.flags = cmClrFlag(pp->cbArg.flags, kIvalUiFl );
858
+    pp->cbArg.dId   = kInvalidDId;
859
+    
860
+  }
861
+
862
+}
863
+
864
+
865
+

+ 99
- 0
src/libcmpp/fltk/cmUiDrvrFltk.h View File

@@ -0,0 +1,99 @@
1
+#ifndef cmUiDrvrFltk_h
2
+#define cmUiDrvrFltk_h
3
+
4
+class Fl_Tabs;
5
+class Fl_Widget;
6
+class Fl_Button;
7
+class Fl_Check_Button;
8
+class Fl_Menu_Button;
9
+class Fl_Select_Browser;
10
+class Fl_Box;
11
+class Fl_Input;
12
+class Fl_Value_Input;
13
+class Fl_Value_Slider;
14
+class Fl_Progress;
15
+class Fl_Vert_Progress;
16
+class Fl_File_Btn; 
17
+class Fl_Text_Display;
18
+
19
+class cmUiDrvrFltk
20
+{
21
+public:
22
+
23
+  cmUiDrvrFltk(cmCtx_t* ctx, Fl_Tabs* tabs, cmUiDriverFunc_t cbFunc, void* cbArg);
24
+  virtual ~cmUiDrvrFltk();
25
+
26
+  void setBaseWindow( Fl_Tabs* tabs );
27
+  void setCallback( cmUiDriverFunc_t cbFunc, void* cbArg );
28
+
29
+  static cmUiRC_t cmUiDriverFunc( void* arg, const cmUiDriverArg_t* a );
30
+
31
+private:
32
+  struct panel_str;
33
+
34
+  typedef struct ctl_str
35
+  {
36
+    cmUiCId_t         cId;     // control type id
37
+    unsigned          usrId;   // user id
38
+    unsigned          flags;   // flags from this controls create call.
39
+    struct panel_str* pnl;     // parent panel
40
+    Fl_Widget*        wdgt;    // this controls FLTK wdgt ptr
41
+    cmUiDriverArg_t   cbArg;   // cached callback arg. recd used by this ctl
42
+    struct ctl_str*   link;    // panel.ctls list link
43
+   
44
+    union
45
+    {
46
+      Fl_Button*         btn;    
47
+      Fl_Check_Button*   chk;
48
+      Fl_Menu_Button*    mbt;
49
+      Fl_Select_Browser* lst;
50
+      Fl_Box*            lbl;
51
+      Fl_Input*          str;
52
+      Fl_Text_Display*   con;
53
+      Fl_Value_Input*    num;
54
+      Fl_Value_Slider*   sld;
55
+      Fl_Progress*       prg;
56
+      Fl_Progress*       mtr;
57
+      Fl_File_Btn*       fnb;
58
+    } u;
59
+  } ctl_t;
60
+
61
+  typedef struct panel_str
62
+  {
63
+    cmUiDrvrFltk*     drvr;   // parent driver object
64
+    Fl_Group*         grp;    // panel Widget
65
+    unsigned          appId;  // id of the app. this panel serves
66
+    unsigned          usrId;  // panels id
67
+    int               x_offs; // left control border
68
+    int               y_offs; // top control border
69
+    ctl_t*            ctls;   // this panels control list
70
+    cmUiDriverArg_t   cbArg;  // cached callback arg recd used by this ctl
71
+    struct panel_str* link;   // links used by _panels
72
+  } panel_t;
73
+
74
+  cmErr_t          _err;     //
75
+  Fl_Tabs*         _tabs;    // Fl_Tabs Widget containing the panels
76
+  cmUiDriverFunc_t _cbFunc;  // application event callback function
77
+  void*            _cbArgs;  // 
78
+  panel_t*         _panels;  // panel list
79
+  ctl_t            _dummy;   // 
80
+    
81
+  void        _insertNewCtl( panel_t* pp, ctl_t* ctl, Fl_Widget* wp, unsigned flags );
82
+  bool        _hasNoAlignFlags( unsigned flags ) const;
83
+  cmUiRC_t    _createCtl(   const cmUiDriverArg_t* a );
84
+  cmUiRC_t    _destroyCtl(  unsigned appId, unsigned panelId, unsigned usrId, bool deleteWindowEleFlag );
85
+  cmUiRC_t    _destroyCtl(  panel_t* pp, unsigned usrId, bool deleteWindowEleFlag );
86
+  cmUiRC_t    _createPanel( const cmUiDriverArg_t* a );
87
+  cmUiRC_t    _setValueCtl( const cmUiDriverArg_t* a );
88
+  cmUiRC_t    _enableCtl( const cmUiDriverArg_t* a );
89
+  cmUiRC_t    _destroyAllPanels( bool deleteWindowEleFl );
90
+  cmUiRC_t    _destroyPanel(panel_t* pp, bool deleteWindowEleFl );
91
+  cmUiRC_t    _findPanel( unsigned appId, unsigned usrId, panel_t*& ppRef, panel_t*& prvPnlRef, bool errFl=true );
92
+  cmUiRC_t    _findCtl( panel_t* pp, unsigned usrId, ctl_t*& ctlRef, ctl_t*& prvCtlRef, bool errFl=true );
93
+  void        _doCb( ctl_t* ctl, cmUiDId_t dId, unsigned flags );
94
+
95
+  static void _s_ctl_cb(Fl_Widget* wp, void* data );
96
+  static void _s_tab_cb(Fl_Widget* wp, void* data );
97
+};
98
+
99
+#endif

+ 11
- 0
src/tlCtl/Makefile.am View File

@@ -0,0 +1,11 @@
1
+
2
+
3
+tlCtlSRC  = src/tlCtl/cmdIf.h        src/tlCtl/cmdIf.cpp
4
+tlCtlSRC += src/tlCtl/gvHashFunc.h   src/tlCtl/gvHashFunc.cpp
5
+tlCtlSRC += src/tlCtl/cmGrTlFltk.h   src/tlCtl/cmGrTlFltk.cpp
6
+tlCtlSRC += src/tlCtl/cmGrScFltk.h   src/tlCtl/cmGrScFltk.cpp
7
+tlCtlSRC += src/tlCtl/cmGrTksbFltk.h src/tlCtl/cmGrTksbFltk.cpp
8
+tlCtlSRC += src/tlCtl/cmGrTksrFltk.h src/tlCtl/cmGrTksrFltk.cpp
9
+tlCtlSRC += src/tlCtl/cmGr2dFltk.h   src/tlCtl/cmGr2dFltk.cpp
10
+
11
+tlCtlSRC += src/tlCtl/tlCtl.h        src/tlCtl/tlCtl.cpp

+ 148
- 0
src/tlCtl/cmGr2dFltk.cpp View File

@@ -0,0 +1,148 @@
1
+#include <FL/Fl.H>
2
+#include <Fl/fl_draw.h>
3
+#include <FL/Fl_Widget.H>
4
+#include <FL/Fl_Double_Window.H>
5
+#include <Fl/Fl_Output.H>
6
+#include <Fl/Fl_Menu_Bar.H>
7
+
8
+#include <vector>
9
+
10
+#include "Fl_CbLinker.h"
11
+
12
+#include "cmGlobal.h"
13
+#include "cmFloatTypes.h"
14
+#include "cmRpt.h"
15
+#include "cmErr.h"
16
+#include "cmCtx.h"
17
+#include "cmMem.h"
18
+#include "cmMallocDebug.h"
19
+#include "cmLinkedHeap.h"
20
+#include "cmText.h"
21
+
22
+#include "cmGr.h"
23
+#include "cmGrDevCtx.h"
24
+#include "cmGrPlot.h"
25
+#include "cmGrPage.h"
26
+#include "cmGrFltk.h"
27
+#include "cmGr2dFltk.h"
28
+
29
+
30
+cmGr2dFltk::cmGr2dFltk(cmCtx_t* ctx, Fl_Menu_Bar* menuBar, int x, int y, int w, int h)
31
+  : cmGrPlotFltk(ctx,x,y,w,h),
32
+    _x(0),_y(0),_radius(0),_angle(0),
33
+    _objId(0)
34
+{
35
+  cmErrSetup(&_err,&ctx->rpt,"cmGr2dFltk");
36
+
37
+  if( cmGrPageIsValid(pageHandle()) == false )
38
+    return;
39
+
40
+  initViews(1,1);
41
+
42
+  unsigned   vwIdx = 0;
43
+  cmGrPgH_t  pgH   = pageHandle();
44
+  cmGrVwH_t  vwH   = cmGrPageViewHandle( pgH, vwIdx);
45
+  cmGrH_t    cvH   = cmGrViewGrHandle( vwH );
46
+  cmGrVExt_t limExt;
47
+
48
+  cmGrVExtSetD(&limExt,-kWidth,-kHeight,kWidth, kHeight);
49
+
50
+  cmGrObjSetWorldExt( cvH, cmGrRootObjH(cvH), &limExt );
51
+  cmGrObjSetWorldLimitExt(cvH, cmGrRootObjH(cvH), &limExt, kLeftGrFl | kRightGrFl | kTopGrFl | kBottomGrFl );
52
+
53
+  _createObj();
54
+
55
+  cmGrSetViewExtentsE( cvH,  &limExt );
56
+
57
+}
58
+
59
+cmGr2dFltk::~cmGr2dFltk()
60
+{
61
+}
62
+
63
+
64
+bool cmGr2dFltk::on_plot_object( cmGrPlotCbArg_t* arg )
65
+{
66
+  if(  arg->selId==kEventCbSelGrPlId && cmIsFlag(arg->eventFlags,kMsDragGrFl ) )
67
+  {
68
+    cmGrVExt_t vext;
69
+    cmGrPlotObjVExt(arg->objH,&vext);
70
+    //cmGrVExtPrint("",&vext);
71
+    _x = cmGrVExtMinX(&vext);
72
+    _y = cmGrVExtMinY(&vext);
73
+    _radius = sqrtf(_x*_x + _y*_y)/kWidth;
74
+    _angle  = -( atan2f(_y,_x) - M_PI/2.0);
75
+
76
+    if( _angle < 0 )
77
+      _angle += 2.0 * M_PI;
78
+
79
+    _angle = 360.0f * _angle / (2.0*M_PI);
80
+
81
+    setStatusText(cmTsPrintfS("r:%f angle:%f",_radius,_angle));
82
+
83
+    callback()(this,user_data());
84
+
85
+  }
86
+
87
+  return true;
88
+}
89
+
90
+
91
+double cmGr2dFltk::x() const
92
+{ return _x; }
93
+
94
+double cmGr2dFltk::y() const
95
+{ return _y; }
96
+
97
+double cmGr2dFltk::radius() const
98
+{ return _radius; }
99
+
100
+double cmGr2dFltk::angle() const
101
+{ return _angle; }
102
+
103
+void cmGr2dFltk::_createObj()
104
+{
105
+  cmGrPlH_t         plH         = plotHandle();
106
+  cmGrPgH_t         pgH         = pageHandle();
107
+  unsigned          vwIdx       = 0;
108
+  cmGrVwH_t         vwH         = cmGrPageViewHandle( pgH, vwIdx );
109
+  cmGrH_t           cvH         = cmGrViewGrHandle( vwH );
110
+  cmGrPlObjH_t      parentObjH  = cmGrPlObjNullHandle;
111
+  cmGrPlObjH_t      xAnchorObjH = cmGrPlObjNullHandle;
112
+  cmGrPlObjH_t      yAnchorObjH = cmGrPlObjNullHandle;
113
+  cmGrPlObjH_t      objH        = cmGrPlObjNullHandle;
114
+  cmGrPlObjTypeId_t objTypeId   = kRectGrPlId;
115
+  cmReal_t          x           = 0;
116
+  cmReal_t          y           = 0;
117
+  cmReal_t          w           = 0;
118
+  cmReal_t          h           = 0;
119
+  unsigned          flags       = 0; //kNoDragGrPlFl;
120
+  cmGrVExt_t*       wext        = NULL;
121
+
122
+  if( cmGrPlotObjCreate(plH, cvH, &objH, _objId++, parentObjH, xAnchorObjH, yAnchorObjH, objTypeId, flags | kNoDragGrPlFl, x, y, w, h, NULL, wext ) != kOkGrPlRC )
123
+  {
124
+    cmErrMsg(&_err,kCreateObjRC,"Plot origin object create failed.");
125
+  }
126
+  else
127
+  {
128
+    cmGrPlotObjSetPhysExt(objH, -2, -2, 2, 2 );
129
+    cmGrPlotObjSetFontSize(objH,8);
130
+  }
131
+    
132
+  objH = cmGrPlObjNullHandle;
133
+
134
+  if( cmGrPlotObjCreate(plH, cvH, &objH, _objId++, parentObjH, xAnchorObjH, yAnchorObjH, objTypeId, flags, x, y, w, h, NULL, wext ) != kOkGrPlRC )
135
+  {
136
+    cmErrMsg(&_err,kCreateObjRC,"Plot object create failed.");
137
+  }
138
+  else
139
+  {
140
+    //unsigned f  = 0 ? (kNorthJsGrFl | kTopJsGrFl) : (kSouthJsGrFl | kBottomJsGrFl);
141
+    //cmGrPlotObjSetLabelAttr( objH,  f | kWestJsGrFl | kTopJsGrFl | kRightJsGrFl, 0, kBlackGrId );
142
+    cmGrPlotObjSetLineColor( objH, kEnablePlGrId, kGreenGrId );
143
+    cmGrPlotObjSetPhysExt(objH, -4, -4, 4, 4 );
144
+    cmGrPlotObjSetFontSize(objH,8);
145
+  }
146
+
147
+}
148
+

+ 44
- 0
src/tlCtl/cmGr2dFltk.h View File

@@ -0,0 +1,44 @@
1
+#ifndef cmGr2dFltk_h
2
+#define cmGr2dFltk_h
3
+
4
+class Fl_Menu_Bar;
5
+
6
+class cmGr2dFltk : public cmGrPlotFltk
7
+{
8
+public:
9
+  cmGr2dFltk(cmCtx_t* ctx, Fl_Menu_Bar* menuBar, int x, int y, int w, int h);
10
+
11
+  virtual ~cmGr2dFltk();
12
+
13
+  virtual bool on_plot_object( cmGrPlotCbArg_t* arg );
14
+
15
+  double x() const;
16
+  double y() const;
17
+  double radius() const;
18
+  double angle() const;
19
+
20
+private:
21
+  enum
22
+  {
23
+    kWidth = 100,
24
+    kHeight = 100
25
+  };
26
+
27
+  enum
28
+  {
29
+    kOkRC = 0,
30
+    kCreateObjRC
31
+  };
32
+
33
+  cmErr_t _err;
34
+  double _x;
35
+  double _y;
36
+  double _radius;
37
+  double _angle;
38
+  unsigned _objId;
39
+
40
+  void _createObj();
41
+  
42
+};
43
+
44
+#endif

+ 565
- 0
src/tlCtl/cmGrScFltk.cpp View File

@@ -0,0 +1,565 @@
1
+#include <FL/Fl.H>
2
+#include <Fl/fl_draw.h>
3
+#include <FL/Fl_Widget.H>
4
+#include <FL/Fl_Double_Window.H>
5
+#include <Fl/Fl_Output.H>
6
+#include <Fl/Fl_Menu_Bar.H>
7
+
8
+#include <vector>
9
+
10
+#include "Fl_CbLinker.h"
11
+
12
+#include "cmGlobal.h"
13
+#include "cmFloatTypes.h"
14
+#include "cmRpt.h"
15
+#include "cmErr.h"
16
+#include "cmCtx.h"
17
+#include "cmMem.h"
18
+#include "cmMallocDebug.h"
19
+#include "cmLinkedHeap.h"
20
+#include "cmText.h"
21
+#include "cmThread.h"
22
+#include "cmPrefs.h"
23
+#include "cmSymTbl.h"
24
+#include "cmTime.h"
25
+#include "cmMidi.h"
26
+#include "cmMidiFile.h"
27
+#include "cmAudioFile.h"
28
+#include "cmAudioFileMgr.h"
29
+#include "cmTimeLine.h"
30
+#include "cmScore.h"
31
+
32
+#include "cmGr.h"
33
+#include "cmGrDevCtx.h"
34
+#include "cmGrPlot.h"
35
+#include "cmGrPage.h"
36
+#include "cmGrFltk.h"
37
+#include "gvHashFunc.h"
38
+#include "cmGrScFltk.h"
39
+#include "cmGrPlotAudio.h"
40
+#include "cmdIf.h"
41
+
42
+cmGrScFltk::cmGrScFltk(cmCtx_t* ctx, cmdIf* cp, Fl_Menu_Bar* menu, int x, int y, int w, int h)
43
+  : cmGrPlotFltk(ctx,x,y,w,h),
44
+    _srate(0),_cmdIf(cp),_menuBar(menu),
45
+    _samplesMetricId(cmInvalidId),_secondsMetricId(cmInvalidId),
46
+    _objSecs(0),_objId(0),
47
+    _togFl(true),
48
+    _lastBarPlotObjH(cmGrPlObjNullHandle)
49
+{
50
+  cmErrSetup(&_err,&ctx->rpt,"cmGrScFltk");
51
+
52
+  _createMenu();
53
+
54
+  if( cmGrPageIsValid(pageHandle()) == false )
55
+    return;
56
+
57
+  initViews(1,1);
58
+
59
+  unsigned   vwIdx = 0;
60
+  cmGrPgH_t  pgH   = pageHandle();
61
+  cmGrVwH_t  vwH   = cmGrPageViewHandle( pgH, vwIdx);
62
+  cmGrH_t    cvH   = cmGrViewGrHandle( vwH );
63
+  cmGrAxH_t  axH   = cmGrAxNullHandle;
64
+  cmGrVExt_t limExt;
65
+
66
+  _samplesMetricId = cmGrPageLabelFuncRegister( pgH, gvRoundHashValueFunc,    this, "Round" );              
67
+  _secondsMetricId = cmGrPageLabelFuncRegister( pgH, gvMinSecMsHashValueFunc, this, "Min:Sec:Ms" );              
68
+  unsigned pitchLabelFuncId  = cmGrPageLabelFuncRegister( pgH, gvMidiSciPitchValueFunc, this, "Pitch" );
69
+
70
+  cmGrVExtSetD(&limExt,0,0,0,127);
71
+  cmGrObjSetWorldExt( cvH, cmGrRootObjH(cvH), &limExt );
72
+
73
+  cmGrObjSetWorldLimitExt(cvH, cmGrRootObjH(cvH), &limExt, kTopGrFl | kBottomGrFl );
74
+
75
+  axH = cmGrViewAxisHandle(vwH, kTopGrIdx);
76
+  cmGrAxisSetCfg( axH, cmClrFlag(cmGrAxisCfg( axH ), kHashMarkGrFl | kHashLabelGrFl ));
77
+
78
+  axH = cmGrViewAxisHandle(vwH, kLeftGrIdx );
79
+  cmGrAxisSetLabelFunc( axH, pitchLabelFuncId );
80
+  cmGrViewSetLabelFunc(  vwH, kLeftGrIdx, pitchLabelFuncId );
81
+  
82
+  axH = cmGrViewAxisHandle(vwH, kRightGrIdx);
83
+  cmGrAxisSetCfg( axH, cmClrFlag(cmGrAxisCfg( axH ), kHashLabelGrFl ));
84
+
85
+  cmGrViewSetCfg( vwH, cmSetFlag(cmGrViewCfg(vwH),kSelectHorzGrFl)  );
86
+
87
+}
88
+
89
+cmGrScFltk::~cmGrScFltk()
90
+{
91
+}
92
+
93
+cmScMsgTypeId_t cmGrScFltk::recvScoreMsg( const void* msg, unsigned msgByteCnt )
94
+{
95
+  cmScMsg_t m;
96
+
97
+  cmScoreDecode(msg,msgByteCnt,&m);
98
+
99
+  switch( m.typeId )
100
+  {
101
+    case kBeginMsgScId:
102
+      {
103
+        _objId   = 0;
104
+        _objSecs = 0;
105
+        // remove all objects from all views
106
+        //cmGrPageClear(pageHandle());
107
+        //_srate = m.srate;
108
+        //_updateSeqMenu(m.seqCnt,m.seqId);
109
+      }
110
+      break;
111
+
112
+    case kEndMsgScId:
113
+      //size(w(),h()+1);
114
+      break;
115
+
116
+    case kEventMsgScId:
117
+      _insertEvent(&m.u.evt);
118
+      break;
119
+
120
+    case kSectionMsgScId:
121
+      _insertSection(&m.u.sect);
122
+      break;
123
+      
124
+    case kVarMsgScId:
125
+      break;
126
+
127
+    default:
128
+      { assert(0); }
129
+  }
130
+
131
+  return m.typeId;
132
+}
133
+
134
+void cmGrScFltk::setSampleRate( double srate )
135
+{ _srate = srate; }
136
+
137
+double cmGrScFltk::sampleRate() const 
138
+{ return _srate; }
139
+
140
+bool cmGrScFltk::on_plot_object(   cmGrPlotCbArg_t* arg )
141
+{
142
+  if(  arg->selId==kStateChangeGrPlId && cmIsFlag(arg->deltaFlags,kSelectGrPlFl) )
143
+  {
144
+    scObj_t* sop = (scObj_t*)cmGrPlotObjUserPtr(arg->objH);
145
+
146
+    if( sop!=NULL && sop->id==kEventMsgScId && sop->u.ep != NULL /* && sep->type == kBarEvtScId */ )
147
+    {
148
+      _lastBarPlotObjH = arg->objH;
149
+      
150
+      unsigned scoreIdx = scoreSelectedEleIndex();
151
+
152
+      // callback to: kcApp::_ctl_cb(ctl_t* cp)
153
+      callback()(this,user_data());
154
+
155
+      _cmdIf->onScoreBarSelected(scoreIdx);
156
+    
157
+      setStatusText(cmTsPrintfS("Score Index:%i",scoreIdx));
158
+    }
159
+  }
160
+  return true;
161
+}
162
+
163
+void cmGrScFltk::selectBar( unsigned barNumb )
164
+{
165
+  cmGrPlH_t plH = plotHandle();
166
+  unsigned  n   = cmGrPlotObjectCount(plH);
167
+  unsigned  i;
168
+  for(i=0; i<n; ++i)
169
+  {
170
+    cmGrPlObjH_t poH = cmGrPlotObjectIndexToHandle(plH,i);
171
+
172
+    if( cmGrPlotObjIsValid(poH) )
173
+    {
174
+      scObj_t* sop = (scObj_t*)cmGrPlotObjUserPtr(poH);
175
+
176
+      if( sop->id==kEventMsgScId && sop->u.ep!=NULL && sop->u.ep->type==kBarEvtScId && sop->u.ep->barNumb==barNumb )
177
+      {
178
+        unsigned flags = cmGrPlotObjStateFlags(poH);
179
+        
180
+        cmGrPlotObjSetStateFlags(poH,cmSetFlag(flags,kFocusGrPlFl | kSelectGrPlFl));
181
+        redraw();
182
+
183
+        _lastBarPlotObjH = poH;
184
+        
185
+        _cmdIf->onScoreBarSelected(sop->u.ep->locIdx);
186
+    
187
+        setStatusText(cmTsPrintfS("Score Index:%i",sop->u.ep->locIdx));
188
+
189
+        break;
190
+      }
191
+    }
192
+  }
193
+  
194
+}
195
+
196
+unsigned cmGrScFltk::scoreSelectedEleIndex() const
197
+{ 
198
+
199
+  if( cmGrPlotObjIsValid(_lastBarPlotObjH) )
200
+  {
201
+    scObj_t* sop = (scObj_t*)cmGrPlotObjUserPtr(_lastBarPlotObjH);
202
+
203
+    if( sop!=NULL && sop->id==kEventMsgScId && sop->u.ep != NULL /* && sop->u.ep->type == kBarEvtScId */ )
204
+      return sop->u.ep->locIdx;
205
+  }
206
+  return cmInvalidIdx;
207
+}
208
+
209
+void cmGrScFltk::setScoreLocation( unsigned locIdx, unsigned vel, unsigned smpIdx )
210
+{
211
+  
212
+}
213
+
214
+void cmGrScFltk::_insertSection( const cmScoreSection_t* m )
215
+{
216
+  // The argument is a serialzed copy of a cmScoreSection_t record.
217
+  // Convert it to a pointer to an actual object in the local score mgr.
218
+  if( cmGrPageIsValid(pageHandle()) == false )
219
+    return;
220
+
221
+  m = _cmdIf->scoreSectionIdToPtr(m->index);
222
+  assert(m!=NULL);
223
+
224
+  const cmScoreEvt_t* ep = _cmdIf->scoreEventIdToPtr(m->begEvtIndex);
225
+  assert( ep != NULL );
226
+
227
+
228
+  cmGrPlH_t         plH         = plotHandle();
229
+  cmGrPgH_t         pgH         = pageHandle();
230
+  unsigned          vwIdx       = 0;
231
+  cmGrVwH_t         vwH         = cmGrPageViewHandle(   pgH, vwIdx );
232
+  cmGrH_t           cvH         = cmGrViewGrHandle( vwH );
233
+  cmGrPlObjH_t      parentObjH  = cmGrPlObjNullHandle;
234
+  cmGrPlObjH_t      xAnchorObjH = cmGrPlObjNullHandle;
235
+  cmGrPlObjH_t      yAnchorObjH = cmGrPlObjNullHandle;
236
+  cmGrPlObjH_t      objH        = cmGrPlObjNullHandle;
237
+  cmGrPlObjTypeId_t objTypeId   = kLineGrPlId;
238
+  cmReal_t          x           = ep->secs;
239
+  cmReal_t          y           = 120;
240
+  cmReal_t          w           = 0;
241
+  cmReal_t          h           = 7;
242
+  const cmChar_t*   label       = m->label;
243
+  unsigned          flags       = kNoDragGrPlFl;
244
+  cmGrVExt_t        wext;
245
+  scObj_t           scObj(m);
246
+  
247
+  cmGrVExtSetNull(&wext);
248
+
249
+  if( cmGrPlotObjCreate(plH, cvH, &objH, _objId++, parentObjH, xAnchorObjH, yAnchorObjH, objTypeId, flags, x, y, w, h, label, cmGrVExtIsNull(&wext)?NULL:&wext ) != kOkGrPlRC )
250
+  {
251
+    cmErrMsg(&_err,kInsertObjFailRC,"Insert failed on a score section.", cmStringNullGuard(label));
252
+    return;
253
+  }
254
+
255
+  cmGrPlotObjAllocUser(objH,&scObj,sizeof(scObj));
256
+
257
+  unsigned f  = 0 ? (kNorthJsGrFl | kTopJsGrFl) : (kSouthJsGrFl | kBottomJsGrFl);
258
+  cmGrPlotObjSetLabelAttr( objH,  f | kWestJsGrFl | kTopJsGrFl | kRightJsGrFl, 0, kBlackGrId );
259
+  cmGrPlotObjSetLineColor( objH, kEnablePlGrId, kGreenGrId );
260
+  //cmGrPlotObjSetPhysExt(objH, 1, 0, 1, 0 );
261
+  cmGrPlotObjSetFontSize(objH,8);
262
+  
263
+  
264
+}
265
+
266
+void cmGrScFltk::_insertEvent( const cmScoreEvt_t* m )
267
+{
268
+  // The argument is a serialzed copy of a cmScoreEvt record.
269
+  // Convert it to a pointer to an actual object in the local score mgr.
270
+  if( cmGrPageIsValid(pageHandle()) == false )
271
+    return;
272
+
273
+  m = _cmdIf->scoreEventIdToPtr(m->index);
274
+  assert(m!=NULL);
275
+    
276
+  cmGrPlH_t         plH         = plotHandle();
2