Bladeren bron

Moved Fl_File_Btn,Fl_Vert_Progress to libcmpp.

Inserted devious ptr trick in kcApp::_setDeviceMenuButton().
master
kevin 11 jaren geleden
bovenliggende
commit
bc2e66ed98
6 gewijzigde bestanden met toevoegingen van 2 en 244 verwijderingen
  1. 0
    2
      Makefile.am
  2. 0
    103
      src/kc/Fl_File_Btn.cpp
  3. 0
    47
      src/kc/Fl_File_Btn.h
  4. 0
    77
      src/kc/Fl_Vert_Progress.cpp
  5. 0
    14
      src/kc/Fl_Vert_Progress.h
  6. 2
    1
      src/kc/kcApp.cpp

+ 0
- 2
Makefile.am Bestand weergeven

@@ -66,8 +66,6 @@ src_kc_kc_SOURCES  = $(tlCtlSRC)
66 66
 
67 67
 src_kc_kc_SOURCES += src/kc/kcMain.cpp 
68 68
 src_kc_kc_SOURCES += src/kc/kcApp.h          src/kc/kcApp.cpp 
69
-src_kc_kc_SOURCES += src/kc/Fl_File_Btn.h    src/kc/Fl_Vert_Progress.h
70
-src_kc_kc_SOURCES += src/kc/Fl_File_Btn.cpp  src/kc/Fl_Vert_Progress.cpp
71 69
 
72 70
 src_kc_kc_LDADD    = $(CMLIBS) $(MYLIBS)
73 71
 bin_PROGRAMS                += src/kc/kc

+ 0
- 103
src/kc/Fl_File_Btn.cpp Bestand weergeven

@@ -1,103 +0,0 @@
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
-}

+ 0
- 47
src/kc/Fl_File_Btn.h Bestand weergeven

@@ -1,47 +0,0 @@
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

+ 0
- 77
src/kc/Fl_Vert_Progress.cpp Bestand weergeven

@@ -1,77 +0,0 @@
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
-}

+ 0
- 14
src/kc/Fl_Vert_Progress.h Bestand weergeven

@@ -1,14 +0,0 @@
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

+ 2
- 1
src/kc/kcApp.cpp Bestand weergeven

@@ -1370,7 +1370,8 @@ void kcApp::_setDeviceMenuButton( unsigned asSubIdx, bool inputFl, unsigned devI
1370 1370
   const Fl_Menu_Item* map = mbp->menu();
1371 1371
   unsigned n = mbp->size();
1372 1372
   unsigned i;
1373
-  void*    di = (void*)devIdx;
1373
+  char*    di = 0;  di += devIdx;  // BEWARE: devious int to ptr trick
1374
+
1374 1375
   for(i=0; i<n; ++i)
1375 1376
     if( map[i].user_data() == di )
1376 1377
       break;

Laden…
Annuleren
Opslaan