source: abuse/trunk/src/imlib/include/scroller.hpp @ 2

Last change on this file since 2 was 2, checked in by Sam Hocevar, 14 years ago
  • imported original 0.7.0 tarball
File size: 4.4 KB
Line 
1#ifndef _SCROLLER_HPP_
2#define _SCROLLER_HPP_
3
4#include "input.hpp"
5
6class scroller : public ifield
7{
8protected :
9  int l,h,drag,vert,last_click;
10
11  int bh();
12  int bw();
13  void drag_area(int &x1, int &y1, int &x2, int &y2);
14  void dragger_area(int &x1, int &y1, int &x2, int &y2);
15  int b1x() { if (vert) return x+l; else return x; }
16  int b1y() { if (vert) return y; else return y+h; }
17  int b2x() { if (vert) return x+l; else return x+l-bw(); }
18  int b2y() { if (vert) return y+h-bh(); else return y+h; }
19  unsigned char *b1();
20  unsigned char *b2();
21  void wig_area(int &x1, int &y1, int &x2, int &y2);
22
23
24  int wig_x();
25  int darea() { return (l-bw()-2)-bw()-bw(); }
26  void draw_wiget(image *screen, window_manager *wm, int erase);
27  int mouse_to_drag(int mx,int my);
28public :
29  int t,sx;
30  scroller(int X, int Y, int ID, int L, int H, int Vert, int Total_items, ifield *Next);
31  virtual void area(int &x1, int &y1, int &x2, int &y2, window_manager *wm);
32  virtual void draw_first(image *screen, window_manager *wm);
33  virtual void draw(int active, image *screen, window_manager *wm);
34  virtual void handle_event(event &ev, image *screen, window_manager *wm, input_manager *im);
35  virtual char *read() { return (char *)&sx; }
36
37  virtual int activate_on_mouse_move() { return 1; }
38  virtual void handle_inside_event(event &ev, image *screen, window_manager *wm, input_manager *inm) {;}
39  virtual void scroll_event(int newx, image *screen, window_manager *wm);
40  virtual void handle_up(image *screen, window_manager *wm, input_manager *inm);
41  virtual void handle_down(image *screen, window_manager *wm, input_manager *inm);
42  virtual void handle_left(image *screen, window_manager *wm, input_manager *inm);
43  virtual void handle_right(image *screen, window_manager *wm, input_manager *inm);
44  virtual void area_config(window_manager *wm) { ; }
45  void set_size(int width, int height) { l=width; h=height; }
46  virtual void set_x(int x, image *screen, window_manager *wm);
47} ;
48
49class spicker : public scroller
50{
51  protected :
52  int r,c,m,last_sel,cur_sel;
53  uchar *select;
54  public :
55  spicker(int X, int Y, int ID, int Rows, int Cols, int Vert, int MultiSelect, ifield *Next);
56  int vis() { if (vert) return r; else return c; }
57  virtual void area_config(window_manager *wm);
58  void set_select(int x, int on);
59  int get_select(int x);
60  int first_selected();
61  virtual void scroll_event(int newx, image *screen, window_manager *wm);
62  virtual void handle_inside_event(event &ev, image *screen, window_manager *wm, input_manager *inm);
63
64  // you should define \/
65  virtual void draw_background(window_manager *wm, image *screen);
66  virtual void draw_item(window_manager *wm, image *screen, int x, int y, int num, int active) = 0;
67  virtual int total() = 0;
68  virtual int item_width(window_manager *wm) = 0;
69  virtual int item_height(window_manager *wm) = 0;
70  virtual void note_selection(window_manager *wm, image *screen, input_manager *inm, int x) { ; }
71  virtual void note_new_current(window_manager *wm, image *screen, input_manager *inm, int x) { ; }
72  virtual int ok_to_select(int num) { return 1; }
73  virtual void handle_up(image *screen, window_manager *wm, input_manager *inm);
74  virtual void handle_down(image *screen, window_manager *wm, input_manager *inm);
75  virtual void handle_left(image *screen, window_manager *wm, input_manager *inm);
76  virtual void handle_right(image *screen, window_manager *wm, input_manager *inm);
77  virtual void set_x(int x, image *screen, window_manager *wm);
78  void reconfigure();   // should be called by constructor after class is ready to take virtual calls
79  ~spicker() { if (select) jfree(select); }
80} ;
81
82struct pick_list_item
83{
84  char *name;
85  int number;
86} ;
87
88class pick_list : public scroller
89{
90  int last_sel,cur_sel,th,wid;
91  pick_list_item *lis;
92  char key_hist[20],key_hist_total;
93  image *tex;
94  public :
95  pick_list(int X, int Y, int ID, int height,
96            char **List, int num_entries, int start_yoffset, ifield *Next, image *texture=NULL);
97  virtual void handle_inside_event(event &ev, image *screen, window_manager *wm, input_manager *inm);
98  virtual void scroll_event(int newx, image *screen, window_manager *wm);
99  virtual char *read() { return (char *)this; }
100  virtual void area_config(window_manager *wm);
101  virtual void handle_up(image *screen, window_manager *wm, input_manager *inm);
102  virtual void handle_down(image *screen, window_manager *wm, input_manager *inm);
103  int get_selection() { return lis[cur_sel].number; }
104  ~pick_list() { jfree(lis); }
105} ;
106
107#endif
108
109
110
111
112
Note: See TracBrowser for help on using the repository browser.