Ignore:
Timestamp:
Mar 15, 2008, 12:55:44 AM (11 years ago)
Author:
Sam Hocevar
Message:
  • Rename the "eh" variable to "wm" because it's a window manager, not an event handler.
  • No longer pass the window manager to functions, there's only one.

Inspired by Win32 Abuse changelog for January 28, 2001:

  • Starting work on singleton code; will get rid of all

references to an arbitrary window_manager* because
there's only going to be one, and it's not ever
going to change.

File:
1 edited

Legend:

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

    r56 r106  
    1212#include "video.hpp"
    1313#include "image.hpp"
     14#include "input.hpp"
    1415#include "event.hpp"
    1516#include "filter.hpp"
     
    201202        ev.type=EV_SPURIOUS;
    202203      } else if (ev.window)
    203         ev.window->inm->handle_event(ev,ev.window,this);
     204        ev.window->inm->handle_event(ev,ev.window);
    204205    }
    205206  } else if (state==dragging)
     
    274275  if (y>screen->height()-4) y=screen->height()-10;
    275276 
    276   jwindow *j=new jwindow(x,y,l,h,this,fields,Name),*k;
     277  jwindow *j=new jwindow(x,y,l,h,fields,Name),*k;
    277278  j->property.hidden=0;
    278279  if (!first)
     
    350351}
    351352
    352 jwindow::jwindow(int X, int Y, int L, int H, window_manager *wm, ifield *fields, char const *Name)
     353jwindow::jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name)
    353354{
    354355  ifield *i;
     
    359360    for (i=fields;i;i=i->next)
    360361    {
    361       i->area(x1,y1,x2,y2,wm);
     362      i->area(x1,y1,x2,y2);
    362363      if ((int)y2>(int)h)
    363364        h=y2+1;
     
    384385  screen->clear(backg);
    385386  next=NULL;
    386   inm=new input_manager(screen,wm,fields);
     387  inm=new input_manager(screen,fields);
    387388  if (Name==NULL)
    388389    name=strcpy((char *)jmalloc(strlen(" ")+1,"jwindow::window name")," "); 
     
    469470{
    470471  if (active)
    471     active->draw(0,screen,wm);
     472    active->draw(0,screen);
    472473
    473474  active=NULL;
    474475}
    475476
    476 void input_manager::handle_event(event &ev, jwindow *j, window_manager *wm)
     477void input_manager::handle_event(event &ev, jwindow *j)
    477478{
    478479  ifield *i,*in_area=NULL;
     
    491492      for (i=first;i;i=i->next)
    492493      {
    493         i->area(x1,y1,x2,y2,wm);
     494        i->area(x1,y1,x2,y2);
    494495        if (ev.mouse_move.x>=x1 && ev.mouse_move.y>=y1 &&
    495496            ev.mouse_move.x<=x2 && ev.mouse_move.y<=y2)
     
    499500      {
    500501        if (active)
    501           active->draw(0,screen,wm);
     502          active->draw(0,screen);
    502503
    503504        active=in_area;
    504505
    505506        if (active)
    506           active->draw(1,screen,wm);
     507          active->draw(1,screen);
    507508      }
    508509    }
    509510    if (ev.type==EV_KEY && ev.key==JK_TAB && active)
    510511    {
    511       active->draw(0,screen,wm);
     512      active->draw(0,screen);
    512513      do
    513514      {
     
    515516        if (!active) active=first;
    516517      } while (active && !active->selectable());
    517       active->draw(1,screen,wm);
     518      active->draw(1,screen);
    518519    }
    519520  } else active=grab;
     
    522523  {
    523524    if (ev.type!=EV_MOUSE_MOVE && ev.type!=EV_MOUSE_BUTTON)
    524       active->handle_event(ev,screen,wm,this);
     525      active->handle_event(ev,screen,this);
    525526    else
    526527    {
    527       active->area(x1,y1,x2,y2,wm);
     528      active->area(x1,y1,x2,y2);
    528529      if (grab || (ev.mouse_move.x>=x1 && ev.mouse_move.y>=y1 &&
    529530          ev.mouse_move.x<=x2 && ev.mouse_move.y<=y2))
    530531      {
    531532        if (j)
    532           active->handle_event(ev,screen,wm,j->inm);
    533         else active->handle_event(ev,screen,wm,this);
     533          active->handle_event(ev,screen,j->inm);
     534        else active->handle_event(ev,screen,this);
    534535      }
    535536    }
     
    552553  ifield *i;
    553554  for (i=first;i;i=i->next)
    554     i->draw_first(screen,wm);
     555    i->draw_first(screen);
    555556  if (active)
    556     active->draw(1,screen,wm);
    557 }
    558 
    559 input_manager::input_manager(image *Screen, window_manager *WM, ifield *First)
     557    active->draw(1,screen);
     558}
     559
     560input_manager::input_manager(image *Screen, ifield *First)
    560561{
    561562  no_selections_allowed=0;
     
    563564  grab=NULL;
    564565  screen=Screen;
    565   wm=WM;
    566566  active=first=First;
    567567  while (active && !active->selectable()) active=active->next;
Note: See TracChangeset for help on using the changeset viewer.