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

Last change on this file since 481 was 481, checked in by Sam Hocevar, 12 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

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