TSkinButton
Fonte: source/classes/tskinbtn.prg
Standalone class (not a visual control, not from TControl)
TSkinButton is a color-skin definition class for skinned buttons. It is a non-visual data class that stores gradient arrays and border color pairs for four button states: focused, pressed, normal, and disabled. The default constructor values produce an Office 2007-inspired blue theme. Apply a TSkinButton instance to any compatible button control via oBtn:SetSkin( oSkin ).
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aClrFocused | Array | Gradient array for the focused/hover state |
aClrPressed | Array | Gradient array for the pressed state |
aClrNormal | Array | Gradient array for the default/normal state |
aClrDisabled | Array | Gradient array for the disabled state |
nClrBorder0_F | Numeric | Border color 1, focused state |
nClrBorder1_F | Numeric | Border color 2, focused state |
nClrBorder0_P | Numeric | Border color 1, pressed state |
nClrBorder1_P | Numeric | Border color 2, pressed state |
nClrBorder0_N | Numeric | Border color 1, normal state |
nClrBorder1_N | Numeric | Border color 2, normal state |
nClrTextDisable_0 | Numeric | Text color for disabled state |
nClrTextDisable_1 | Numeric | 3D highlight text color for disabled state |
Methods
| Method | Description |
|---|---|
New( aClrFocused, aClrPressed, aClrNormal, aClrDisabled, nClrBdr0_F, nClrBdr1_F, nClrBdr0_P, nClrBdr1_P, nClrBdr0_N, nClrBdr1_N, nClrTxtDis0, nClrTxtDis1 ) | Create a TSkinButton skin definition with custom colors |
Example: Custom Skin and Apply
#include "FiveWin.ch"
function Main()
local oWnd, oBtn, oSkin
DEFINE WINDOW oWnd TITLE "SkinButton Demo" SIZE 300, 200
// Create a custom skin (Office 2007 blue defaults)
oSkin := TSkinButton():New()
// Apply to a button
@ 20, 20 BTNBMP oBtn ;
SIZE 100, 30 PIXEL OF oWnd ;
PROMPT "Skinned"
oBtn:SetSkin( oSkin )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- TSkinButton is a pure data class with no visual window handle. It only stores gradient and color definitions for consumption by skinned button controls.
- Each gradient array is structured as a list of segments:
{ { nFraction, nColorTop, nColorBottom }, ... }. The fraction indicates the vertical position of the segment boundary (0.0 to 1.0). - Apply a skin to any compatible TBtnBmp button using the
SetSkin()method. The button reads the gradient and border values during its paint cycle. - The default theme mimics Office 2007's blue command button appearance. Pass custom values to
New()to create any color scheme.