[Y-devel] shapes?

Mark Thomas mark at www.y-windows.org
Tue Feb 24 22:14:01 GMT 2004


On Tue, 24 Feb 2004 drizzt321 at phpfreaks.com wrote:

> Yea, I just noticed that painter uses virtual methods which end up
> pointing to rgbabuffer methods that do the actual work(thanx MattK10!).

That's correct.  Actual painting depends on the underlying structure of
the buffer onto which you are painting.  In OO terms, Painter is an
interface, and RGBABuffer has an inner class "RGBABuffer::Painter" which
implements that interface for RGBABuffers.

The theme should use the painter to paint to buffers, widgets should use a
combination of themes and painters to paint themselves to buffers
(prefering the theme unless it doesn't make sense).

The only class which exposes the painter methods to the client should be
the canvas.  The canvas should also expose parts of the theme interface so
that custom widgets can be made.

I realised today that the patch I merged for the theme interface isn't
quite what I want.  The visitor-pattern-style call to "themeDrawWidget" is
hard to expose to clients in a way that they can draw them themselves.
I'm thinking of a staged interface, i.e. for buttons:

[ I'm missing out any theme and painter pointers for all these
  prototypes... ]

  themeDrawButton (int x, int y, int w, int h, enum ButtonState state);
  themeDrawButtonWithLabel (int x, int y, int w int h,
                            enum ButtonState state, wchar_t *textLabel);
  themeDrawButtonWithChild (int x, int y, int w, int h,
                            enum ButtonState state,
                            int *cx, int *cy, int *cw, int *ch);
   /* this last one returns the child rectangle to draw the child
      widgets in */
   /* these three are exposed to the clients by canvases */

  themeDrawButtonFromObject (struct Button *);
   /* server-internal use only */

So in Y/widget/button.c:buttonPaint we call
   themeDrawButtonFromObject (painter, self);

Any thoughts on this?

Regards,

  Mark.
-- 
|| Mark Thomas
|| efaref.net
||
|| "I'm so cool you can store meat in me." - Zaphod



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved