source: abuse/trunk/src/imlib/pmenu.h @ 682

Last change on this file since 682 was 668, checked in by Sam Hocevar, 9 years ago

imlib: make JCFont use vec2i classes.

  • Property svn:keywords set to Id
File size: 2.1 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 __PMENU_HPP_
12#define __PMENU_HPP_
13
14#include "input.h"
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()->Size().x+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.