Re: A new draw on XP refactoring


Subject: Re: A new draw on XP refactoring
From: Hubert Figuiere (hfiguiere@teaser.fr)
Date: Fri Feb 01 2002 - 07:03:20 CST


begin F J Franklin <F.J.Franklin@sheffield.ac.uk> quotation:
> More thoughts for post-1.0:
>
> As I mentioned on IRC yesterday, I'd like to start work on "AbiDraw" (?)
> while I work on SVG rendering.
>
> Since we'll be re-arranging the code, this will be the best time to
> distinguish AbiSuite code from AbiWord code, a line long blurred...
> (or should that be "anti-aliased"?)

That sort of thing IS supposed to be done as wp/* is for Word Processor and
af/* is for Application Framework

But here are my thought.

Current framework does the following (I take a specific class, but this does
apply to most of them):

XAP_Frame -> XAP_<FE>Frame -> AP_<FE>Frame

<FE> is the front end (Unix, Win, Cocoa, etc.)
The difference beetween XAP and AP is that XAP is for any app and AP is
specific to the app (XAP are in af/xap while AP are in wp/ap currently).

That means that the difference beetween generic application and the
application itself is in paltform code. The cost of maintenance of this code
is the number of platforms.....

My idea is to change the hierarchy as is:

XAP_Frame -> AP_Frame

And provide implementation with:

XAP_FrameImp -> XAP_<FE>FrameImp -> AP_<FE>FrameImp

Then each of the classes create (thru a factory, that means in a
crossplatform way) the implementation class that is platform specific and
that will be delegated all the implementation work.

createImplementation() will create the implementation instance for the
platform and the class. Implementation for application will (at least it
seems logical) inherit from the XAP implementation (or that least from the
base implementation class).

Sample implementation (dummy code to get the idea. Sorry for the
objective-C++ dialect) with 2 platforms:

/* XP code */

class XAP_Frame
{
  XAP_Frame ();
  ~XAP_Frame ()
  virtual bool raise () { m_imp->raise(); }; // delegate
  virtual bool close () { m_imp->close(); }; // delegate
  virtual bool loadUI () { m_imp->loadUI(); };
  virtual createImplementation ()
     { m_imp = createObjectImpFromFactory ("XAP_Frame"); };
  
protected:
  XAP_FrameImp * m_imp;
}

class AP_Frame
  : XAP_Frame
{
  AP_Frame ();
  ~AP_Frame ()
  virtual raise () { /* AP specific */ XAP_Frame::raise(); /* AP specific */ };
  
  virtual createImplementation ()
     { m_imp = createObjectImpFromFactory ("AP_Frame"); }; // don't call inherited

}

class XAP_FrameImp
{
//abstract class
  virtual raise() = 0;
  virtual close() = 0;
}

/* UNIX/GTK specific platform */

class XAP_UnixFrameImp
  : XAP_FrameImp
{
  virtual bool raise() {
     gdk_window_raise(m_window->window);
  }
  virtual bool close() {
     gtk_widget_destroy (m_window);
  }
  virtual bool loadUI () {
     m_window = gtk_new_window();
     // all the window construction code...
  }

  GtkWidget * m_window;
}

/* Cocoa specific paltform */

class XAP_CocaFrameImp
  : XAP_FrameImp
{
  virtual bool raise() {
     [[m_window window] makeKeyAndOrderFront:m_window];
  };
  virtual bool close() {
     [m_window close];
  };
  
  virtual bool loadUI () {
     [[m_window alloc] loadWindowNib:_getImplemetationNibName()]
  }
  virtual NSString * _getImplementationNibName() { return @"XAP_CocaFrameImp" };
  NSWindowController * m_window;
}

etc...

> Also, I know little about GUI stuff, so if anyone feels like whipping up
> an interface, that would make my life a lot easier :-)

We'll think about that.

Hub



This archive was generated by hypermail 2b25 : Fri Feb 01 2002 - 07:02:25 CST