source: abuse/tags/pd/macabuse/imlib/include/pmenu.hpp @ 49

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