source: abuse/trunk/src/imlib/input.h @ 555

Last change on this file since 555 was 555, checked in by Sam Hocevar, 8 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#ifndef __INPUT_HPP_
12#define __INPUT_HPP_
13#include "jwindow.h"
14#include "filter.h"
15
16extern WindowManager *wm; /* FIXME: get rid of this if possible */
17
18class button : public ifield
19{
20  int up,act;
21  char *text;
22  image *visual,*pressed,*act_pict;
23  int act_id;
24public :
25  button(int X, int Y, int ID, char const *Text, ifield *Next);
26  button(int X, int Y, int ID, image *vis, ifield *Next);
27  button(int X, int Y, int ID, image *Depressed, image *Pressed, image *active, ifield *Next);
28
29  virtual void area(int &x1, int &y1, int &x2, int &y2);
30  virtual void draw_first(image *screen);
31  virtual void draw(int active, image *screen);
32  virtual void handle_event(event &ev, image *screen, InputManager *im);
33  void change_visual(image *new_visual);
34  virtual void remap(filter *f);
35  virtual ~button() { if (text) free(text); }
36  void push();
37  virtual char *read() { return (char *)&up; }
38  int status() { return up; }
39  void set_act_id(int id) { act_id=id; }
40} ;
41
42class button_box : public ifield
43{
44  button *buttons;
45  int maxdown;
46public :
47  button_box(int X, int Y, int ID, int MaxDown, button *Buttons, ifield *Next);
48  void add_button(button *b);
49  void press_button(int id);      // if button box doesn't contain id, nothing happens
50  virtual void remap(filter *f);
51  virtual void move(int newx, int newy);
52  virtual void area(int &x1, int &y1, int &x2, int &y2);
53  virtual void draw_first(image *screen);
54  virtual void draw(int active, image *screen);
55  virtual void handle_event(event &ev, image *screen, InputManager *im);
56  virtual ~button_box();
57  virtual char *read();   // return pointer to first button which is depressed
58  virtual ifield *find(int search_id);  // should return pointer to item you control with this id
59  void arrange_left_right();
60  void arrange_up_down();
61} ;
62
63class text_field : public ifield
64{
65  int cur;
66  char *prompt,*data,*format;
67  int xstart() { return x+wm->font()->width()*(strlen(prompt)+1)+3; }
68  int xend() { return x+wm->font()->width()*(strlen(prompt)+1+strlen(format))+7; }
69  int yend() { return y+wm->font()->height()+5; }
70  void draw_cur(int color, image *screen);
71  int last_spot() { int x=strlen(data); while (x && data[x-1]==' ') x--; return x; }
72  void draw_text(image *screen)
73  {
74    screen->bar(xstart()+1,y+1,xend()-1,yend()-1,wm->dark_color());
75    wm->font()->put_string(screen,xstart()+1,y+3,data);
76  }
77public :
78  text_field(int X, int Y, int ID, char const *Prompt, char const *Format,
79                               char const *Data, ifield *Next);
80  text_field(int X, int Y, int ID, char const *Prompt, char const *Format,
81                               double Data, ifield *Next);
82
83  virtual void area(int &x1, int &y1, int &x2, int &y2);
84  virtual void draw_first(image *screen);
85  virtual void draw(int active, image *screen);
86  virtual void handle_event(event &ev, image *screen, InputManager *im);
87
88  virtual ~text_field() { free(prompt); free(format); free(data); }
89  virtual char *read();
90  void change_data(char const *new_data, int new_cursor,       // cursor==-1, does not change it.
91           int active, image *screen);
92} ;
93
94
95class info_field : public ifield
96{
97  char *text;
98  int w,h;
99  void put_para(image *screen, char const *st, int dx, int dy, int xspace,
100        int yspace, JCFont *font, int color);
101public :
102  info_field(int X, int Y, int ID, char const *info, ifield *Next);
103  virtual void area(int &x1, int &y1, int &x2, int &y2);
104  virtual void draw_first(image *screen);
105  virtual void draw(int active, image *screen) { ; }
106  virtual void handle_event(event &ev, image *screen, InputManager *im) { ; }
107  virtual char *read() { return text; }
108  virtual int selectable() { return 0; }
109  virtual ~info_field() { free(text); }
110} ;
111
112#endif
113
114
115
116
117
118
119
120
121
122
Note: See TracBrowser for help on using the repository browser.