File: Flu_Combo_Box.h

package info (click to toggle)
drawxtl 5.4%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 10,004 kB
  • ctags: 1,988
  • sloc: cpp: 34,558; ansic: 2,271; makefile: 190; sh: 55
file content (119 lines) | stat: -rw-r--r-- 2,948 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// $Id: Flu_Combo_Box.h 672 2007-09-02 15:47:45Z Larry $

/***************************************************************
 *                FLU - FLTK Utility Widgets 
 *  Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
 *
 * This file and its content is protected by a software license.
 * You should have received a copy of this license with this file.
 * If not, please contact the Ohio Supercomputer Center immediately:
 * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
 * 
 ***************************************************************/



#ifndef _FLU_COMBO_BOX_H
#define _FLU_COMBO_BOX_H

#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Group.H>
#include <stdio.h>

#include "Flu_Enumerations.h"

//! This is a generic base class for implementing widgets with combo-box-like behavior (i.e. a pulldown menu where the "input" area is editable
class FLU_EXPORT Flu_Combo_Box : public Fl_Group
{

public:

  //! Normal FLTK widget constructor
  Flu_Combo_Box( int x, int y, int w, int h, const char *l = 0 );

  //! Default destructor
  ~Flu_Combo_Box();

  //! Get whether the input field can be edited. Default is \c true
  inline bool editable() const
    { return (int)(!input.readonly()); }

  //! Set whether the input field can be edited.
  inline void editable( bool b )
    { input.readonly( (int)(!b) ); }

  //! Get the string in the input field
  inline const char* value() const
    { return input.value(); }

  //! Set the string in the input field and the value of the popup box.
  void value( const char *v );

  //! Set the height of the popup box
  inline void pop_height( int h )
    { popHeight = h; }

  //! Get the height of the popup box
  inline int pop_height()
    { return popHeight; }

  //! Override of Fl_Group::handle()
  int handle( int );

  //! Override of Fl_Group::resize()
  void resize( int X, int Y, int W, int H );

  //! Set the function that will be called when the input area is interacted with
  inline void input_callback( void (*cb)(Fl_Widget*,void*), void* cbd = NULL )
    { _inputCB = cb; _inputCBD = cbd; }

  //! Publicly exposed input widget
  Fl_Input input;

protected:

  void (*_inputCB)(Fl_Widget*,void*);
  void* _inputCBD;
 
  virtual bool _value( const char *v ) = 0;
  virtual const char* _next() = 0;
  virtual const char* _previous() = 0;
  virtual void _hilight( int x, int y ) = 0;

  void draw();

  void selected( const char *v );

  void set_combo_widget( Fl_Widget *w );

  uchar _valbox;
  bool _pushed, _popped;
  Fl_Widget *_cbox;
  int popHeight;

  static void input_cb( Fl_Widget*, void* v );

  class FLU_EXPORT Popup : public Fl_Double_Window
    {

    public:

      Popup( Flu_Combo_Box *b, Fl_Widget *c, int H );

      ~Popup();

      int handle( int event );

    protected:

      Flu_Combo_Box *combo;
      bool dragging;
      const char* selected;

    };
  friend class Popup;

};

#endif