From bc2e66ed989bbca31e7fdc1a300dc5e3755df20e Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 17 Mar 2013 14:58:10 -0700 Subject: [PATCH] Moved Fl_File_Btn,Fl_Vert_Progress to libcmpp. Inserted devious ptr trick in kcApp::_setDeviceMenuButton(). --- Makefile.am | 2 - src/kc/Fl_File_Btn.cpp | 103 ------------------------------------ src/kc/Fl_File_Btn.h | 47 ---------------- src/kc/Fl_Vert_Progress.cpp | 77 --------------------------- src/kc/Fl_Vert_Progress.h | 14 ----- src/kc/kcApp.cpp | 3 +- 6 files changed, 2 insertions(+), 244 deletions(-) delete mode 100644 src/kc/Fl_File_Btn.cpp delete mode 100644 src/kc/Fl_File_Btn.h delete mode 100644 src/kc/Fl_Vert_Progress.cpp delete mode 100644 src/kc/Fl_Vert_Progress.h diff --git a/Makefile.am b/Makefile.am index e12cb29..44bb31a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,8 +66,6 @@ src_kc_kc_SOURCES = $(tlCtlSRC) src_kc_kc_SOURCES += src/kc/kcMain.cpp src_kc_kc_SOURCES += src/kc/kcApp.h src/kc/kcApp.cpp -src_kc_kc_SOURCES += src/kc/Fl_File_Btn.h src/kc/Fl_Vert_Progress.h -src_kc_kc_SOURCES += src/kc/Fl_File_Btn.cpp src/kc/Fl_Vert_Progress.cpp src_kc_kc_LDADD = $(CMLIBS) $(MYLIBS) bin_PROGRAMS += src/kc/kc diff --git a/src/kc/Fl_File_Btn.cpp b/src/kc/Fl_File_Btn.cpp deleted file mode 100644 index 450e3d8..0000000 --- a/src/kc/Fl_File_Btn.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include -#include "Fl_File_Btn.h" - -Fl_File_Btn::Fl_File_Btn( int xx, int yy, int ww, int hh, const char* l ) - : Fl_Group(xx,yy,ww,hh,l), - _patStr(NULL),_typeId(kFile_Type_Id),_btn(NULL),_out(NULL) -{ - _init(); -} - -Fl_File_Btn::Fl_File_Btn( unsigned typeId, const char* patStr, int xx, int yy, int ww, int hh, const char* l ) - : Fl_Group(xx,yy,ww,hh,l), - _patStr(NULL),_typeId(typeId),_btn(NULL),_out(NULL) -{ - _init(); - type(typeId); - pattern_string(patStr); -} - -Fl_File_Btn::~Fl_File_Btn() -{ delete[] _patStr; } - -unsigned Fl_File_Btn::type() -{ return _typeId; } - -void Fl_File_Btn::type( unsigned typeId ) -{ - switch(typeId) - { - case kFile_Type_Id: - _btn->label("File"); - _typeId = typeId; - break; - - case kDir_Type_Id: - _btn->label("Dir"); - _typeId = typeId; - break; - } - - -} - -const char* Fl_File_Btn::pattern_string() -{ return _patStr; } - -void Fl_File_Btn::pattern_string( const char* pat) -{ - delete[] _patStr; - if( pat != NULL ) - { - _patStr = new char[ strlen(pat) + 1]; - strcpy(_patStr,pat); - } -} - -void Fl_File_Btn::btn_width( int ww ) -{ - _btn->resize(_btn->x(),_btn->y(),ww,_btn->h()); - _out->resize(_btn->x() + _btn->w() + 2, _out->y(), w() - _btn->w() - 2, _out->h()); -} - -int Fl_File_Btn::btn_width() -{ return _btn->w(); } - -void Fl_File_Btn::filename( const char* fn ) -{ _out->value(fn); _out->redraw(); } - -const char* Fl_File_Btn::filename() const -{ return _out->value(); } - - -void Fl_File_Btn::_s_btn_cb(Fl_Widget* w, void* data) -{ ((Fl_File_Btn*)data)->_btn_cb(); } - -void Fl_File_Btn::_btn_cb() -{ - char* fn; - if( _typeId == kFile_Type_Id ) - fn = fl_file_chooser("Select a file",_patStr,_out->value(),0); - else - fn = fl_dir_chooser("Select a directory",_out->value(),0); - - if( fn != NULL ) - { - _out->value(fn); - do_callback(this,user_data()); - } - -} - -void Fl_File_Btn::_init() -{ - _btn = new Fl_Button(x(),y(),40,h(),_typeId==kFile_Type_Id ? "File" : "Dir"); - _btn->callback(_s_btn_cb,this); - - _out = new Fl_Output(x() + _btn->w() + 2, y(), w() - _btn->w(), h()); - -} diff --git a/src/kc/Fl_File_Btn.h b/src/kc/Fl_File_Btn.h deleted file mode 100644 index d9d937d..0000000 --- a/src/kc/Fl_File_Btn.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef Fl_File_Btn_h -#define Fl_File_Btn_h - -class Fl_Button; -class Fl_Output; - -class Fl_File_Btn : public Fl_Group -{ -public: - enum - { - kFile_Type_Id, - kDir_Type_Id - }; - - Fl_File_Btn( int x, int y, int w, int h, const char* l = 0 ); - - Fl_File_Btn( unsigned typeId, const char* patStr, int x, int y, int w, int h, const char* l = 0 ); - virtual ~Fl_File_Btn(); - - unsigned type(); - void type( unsigned typeId ); - - const char* pattern_string(); - void pattern_string( const char* pat); - - void btn_width( int w ); - int btn_width(); - - void filename( const char* fn ); - const char* filename() const; - -private: - char* _patStr; - unsigned _typeId; - Fl_Button* _btn; - Fl_Output* _out; - - static void _s_btn_cb(Fl_Widget* w, void* data); - void _btn_cb(); - - void _init(); - -}; - - -#endif diff --git a/src/kc/Fl_Vert_Progress.cpp b/src/kc/Fl_Vert_Progress.cpp deleted file mode 100644 index 8f09b28..0000000 --- a/src/kc/Fl_Vert_Progress.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include -#include "Fl_Vert_Progress.h" - -Fl_Vert_Progress::Fl_Vert_Progress(int x, int y, int w, int h, const char* l) - : Fl_Progress(x,y,w,h) -{ -} - -void Fl_Vert_Progress::draw() -{ - int progress; // Size of progress bar... - int bx, by, bw, bh; // Box areas... - int tx, ty, tw, th; // Temporary X + width - - float min_ = minimum(); - float max_ = maximum(); - float val_ = value(); - - // Get the box borders... - bx = Fl::box_dx(box()); - by = Fl::box_dy(box()); - bw = Fl::box_dw(box()); - bh = Fl::box_dh(box()); - - tx = x() + bx; - ty = y() + by; - tw = w() - bw; - th = h() - bh; - - - // Draw the progress bar... - if (max_ > min_) - progress = (int)( th * (val_ - min_) / (max_ - min_) ); - else - progress = 0; - - // Draw the box and label... - if (progress > 0) - { - Fl_Color c = labelcolor(); - labelcolor(fl_contrast(labelcolor(), selection_color())); - - - // draw the progress area - //fl_push_clip(x(), y() + h() - progress, w(), progress); - fl_push_clip(tx,ty + th - progress, tw, progress ); - draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color())); - draw_label(tx, y() + by, tw, h() - bh); - fl_pop_clip(); - - labelcolor(c); - - if (progressmenu(); unsigned n = mbp->size(); unsigned i; - void* di = (void*)devIdx; + char* di = 0; di += devIdx; // BEWARE: devious int to ptr trick + for(i=0; i