5,445,109 members and growing! (13,927 online)
Email Password   helpLost your password?
Languages » C# » General     Intermediate

OpenTheme : An open source graphic user interface (GUI) toolkit

By weiqj

An innovative alternative to XAML and XUL
C#, Win Mobile, .NET, NT4, Win2K, WinXP, Win2003, Vista, TabletPC, Embedded, Windows, Visual Studio, Dev

Posted: 22 Oct 2004
Updated: 22 Oct 2004
Views: 176,177
Bookmarked: 221 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
152 votes for this Article.
Popularity: 10.34 Rating: 4.74 out of 5
2 votes, 1.3%
1
0 votes, 0.0%
2
3 votes, 2.0%
3
4 votes, 2.6%
4
143 votes, 94.1%
5

Sample Image - maximum width is 600 pixels

Introduction

OpenTheme is an XML based GUI toolkit with a set of foundation class and WYSIWYG editor. Although it's originally designed for full screen GUI, it is also good for Windowed user interface, with full localization support and arbitary look-and-feel.

I prepared a full tutorial at

Background

When I was developing my OpenHTPC project, I was always thinking about how to make it looking cool. Since I'm not a graphic designer, I know I will never actually design any 'cool' graphics. That brought up an interesting old question, is there a way to completely separate the design of graphic user interface from the design of the business logic?

Well, since I'm confident I'm a fairly good software architect, I think I can do this job better. Finally, I designed this OpenTheme project. In this project, I tried some new technics. And finally I had chance to express my own opinion about software design and implementation in this project.

Using the code

It is still the preliminary Alpha release. So some of the design is still subject to changes. The best way to understand the design is to read the tutorial from a user's point of view.

But this release is already stable enough. The ThemeEditor can be used to design the entire ThemePack. In your code, just use the following code to load a Themepack.

// Create a ThemePack

ThemePack tp = ThemePack.FromXml(fileName, null);
// Run through Themes contained in the ThemePack


foreach (Theme curTheme in tp)
{
   // ........

}

// Get a Top Level page from Theme

ThemeObject themeObj = curTheme.GetThemeObject(ID);
// Draw this ThemeObject with a Graphics

themeObj.SetBounds(......);
themeObj.RecalculateLayout(Graphics g);
themeObj.Invalidate(Graphics g);

Points of Interest

A Theme is a collection of layered graphics (with alpha transparancy) with layout manager. System provides a set of 'atomic' components such as Images (OpenThemePictureBox), Text (OpenThemeTextBox), Color block (OpenThemeColorBox). Components can contain sub components within their bounds. The sub-components may contain other sub-components.

System also provides some more complicated components with custom code to determine the bounds of its sub-components for more complicated layout management. Those are called 'container' components.

Programmers can easily implement their own 'atomic' components and 'container' components. For example, the system provides a button component to support buttons with absolutly ARBITARY user designed look and feel. Below are the look and feels of that button with different state.

Disabled

Enabled

Active

Focused

Toggled

Another example is the horizontal scrollbar.

The logic is complete to define any popular components (such as button, radio, scrollbar, menu etc) with completely user defined look and feel, for full screen or windowed applications.

The system is very light-weighted. The core part only have barely more than 2000 lines of code and only dependent on some very basic GDI+ functions and XML library. And it doesn't even depend on Windows Forms classes. I would expect it to be ported to Linux platform and .Net compact framework with very little or no modification in the near future.

History

  • Oct. 20, Initial Alpha release.

TODO List:

  • Event model
  • Finish all common controls
  • Visual Studio .Net extensibility integration

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

weiqj


Hello All!
Occupation: Web Developer
Location: United States United States

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 105 (Total in Forum: 105) (Refresh)FirstPrevNext
Subject  Author Date 
Generalgoodmemberfuturejo4:15 3 Aug '08  
QuestionlicensingmemberJayTau20:26 11 May '07  
AnswerRe: licensingmemberdedel0:10 20 Aug '07  
GeneralGreat job man...memberantecedents14:53 6 Feb '07  
GeneralNice but...memberMarcel Härry13:51 16 Nov '06  
GeneralRe: Nice but...memberweiqj13:55 16 Nov '06  
GeneralRe: Nice but...memberKenGuru21:41 16 Nov '06  
GeneralRe: Nice but...memberweiqj13:14 18 Nov '06  
QuestionRe: Nice but...memberstixoffire11:58 22 Mar '07  
AnswerRe: Nice but...memberweiqj6:55 23 Mar '07  
QuestionEventsmemberobeea10:45 9 Aug '06  
AnswerRe: Eventsmemberweiqj10:41 11 Aug '06  
Generalpublic repository?memberN e m a9:29 23 Jan '06  
QuestionNo images, no iconsmemberGord Murdoch19:28 15 Nov '05  
AnswerRe: No images, no iconsmemberweiqj14:49 16 Nov '05  
GeneralRe: No images, no iconsmemberGord Murdoch8:52 18 Nov '05  
GeneralGetRelativeDirectory() errormemberSmangood19:08 18 Oct '05  
GeneralRe: GetRelativeDirectory() errorsussAnonymous17:33 23 Oct '05  
GeneralAn error at runtimememberCong Dan23:39 28 Sep '05  
GeneralRe: An error at runtimememberweiqj4:04 1 Oct '05  
Generalwhere can i download the ThemeEditor?memberYour details have been updated21:20 11 Aug '05  
GeneralRe: where ican i download the ThemeEditor?memberweiqj5:02 14 Aug '05  
GeneralRe: where can i download the ThemeEditor?memberYour details have been updated17:53 14 Aug '05  
GeneralRe: where can i download the ThemeEditor?memberweiqj10:53 15 Aug '05  
GeneralRe: where can i download the ThemeEditor?memberYour details have been updated16:15 15 Aug '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 22 Oct 2004
Editor: Nishant Sivakumar
Copyright 2004 by weiqj
Everything else Copyright © CodeProject, 1999-2008
Web18 | Advertise on the Code Project