kcApp.h/cpp, kcMain.cpp Added use of preference file.

This commit is contained in:
kevin 2012-12-03 17:22:15 -08:00
parent 662d12cc62
commit 82fff39f11
3 changed files with 48 additions and 15 deletions

View File

@ -61,9 +61,9 @@
#define TIMER_PERIOD (1.0/20.0) // 50ms #define TIMER_PERIOD (1.0/20.0) // 50ms
kcApp::kcApp(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] ) kcApp::kcApp(cmCtx_t* ctx, cmPrH_t prH, cmTsMp1cH_t printqH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] )
: Fl_Double_Window(w, h,title), : Fl_Double_Window(w, h,title),
_ctx(ctx),_aiH(aiH), _ctx(ctx),_prH(prH),_aiH(aiH),
_menu(NULL),_splt(NULL),_con(NULL),_tabs(NULL),_mstr_grp(NULL), _menu(NULL),_splt(NULL),_con(NULL),_tabs(NULL),_mstr_grp(NULL),
_as_btn(NULL),_ai_btn(NULL),_ao_btn(NULL),_pgm_btn(NULL), _as_btn(NULL),_ai_btn(NULL),_ao_btn(NULL),_pgm_btn(NULL),
_ss_btn(NULL),_sr_btn(NULL),_ena_chk(NULL), _ss_btn(NULL),_sr_btn(NULL),_ena_chk(NULL),
@ -142,6 +142,8 @@ void kcApp::resize(int x, int y, int w, int h)
{ {
Fl_Double_Window::resize(x, y, w, h); Fl_Double_Window::resize(x, y, w, h);
_splt->resize(0, kMenuH, w, h-kStatusH); _splt->resize(0, kMenuH, w, h-kStatusH);
cmPrefsPathSetInt(_prH,"appWndW",w);
cmPrefsPathSetInt(_prH,"appWndH",h);
} }
void kcApp::tlCtlNewTimeLineFile( tlCtl* tlCtl, const cmChar_t* fn ) void kcApp::tlCtlNewTimeLineFile( tlCtl* tlCtl, const cmChar_t* fn )

View File

@ -26,12 +26,7 @@ class Fl_Progress;
kFileSysFailKmRC, kFileSysFailKmRC,
kQueueFailKmRC, kQueueFailKmRC,
kTextSysFailKmRC, kTextSysFailKmRC,
kPrefsFailKmRC,
kPrefsNotFoundKmRC,
kPrefWriteFailKmRC,
kPrefLoadFailKmRC,
kPrefFailKmRC,
kPrefSetFailKmRC,
kMlistLoadFailKmRC, kMlistLoadFailKmRC,
kJsonFailKmRC, kJsonFailKmRC,
kDeserialFailKmRC, kDeserialFailKmRC,
@ -44,7 +39,7 @@ class kcApp : public Fl_Double_Window, public tlCtlRspdr
public: public:
typedef unsigned kcKmRC_t; typedef unsigned kcKmRC_t;
kcApp(cmCtx_t* ctx, cmTsMp1cH_t printQH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] ); kcApp(cmCtx_t* ctx, cmPrH_t prH, cmTsMp1cH_t printQH, int w, int h, const cmChar_t* title, cmAiH_t aiH, int argc, char* argv[] );
virtual ~kcApp(); virtual ~kcApp();
void resize(int x, int y, int w, int h); void resize(int x, int y, int w, int h);
@ -278,6 +273,7 @@ private:
cmCtx_t* _ctx; cmCtx_t* _ctx;
cmPrH_t _prH;
cmAiH_t _aiH; cmAiH_t _aiH;
Fl_Menu_Bar* _menu; Fl_Menu_Bar* _menu;

View File

@ -22,6 +22,7 @@
#include "cmThread.h" #include "cmThread.h"
#include "cmText.h" #include "cmText.h"
#include "cmFileSys.h" #include "cmFileSys.h"
#include "cmPrefs.h"
#include "cmDspValue.h" #include "cmDspValue.h"
#include "cmMsgProtocol.h" #include "cmMsgProtocol.h"
#include "cmAudDspIF.h" #include "cmAudDspIF.h"
@ -36,6 +37,12 @@
#include "tlCtl.h" #include "tlCtl.h"
#include "kcApp.h" #include "kcApp.h"
enum
{
kAppWndW = 1600,
kAppWndH = 750
};
kcApp* kcAppPtr = NULL; kcApp* kcAppPtr = NULL;
@ -57,20 +64,33 @@ cmRC_t handleStatusMsg( void* cbDataPtr, const cmAudioSysStatus_t* r, const doub
cmRC_t handleUiMsg( void* cbDataPtr, const cmDspUiHdr_t* r ) cmRC_t handleUiMsg( void* cbDataPtr, const cmDspUiHdr_t* r )
{ kcAppPtr->_handleUiMsg(r); return cmOkRC;} { kcAppPtr->_handleUiMsg(r); return cmOkRC;}
cmPrRC_t kcInitPrefs( cmCtx_t* ctx, cmPrH_t* prH )
{
cmPrRC_t rc = kOkPrRC;
if((rc = cmPrefsInit(ctx, prH, NULL, NULL, NULL, NULL )) != kOkPrRC )
return rc;
unsigned flags = 0;
cmPrefsCreateInt(*prH, 1, "appWndW", flags, kAppWndW );
cmPrefsCreateInt(*prH, 2, "appWndH", flags, kAppWndH );
return cmPrefsRC(*prH);
}
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
cmCtx_t ctx; cmCtx_t ctx;
cmTsMp1cH_t printqH = cmTsMp1cNullHandle; cmTsMp1cH_t printqH = cmTsMp1cNullHandle;
int appWndW = 1600;
int appWndH = 750;
const char* appPrefDir = "kc"; const char* appPrefDir = "kc";
const char* appTitle = "KC Console"; const char* appTitle = "KC Console";
bool memDebugFl = cmDEBUG_FL; bool memDebugFl = false; //cmDEBUG_FL;
unsigned memPadByteCnt = memDebugFl ? 8 : 0; unsigned memPadByteCnt = memDebugFl ? 8 : 0;
unsigned memAlignByteCnt = 16; unsigned memAlignByteCnt = 16;
unsigned memFlags = memDebugFl ? (kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl) : 0; unsigned memFlags = memDebugFl ? (kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl) : 0;
cmAdlH_t adlH = cmAdlNullHandle; cmAdlH_t adlH = cmAdlNullHandle;
cmAiH_t aiH = cmAiNullHandle; cmAiH_t aiH = cmAiNullHandle;
cmPrH_t prH = cmPrNullHandle;
cmAdIfDispatch_t r; cmAdIfDispatch_t r;
cmCtxSetup(&ctx,appTitle,print,print,NULL,memPadByteCnt,memAlignByteCnt,memFlags); cmCtxSetup(&ctx,appTitle,print,print,NULL,memPadByteCnt,memAlignByteCnt,memFlags);
@ -90,6 +110,10 @@ int main( int argc, char* argv[] )
if( cmTsInitialize(&ctx) != kOkTxRC ) if( cmTsInitialize(&ctx) != kOkTxRC )
cmErrMsg(&ctx.err,kTextSysFailKmRC,"Text system initialization failed."); cmErrMsg(&ctx.err,kTextSysFailKmRC,"Text system initialization failed.");
// iniitalize the preferences
if( kcInitPrefs(&ctx,&prH) != kOkPrRC )
cmErrMsg(&ctx.err,kPrefsFailKmRC,"Preference initializatkion failed.");
// create the print queue // create the print queue
if( cmTsMp1cCreate( &printqH, 8192, print_queue_cb, NULL, NULL ) != kOkThRC ) if( cmTsMp1cCreate( &printqH, 8192, print_queue_cb, NULL, NULL ) != kOkThRC )
cmErrMsg(&ctx.err,kQueueFailKmRC,"Print queue creation failed."); cmErrMsg(&ctx.err,kQueueFailKmRC,"Print queue creation failed.");
@ -108,8 +132,10 @@ int main( int argc, char* argv[] )
if( cmErrLastRC(&ctx.err) == kOkKmRC ) if( cmErrLastRC(&ctx.err) == kOkKmRC )
{ {
int appWndW = cmPrefsIntDef(prH,"appWndW", kAppWndW);
int appWndH = cmPrefsIntDef(prH,"appWndH", kAppWndH);
kcAppPtr = new kcApp(&ctx, printqH, appWndW, appWndH, appTitle, aiH, argc, argv); kcAppPtr = new kcApp(&ctx, prH, printqH, appWndW, appWndH, appTitle, aiH, argc, argv);
cmAudDspLocalSendSetup(adlH); cmAudDspLocalSendSetup(adlH);
@ -139,6 +165,15 @@ int main( int argc, char* argv[] )
if( cmTsMp1cDestroy(&printqH) != kOkThRC ) if( cmTsMp1cDestroy(&printqH) != kOkThRC )
cmErrMsg(&ctx.err,kQueueFailKmRC,"Print queue destroy failed."); cmErrMsg(&ctx.err,kQueueFailKmRC,"Print queue destroy failed.");
// write the preferences file
if( cmPrefsIsDirty(prH) )
if( cmPrefsWrite(prH,cmPrefsFileName(prH)) != kOkPrRC )
cmErrMsg(&ctx.err,kPrefsFailKmRC,"Preferences save failed.");
// finalize the preferences file
if( cmPrefsFinalize(&prH) != kOkPrRC )
cmErrMsg(&ctx.err,kPrefsFailKmRC,"Preference finalize failed.");
// finalize the text system // finalize the text system
if( cmTsFinalize() != kOkTxRC ) if( cmTsFinalize() != kOkTxRC )
cmErrMsg(&ctx.err,kTextSysFailKmRC,"Text system finalization failed."); cmErrMsg(&ctx.err,kTextSysFailKmRC,"Text system finalization failed.");