source: abuse/trunk/src/imlib/pmenu.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: 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.