source: abuse/trunk/src/imlib/pmenu.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: 2.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 __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 :
[39]22  char *n;
23  char const *on_off;
[2]24  psub_menu *sub;
25
26  int id,xp;
27  pmenu_item *next;
[39]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);
[2]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, window_manager *wm, int active);
34  void draw_self  (jwindow *parent, int x, int y, int w, int top, window_manager *wm, int active);
35  int handle_event(jwindow *parent, int x, int y, int w, int top, window_manager *wm, 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  window_manager *wm;
47  jwindow *win;
48  pmenu_item *item_num(int x) { pmenu_item *p=first; while (x-- && p) p=p->next; return p; }
49public :
50  void calc_size(int &w, int &h, window_manager *wm);
51  pmenu_item *find_id(int search_id);
52  pmenu_item *find_key(int key);
53  psub_menu(pmenu_item *First, psub_menu *Next)
54  { first=First; Next=Next; win=0; active=0; }
55  int handle_event(jwindow *parent, int x, int y, window_manager *wm, event &ev);
56  void draw(jwindow *parent, int x, int y, window_manager *wm);
57  void hide(jwindow *parent, int x, int y, window_manager *wm);
58  int own_event(event &ev);
59  ~psub_menu();
60} ;
61
62class pmenu
63{
64  window_manager *wm;
65  jwindow *bar;
66  pmenu_item *top,*active;
67  int itemw(pmenu_item *p, window_manager *wm)
68  { return strlen(p->name())*wm->font()->width()+2; }
69  int itemx(pmenu_item *p, window_manager *wm);
70  pmenu_item *inarea(int mx, int my, image *screen, window_manager *wm);
71public :
72  ~pmenu();
73  pmenu(int X, int Y, pmenu_item *first, image *screen, window_manager *wm);
74  void move(int new_x, int new_y);
75  void draw(image *screen, window_manager *wm, int top_only=0);
76  int handle_event(event &ev, image *screen, window_manager *wm); 
77
78} ;
79
80#endif
81
82
Note: See TracBrowser for help on using the repository browser.