summaryrefslogtreecommitdiffstats
path: root/fltk-2/include/fltk/ComboBox.h
blob: bdd9be623e28161fbed77d8106eb72ef711393c9 (plain) (blame)
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
//
// 
//
// single line input field with predefined choices via popup menu
//
// Copyright 2002 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//

#ifndef fltk_ComboBox_h
#define fltk_ComboBox_h

#include "Choice.h"
#include "Input.h"

namespace fltk {

class FL_API ComboBox : public Choice {
public:
  ComboBox(int,int,int,int,const char * = 0);
  ~ComboBox();
  static NamedStyle* default_style;

  void draw();
  void layout();
  int handle(int);
  int popup(const Rectangle&,const char* title=0,bool menubar=false);

  int choice(int v);
  int choice() const;
  int find_choice() const;
  bool text(const char *txt)
	{ return text_changed_(input_->text(txt)); }
  bool text(const char *txt, int n)
	{ return text_changed_(input_->text(txt, n)); }
  bool static_text(const char *txt)
	{ return text_changed_(input_->static_text(txt)); }
  bool static_text(const char *txt, int n)
	{ return text_changed_(input_->static_text(txt, n)); }
  const char* text() const { return input_->text();}
  char at(int i) const { return input_->at(i); }
  
  int size(bool ofText) const 
	{ return ofText ? input_->size() : Choice::size(); }

  int position() const { return input_->position();}
  int mark() const { return input_->mark();}
  void position(int p, int m)
	{ input_->position(p, m); text_changed_(); }
  void position(int p) { position(p, p); }
  void up_down_position(int p, bool m) 
	{ input_->up_down_position(p, m); text_changed_(); }
  void mark(int m) { position(position(), m);}

  virtual bool replace(int a, int b, const char *c, int d)
	{ return text_changed_(input_->replace(a, b, c, d)); }
  bool cut() {return replace(position(), mark(), 0, 0);}
  bool cut(int n) {return replace(position(), position()+n, 0, 0);}
  bool cut(int a, int b) {return replace(a, b, 0, 0);}
  bool insert(const char* t, int l=0)
	{ return replace(input_->position(), input_->mark(), t, l); }
  bool replace(int a, int b, char c) { return replace(a,b,&c,1); }
  bool copy(bool clipboard = true) { return input_->copy(clipboard); }
  bool undo() { return text_changed_(input_->undo()); }

  int word_start(int i) const { return input_->word_start(i); }
  int word_end(int i) const { return input_->word_end(i); }
  int line_start(int i) const { return input_->line_start(i); }
  int line_end(int i) const  { return input_->line_end(i); }
  int mouse_position(const Rectangle& r) const
	{ return input_->mouse_position(r); }
  int xscroll() const { return input_->xscroll();}
  int yscroll() const { return input_->yscroll();}
  
protected:
  bool text_changed_(bool ret=true);

private:
  Input *input_;
#if defined (_WIN32) || (defined( __GNUC__ ) && __GNUC__ < 3) 
 public:
#endif
  static void input_callback_(Widget*,void*);
};

}

#endif

//
// 
//