source: abuse/trunk/src/imlib/scroller.hpp @ 106

Last change on this file since 106 was 106, checked in by Sam Hocevar, 15 years ago
  • Rename the "eh" variable to "wm" because it's a window manager, not an event handler.
  • No longer pass the window manager to functions, there's only one.

Inspired by Win32 Abuse changelog for January 28, 2001:

  • Starting work on singleton code; will get rid of all

references to an arbitrary window_manager* because
there's only going to be one, and it's not ever
going to change.

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