Ignore:
Timestamp:
Mar 16, 2008, 2:17:43 AM (11 years ago)
Author:
Sam Hocevar
Message:
  • Simplified the window creation arguments. Got rid of a lot of macros and hid stuff in private namespaces.

Inspired by Win32 Abuse changelog for January 28, 2001:

  • Well, in the process of adding changes necessary to

handle recovery from alt-tabbing away from Abuse
(which is why I was updating jwindow::redraw()),
the entire windowing system is getting an overhaul.
It's gonna be sweet when I'm done, though.

  • jwindow::redraw() has been changed to a virtual

function requiring no parameters. This'll make
it much easier to implement special specific-
purpose windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/jwindow.hpp

    r109 r111  
    2121class jwindow;
    2222
    23 int frame_top();
    24 int frame_bottom();
    25 int frame_left();
    26 int frame_right();
     23extern int frame_top();
     24extern int frame_bottom();
     25extern int frame_left();
     26extern int frame_right();
    2727
    2828void set_frame_size(int x);
    29 
    30 #define WINDOW_FRAME_TOP  frame_top()
    31 #define WINDOW_FRAME_BOTTOM frame_bottom()
    32 #define WINDOW_FRAME_LEFT  frame_left()
    33 #define WINDOW_FRAME_RIGHT frame_right()
    3429
    3530class input_manager
     
    8883} ;
    8984
    90 struct jwindow_properties
    91 {
    92     bool moveable, hidden;
    93 };
    94 
    9585class jwindow
    9686{
     
    9888
    9989private:
    100     bool hidden;
    101     bool moveable;
     90    char *_name;
     91    bool _hidden;
     92    bool _moveable;
     93
     94    void reconfigure();
    10295
    10396protected:
    10497    jwindow *owner;
     98    int _x1, _y1, _x2, _y2;
    10599
    106100public:
    107101    jwindow *next;
    108     char *name;
    109102    int x, y, l, h, backg;
    110103    image *screen;
    111104    input_manager *inm;
    112105    void *local_info;  // pointer to info block for local system (may support windows)
    113     jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name = NULL);
    114     void redraw(int hi, int med, int low, JCFont *fnt);
     106
     107    jwindow();
     108    jwindow(int X, int Y, int L, int H, ifield *f, char const *name = NULL);
     109    ~jwindow();
     110
     111    void redraw();
    115112    void resize(int L, int H);
    116113    void clear(int color = 0) { screen->bar(x1(), y1(), x2(), y2(), color); }
    117     void show() { hidden = false; }
    118     void hide() { hidden = true; }
    119     bool is_hidden() { return hidden; }
    120     void freeze() { moveable = false; }
    121     void thaw() { moveable = true; }
    122     bool is_moveable() { return moveable; }
    123     int x1() { return WINDOW_FRAME_LEFT; }
    124     int y1() { return WINDOW_FRAME_TOP; }
    125     int x2() { return l-WINDOW_FRAME_RIGHT-1; }
    126     int y2() { return h-WINDOW_FRAME_BOTTOM-1; }
    127     void clip_in() { screen->set_clip(x1(),y1(),x2(),y2()); }
    128     void clip_out() { screen->set_clip(0,0,l-1,h-1); }
     114    void show() { _hidden = false; }
     115    void hide() { _hidden = true; }
     116    bool is_hidden() { return _hidden; }
     117    void freeze() { _moveable = false; }
     118    void thaw() { _moveable = true; }
     119    bool is_moveable() { return _moveable; }
     120    int x1() { return _x1; }
     121    int y1() { return _y1; }
     122    int x2() { return _x2; }
     123    int y2() { return _y2; }
     124    void clip_in() { screen->set_clip(x1(), y1(), x2(), y2()); }
     125    void clip_out() { screen->set_clip(0, 0, l - 1, h - 1); }
    129126    char *read(int id) { return inm->get(id)->read(); } 
    130127    void local_close();
    131     ~jwindow() { local_close(); delete screen; delete inm; jfree(name); }
    132 } ;
     128
     129    static int left_border();
     130    static int right_border();
     131    static int top_border();
     132    static int bottom_border();
     133};
    133134
    134135class window_manager
    135136{
    136   friend class jwindow;
     137    friend class jwindow;
     138
     139protected:
     140    void add_window(jwindow *);
     141    void remove_window(jwindow *);
    137142
    138143public:
    139   event_handler *eh;
    140   jwindow *first,*grab;
    141   image *screen,*mouse_pic,*mouse_save;
    142   palette *pal;
    143   int hi,med,low,bk;                            // bright, medium, dark and black colors
    144   int key_state[512];
    145   enum { inputing,dragging } state;
    146   int drag_mousex, drag_mousey,frame_suppress;
    147   jwindow *drag_window;
    148   JCFont *fnt,*wframe_fnt;
     144    event_handler *eh;
     145    jwindow *first, *grab;
     146    image *screen, *mouse_pic, *mouse_save;
     147    palette *pal;
     148    int hi, med, low, bk; // bright, medium, dark and black colors
     149    int key_state[512];
     150    enum { inputing, dragging } state;
     151    int drag_mousex, drag_mousey, frame_suppress;
     152    jwindow *drag_window;
     153    JCFont *fnt, *wframe_fnt;
    149154
    150   window_manager(image *Screen, palette *Pal, int Hi, int Med, int Low, JCFont *Font);
     155    window_manager(image *, palette *, int hi, int med, int low, JCFont *);
     156    ~window_manager();
    151157
    152   jwindow *new_window(int x, int y, int l, int h, ifield *fields=NULL, char const *Name=NULL);
    153   void set_frame_font(JCFont *fnt) { wframe_fnt=fnt; }
    154   JCFont *frame_font() { return wframe_fnt; }
    155   void close_window(jwindow *j);
    156   void resize_window(jwindow *j, int l, int h);
    157   void move_window(jwindow *j, int x, int y);
    158   void get_event(event &ev);
    159   void push_event(event *ev) { eh->push_event(ev); }
    160   int event_waiting() { return eh->event_waiting(); }
    161   void flush_screen();
    162   int bright_color() { return hi; }
    163   int medium_color() { return med; }
    164   int dark_color() { return low; }
    165   int black() { return bk; }
    166   void set_colors(int Hi, int Med, int Low) { hi=Hi; med=Med; low=Low; }
    167   JCFont *font() { return fnt; }
    168   int has_mouse() { return eh->has_mouse(); }
    169   void mouse_status(int &x, int &y, int &button) {eh->mouse_status(x,y,button); }             
    170   void set_mouse_shape(image *im, int centerx, int centery)
    171   { eh->set_mouse_shape(im,centerx,centery); }
     158    jwindow *new_window(int x, int y, int l, int h,
     159                        ifield *fields = NULL, char const *Name = NULL);
    172160
    173   void set_mouse_position(int mx, int my)
    174   { eh->set_mouse_position(mx,my); }
     161    void set_frame_font(JCFont *fnt) { wframe_fnt = fnt; }
     162    JCFont *frame_font() { return wframe_fnt; }
     163    void close_window(jwindow *j);
     164    void resize_window(jwindow *j, int l, int h);
     165    void move_window(jwindow *j, int x, int y);
     166    void get_event(event &ev);
     167    void push_event(event *ev) { eh->push_event(ev); }
     168    int event_waiting() { return eh->event_waiting(); }
     169    void flush_screen();
     170    int bright_color() { return hi; }
     171    int medium_color() { return med; }
     172    int dark_color() { return low; }
     173    int black() { return bk; }
     174    void set_colors(int Hi, int Med, int Low) { hi=Hi; med=Med; low=Low; }
     175    JCFont *font() { return fnt; }
     176    int has_mouse() { return eh->has_mouse(); }
     177    void mouse_status(int &x, int &y, int &button) {eh->mouse_status(x,y,button); }           
     178    void set_mouse_shape(image *im, int centerx, int centery)
     179    { eh->set_mouse_shape(im,centerx,centery); }
    175180
    176   int key_pressed(int x) { return key_state[x]; }
    177   ~window_manager() { delete eh; while (first) close_window(first); }
    178   void hide_windows();
    179   void show_windows();
    180   void hide_window(jwindow *j);
    181   void show_window(jwindow *j);
    182   void set_frame_suppress(int x) { frame_suppress=x; }
    183   void grab_focus(jwindow *j);
    184   void release_focus();
    185   int window_in_area(int x1, int y1, int x2, int y2); // true if a window lies in this area
    186 } ;
     181    void set_mouse_position(int mx, int my)
     182    { eh->set_mouse_position(mx,my); }
     183
     184    int key_pressed(int x) { return key_state[x]; }
     185    void hide_windows();
     186    void show_windows();
     187    void hide_window(jwindow *j);
     188    void show_window(jwindow *j);
     189    void set_frame_suppress(int x) { frame_suppress=x; }
     190    void grab_focus(jwindow *j);
     191    void release_focus();
     192    int window_in_area(int x1, int y1, int x2, int y2); // true if a window lies in this area
     193};
    187194
    188195#endif
Note: See TracChangeset for help on using the changeset viewer.