Browse Source

Initial commit

master
kpl 11 years ago
parent
commit
4d4988c764

+ 8
- 4
Makefile.am View File

@@ -56,7 +56,11 @@ include_HEADERS += $(cmHDR)
56 56
 lib_LTLIBRARIES += src/libcm/libcm.la
57 57
 
58 58
 
59
-src_cmflapp_cmflapp_SOURCES  = src/cmflapp/main.cpp src/cmflapp/app.h src/cmflapp/app.cpp 
60
-src_cmflapp_cmflapp_SOURCES += src/cmflapp/Fl_Splitter.h src/cmflapp/Fl_Splitter.cpp
61
-src_cmflapp_cmflapp_LDADD    = $(CMLIBS) $(MYLIBS)
62
-bin_PROGRAMS                += src/cmflapp/cmflapp
59
+src_kc_kc_SOURCES  = src/kc/kcMain.cpp 
60
+src_kc_kc_SOURCES += src/kc/kcApp.h          src/kc/kcApp.cpp 
61
+src_kc_kc_SOURCES += src/kc/Fl_Splitter.h    src/kc/Fl_Splitter.cpp
62
+src_kc_kc_SOURCES += src/kc/Fl_File_Btn.h    src/kc/Fl_Vert_Progress.h
63
+src_kc_kc_SOURCES += src/kc/Fl_File_Btn.cpp  src/kc/Fl_Vert_Progress.cpp
64
+
65
+src_kc_kc_LDADD    = $(CMLIBS) $(MYLIBS)
66
+bin_PROGRAMS                += src/kc/kc

+ 2
- 2
configure.ac View File

@@ -3,10 +3,10 @@
3 3
 # this configure.ac or any of the Makefile.am files.
4 4
 #
5 5
 
6
-AC_INIT([cmflapp],[1.0],[cmflapp@larke.org])
6
+AC_INIT([kc],[1.0],[kc@larke.org])
7 7
 AC_CONFIG_AUX_DIR([build-aux])                    # put aux files in build-aux
8 8
 AM_INIT_AUTOMAKE([1.9 -Wall foreign subdir-objects]) # subdir-objects needed for non-recursive make
9
-AC_CONFIG_SRCDIR([src/cmflapp/main.cpp])
9
+AC_CONFIG_SRCDIR([src/kc/kcMain.cpp])
10 10
 AC_CONFIG_HEADERS([config.h])
11 11
 AC_CONFIG_MACRO_DIR([m4])
12 12
 

+ 0
- 555
src/cmflapp/app.cpp View File

@@ -1,555 +0,0 @@
1
-#include <FL/Fl.H>
2
-#include <FL/Fl_Widget.H>
3
-#include <FL/Fl_Double_Window.H>
4
-#include <FL/Fl_Text_Buffer.H>
5
-#include <FL/Fl_Text_Display.H>
6
-#include <FL/Fl_Tabs.H>
7
-#include <FL/Fl_Menu_Item.H>
8
-#include <FL/Fl_Menu_Bar.H>
9
-#include <FL/Fl_Button.H>
10
-#include <FL/Fl_Check_Button.H>
11
-#include <FL/Fl_Menu_Button.H>
12
-#include <FL/Fl_Value_Input.H>
13
-#include <FL/Fl_Value_Slider.H>
14
-#include <FL/Fl_Input.H>
15
-#include <FL/Fl_Box.H>
16
-#include <FL/Fl_File_Chooser.H>
17
-#include <FL/fl_draw.H>
18
-
19
-#include "Fl_Splitter.h"
20
-
21
-#include "cmPrefix.h"
22
-#include "cmGlobal.h"
23
-#include "cmRpt.h"
24
-#include "cmErr.h"
25
-#include "cmCtx.h"
26
-#include "cmMem.h"
27
-#include "cmMallocDebug.h"
28
-#include "cmFileSys.h"
29
-#include "cmThread.h"
30
-
31
-#include "appErr.h"
32
-#include "app.h"
33
-
34
-class drawWnd : public Fl_Widget
35
-{
36
-public:
37
-  drawWnd(app* ap, int x, int y, int w, int h, const char* label = NULL );
38
-  virtual ~drawWnd();
39
-
40
-  virtual int handle(int event);
41
-  virtual void resize(int x, int y, int w, int h );
42
-
43
-protected:
44
-  virtual void draw();
45
-
46
-private:
47
-  app* _app;
48
-};
49
-
50
-drawWnd::drawWnd(app* ap, int x, int y, int w, int h, const char* label )
51
-  : Fl_Widget(x,y,w,h,label),
52
-    _app(ap)
53
-{}
54
-
55
-drawWnd::~drawWnd()
56
-{}
57
-
58
-int drawWnd::handle(int event)
59
-{
60
-  switch(event)
61
-  {
62
-    case FL_PUSH:
63
-      {
64
-        const char* label;
65
-        switch( Fl::event_button() )
66
-        {
67
-          case FL_LEFT_MOUSE:   label = "left";  break;
68
-          case FL_RIGHT_MOUSE:  label = "right";  break;
69
-          case FL_MIDDLE_MOUSE: label = "middle"; break;
70
-          default:
71
-            label = "none";
72
-        }
73
-
74
-        _app->print("%i %i %s\n",Fl::event_x(),Fl::event_y(),label);
75
-      }
76
-      break;
77
-
78
-    default:
79
-      return Fl_Widget::handle(event);
80
-  }
81
-
82
-  return 1;
83
-}
84
-
85
-void drawWnd::resize(int x, int y, int w, int h )
86
-{ 
87
-  // must call base to make size change
88
-  Fl_Widget::resize(x,y,w,h); 
89
-}
90
-
91
-void drawWnd::draw()
92
-{
93
-  int offs = 10;
94
-  //fl_draw_box(FL_DOWN_BOX,x()+10,y()+10,w()-20,h()-20,FL_RED);
95
-  //fl_frame("XXXX",x()+offs,y()+offs,w()-2*offs,h()-2*offs);
96
-  fl_line_style(FL_SOLID,1,NULL);
97
-  fl_color(FL_RED);
98
-  fl_line(x()+offs,y()+offs,x()+w()-offs,y()+h()-offs);
99
-
100
-
101
-  int x = w()/2;
102
-  int y = h()/2;
103
-
104
-  fl_color(FL_BLACK);
105
-  fl_draw(90,"string",x,y);
106
-
107
-  // XXXXXXX
108
-  // X00000X
109
-  // X00000X
110
-  // X00X00X
111
-  // X00000X
112
-  // X00000X
113
-  // XXXXXXX
114
-
115
-  fl_rect(x-3,y-3,7,7); 
116
-  fl_point(x,y);
117
-}
118
-
119
-//----------------------------------------------------------------------------------------------------
120
-//----------------------------------------------------------------------------------------------------
121
-//----------------------------------------------------------------------------------------------------
122
-
123
-app::app(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const char* label, int argc, char* argv[])
124
-  : Fl_Double_Window(w,h,label), _timerPeriodSecs(0),
125
-    _ctx(ctx), _splt(NULL),_buf(NULL),_con(NULL),_tabs(NULL),_menu(NULL),
126
-    _printqH(printqH),_printFl(0)
127
-{
128
-
129
-  // install a callback to cleanup when the app window closes
130
-  // (the btn and menu callbacks also rely on a pointer to 'this' being found in app.user_data()
131
-  //  see _getApp())
132
-  callback(_s_callback,this);
133
-
134
-  // the main window is divided between the menu bar on top
135
-  // and a horizontal splitter on the bottom
136
-  begin();
137
-  createMenu(w,kMenuH);
138
-  _splt = new Fl_HSplitter(0, kMenuH, w, h-kStatusH, h-kStatusH-100);
139
-  end();
140
-
141
-  // Create a text display object for console output and
142
-  // add it to the lower splitter area
143
-  _buf = new Fl_Text_Buffer();
144
-  _con = new Fl_Text_Display(_splt->container2->x(),_splt->container2->y(),_splt->container2->w(),_splt->container2->h());
145
-  _con->buffer(_buf);
146
-  _splt->container2->add(_con);
147
-
148
-  // create tabbed windows
149
-  const char* titles[] = { "Title 1", "Title 2" };
150
-  _create_tabs(2,titles);
151
-
152
-  // make the splitter the resizable group element (thereby making the menu non-resizable).
153
-  // see:http://fltk.org/articles.php?L415+I0+T+M1000+P1
154
-  resizable(_splt); 
155
-  show(argc, argv);
156
-
157
-  // The application is now visible.
158
-  // direct all output to the console window
159
-  cmRptSetup(&_ctx->rpt,_s_print,_s_print, this);
160
-  cmTsMp1cSetCbFunc(_printqH, _s_print_queue_cb, this );
161
-
162
-
163
-  // install a timer
164
-  _timerPeriodSecs = 0.1;
165
-  Fl::add_timeout(_timerPeriodSecs,app::_s_timer_cb,this);
166
-
167
-  // install an idle callback 
168
-  //Fl::add_idle(_s_idle_cb,this);
169
-
170
-  print("Started!\n");
171
-}
172
-
173
-app::~app()
174
-{}
175
-
176
-void app::createControls(Fl_Group* grp)
177
-{
178
-  const int vBord     = 3;
179
-  const int ctl_width = 100;
180
-  int       xx        = grp->x() + 5;
181
-  int       yy        = grp->y() + vBord;
182
-
183
-  Fl_Check_Button* cbt = new Fl_Check_Button(xx,yy,ctl_width,kCtlH,"Check");
184
-  cbt->callback( _s_btn_cb, kBtn1MId );
185
-  yy += cbt->h() + vBord;
186
-
187
-  Fl_Button* btn = new Fl_Button(xx,yy,ctl_width,kCtlH,"Button");
188
-  btn->callback( _s_btn_cb, kBtn2MId );
189
-  yy += btn->h() + vBord;
190
-
191
-  // menu buttons callback through menuCallback() not btnCallback()
192
-  Fl_Menu_Button* mbt  = new Fl_Menu_Button(xx,yy,ctl_width,kCtlH,"Menu");
193
-  
194
-  mbt->add("Item 1",0,_s_menu_btn_cb, (void*)kMenuBtn1MId, 0);
195
-  mbt->add("Item 2",0,_s_menu_btn_cb, (void*)kMenuBtn2MId, 0);
196
-  yy += mbt->h() + vBord;
197
-
198
-  Fl_Value_Input* vip = new Fl_Value_Input(xx,yy,ctl_width/2,kCtlH,"Value In");
199
-  vip->callback(_s_value_cb, kValue1MId );
200
-  vip->align(FL_ALIGN_RIGHT);   // place label to the right of the input ctl
201
-  // Only make the callback when the enter key is struck or the ctl loses focus and the value has changed.
202
-  // Removing this line causes the callback whenever the input changes.
203
-  vip->when(FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE ); 
204
-  vip->bounds(-10.0,10.0);
205
-  vip->step(0.1);
206
-  yy += vip->h() + vBord;
207
-  
208
-  Fl_Value_Slider* sdp =    new Fl_Value_Slider(xx,yy,ctl_width,kCtlH,"Slider");
209
-  sdp->callback(_s_value_cb, kValue2MId );
210
-  sdp->align(FL_ALIGN_RIGHT);
211
-  sdp->type(FL_HOR_NICE_SLIDER);
212
-  sdp->bounds(-10.0,10.0);
213
-  sdp->step(0.1);
214
-  yy += sdp->h() + vBord;
215
-
216
-  Fl_Input* inp = new Fl_Input(xx,yy,ctl_width/2,kCtlH,"Text");
217
-  inp->callback(_s_input_cb,kInput1MId);
218
-  inp->align(FL_ALIGN_RIGHT);
219
-  yy += inp->h() + vBord;
220
-
221
-
222
-}
223
-
224
-
225
-void app::initializeTab(int tabIndex, int x, int y, int w, int h, const char* label)
226
-{
227
-  switch(tabIndex)
228
-  {
229
-    case 0:
230
-      {
231
-        Fl_Group* grp = new Fl_Group(x,y,w,h,label);  
232
-        grp->begin();
233
-        createControls(grp);
234
-        grp->end();
235
-      }
236
-      break;
237
-
238
-    case 1:
239
-      {
240
-        Fl_Group* grp = new Fl_Group(x,y,w,h,label);  
241
-        grp->begin();
242
-        _draw = new drawWnd(this,x,y,w,h,NULL);
243
-        grp->end();
244
-      }
245
-      break;
246
-  }
247
-
248
-}
249
-
250
-void app::createMenu(int w, int h)
251
-{
252
-  Fl_Menu_Item items[] =
253
-  {
254
-    { "&File", 0, 0, 0, FL_SUBMENU },
255
-    { "&New File",  FL_COMMAND + 'n', (Fl_Callback*)_s_menu_cb, (void*)kFileNewMId },
256
-    { "&Open File", FL_COMMAND + 'o', (Fl_Callback*)_s_menu_cb, (void*)kFileOpenMId },
257
-    { 0 },
258
-    { "&Edit", 0, 0, 0, FL_SUBMENU },
259
-    { "&Copy",  FL_COMMAND + 'c', (Fl_Callback*)_s_menu_cb, (void*)kEditCopyMId },
260
-    { "&Paste", FL_COMMAND + 'v', (Fl_Callback*)_s_menu_cb, (void*)kEditPasteMId },
261
-    { 0 },
262
-    { 0 }
263
-  };
264
-  
265
-  _menu = new Fl_Menu_Bar(0,0,w,h);
266
-  _menu->copy(items);
267
-}
268
-
269
-void app::menuCallback(const Fl_Menu_Item* mip, long int id)
270
-{
271
-  switch(id)
272
-  {
273
-    case kFileOpenMId:
274
-      {
275
-        // file chooser demo
276
-
277
-        const char* pathStr   = cmFsUserDir(); // make the default dir the user's home dir
278
-        const char patStr[]   = "Text Files (*.txt)\tAudio Files (*.{wav,aif,aiff})"; // All Files (*.*) is append to this automatically
279
-        const char titleStr[] = "Select files";
280
-
281
-        Fl_File_Chooser fc = Fl_File_Chooser(pathStr,patStr,Fl_File_Chooser::MULTI,titleStr);
282
-
283
-        fc.preview(0); // default the previous option to 'off'.
284
-        fc.show();     // show the chooser
285
-
286
-        // make the chooser modal
287
-        while( fc.shown() )
288
-          Fl::wait();
289
-
290
-        // print the selected files
291
-        int i;
292
-        for(i=1; i<=fc.count(); ++i)
293
-          print("%i %s\n",i,cmStringNullGuard(fc.value(i)));
294
-
295
-      }
296
-      break;
297
-  }
298
-
299
-  print("%i %s\n",id,mip->label());
300
-}
301
-
302
-void app::btnCallback(const Fl_Button* bp, int id )
303
-{
304
-  print("%i %s %i\n",id,bp->label(),bp->value());
305
-}
306
-
307
-void app::valueCallback(const Fl_Valuator*  vp, int id )
308
-{
309
-  print("%i %s %f\n",id,vp->label(),vp->value());
310
-}
311
-
312
-void app::inputCallback(const Fl_Input*  ip, int id )
313
-{
314
-  print("%i %s %s\n",id,ip->label(),ip->value());
315
-}
316
-
317
-void app::appCallback(Fl_Widget* wp)
318
-{
319
-  switch( Fl::event() )
320
-  {
321
-    case FL_CLOSE:
322
-      {
323
-
324
-        /*
325
-        int cc = _closeCnt;
326
-
327
-        // attempt to shut down the pgm
328
-        _closeCnt += finalizePgm() == false;
329
-
330
-        // the first time the pgm fails to shut down 
331
-        // do not allow the pgm to close the main window
332
-        // this will give a chance for the error messages
333
-        // to be diplayed in the console - all successive
334
-        // times the return value from finalizePgm() is
335
-      
336
-        // ignored and the program is terminated.
337
-        if( _closeCnt == 1 && cc==0)
338
-        {
339
-          // send a strong hint that a problem occurred on shutdown 
340
-          // and prevent the app from receiving events that might cause it to 
341
-          // crash
342
-          deactivate(); 
343
-          return;
344
-        }
345
-        */
346
-
347
-        // When all windows are windows are closed then the app.
348
-        // will close - so hiding the application window
349
-        // causes the program to close.  
350
-        //
351
-        // Note that simply returning from this callback will
352
-        // prevent the application from closing. Because the existence
353
-        // of the callback alone is enough to disable default 
354
-        // event handling.
355
-        hide();  
356
-      }
357
-      break;
358
-  }
359
-
360
-}
361
-bool app::idleCallback()
362
-{ return true; }
363
-
364
-
365
-bool app::timerCallback()
366
-{ 
367
-  _checkPrintQueue();
368
-  return true;
369
-}
370
-
371
-void app::error( const char* fmt, ... )
372
-{
373
-  va_list vl;
374
-  va_start(vl,fmt);
375
-
376
-  int bufCharCnt = 511;
377
-  char buf[bufCharCnt+1];
378
-
379
-  int n = vsnprintf(buf,bufCharCnt,fmt,vl);
380
-
381
-  if( n > 0 )
382
-    print("%s Error: %s\n",label(),buf);
383
-  
384
-  va_end(vl);
385
-}
386
-
387
-void app::vprint(const char* fmt, va_list vl )
388
-{
389
-  int bufCharCnt = 511;
390
-  char buf[bufCharCnt+1];
391
-
392
-  int n = vsnprintf(buf,bufCharCnt,fmt,vl);
393
-
394
-  if( n > 0 )
395
-  {
396
-    // if the print queue exists (it might not during startup or shutdown) ...
397
-    if( cmTsMp1cIsValid(_printqH) )
398
-    {
399
-      cmThRC_t thRC;
400
-
401
-      // ... enqueue the text to print 
402
-      if((thRC = cmTsMp1cEnqueueMsg(_printqH,buf,n+1)) != kOkThRC && _printFl==0 )
403
-      {
404
-        // Print queue error msg's directly to stdout rather than throught
405
-        // the error mechanism - this prevents generating a stack overflow
406
-        // when the print queue runs out of space and attempts to print a 
407
-        // 'queue out of memory' error msg.
408
-        // The queue itself does will not print errors because it does
409
-        // not have a valid cmRpt_t pointer.  See cmMp1cCreate() above.
410
-        ++_printFl;
411
-        cmErrMsg(&_ctx->err,kQueueFailAppRC,"Print enqueue failed.");
412
-        --_printFl;
413
-      }
414
-    }
415
-    else
416
-      _print(buf); // ... otherwise just send the text directly to the output console
417
-  }
418
-
419
-}
420
-
421
-void app::print( const char* fmt, ... )
422
-{
423
-  va_list vl;
424
-  va_start(vl,fmt);
425
-  vprint(fmt,vl);
426
-  va_end(vl);
427
-}
428
-
429
-void app::_s_menu_cb(Fl_Widget* wp, void* data)
430
-{ 
431
-  const Fl_Menu_Item* mip;
432
-  app*                ap;
433
-
434
-  if((ap=_getApp(wp)) != NULL )
435
-    if((mip = ap->_menu->mvalue()) != NULL )
436
-      ap->menuCallback(mip,(long int)mip->user_data());
437
-}
438
-
439
-void app::_s_menu_btn_cb(Fl_Widget* wp, void* data)
440
-{ 
441
-  const Fl_Menu_Button* bp;
442
-  const Fl_Menu_Item*   mip;
443
-  app*                  ap;
444
-
445
-  if((ap=_getApp(wp)) != NULL )
446
-    if((bp = static_cast<Fl_Menu_Button*>(wp)) != NULL )
447
-      if((mip = bp->mvalue()) != NULL)
448
-        ap->menuCallback(mip,(long int)data);
449
-}
450
-
451
-void app::_s_btn_cb(Fl_Widget* wp, long data )
452
-{
453
-  app*             ap;
454
-
455
-  if((ap = _getApp(wp)) != NULL )
456
-    if( wp != NULL )
457
-      ap->btnCallback( static_cast<const Fl_Button*>(wp),data);
458
-}
459
-
460
-void app::_s_value_cb(     Fl_Widget* wp, long data)
461
-{
462
-  app*             ap;
463
-  Fl_Valuator*     vp;
464
-
465
-  if((ap = _getApp(wp)) != NULL )
466
-    if((vp = static_cast<Fl_Valuator*>(wp)) != NULL)
467
-      ap->valueCallback(vp,data);
468
-}
469
-
470
-void app::_s_input_cb(   Fl_Widget* wp, long data)
471
-{
472
-  app* ap;
473
-  Fl_Input* inp;
474
-
475
-  if((ap = _getApp(wp)) != NULL)
476
-    if((inp = static_cast<Fl_Input*>(wp)) != NULL )
477
-      ap->inputCallback(inp,data);
478
-}
479
-
480
-void app::_s_callback(Fl_Widget* wp, void* data)
481
-{ ((app*)data)->appCallback(wp); }
482
-
483
-void app::_s_idle_cb(void *data)
484
-{ 
485
-  app* thisPtr = (app*)data;
486
-
487
-  if( thisPtr->idleCallback() == false )
488
-    Fl::remove_idle(_s_idle_cb,data);
489
-}
490
-
491
-void app::_s_timer_cb(void* userPtr)
492
-{ 
493
-  app* thisPtr = (app*)userPtr;
494
-
495
-  if( thisPtr->timerCallback() )
496
-    Fl::repeat_timeout(thisPtr->_timerPeriodSecs,_s_timer_cb,userPtr);
497
-}
498
-
499
-void app::_s_print( void* userPtr, const char* text )
500
-{ ((app*)userPtr)->print(text); }
501
-
502
-
503
-void app::_create_tabs(int titleCnt, const char* titleArray[])
504
-{
505
-  // Create a tab view and added it to the upper splitter area
506
-  _tabs = new Fl_Tabs(_splt->container1->x(),_splt->container1->y(),_splt->container1->w(),_splt->container1->h());
507
-  _splt->container1->add(_tabs);
508
-
509
-  int tx,ty,th,tw,i;
510
-  _tabs->client_area(tx,ty,tw,th);
511
-
512
-  for(i=0; i<titleCnt; ++i)
513
-  {
514
-    _tabs->begin();
515
-    initializeTab(i,tx,ty,tw,th,titleArray[i]);
516
-    _tabs->end();
517
-  }
518
-  
519
-  // Create an empty tab group and make it resizable 
520
-  // to prevent the other tab groups from being resizable.
521
-  _tabs->begin();
522
-  _tabs->resizable(new Fl_Group(tx,ty+30,1,1));
523
-  _tabs->end();
524
-}
525
-
526
-app*   app::_getApp( Fl_Widget* w )
527
-{
528
-  // walk up the widget tree until the top widget is  found
529
-  Fl_Group* gp = w->parent();
530
-  while( gp->parent() != NULL )
531
-    gp=gp->parent();
532
-
533
-  // the user data for the top widget is a pointer app - as set in:  callback(_s_callback,this);
534
-  return (app*)gp->user_data();
535
-}
536
-
537
-cmRC_t  app::_s_print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr )
538
-{
539
-  app* ap = (app*)userCbPtr;
540
-  ap->_print((const char*)msgDataPtr);
541
-  return cmOkRC;
542
-}
543
-
544
-void app::_checkPrintQueue()
545
-{
546
-  while( cmTsMp1cMsgWaiting(_printqH) )
547
-    if( cmTsMp1cDequeueMsg(_printqH, NULL, 0) != kOkThRC )
548
-      error("Print dequeue failed.");
549
-}
550
-
551
-void app::_print( const char* text )
552
-{
553
-  if( _con != NULL )
554
-    _con->insert(text);
555
-}

+ 0
- 119
src/cmflapp/app.h View File

@@ -1,119 +0,0 @@
1
-#ifndef app_h
2
-#define app_h
3
-
4
-class Fl_HSplitter;
5
-class Fl_Text_Buffer;
6
-class Fl_Text_Display;
7
-class Fl_Box;
8
-class Fl_Tabs;
9
-struct Fl_Menu_Item;
10
-class Fl_Menu_Bar;
11
-class Fl_Group;
12
-class Fl_Button;
13
-class Fl_Valuator;
14
-class Fl_Input;
15
-class drawWnd;
16
-
17
-class app : public Fl_Double_Window
18
-{
19
-
20
-public:
21
-
22
-  // widget id's for widgets created by createControls()
23
-  enum
24
-  {
25
-    kFileOpenMId,
26
-    kFileNewMId,
27
-    kEditCopyMId,
28
-    kEditPasteMId,
29
-
30
-    kBtn1MId,
31
-    kBtn2MId,
32
-    kBtn3MId,
33
-
34
-    kMenuBtn1MId,
35
-    kMenuBtn2MId,
36
-
37
-    kValue1MId,
38
-    kValue2MId,
39
-
40
-    kInput1MId
41
-  };
42
-
43
-  app(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const char *l, int argc, char *argv[]);
44
-  virtual ~app();
45
-
46
-  // Example tabbed window initialization example function 
47
-  // which also demonstrates some widgets
48
-  void createControls(Fl_Group* grp);
49
-
50
-  // called once from app() to initialize each tabbed window
51
-  virtual void initializeTab(int tabIndex, int x, int y, int w, int h, const char* label);
52
-
53
-  // Create the application menu
54
-  virtual void createMenu( int menuWidth, int menuHeight ); 
55
-
56
-  // Widget type specific callbacks
57
-  virtual void menuCallback( const Fl_Menu_Item* ip, long int id ); // menu and menu btn callback
58
-  virtual void btnCallback(  const Fl_Button*    bp, int id ); // btn callback
59
-  virtual void valueCallback(const Fl_Valuator*  vp, int id ); // valuator callback
60
-  virtual void inputCallback(const Fl_Input*     ip, int id ); // text input callback
61
-
62
-  virtual void appCallback(Fl_Widget* wp);    // app event callback
63
-  virtual bool idleCallback();                // return false to stop callback
64
-  virtual bool timerCallback();               // return false to stop callback
65
-
66
-  void error( const char* fmt, ... ); // report on error
67
-  
68
-  // print to the console
69
-  virtual void vprint( const char* fmt, va_list vl );
70
-  virtual void print( const char* fmt, ... ); 
71
-
72
-protected:
73
-  enum
74
-  {
75
-    kStatusH = 30,
76
-    kMenuH   = 30,
77
-    kCtlH    = 30
78
-  };
79
-
80
-  // static callbacks
81
-  static void _s_menu_cb(    Fl_Widget* wp, void* data);  // menu item callback
82
-  static void _s_menu_btn_cb(Fl_Widget* wp, void* data);  // menu btn callback
83
-  static void _s_btn_cb(     Fl_Widget* wp, long data);   // button callback
84
-  static void _s_value_cb(   Fl_Widget* wp, long data);   // value input or slider callback
85
-  static void _s_input_cb(   Fl_Widget* wp, long data);   // text input callback
86
-  static void _s_callback(   Fl_Widget* wp, void* data);  // main app callback
87
-  
88
-  static void _s_idle_cb(  void* data);    // idle callback
89
-  static void _s_timer_cb( void* userPtr); // timer callback
90
-  static void _s_print(    void* userPtr, const char* text ); // print text to the console
91
-
92
-  void _create_tabs(int titleCnt, const char* titleArray[]);
93
-
94
-  // walk down the widget tree until the app (root) widget is located
95
-  static app* _getApp( Fl_Widget* w );
96
-
97
-  // called internally by cmTsQueueDequeue() to send text to _print()
98
-  static cmRC_t _s_print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr );
99
-
100
-  // called periodically to check the print queue for waiting text.
101
-  void        _checkPrintQueue();
102
-
103
-  // send a string of text directly to the output console window
104
-  void        _print( const char* text );
105
-
106
-  double _timerPeriodSecs; // repeat period for the timer callback
107
-
108
-  cmCtx_t*          _ctx;   //
109
-  Fl_HSplitter*     _splt;  // main splitter window
110
-  Fl_Text_Buffer*   _buf;   // text buffer used by _con
111
-  Fl_Text_Display*  _con;   // text console output window
112
-  Fl_Tabs*          _tabs;  // tabs window
113
-  Fl_Menu_Bar*      _menu;  // app. menu
114
-  drawWnd*          _draw;  // custom widget
115
-  cmTsMp1cH_t       _printqH; // thread-safe queue for controlling access to the output console from multiple threads
116
-  int               _printFl; // used to prevent recursion due to throwing printing error
117
-};
118
-
119
-#endif

+ 0
- 24
src/cmflapp/appErr.h View File

@@ -1,24 +0,0 @@
1
-#ifndef appErr_h
2
-#define appErr_h
3
-
4
-#ifdef __cplusplus
5
-extern "C" {
6
-#endif
7
-
8
-enum
9
-{
10
-  kOkAppRC,
11
-  kQueueFailAppRC,
12
-  kFileSysFailAppRC,
13
-  kMemFailAppRC,
14
-  kTextSysFailAppRC,
15
-  kPrefsFailAppRC
16
-};
17
-
18
-  typedef unsigned cmAppRC_t;
19
-
20
-#ifdef __cplusplus
21
-}
22
-#endif
23
-
24
-#endif

+ 0
- 110
src/cmflapp/main.cpp View File

@@ -1,110 +0,0 @@
1
-#include <FL/Fl.H>
2
-#include <Fl/fl_draw.H>
3
-#include <FL/Fl_Double_Window.H>
4
-
5
-#include "cmPrefix.h"
6
-#include "cmGlobal.h"
7
-#include "cmFloatTypes.h"
8
-#include "cmRpt.h"
9
-#include "cmErr.h"
10
-#include "cmCtx.h"
11
-#include "cmMem.h"
12
-#include "cmMallocDebug.h"
13
-#include "cmLinkedHeap.h"
14
-#include "cmThread.h"
15
-#include "cmFileSys.h"
16
-#include "cmText.h"
17
-
18
-#include "appErr.h"
19
-#include "app.h"
20
-
21
-
22
-
23
-
24
-void print( void*, const cmChar_t* text)
25
-{ puts(text); }
26
-
27
-cmRC_t  print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr )
28
-{
29
-  print(NULL,(const char*)msgDataPtr);
30
-  return cmOkRC;
31
-}
32
-
33
-
34
-int main( int argc, char* argv[] )
35
-{
36
-  cmCtx_t     ctx;
37
-  cmTsMp1cH_t printqH         = cmTsMp1cNullHandle;
38
-  int         appWndW         = 1000;
39
-  int         appWndH         = 750;
40
-  const char* appPrefDir      = "gv";
41
-  const char* appTitle        = "GV Console";
42
-  bool        memDebugFl      = cmDEBUG_FL;
43
-  unsigned    memPadByteCnt   = memDebugFl ? 8 : 0;
44
-  unsigned    memAlignByteCnt = 16;
45
-  unsigned    memFlags        = memDebugFl ? (kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl) : 0;
46
-
47
-  cmCtxSetup(&ctx,appTitle,print,print,NULL,memPadByteCnt,memAlignByteCnt,memFlags);
48
-
49
-  // initialize the memory mgr
50
-  if(cmMdInitialize( memPadByteCnt, memAlignByteCnt, memFlags, &ctx.rpt ) != kOkMmRC )
51
-  {
52
-    cmErrMsg(&ctx.err,kMemFailAppRC,"Heap initialization failed.");
53
-    goto errLabel;
54
-  }
55
-
56
-  // initialize the file system
57
-  if( cmFsInitialize( &ctx, appPrefDir ) != kOkFsRC )
58
-    cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system initialization failed.");
59
-
60
-  // initialize the text system
61
-  if( cmTsInitialize(&ctx) != kOkTxRC )
62
-    cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system initialization failed.");
63
-
64
-  // create the print queue
65
-  if( cmTsMp1cCreate( &printqH, 8192, print_queue_cb, NULL, NULL ) != kOkThRC )
66
-    cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue creation failed.");
67
-
68
-
69
-  if( cmErrLastRC(&ctx.err) == kOkAppRC )
70
-  {
71
-    app proj(&ctx, printqH, appWndW, appWndH, appTitle, argc, argv);
72
-    Fl::run();
73
-
74
-    // reset the pgm context and print queue  console output to stdout
75
-    cmRptSetup(&ctx.rpt,print,print,NULL);
76
-    cmTsMp1cSetCbFunc(printqH, print_queue_cb, NULL );
77
-  }
78
-
79
-  // empty any pending text to stdout
80
-  while( cmTsMp1cMsgWaiting(printqH) )
81
-    if( cmTsMp1cDequeueMsg(printqH, NULL, 0) != kOkThRC )
82
-      cmErrMsg(&ctx.err,kQueueFailAppRC,"Print dequeue failed.");
83
-
84
-  // destroy the print queue
85
-  if( cmTsMp1cDestroy(&printqH) != kOkThRC )
86
-    cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue destroy failed.");
87
-
88
-  // finalize the text system
89
-  if( cmTsFinalize() != kOkTxRC )
90
-    cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system finalization failed.");
91
-
92
-  // finalize the file system
93
-  if( cmFsFinalize() != kOkFsRC )
94
-    cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system finalize failed.");
95
-
96
-  // report memory mgr errors
97
-  if( cmMdIsValid() )
98
-    cmMdReport( kIgnoreNormalMmFl );
99
-
100
-  // finalize the memory manager
101
-  if( cmMdFinalize() != kOkMmRC )
102
-    cmErrMsg(&ctx.err,kMemFailAppRC,"Heap finalization failed.");
103
-
104
- errLabel:
105
-
106
-
107
-  
108
-
109
-  return 0;
110
-}

+ 103
- 0
src/kc/Fl_File_Btn.cpp View File

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

+ 47
- 0
src/kc/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

src/cmflapp/Fl_Splitter.cpp → src/kc/Fl_Splitter.cpp View File

@@ -1,6 +1,6 @@
1 1
 // Code based on: http://www.mail-archive.com/fltk@easysw.com/msg04573.html
2 2
 // Lucas Sanner/Ian MacArthur
3
-
3
+#include <stdio.h>
4 4
 #include "Fl_Splitter.h"
5 5
 
6 6
 void Fl_HSplitter::draw()

src/cmflapp/Fl_Splitter.h → src/kc/Fl_Splitter.h View File


+ 77
- 0
src/kc/Fl_Vert_Progress.cpp View File

@@ -0,0 +1,77 @@
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
+void Fl_Vert_Progress::draw()
12
+{
13
+  int progress;        // Size of progress bar...
14
+  int bx, by, bw, bh;  // Box areas...
15
+  int tx, ty, tw, th;  // Temporary X + width
16
+
17
+  float min_ = minimum();
18
+  float max_ = maximum();
19
+  float val_ = value();
20
+
21
+  // Get the box borders...
22
+  bx = Fl::box_dx(box());
23
+  by = Fl::box_dy(box());
24
+  bw = Fl::box_dw(box());
25
+  bh = Fl::box_dh(box());
26
+
27
+  tx = x() + bx;
28
+  ty = y() + by;
29
+  tw = w() - bw;
30
+  th = h() - bh;
31
+
32
+
33
+  // Draw the progress bar...
34
+  if (max_ > min_)
35
+    progress = (int)( th * (val_ - min_) / (max_ - min_) );
36
+  else
37
+    progress = 0;
38
+
39
+  // Draw the box and label...
40
+  if (progress > 0) 
41
+  {
42
+    Fl_Color c = labelcolor();
43
+    labelcolor(fl_contrast(labelcolor(), selection_color()));
44
+
45
+
46
+    // draw the progress area
47
+    //fl_push_clip(x(), y() + h() - progress, w(), progress);
48
+    fl_push_clip(tx,ty + th - progress, tw, progress );
49
+    draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color()));
50
+    draw_label(tx, y() + by, tw, h() - bh);
51
+    fl_pop_clip();
52
+
53
+    labelcolor(c);
54
+
55
+    if (progress<w()) 
56
+    {
57
+      // draw the non-progress area
58
+      //fl_push_clip(x(), y(), w(), h() - progress );
59
+      fl_push_clip(tx,ty,tw,th-progress );
60
+      draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
61
+      draw_label(tx, y() + by, tw, h() - bh);
62
+      fl_pop_clip();
63
+    }
64
+
65
+  } 
66
+  else 
67
+  {
68
+    draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
69
+    draw_label(tx, y() + by, tw, h() - bh);
70
+  }
71
+
72
+  //fl_draw_box(FL_FLAT_BOX,x(),y(),w(),h(), FL_RED);
73
+  //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th, FL_GREEN);
74
+  //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th-progress, FL_BLACK); // non-prog
75
+  //fl_draw_box(FL_FLAT_BOX,tx,ty + th - progress,tw,progress,FL_BLUE);      // prog
76
+
77
+}

+ 14
- 0
src/kc/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

+ 2337
- 0
src/kc/kcApp.cpp
File diff suppressed because it is too large
View File


+ 406
- 0
src/kc/kcApp.h View File

@@ -0,0 +1,406 @@
1
+#ifndef kcApp_h
2
+#define kcApp_h
3
+
4
+extern "C" struct cmApBufState_str; 
5
+
6
+class Fl_Menu_Bar;
7
+class Fl_HSplitter;
8
+class Fl_Text_Buffer;
9
+class Fl_Text_Display;
10
+class Fl_Box;
11
+class Fl_Tabs;
12
+class Fl_Check_Button;
13
+class Fl_Value_Slider;
14
+class Fl_Menu_Button;
15
+class Fl_File_Btn;
16
+class Fl_Select_Browser;
17
+class Fl_Valuator;
18
+class Fl_Value_Input;
19
+class Fl_Progress;
20
+
21
+class kcApp : public Fl_Double_Window
22
+{
23
+public:
24
+  typedef unsigned kcKmRC_t;
25
+
26
+
27
+  enum
28
+  {
29
+    kOkKmRC,
30
+    kEngFailKmRC,
31
+    kMemFailKmRC,
32
+    kPrefsNotFoundKmRC,
33
+    kPrefWriteFailKmRC,
34
+    kPrefLoadFailKmRC,
35
+    kPrefFailKmRC,
36
+    kPrefSetFailKmRC,
37
+    kMlistLoadFailKmRC,
38
+    kJsonFailKmRC,
39
+    kDeserialFailKmRC,
40
+    kPrintQueFailKmRC,
41
+  
42
+  };
43
+
44
+
45
+  kcApp(int w, int h, const char *l, int argc, char *argv[]);
46
+  virtual ~kcApp();
47
+
48
+  kcKmRC_t audioDspInitialize( cmCtx_t* ctx, cmRptPrintFunc_t printFunc, void* printFuncArg );
49
+  kcKmRC_t audioDspFinalize();
50
+  bool     audioDspIsValid();
51
+
52
+  void print( const char* fmt, ... );
53
+  void vprint( const char* fmt, va_list vl );
54
+
55
+
56
+private:
57
+  enum
58
+  {
59
+    kMenuH = 30,
60
+    kStatusH = 30,
61
+    kIndH = 25,
62
+    kIndW = 25,
63
+    
64
+    kSsPhaseMax = 20
65
+  };
66
+
67
+  Fl_Menu_Bar*     menu;
68
+  Fl_HSplitter*    splt;
69
+  Fl_Box*          ind[4];
70
+  Fl_Text_Buffer*  buf;
71
+  Fl_Text_Display* con;
72
+  Fl_Tabs*         tabs;
73
+  Fl_Check_Button* ena_chk;
74
+  //Fl_Group*        ctl_grp;
75
+
76
+  Fl_Menu_Button*  as_btn;
77
+  Fl_Menu_Button*  ai_btn;
78
+  Fl_Menu_Button*  ao_btn;
79
+  Fl_Menu_Button*  pgm_btn;
80
+  Fl_Menu_Button*  ss_btn;
81
+  Fl_Menu_Button*  sr_btn;
82
+
83
+  Fl_Group*        mstr_grp;
84
+
85
+
86
+  enum
87
+  {
88
+    kSldrTypeId,
89
+    kNumbTypeId,
90
+    kTextTypeId,
91
+    kButnTypeId,
92
+    kChckTypeId,
93
+    kLablTypeId,
94
+    kFnamTypeId,
95
+    kMlstTypeId,
96
+    kMetrTypeId,
97
+
98
+
99
+    kSldrMinArgIdx = 0,
100
+    kSldrMaxArgIdx = 1,
101
+    kSldrStpArgIdx = 2,
102
+    kSldrValArgIdx = 3,
103
+    kSldrLblArgIdx = 4,
104
+    kSldrVarCnt    = 5,
105
+
106
+    kTextValArgIdx = 0,
107
+    kTextLblArgIdx = 1,
108
+    kTextVarCnt    = 2,
109
+
110
+    kButnValArgIdx = 0,
111
+    kButnLblArgIdx = 1,
112
+    kButnVarCnt    = 2,
113
+
114
+    kLablValArgIdx  = 0,
115
+    kLablAlignArgIdx= 1,
116
+    kLablVarCnt     = 2,
117
+
118
+    kChckValArgIdx  = 0,
119
+    kChckLblArgIdx  = 1,
120
+    kChckVarCnt     = 2,
121
+
122
+    kFnamValArgIdx = 0,
123
+    kFnamPatArgIdx = 1,
124
+    kFnamDirArgIdx = 2,
125
+    kFnamVarCnt    = 3,
126
+
127
+    kMlstHgtArgIdx = 0,
128
+    kMlstSelArgIdx = 1,
129
+    kMlstLstArgIdx = 2,
130
+    kMlstVarCnt    = 3,
131
+
132
+    kMetrMinArgIdx = 0,
133
+    kMetrMaxArgIdx = 1,
134
+    kMetrValArgIdx = 2,
135
+    kMetrLblArgIdx = 3,
136
+    kMetrVarCnt    = 4
137
+
138
+  }; 
139
+
140
+  enum
141
+  {
142
+    kEnableBtnId = 1,
143
+    kAudDevRptBtnId,
144
+    kAudioSysCfgBtnId,
145
+    kInAudDevBtnId,
146
+    kOutAudDevBtnId,
147
+    kPgmBtnId,
148
+    kSubSystemIdxBtnId,
149
+    kSrateBtnId,
150
+    kTestBtnId
151
+  };
152
+
153
+  enum
154
+  {
155
+    k44100SrateIdx,
156
+    k48000SrateIdx,
157
+    k96000SrateIdx
158
+  };
159
+
160
+  typedef struct sldr_str
161
+  {
162
+    union
163
+    {
164
+      Fl_Value_Slider*  sldr;
165
+      Fl_Value_Input*   numb;
166
+    } u;
167
+    Fl_Valuator*      val;
168
+    double            defaultVal;
169
+    unsigned          varIdArray[ kSldrVarCnt ];
170
+  } sldr_t;
171
+
172
+  typedef struct text_str
173
+  {
174
+    Fl_Input* text;
175
+    char*      val;
176
+    unsigned   varIdArray[ kTextVarCnt ];
177
+  } text_t;
178
+
179
+  typedef struct butn_str
180
+  {
181
+    Fl_Button* butn;
182
+    double     val;
183
+    unsigned   varIdArray[ kButnVarCnt ];
184
+  } butn_t;
185
+
186
+  typedef struct chck_str
187
+  {
188
+    Fl_Check_Button* chck;
189
+    double           val;
190
+    unsigned         varIdArray[ kChckVarCnt ];
191
+  } chck_t;
192
+
193
+  typedef struct labl_str
194
+  {
195
+    Fl_Box* box;
196
+    unsigned varIdArray[ kLablVarCnt ];
197
+  } labl_t;
198
+
199
+  typedef struct fname_str
200
+  {
201
+    Fl_File_Btn* fnam;
202
+    unsigned     varIdArray[ kFnamVarCnt ];
203
+  } fnam_t;
204
+
205
+  typedef struct mlst_str
206
+  {
207
+    Fl_Select_Browser* mlst;
208
+    Fl_Menu_Button*    mbtn;
209
+    int                sel;
210
+    unsigned           varIdArray[ kMlstVarCnt ];
211
+  } mlst_t;
212
+
213
+  typedef struct metr_str
214
+  {
215
+    Fl_Progress* prog;
216
+    unsigned     varIdArray[ kMetrVarCnt ];
217
+  } metr_t;
218
+
219
+  typedef struct ctl_str
220
+  {
221
+    kcApp*     thisPtr;
222
+    unsigned   asSubIdx;
223
+    unsigned   typeId;
224
+    unsigned   instId;
225
+    Fl_Widget* wdgtPtr;
226
+    bool       mstrFl;
227
+    union
228
+    {
229
+      sldr_t     sldr;
230
+      text_t     text;
231
+      butn_t     butn;
232
+      chck_t     chck;
233
+      labl_t     labl;
234
+      fnam_t     fnam;
235
+      mlst_t     mlst;
236
+      metr_t     metr;
237
+    } u;
238
+    struct ctl_str* linkPtr;
239
+  } ctl_t;
240
+
241
+  typedef struct page_str
242
+  {
243
+    Fl_Group* grp;
244
+    struct page_str* link;
245
+    page_str() : grp(NULL), link(NULL) {}
246
+  } page_t;
247
+
248
+  enum
249
+  {
250
+    kUpdateSsIdx,
251
+    kWakeupSsIdx,
252
+    kMsgSsIdx,
253
+    kAudioCbSsIdx,
254
+    kProgSsCnt
255
+  };
256
+
257
+  // each audio sub-system is represented by an ss_t record in _ssArray[_ssCnt]
258
+  typedef struct ss_str
259
+  {
260
+    Fl_Progress* prog[kProgSsCnt]; // status indicator controls
261
+    unsigned     cnt[kProgSsCnt];  // previous status count value
262
+    
263
+  } ss_t;
264
+
265
+
266
+  cmCtx_t         _ctx;
267
+  cmAdlH_t        _adlH;
268
+  cmAiH_t         _aiH;
269
+  unsigned        _statIdx;
270
+  page_t*         _pageList;
271
+  ctl_t*          _ctlList;
272
+  const cmChar_t* _prefFn;
273
+  cmPrH_t         _prH;
274
+  const cmChar_t* _prefsFn;
275
+  bool            _stopTimerFl;
276
+  cmJsonH_t       _jsH;
277
+  bool             _newPageFl;
278
+  unsigned         _incrColW;
279
+  unsigned         _colW;
280
+  bool            _horzBordFl;
281
+  unsigned        _horzBord;
282
+  unsigned        _closeCnt;
283
+  unsigned        _ssCnt;   // count of audio system sub-systems (set in _handleSsInitMsg())
284
+  ss_t*           _ssArray;
285
+  int             _ssPhase;
286
+  bool            _ssUpdateFl; 
287
+  cmTsQueueH_t    _printqH; // thread-safe queue for controlling access to the output console from multiple threads
288
+
289
+  void resize(int x, int y, int w, int h);
290
+
291
+  void          _createSetupDlg(Fl_Group* grp);
292
+
293
+  void          _createPage( const char* title );
294
+
295
+  unsigned      _getCtlCount() const;
296
+  void          _clearCtlList(bool mstrFl);
297
+  void          _clearSsArray();
298
+  void          _getNewCtlPosn( const cmDspUiHdr_t* m, int& x, int& y, int& w, int& h );
299
+  ctl_t*        _findCtl( unsigned instId, unsigned asSubIdx, unsigned mstrFl=false );
300
+  ctl_t*        _createCtl( const cmDspUiHdr_t* m, unsigned typeId, int& x, int& y, int& w, int& h );
301
+  void          _insertNewCtl( ctl_t* cp, const cmDspUiHdr_t* m, Fl_Widget* wdgt, unsigned* varIdArray, unsigned varIdCnt );
302
+
303
+  void          _createSlider(  const cmDspUiHdr_t* m );
304
+  void          _setSldrValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
305
+  void          _createText(  const cmDspUiHdr_t* m );
306
+  void          _setTextValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
307
+  void          _createFnameCtl(   const cmDspUiHdr_t* m );
308
+  void          _setFnamValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
309
+  void          _createMlistCtl(   const cmDspUiHdr_t* m );
310
+  kcKmRC_t      _loadMlist( ctl_t* cp, const cmJsonNode_t* np );
311
+  void          _setMlistValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
312
+  void          _createMeter( const cmDspUiHdr_t* m );
313
+  void          _setMeterValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
314
+  void          _createButton( const cmDspUiHdr_t* m );
315
+  void          _setButtonValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
316
+  void          _createCheck( const cmDspUiHdr_t* m );
317
+  void          _setCheckValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
318
+  void          _createLabel( const cmDspUiHdr_t* m );
319
+  void          _setLabelValue( ctl_t* cp, unsigned instVarId, const cmDspValue_t* vp );
320
+  void          _newColumn( const cmDspUiHdr_t* m );
321
+
322
+  void          _insertAudioSysCfgLabel(unsigned long idx, const cmChar_t* label );
323
+  void          _insertDeviceLabel( unsigned long idx, bool inputFl, const cmChar_t* label );
324
+  void          _insertProgramLabel( unsigned long idx, const cmChar_t* label );
325
+  void          _insertSubSysCnt( unsigned long subSysCnt );
326
+  unsigned      _getCurAudioSubSysIdx();
327
+  void          _setMenuButton( Fl_Menu_Button* b, unsigned value, const char* dfltLabel );
328
+  void          _setDeviceMenuButton( unsigned asSubIdx, bool inputFl, unsigned devIdx );
329
+  void          _setSampleRateBtn( unsigned value );
330
+
331
+  void          _updateMeters( unsigned asSubIdx, unsigned devIdx, unsigned inFl, const double* meterArray, unsigned meterCnt );
332
+  void          _updateSsStatusIndicator( unsigned asSubIdx, unsigned indicatorIdx, unsigned cnt );
333
+  void          _printStatusCounts();
334
+  void          _handleStatusMsg( const cmAudioSysStatus_t* st, const double* iMeterArray, const double* oMeterArray );
335
+  void          _clearStatusIndicators();
336
+
337
+  void          _sendMasterUiMsg(  unsigned asSubIdx, unsigned selId, unsigned instId, unsigned instVarId, const cmDspValue_t* v );
338
+  void          _sendMasterUiValue(unsigned asSubIdx, unsigned instId, const double* v, unsigned vn, const cmChar_t* text );
339
+  void          _createMasterCtl(  unsigned asSubIdx, unsigned selId, unsigned instId, unsigned varCnt, const double* dv, unsigned dn, const cmChar_t* label);
340
+  void          _handleSsInitMsg(  const cmAudioSysSsInitMsg_t* m, const cmChar_t* inDevLabel, const cmChar_t* outDevLabel );
341
+  void          _onRecvValue( const cmDspUiHdr_t* m );
342
+  void          _handleUiMsg( const cmDspUiHdr_t* m );
343
+  void          _getEngMsg();
344
+
345
+  static cmRC_t _s_handleSsInitMsg( void* cbDataPtr, const cmAudioSysSsInitMsg_t* r, const char* iDevLabel, const char* oDevLabel );
346
+  static cmRC_t _s_handleStatusMsg( void* cbDataPtr, const cmAudioSysStatus_t* r, const double* iMeterArray, const double* oMeterArray );
347
+  static cmRC_t _s_handleUiMsg(     void* cbDataPtr, const cmDspUiHdr_t* r );
348
+
349
+  static kcApp* _getApp( Fl_Widget* w );
350
+
351
+  kcKmRC_t      _restartEngine();
352
+
353
+  void          _testStub();
354
+
355
+  // main app callback
356
+  static void _s_callback(Fl_Widget* wp, void* data);
357
+  void _callback(void* data);
358
+
359
+  // idle callback
360
+  static void _s_on_idle(void* data);
361
+  void _on_idle();
362
+
363
+
364
+  // timer callback
365
+  static void _s_status_timeout_cb(void* userPtr);
366
+  bool _status_timeout_cb();
367
+
368
+  static void _s_file_new_cb(Fl_Widget *w, void *data); 
369
+  void _file_new_cb(Fl_Widget *w); 
370
+
371
+  static void _s_file_open_cb(Fl_Widget *w, void *data); 
372
+  void _file_open_cb(Fl_Widget *w); 
373
+
374
+  static void _s_edit_copy_cb(Fl_Widget *w, void *data); 
375
+  void _edit_copy_cb(Fl_Widget *w); 
376
+
377
+  static void _s_edit_paste_cb(Fl_Widget *w, void *data); 
378
+  void _edit_paste_cb(Fl_Widget *w); 
379
+
380
+  static void _s_btn_cb(Fl_Widget* w, long data);
381
+  void _btn_cb(Fl_Widget* w,  long arg);
382
+
383
+  static void _s_ctl_cb(Fl_Widget* w, void* data);
384
+  void _ctl_cb(ctl_t* cp);
385
+
386
+  static void _s_tab_cb(Fl_Widget* w, void* data);
387
+  void _tab_cb(Fl_Widget* w);
388
+
389
+  // 
390
+  static void _s_print( void* userPtr, const char* text );
391
+
392
+  // called internally by cmTsQueueDequeue() to send text to _print()
393
+  static cmRC_t _s_print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr );
394
+
395
+  // called periodically to check the print queue for waiting text.
396
+  void        _checkPrintQueue();
397
+
398
+  // send a string of text directly to the output console window
399
+  void        _print( const char* text );
400
+
401
+
402
+};
403
+
404
+
405
+
406
+#endif

+ 39
- 0
src/kc/kcMain.cpp View File

@@ -0,0 +1,39 @@
1
+#include <FL/Fl.H>
2
+#include <FL/Fl_Double_Window.H>
3
+#include <FL/Fl_Menu_Item.H>
4
+#include <Fl/Fl_Menu_Bar.H>
5
+#include <Fl/Fl_Button.H>
6
+#include <Fl/Fl_Text_Buffer.H>
7
+#include <Fl/Fl_Text_Display.H>
8
+#include <Fl/Fl_Tabs.H>
9
+#include <Fl/Fl_File_Chooser.H>
10
+
11
+#include "Fl_Splitter.h"
12
+
13
+#include "cmGlobal.h"
14
+#include "cmFloatTypes.h"
15
+#include "cmRpt.h"
16
+#include "cmErr.h"
17
+#include "cmCtx.h"
18
+#include "cmPrefs.h"
19
+#include "cmJson.h"
20
+#include "cmThread.h"
21
+#include "cmDspValue.h"
22
+#include "cmMsgProtocol.h"
23
+#include "cmAudDspIF.h"
24
+#include "cmAudDspLocal.h"
25
+#include "kcApp.h"
26
+
27
+
28
+void print(void* cmRptUserPtr, const char* text)
29
+{ printf("%s",text); }
30
+
31
+int main(int argc, char* argv[] )
32
+{
33
+  kcApp myApp(1600, 750, "Console", argc, argv);
34
+  Fl::run();
35
+ 
36
+  //test();
37
+
38
+  return 0;
39
+}

Loading…
Cancel
Save