Theme library: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Theme library
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## What is a Theme manager? | |
| 2 | + | ||
| 3 | + | 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. | |
| 4 | + | ||
| 5 | + | ## Why do we need a Theme manager? | |
| 6 | + | ||
| 7 | + | It gives the ability to have ownerdraw controls with the same look and feel as native controls. | |
| 8 | + | ||
| 9 | + | ## What ownerdraw controls do we have? | |
| 10 | + | ||
| 11 | + | 1. TCustomSpeedButton descendants (TSpeedButton) | |
| 12 | + | 2. TCustomSplitter descendants (TSplitter) | |
| 13 | + | 3. TCustomGrid descendants (TStringGrid, TDBGrid) | |
| 14 | + | 4. TCustomUpDown descendants (TUpDown) | |
| 15 | + | 5. ... | |
| 16 | + | ||
| 17 | + | ## What is the current state of implementation? | |
| 18 | + | ||
| 19 | + | **Windows XP and Vista applications with manifest** - fully implemented since theme manager originally created for Windows XP. | |
| 20 | + | ||
| 21 | + | | Element | default | gtk | gtk2 | carbon | qt | Used in components | | |
| 22 | + | |----|----|----|----|----|----|----| | |
| 23 | + | | teButton | Partially Implemented | Partially Implemented | Partially Implemented | Partially Implemented | Partially Implemented | TSpeedButton | | |
| 24 | + | | teHeader | Partially Implemented | Partially Implemented | Partially Implemented | Not Implemented | Partially Implemented | TCustomGrid | | |
| 25 | + | | teRebar | Partially Implemented | Partially Implemented | Partially Implemented | Partially Implemented | Not Implemented | TSplitter | | |
| 26 | + | | teToolBar | Partially Implemented | Partially Implemented | Partially Implemented | Partially Implemented | Partially Implemented | TSpeedButton | | |
| 27 | + | ||
| 28 | + | ## How to use ThemeServices class for painting? | |
| 29 | + | ||
| 30 | + | Simply proceed as follows. Create an empty form and paint a push button on it with normal state. | |
| 31 | + | ||
| 32 | + | ``` pascal | |
| 33 | + | unit Unit1; | |
| 34 | + | {$mode objfpc}{$H+} | |
| 35 | + | ||
| 36 | + | interface | |
| 37 | + | uses | |
| 38 | + | Classes, SysUtils, LResources, Forms, Controls, Graphics; | |
| 39 | + | ||
| 40 | + | type | |
| 41 | + | TForm1 = class(TForm) | |
| 42 | + | private | |
| 43 | + | { private declarations } | |
| 44 | + | public | |
| 45 | + | procedure Paint; override; | |
| 46 | + | end; | |
| 47 | + | ||
| 48 | + | var | |
| 49 | + | Form1: TForm1; | |
| 50 | + | ||
| 51 | + | implementation | |
| 52 | + | {$R manifest.res} | |
| 53 | + | ||
| 54 | + | uses | |
| 55 | + | LCLType, Themes; | |
| 56 | + | ||
| 57 | + | procedure TForm1.Paint; | |
| 58 | + | var | |
| 59 | + | Details: TThemedElementDetails; | |
| 60 | + | PaintRect: TRect; | |
| 61 | + | begin | |
| 62 | + | inherited Paint; | |
| 63 | + | PaintRect := Rect(10, 10, 80, 50); | |
| 64 | + | Details := ThemeServices.GetElementDetails(tbPushButtonNormal); | |
| 65 | + | ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect, nil); | |
| 66 | + | PaintRect := ThemeServices.ContentRect(Canvas.Handle, Details, PaintRect); | |
| 67 | + | ThemeServices.DrawText(Canvas, Details, 'Test caption', PaintRect, | |
| 68 | + | DT_CENTER or DT_VCENTER or DT_SINGLELINE, 0); | |
| 69 | + | end; | |
| 70 | + | ||
| 71 | + | initialization | |
| 72 | + | {$I unit1.lrs} | |
| 73 | + | end. | |
| 74 | + | ``` | |
| 75 | + | ||
| 76 | + | And the result will look so: | |
| 77 | + | ||
| 78 | + |  | |
| 79 | + | ||
| 80 | + | --Paul Ishenin 20:31, 9 June 2007 (CEST) | |
| 81 | + | ||
| 82 | + | --- | |
| 83 | + | *From the Free Pascal wiki, page "Theme library", as it stood on 2020-01-29 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 84 | + | Category: Libraries |
