source: abuse/trunk/src/imlib/input.hpp @ 57

Last change on this file since 57 was 57, checked in by Sam Hocevar, 11 years ago
  • Move each header to the same directory as its corresponding source, to get a better idea of which files are likely to export symbols.
File size: 4.3 KB
RevLine 
[56]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
[2]10#ifndef __INPUT_HPP_
11#define __INPUT_HPP_
12#include "jwindow.hpp"
13#include "filter.hpp"
14
15
16class button : public ifield
17{
18  int up,act;
19  char *text;
20  image *visual,*pressed,*act_pict;
21  int act_id;
22public :
[39]23  button(int X, int Y, int ID, char const *Text, ifield *Next);
[2]24  button(int X, int Y, int ID, image *vis, ifield *Next);
25  button(int X, int Y, int ID, image *Depressed, image *Pressed, image *active, ifield *Next);
26
27  virtual void area(int &x1, int &y1, int &x2, int &y2, window_manager *wm);
28  virtual void draw_first(image *screen, window_manager *wm);
29  virtual void draw(int active, image *screen, window_manager *wm);
30  virtual void handle_event(event &ev, image *screen, window_manager *wm, input_manager *im);
31  void change_visual(image *new_visual);
32  virtual void remap(filter *f);
33  virtual ~button() { if (text) jfree(text); }
34  void push();
35  virtual char *read() { return (char *)&up; }
36  int status() { return up; }
37  void set_act_id(int id) { act_id=id; }
38} ;
39
40class button_box : public ifield
41{
42  button *buttons;
43  int maxdown;
44  public :
45  button_box(int X, int Y, int ID, int MaxDown, button *Buttons, ifield *Next);
46  void add_button(button *b);
47  void press_button(int id);      // if button box doesn't contain id, nothing happens
48  virtual void remap(filter *f);
49  virtual void area(int &x1, int &y1, int &x2, int &y2, window_manager *wm);
50  virtual void draw_first(image *screen, window_manager *wm);
51  virtual void draw(int active, image *screen, window_manager *wm);
52  virtual void handle_event(event &ev, image *screen, window_manager *wm, input_manager *im); 
53  virtual ~button_box();
54  virtual char *read();   // return pointer to first button which is depressed
55  virtual ifield *find(int search_id);  // should return pointer to item you control with this id
56  void arrange_left_right(window_manager *wm);
57  void arrange_up_down(window_manager *wm);
58} ;
59
60class text_field : public ifield
61{
62  int cur;
63  char *prompt,*data,*format;
64  int xstart(window_manager *wm) { return x+wm->font()->width()*(strlen(prompt)+1)+3; }
65  int xend(window_manager *wm) { return x+wm->font()->width()*(strlen(prompt)+1+strlen(format))+7; }
66  int yend(window_manager *wm) { return y+wm->font()->height()+5; }
67  void draw_cur(int color, image *screen, window_manager *wm);
68  int last_spot() { int x=strlen(data); while (x && data[x-1]==' ') x--; return x; }
69  void draw_text(image *screen, window_manager *wm)
70  {
71    screen->bar(xstart(wm)+1,y+1,xend(wm)-1,yend(wm)-1,wm->dark_color());
72    wm->font()->put_string(screen,xstart(wm)+1,y+3,data);
73  }
74public :
[39]75  text_field(int X, int Y, int ID, char const *Prompt, char const *Format,
76                               char const *Data, ifield *Next);
77  text_field(int X, int Y, int ID, char const *Prompt, char const *Format,
[2]78                               double Data, ifield *Next);
79
80  virtual void area(int &x1, int &y1, int &x2, int &y2, window_manager *wm);
81  virtual void draw_first(image *screen, window_manager *wm);
82  virtual void draw(int active, image *screen, window_manager *wm);
83  virtual void handle_event(event &ev, image *screen, window_manager *wm, input_manager *im);
84 
85  virtual ~text_field() { jfree(prompt); jfree(format); jfree(data); }
86  virtual char *read();
[39]87  void change_data(char const *new_data, int new_cursor,       // cursor==-1, does not change it.
[2]88                   int active, image *screen, window_manager *wm);
89} ;
90
91
92class info_field : public ifield
93{
94  char *text;
95  int w,h;
[39]96  void put_para(image *screen, char const *st, int dx, int dy, int xspace,
[2]97                int yspace, JCFont *font, int color);
98public :
[39]99  info_field(int X, int Y, int ID, char const *info, ifield *Next);
[2]100  virtual void area(int &x1, int &y1, int &x2, int &y2, window_manager *wm);
101  virtual void draw_first(image *screen, window_manager *wm);
102  virtual void draw(int active, image *screen, window_manager *wm) { ; }
103  virtual void handle_event(event &ev, image *screen, window_manager *wm, input_manager *im) { ; }
104  virtual char *read() { return text; }
105  virtual int selectable() { return 0; }
106  virtual ~info_field() { jfree(text); }
107} ;
108
109#endif
110
111
112
113
114
115
116
117
118
119
Note: See TracBrowser for help on using the repository browser.