7 Patterns-442-12-by6

Parameters are instances of a glyph subclass called

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: or* _compositor; Component* _components; int _componentCount; int _lineWidth; int* _lineBreaks; int lineCount; } 50 Pattern Pattern Sample code (cont d) Sample code (cont d) class Compositor { public: virtual int Compose( Coord natural, Coord stretch, Coord shrink, int componentCount, int lineWidth, int breaks ) =0; protected: Compositor(); } 51 void Composition::Repair() { Coord* natural; Coord* stretchability; Coord* shrinkability; int componentCount; int* breaks; // initialize arrays ... int breakCount; breakCount = _compositor->Compose( natural, stretchability, shrinkability,componentCount,lineWidth, breaks); // lay out components according to breaks ... } 52 Pattern Pattern Sample code (cont d) Sample code (cont d) class SimpleCompositor : public Compositor { public: SimpleCompositor(); virtual int Compose( Coord natural, Coord stretch, Coord shrink, int componentCount, int lineWidth, int breaks ); // ... } 53 class ArrayCompositor : public Compositor { public: ArrayCompositor(int lineInterval); virtual int Compose( Coord natural, Coord stretch, Coord shrink, int componentCount, int lineWidth, int breaks ); // ... } 54 Pattern Pattern Sample code (cont d) Adding scroll bars and borders Use of inheritance can lead to explosion in number of classes Use composition instead ( has a ) Big question: Where do we deGine classes for scrollbars and borders? Answer: DeGine as subclasses of Glyph 1. scrollbars and borders are displayable objects, after all 2. support notion of transparent enclosure (clients don t need to know whether they are dealing with a component or with an enclosure) 55 56 // Initialization of compositions... Composition* quick = new Composition(new SimpleCompositor); Composition* iconic = new Composition(new ArrayCompositor(10)); Case study Case study Embellished object structure Glyph Draw(Window) Monoglyph class ... border ... MonoGlyph component Draw(Window) scroller composition Scroll Bar Draw(Window) Border Draw(Window) Draw_Border(Window) column row row gif ..... 58 void MonoGlyph::Draw (Wind...
View Full Document

This note was uploaded on 02/23/2012 for the course COMP 553 taught by Professor Ajay during the Spring '12 term at Ill. Chicago.

Ask a homework question - tutors are online