About SmartWin

From SmartWin Wiki

Table of contents

History

SmartWin++ was started by Thomas Hansen as an attempt to build a better Windows API GUI library. There are MFC and WTL created by Microsoft (http://www.microsoft.com). wxWidgets and Qt are portable GUI libraries written by the wxWidgets team and Trolltech. In addition there are several other libraries like FLTK and some other minor GUI libraries. Missing, though, was a small, pure Windows API abstraction with good architecture and design. The only library which had a decent design and architecture was a commercial library which was very expensive (and still is) when used to develop commercial applications. Because of its age, Qt has many drawbacks such as the MOC compiler and its own string class.

There was a gap for people who wanted to develop only for Windows API-enabled systems (Windows NT family, Windows 9x family and Windows CE family) using a modern, fast GUI library with small footprint and low overhead.

There are over 30 people who have contributed to the library and about 10 developers who have write access to the CVS repository.

Architecture

SmartWin++ is built from the lessons learned from Andrei Alexandrescu in his "Modern C++ Design" book and heavily relies on technologies and paradigms such as Generic Programming, Policy Based Design, Signals and Slots and Event Handlers. To see some of the bricks that comprise the SmartWin++ GUI library, look at Widgets, Aspects, Events and Event Handlers.

The basic component of SmartWin++ is, as in most GUI libraries, a Widget. Most Widgets inherit from a couple of Aspects which helps the Widget implement some common features shareable among different Widgets. Here SmartWin++ uses multiple inheritance to bring in the different Aspects. Most Widgets inherit from 5 to 25 different classes which implements the common functionality. This makes it easy to maintain and easy to learn. Once you've learned how to handle the Focus Event Handler in a WidgetButton, you have also learned how to handle the Focus Event Handler in all other Widgets.

There are three types of functions in SmartWin++'s Widgets.

  • Setters - which change some property of a Widget and all start with "set".
  • Getters - which retrieve some property of a Widget and all start with "get".
  • Event Handler Setter - which declare a function to be called when some event occurs and all start with "on".

Event Handlers

An Event Handler is normally a function which you declare in a class which inherits from a Widget type. For "control Widgets" this will normally be a function declared in the "container Widget" which contains your "control Widget" unless you have inherited from a control Widget to make your own custom Widget. All Event Handlers have specific signatures. Most Event Handlers cannot be reused for different Event types. For instance, the Closing Event of a WidgetWindow demands that the function returns a bool value and therefore will not be reuseable in a Sized Event Handler. This makes SmartWin++ typesafe compared to the .Net framework where you can reuse the same Event Handler for all your Events in all your windows! Also what you see as, for example, a WidgetButtonPtr is actually a typedef to a template class which is unique for every Container Widge. This means that you cannot declare a container Widget class X to handle another container class Y's control Widgets Events. If you want one Widget to be "signaled" when a control Widget in another container Widget is firing an Event you need to compose this logic yourself. This is obviously a disadvantage but has been chosen to make the event handling system fast and slick! If you need this specific behavior and want to use signals and slots, there exists several commercial and non-commercial libraries to help you. One is Boost (http://www.boost.org)'s implementation. With the help of boost::signals you can, for example, fire a signal in Event Handler X of WidgetY and let other Widgets connect slots to this signal.

Portability

The fact that SmartWin++ is built on top of Windows API is something many see as a disadvantage but this is unfair. First, very few people (even in Java) manage to build truly portable applications. Second, if you build on top of Windows API and don't care about portability, you can utilize Windows API or some other platform-specific API/SDK whenever the GUI library comes up short. Third, and most important, a portable GUI library will never be as fast, slick, easy to use, easy to maintain and as bug free as SmartWin++!

Finally, SmartWin++ is portable. You can use it in combination with WineLib (http://www.winehq.com/site/winelib) (This requires modifications to the library since this is not (yet) an officially supported platform.)

Windows CE-Based Systems

SmartWin++ is, together with WTL, the only library with realistic support for Windows CE-based systems, such as Pocket PC-based systems. This platform is officially supported since we believe that it will probably be the most important platform for "desktop" future GUI applications. You can, in most cases, take your existing desktop client code and recompile with some new compiler switches, link to SmartWinDevices.lib instead of SmartWinXX.lib and you have a working Windows CE application. There are, however, some features which are not supported in Windows CE based SmartWin++ applications.

  • RichEdit does not exist in Windows CE. You cannot use the WidgetRichTextBox Widget.
  • MDI does not exist in Windows CE. You cannot use the WidgetMDIChild/Parent Widgets.
  • WidgetMenuExtended is not (yet) ported to Windows CE.
  • WidgetMenu is slightly different since it does not have the "attach" function in Windows CE. Therefore you cannot swap menus during runtime on Windows CE.
  • WidgetChooseFont does not exist on Windows CE since the ChooseFont function from Windows API does not exist on the Windows CE Windows API.
  • WidgetSplitter is not (yet) ported to Windows CE.
  • WidgetToolbar is not (yet) ported to Windows CE.
  • SmartWin++ does NOT build with Microsoft Compiler older than the VC++7.1. You must use VC++ 2005 or newer to build Windows CE based applications.

Apart from those limitations you can use everything in SmartWin++ on both desktop systems and Windows CE-based systems! The code for the library is the same which guarantees that the API for developing against Windows CE-based systems is the same as developing against Windows desktop systems!

Thomas Hansen is using SmartWin++ in his own company to build commercial SmartWin++ applications for Pocket PC-based systems. In that company, the entire business model is comprised of SmartWin++ based Pocket PC applications! You can trust us not to break the Windows CE port of SmartWin++!