Ignore:
Timestamp:
May 13, 2011, 9:13:53 AM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: refactor Event and EventHandler?.

File:
1 edited

Legend:

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

    r579 r643  
    2222#include "event.h"
    2323#include "filter.h"
    24 #include "event.h"
    2524#include "jwindow.h"
    2625
     
    7372        {
    7473            p->hide();
    75             screen->AddDirty(p->x, p->y, p->x + p->l, p->y + p->h);
     74            m_screen->AddDirty(p->x, p->y, p->x + p->l, p->y + p->h);
    7675        }
    7776    }
     
    10099        k->next = j->next;
    101100    }
    102     screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
     101    m_screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
    103102    j->hide();
    104103}
     
    113112}
    114113
    115 void WindowManager::get_event(event &ev)
    116 {
    117   Jwindow *j;
    118   eh->get_event(ev);
     114void WindowManager::get_event(Event &ev)
     115{
     116  Get(ev);
     117
    119118  if (ev.type==EV_KEY)
    120119    key_state[ev.key]=1;
     
    124123  if (state==inputing)
    125124  {
     125    Jwindow *j;
    126126    for (ev.window=NULL,j=first; j; j=j->next)
    127127      if (!j->is_hidden() && ev.mouse_move.x>=j->x && ev.mouse_move.y>=j->y &&
     
    180180    {
    181181      Jwindow *j=ev.window;
    182 /*      screen->AddDirty(j->x,j->y,j->x+j->l,j->y+j->h);
     182/*      m_screen->AddDirty(j->x,j->y,j->x+j->l,j->y+j->h);
    183183      for (p=first; p!=j; p=p->next)
    184184        p->screen->AddDirty(j->x-p->x,j->y-p->y,j->x+j->l-p->x,j->y+j->h-p->y); */
     
    213213  if (ev.type == EV_REDRAW)
    214214  {
    215     for (j=first; j; j=j->next)
     215    for (Jwindow *j = first; j; j = j->next)
    216216       j->screen->AddDirty(ev.redraw.x1 - j->x, ev.redraw.y1 - j->y,
    217217                           ev.redraw.x2 + 1 - j->x, ev.redraw.y2 + 1 - j->y);
    218     screen->AddDirty(ev.redraw.x1, ev.redraw.y1, ev.redraw.x2 + 1, ev.redraw.y2 + 1);
     218    m_screen->AddDirty(ev.redraw.x1, ev.redraw.y1, ev.redraw.x2 + 1, ev.redraw.y2 + 1);
    219219    flush_screen();
    220220    ev.type=EV_SPURIOUS;   // we took care of this one by ourselves.
     
    231231{
    232232  Jwindow *p;
    233   screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
     233  m_screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
    234234  for (p=first; p!=j; p=p->next)
    235235    p->screen->AddDirty(j->x - p->x, j->y - p->y, j->x + j->l - p->x, j->y + j->h - p->y);
     
    241241void WindowManager::move_window(Jwindow *j, int x, int y)
    242242{
    243     screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
     243    m_screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h);
    244244    for(Jwindow *p = first; p != j; p = p->next)
    245245        p->screen->AddDirty(j->x - p->x, j->y - p->y,
     
    250250}
    251251
    252 WindowManager::WindowManager(image *Screen, palette *Pal, int Hi,
     252WindowManager::WindowManager(image *screen, palette *pal, int Hi,
    253253                             int Med, int Low, JCFont *Font)
     254  : EventHandler(screen, pal)
    254255{
    255256    wm = this;
    256     screen = Screen;
    257     hi = Hi; low = Low; med = Med; first = NULL; pal = Pal; grab = NULL;
     257    m_screen = screen;
     258    hi = Hi; low = Low; med = Med; first = NULL; m_pal = pal; grab = NULL;
    258259    bk = pal->find_closest(0, 0, 0);
    259260    state = inputing; fnt = Font;  wframe_fnt = Font;
    260261    memset(key_state, 0, sizeof(key_state));
    261     eh = new event_handler(screen, pal);
    262262    frame_suppress = 0;
    263263}
     
    265265WindowManager::~WindowManager()
    266266{
    267     delete eh;
    268267    while(first)
    269268        close_window(first);
     
    310309    }
    311310
    312     screen->AddDirty(win->x, win->y, win->x + win->l, win->y + win->h);
     311    m_screen->AddDirty(win->x, win->y, win->x + win->l, win->y + win->h);
    313312}
    314313
     
    316315                                     ifield * fields, char const *name)
    317316{
    318     if(x > screen->Size().x - 4)
    319         x = screen->Size().x - 25;
    320     if(y > screen->Size().y - 4)
    321         y = screen->Size().y - 10;
     317    if(x > m_screen->Size().x - 4)
     318        x = m_screen->Size().x - 25;
     319    if(y > m_screen->Size().y - 4)
     320        y = m_screen->Size().y - 10;
    322321
    323322    Jwindow * j = new Jwindow (x, y, l, h, fields, name);
     
    336335    if(has_mouse())
    337336    {
    338         mouse_pic = eh->mouse_sprite()->visual;
    339         mouse_save = eh->mouse_sprite()->save;
    340         mx = eh->mouse->drawx();
    341         my = eh->mouse->drawy();
    342 
    343         screen->put_part(mouse_save, 0, 0, mx, my,
     337        mouse_pic = mouse_sprite()->visual;
     338        mouse_save = mouse_sprite()->save;
     339        mx = mouse->drawx();
     340        my = mouse->drawy();
     341
     342        m_screen->put_part(mouse_save, 0, 0, mx, my,
    344343                         mx + mouse_pic->Size().x - 1,
    345344                         my + mouse_pic->Size().y - 1);
    346         mouse_pic->put_image(screen, mx, my, 1);
     345        mouse_pic->put_image(m_screen, mx, my, 1);
    347346    }
    348347
    349348    for(p = first; p; p = p->next)
    350349        if(!p->is_hidden())
    351             screen->delete_dirty(p->x, p->y, p->x + p->l, p->y + p->h);
    352     update_dirty(screen);
     350            m_screen->delete_dirty(p->x, p->y, p->x + p->l, p->y + p->h);
     351    update_dirty(m_screen);
    353352
    354353    if(has_mouse())
    355         mouse_save->put_image(screen, mx, my);
     354        mouse_save->put_image(m_screen, mx, my);
    356355
    357356    for(p = first; p; p = p->next)
     
    369368        }
    370369
    371 //          screen->delete_dirty(p->x, p->y, p->x+p->l, p->y+p->h);
     370//          m_screen->delete_dirty(p->x, p->y, p->x+p->l, p->y+p->h);
    372371        for(q = p->next; q; q = q->next)
    373372            if(!q->is_hidden())
     
    598597}
    599598
    600 void InputManager::handle_event(event &ev, Jwindow *j)
     599void InputManager::handle_event(Event &ev, Jwindow *j)
    601600{
    602601  ifield *i,*in_area=NULL;
Note: See TracChangeset for help on using the changeset viewer.