This is a discussion on Design question for UI library within the Software Patterns forums, part of the Testing category; Hi everyone, I am writing a small user interface library in C++ (I know it has been done to death, ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Design question for UI library
Hi everyone,
I am writing a small user interface library in C++ (I know it has been done to death, but it is good for learning ). Anyways, I need some help/advice with the deisgn of the software architecture. The problem I am facing is that a control can have so many states... For example, a button could be have various shapes (rounded, square, some other custom geometry). Also, it could be bitmapped, textured, text only, text with bitmap etc. So, you get the picture. Having a specialized Button class for each of these would be very difficult to maintain. So, my question to you gurus is how would you organize a widget library like that. What design patterns would you recommend that I look into? Any advice would be appreciated. Thanks and cheers! xargy |
|
|||
|
Re: Design question for UI library
First, you should probably get the book called GoF95. It'll be very
handful for this task and for any other that you'll do in future. For your information, the patterns that you'll need to use for the button example will first be the visitor and the state. In that case, the visitor will be able to change the state of the button using strategies. Since your GUI classes will probably be built using a composite (in order to be able to use any widget as a widget), everything will be produced from a factory. Then in general, those are patterns that will show a very simple architecture. Remember that you can't just use one design pattern for something. DP are beautiful because they are like lego. Assemble them as you wish and you are going to get something good. Anyway, GoF95 will be a good start in order to get your hands on a few and really useful design patterns. Something that you'll probably appreciate from that book, are the examples. They are using 'GUI' code to demonstrate patterns. GoF95 stands for Gang of Four (produced in 1995) The real name of the book is: "Design Patterns" done by 4 guys... I hope that's going to help you iscy |
|
|||
|
Re: Design question for UI library
Look for the Movel-View-Controller design pattern. This pattern has
been used in several GUI frameworks. -- EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio Sequence Diagram Based Systems Engineering and Object Modeling Tool |
![]() |
| Thread Tools | |
|
|