source: abuse/trunk/src/imlib/pmenu.hpp @ 120

Last change on this file since 120 was 120, checked in by Sam Hocevar, 11 years ago
File size: 2.0 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 __PMENU_HPP_
11#define __PMENU_HPP_
12
13#include "jmalloc.hpp"
14#include "input.hpp"
15
16class psub_menu;
17
18class pmenu_item
19{
20  int hotkey;
21public :
22  char *n;
23  char const *on_off;
24  psub_menu *sub;
25
26  int id,xp;
27  pmenu_item *next;
28  pmenu_item(int ID, char const *name, char const *on_off_flag, int Hotkey, pmenu_item *Next);
29  pmenu_item(char const *Name, psub_menu *Sub, pmenu_item *Next, int xpos=-1);
30  char *name() { return n; }
31  pmenu_item *find_id(int search_id);
32  pmenu_item *find_key(int key);
33  void draw       (Jwindow *parent, int x, int y, int w, int top, int active);
34  void draw_self  (Jwindow *parent, int x, int y, int w, int top, int active);
35  int handle_event(Jwindow *parent, int x, int y, int w, int top, event &ev);
36  int own_event(event &ev);
37  ~pmenu_item();
38} ;
39
40
41class psub_menu
42{
43  pmenu_item *first;
44  psub_menu *next;
45  int active;
46  Jwindow *win;
47  pmenu_item *item_num(int x) { pmenu_item *p=first; while (x-- && p) p=p->next; return p; }
48public :
49  void calc_size(int &w, int &h);
50  pmenu_item *find_id(int search_id);
51  pmenu_item *find_key(int key);
52  psub_menu(pmenu_item *First, psub_menu *Next)
53  { first=First; Next=Next; win=0; active=0; }
54  int handle_event(Jwindow *parent, int x, int y, event &ev);
55  void draw(Jwindow *parent, int x, int y);
56  void hide(Jwindow *parent, int x, int y);
57  int own_event(event &ev);
58  ~psub_menu();
59} ;
60
61class pmenu
62{
63  Jwindow *bar;
64  pmenu_item *top,*active;
65  int itemw(pmenu_item *p)
66  { return strlen(p->name())*wm->font()->width()+2; }
67  int itemx(pmenu_item *p);
68  pmenu_item *inarea(int mx, int my, image *screen);
69public :
70  ~pmenu();
71  pmenu(int X, int Y, pmenu_item *first, image *screen);
72  void move(int new_x, int new_y);
73  void draw(image *screen, int top_only=0);
74  int handle_event(event &ev, image *screen); 
75
76} ;
77
78#endif
79
80
Note: See TracBrowser for help on using the repository browser.