Difference between revisions of "Theme library"

From Lazarus wiki
Jump to navigationJump to search
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== What is Theme manager? ==
+
== What is a Theme manager? ==
  
Theme manager has been originally created by Mike Lischke (see http://www.soft-gems.net/) to enable Windows XP theme painting in Borland Delphi and Borland C++ Builder applications.  
+
The Theme manager was originally created by Mike Lischke (see http://www.soft-gems.net/) to enable Windows XP theme painting in Borland Delphi and Borland C++ Builder applications.  
  
== Why do we need Theme manager? ==
+
== Why do we need a Theme manager? ==
  
 
It gives the ability to have ownerdraw controls with the same look and feel as native controls.
 
It gives the ability to have ownerdraw controls with the same look and feel as native controls.
Line 12: Line 12:
 
# TCustomSplitter descendants (TSplitter)
 
# TCustomSplitter descendants (TSplitter)
 
# TCustomGrid descendants (TStringGrid, TDBGrid)
 
# TCustomGrid descendants (TStringGrid, TDBGrid)
 +
# TCustomUpDown descendants (TUpDown)
 
# ...
 
# ...
  
Line 18: Line 19:
 
'''Windows XP and Vista applications with manifest''' - fully implemented since theme manager originally created for Windows XP.
 
'''Windows XP and Vista applications with manifest''' - fully implemented since theme manager originally created for Windows XP.
  
{| BORDER="1" CELLSPACING="0"
+
{| class="wikitable"
!COLSPAN="1" STYLE="background:#ffdead;"|'''Element'''
+
! Element !! default !! gtk !! gtk2 !! carbon !! qt !! Used in components
!COLSPAN="1" STYLE="background:#ffdead;"|'''default'''
 
!COLSPAN="1" STYLE="background:#ffdead;"|'''gtk'''
 
!COLSPAN="1" STYLE="background:#ffdead;"|'''gtk2'''
 
!COLSPAN="1" STYLE="background:#ffdead;"|'''carbon'''
 
!COLSPAN="1" STYLE="background:#ffdead;"|'''qt'''
 
!COLSPAN="1" STYLE="background:#ffdead;"|'''Used in components'''
 
 
|----
 
|----
|teButton||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||TSpeedButton
+
|teButton||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||TSpeedButton
 
|----
 
|----
|teHeader||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||class="not"|Not Implemented||TCustomGrid
+
|teHeader||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||class="partial"|Partially Implemented||TCustomGrid
 
|----
 
|----
 
|teRebar||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||TSplitter
 
|teRebar||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||TSplitter
 
|----
 
|----
|teToolBar||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="not"|Not Implemented||TSpeedButton
+
|teToolBar||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||class="partial"|Partially Implemented||TSpeedButton
 
|}
 
|}
  
 
== How to use ThemeServices class for painting? ==
 
== How to use ThemeServices class for painting? ==
  
It is rather simple. Let's do an empty form and paint a push button on it with normal state.
+
Simply proceed as follows. Create an empty form and paint a push button on it with normal state.
  
 +
<syntaxhighlight lang=pascal>
 
  unit Unit1;  
 
  unit Unit1;  
 
  {$mode objfpc}{$H+}
 
  {$mode objfpc}{$H+}
Line 81: Line 77:
 
   {$I unit1.lrs}
 
   {$I unit1.lrs}
 
  end.
 
  end.
 +
</syntaxhighlight>
  
 
And the result will look so:
 
And the result will look so:
Line 86: Line 83:
 
[[Image:theme_painting.png]]
 
[[Image:theme_painting.png]]
  
--[[User:Paul Ishenin|Paul Ishenin]] 08:11, 23 May 2007 (CEST)
+
--[[User:Paul Ishenin|Paul Ishenin]] 20:31, 9 June 2007 (CEST)
 +
 
 +
[[Category:Libraries]]

Latest revision as of 17:11, 29 January 2020

What is a Theme manager?

The Theme manager was originally created by Mike Lischke (see http://www.soft-gems.net/) to enable Windows XP theme painting in Borland Delphi and Borland C++ Builder applications.

Why do we need a Theme manager?

It gives the ability to have ownerdraw controls with the same look and feel as native controls.

What ownerdraw controls do we have?

  1. TCustomSpeedButton descendants (TSpeedButton)
  2. TCustomSplitter descendants (TSplitter)
  3. TCustomGrid descendants (TStringGrid, TDBGrid)
  4. TCustomUpDown descendants (TUpDown)
  5. ...

What is the current state of implementation?

Windows XP and Vista applications with manifest - fully implemented since theme manager originally created for Windows XP.

Element default gtk gtk2 carbon qt Used in components
teButton Partially Implemented Partially Implemented Partially Implemented Partially Implemented Partially Implemented TSpeedButton
teHeader Partially Implemented Partially Implemented Partially Implemented Not Implemented Partially Implemented TCustomGrid
teRebar Partially Implemented Partially Implemented Partially Implemented Partially Implemented Not Implemented TSplitter
teToolBar Partially Implemented Partially Implemented Partially Implemented Partially Implemented Partially Implemented TSpeedButton

How to use ThemeServices class for painting?

Simply proceed as follows. Create an empty form and paint a push button on it with normal state.

 unit Unit1; 
 {$mode objfpc}{$H+}
 
 interface
 uses
   Classes, SysUtils, LResources, Forms, Controls, Graphics;
 
 type
   TForm1 = class(TForm)
   private
     { private declarations }
   public
     procedure Paint; override;
   end;
 
 var
   Form1: TForm1; 
 
 implementation
 {$R manifest.res}
 
 uses
   LCLType, Themes;
   
 procedure TForm1.Paint;
 var
   Details: TThemedElementDetails;
   PaintRect: TRect;
 begin
   inherited Paint;
   PaintRect := Rect(10, 10, 80, 50);
   Details := ThemeServices.GetElementDetails(tbPushButtonNormal);
   ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect, nil);
   PaintRect := ThemeServices.ContentRect(Canvas.Handle, Details, PaintRect);
   ThemeServices.DrawText(Canvas, Details, 'Test caption', PaintRect,
     DT_CENTER or DT_VCENTER or DT_SINGLELINE, 0);
 end;
 
 initialization
   {$I unit1.lrs}
 end.

And the result will look so:

theme painting.png

--Paul Ishenin 20:31, 9 June 2007 (CEST)