Difference between revisions of "Colors/fi"

From Free Pascal wiki
Jump to navigationJump to search
m (syntaxfix)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{Colors}}
 
{{Colors}}
  
==Overview==
+
== Värit ==
  
In the [[LCL]] TColor is the standard color type. It is compatible with [[Delphi]]'s TColor. TColor can represent ''either'' an RGB (3x8bit) value, ''or'' a '''system''' color like '''clDefault'''. The LCL can also work with the fpImage system which uses the TFPColor type (which is RGBA (4x16bit), not RGB (3x8bit) like TColor).
 
  
===Conversions between TColor and RGB values===
 
  
The '''Graphics''' [[Unit|unit]] provides the following [[Function|functions]]:
+
[[LCL/fi|LCL]]:ssä TColor on vakiovärityyppi. Se on yhteensopiva [[Delphi/fi|Delphin]] TColorin kanssa. TColor voi edustaa joko RGB (3x8bit) arvoa tai järjestelmän väriä kuten clDefault. LCL voi toimia myös fpImage-järjestelmän kanssa, joka käyttää TFPColor-tyyppiä (joka on RGBA (4x16bit), ei RGB (3x8bit) kuten TColor).
 +
 
 +
=== Muunnokset TColor- ja RGB-arvojen välillä ===
 +
 
 +
[[Unit/fi|käännösyksikkö (eli unit)]]'''Graphics'''  tarjoaa seuraavat toiminnot:
  
 
<syntaxhighlight lang="pascal">function Blue(rgb: TColor): BYTE; // does not work on system color
 
<syntaxhighlight lang="pascal">function Blue(rgb: TColor): BYTE; // does not work on system color
Line 18: Line 20:
 
function IsSysColor(AColor: TColorRef): Boolean;</syntaxhighlight>
 
function IsSysColor(AColor: TColorRef): Boolean;</syntaxhighlight>
  
===Convert TColor to/from string===
+
 
Functions to convert strings like "25500" or "[[Dollar_sign|$]]AA0088" or "clNavy" to TColor:
+
=== TColor:n muunto merkkijonoksi ja päinvastoin ===
 +
 
 +
Seuraavat [[Function/fi|funktiot]] muuntaa merkkijonot kuten "25500", "[[Dollar_sign/fi|$]]AA0088" tai "clNavy" TColoriksi:
  
 
* StringToColor
 
* StringToColor
 
* StringToColorDef
 
* StringToColorDef
  
To convert TColor to a nice string like "clNavy" or "$AA0002":
+
Voit muuntaa TColorin arvon merkkijonoksi kuten "clNavy" tai "$AA0002":
  
* ColorToString
+
* ColorToString  
  
===Convert TColor to/from HTML string #rrggbb===
+
=== Muunna TColor HTML-merkkijonoksi #rrggbb ===
  
See code in [[Convert color to/from HTML]].
+
Katso koodi kohdasta [[Convert color to/from HTML]].
  
==Table of standard colors==
+
=== Taulukko vakioväreistä ===
  
About 20 predefined color [[Constant|constants]] are provided, which are Delphi-compatible:
+
Tarjotaan noin 20 ennalta määritettyä värivakiota, jotka ovat [[Delphi]]-yhteensopivia:
<!--<syntaxhighlight lang="pascal">  // standard colors
 
  clBlack  = TColor($000000);
 
  clMaroon  = TColor($000080);
 
  clGreen  = TColor($008000);
 
  clOlive  = TColor($008080);
 
  clNavy    = TColor($800000);
 
  clPurple  = TColor($800080);
 
  clTeal    = TColor($808000);
 
  clGray    = TColor($808080);
 
  clSilver  = TColor($C0C0C0);
 
  clRed    = TColor($0000FF);
 
  clLime    = TColor($00FF00);
 
  clYellow  = TColor($00FFFF);
 
  clBlue    = TColor($FF0000);
 
  clFuchsia = TColor($FF00FF);
 
  clAqua    = TColor($FFFF00);
 
  clLtGray  = TColor($C0C0C0); // clSilver alias
 
  clDkGray  = TColor($808080); // clGray alias
 
  clWhite  = TColor($FFFFFF);</syntaxhighlight>-->
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Colour constant
+
! Värivakio
! Meaning
+
! Merkitys
! [[Hexadecimal]] value for use with TColor
+
! [[Hexadecimal/fi|Heksadesimaalinen]] arvo käytettäväksi TColor:n kanssa
! Example
+
! Esimerkki
 
|-
 
|-
 
| clBlack
 
| clBlack
Line 155: Line 140:
 
| Cream
 
| Cream
 
| TColor($F0FBFF);
 
| TColor($F0FBFF);
| style="background: #FFFBF0;" | Lazarus 1.2 and newer
+
| style="background: #FFFBF0;" | Lazarus 1.2 ja uudemmat
 
|-
 
|-
 
| clMedGray   
 
| clMedGray   
 
| Medium Grey
 
| Medium Grey
 
| TColor($A4A0A0);
 
| TColor($A4A0A0);
| style="background: #A0A0A4;" | Lazarus 1.2 and newer
+
| style="background: #A0A0A4;" | Lazarus 1.2 ja uudemmat
 
|-
 
|-
 
| clMoneyGreen   
 
| clMoneyGreen   
 
| Mint Green
 
| Mint Green
 
| TColor($C0DCC0);
 
| TColor($C0DCC0);
| style="background: #C0DCC0;" | Lazarus 1.2 and newer
+
| style="background: #C0DCC0;" | Lazarus 1.2 ja uudemmat
 
|-
 
|-
 
| clSkyBlue   
 
| clSkyBlue   
 
| Sky Blue
 
| Sky Blue
 
| TColor($F0CAA6);
 
| TColor($F0CAA6);
| style="background: #A6CAF0;" | Lazarus 1.2 and newer
+
| style="background: #A6CAF0;" | Lazarus 1.2 ja uudemmat
 
|}
 
|}
  
==System colors==
+
=== Järjestelmän värit ===
 +
==== Esimerkki: clInfoBk, clInfoText ====
  
===Example: clInfoBk, clInfoText===
+
Järjestelmävärit ovat värivakioita, joilla on erityinen merkitys. Niiden todellinen arvo riippuu kontekstista ja teemasta. Ne eivät ole yksinkertaisia ​​värejä. Esimerkiksi '''clInfoBk''':
  
System colors are color constants with a special meaning. Their real value depends on the context and theme. They are not simple colors.
+
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk;  // // käytä vihje-ikkunan oletustaustaväriä
For example '''clInfoBk''':
+
Form1.Canvas.FillRect(10,10,50,50);</syntaxhighlight>
  
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk;  // use the default background brush of a hint window
 
Form1.Canvas.FillRect(10,10,50,50);</syntaxhighlight>
 
  
A hint window on MS Windows might have a white background so the above will draw white. On Linux/gtk2 it might be a metallic texture, so the above will draw the texture. If you want to put some text onto this you need a corresponding color like '''clInfoText''', otherwise your text might be unreadable for the user. For example:
+
Vihje-ikkunassa MS Windowsissa voi olla valkoinen tausta, joten yllä oleva piirtää valkoisella. Linuxissa / gtk2: ssa se voi olla metallinen tekstuuri, joten yllä oleva kuvioi kyseisellä tekstuurilla. Jos haluat laittaa tekstiä tähän, tarvitset vastaavan värin kuin '''clInfoText''', muuten teksti voi olla käyttäjän kannalta lukukelvoton. Esimerkiksi:
  
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk;  // use the default background brush of a hint window
+
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk;  // käytä vihje-ikkunan oletustaustaväriä
 
Form1.Canvas.FillRect(10,10,50,50);
 
Form1.Canvas.FillRect(10,10,50,50);
Form1.Canvas.Font.Color:=clInfoText;  // use the default text color of a hint window
+
Form1.Canvas.Font.Color:=clInfoText;  // käytä vihjeikkunan oletustekstiväriä
 
Form1.Canvas.TextOut(10,10,'Hint');</syntaxhighlight>
 
Form1.Canvas.TextOut(10,10,'Hint');</syntaxhighlight>
  
The system color '''clInfoBk''' can not be used for Pen.Color and not for Font.Color. If you do so the result is undefined and depends on the widgetset and user theme.
 
The same for '''clInfoText''': It can only be used as a Font.Color. Using it as Brush.Color may not work. At the moment all widgetsets allow to use it as Pen.Color too.
 
  
===Theme changes===
+
Järjestelmän väriä '''clInfoBk''' ei voi käyttää Pen.Color:lla eikä Font.Color:lla. Jos näin tehdään, tulos on määrittelemätön ja riippuu widgetet- ja käyttäjäteemasta.
 +
Sama koskee myös väriä '''clInfoText''': Sitä voidaan käyttää vain Font.Color:na. Sen käyttö Brush.Color:na ei ehkä toimi. Tällä hetkellä kaikki widgetit sallivat sen käytön myös Pen.Color:na.
 +
 
 +
==== Teeman muutokset ====
  
When the user switches the theme the system colors changes. A '''clInfoBk''' might change from white to blue or from a color to a texture. This change will happen when you allocate a new Brush handle. Keep in mind that a simple assignment Brush.Color:=clInfoBk does not allocate a Brush Handle. The Brush Handle is allocated on use. For example:
+
Kun käyttäjä vaihtaa teeman, järjestelmän värit muuttuvat. Väri '''clInfoBk''' saattaa muuttua valkoisesta siniseksi tai yhtenäisestä väristä tekstuuriksi. Tämä muutos tapahtuu, kun jaat uuden Brush Handle. Muista, että yksinkertainen tehtävä Brush.Color:=clInfoBk ei jaa Brush Handle. Brush Handle on jaettu käyttöön. Esimerkiksi:
  
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk; // this will not create a new brush handle
+
<syntaxhighlight lang="pascal">Form1.Canvas.Brush.Color:=clInfoBk; // tämä ei luo uutta brush handle:a
Form1.Canvas.FillRect(10,10,50,50); // this will create the brush handle with the currently active theme brush for hint windows
+
Form1.Canvas.FillRect(10,10,50,50); // tämä luo brush handletällä hetkellä aktiivisen teeman brush vihjeikkunoita varten
 +
...
 
...
 
...
// if the theme changes in this moment the Brush.Handle is still allocated with the old values
+
// jos teema muuttuu niin tällä hetkellä Brush.Handle on edelleen varattu vanhojen arvojen kanssa
 
...
 
...
Form1.Canvas.FillRect(10,10,50,50); // this will paint with the old theme brush
+
Form1.Canvas.FillRect(10,10,50,50); // tämä maalaa vanhan teeman brush:lla
Form1.Canvas.Brush.Color:=clInfoBk; // assigning the old value will not create a new brush handle
+
Form1.Canvas.Brush.Color:=clInfoBk; // vanhan arvon liittäminen ei luo uutta brush handle:a
Form1.Canvas.FillRect(10,10,50,50); // this will paint with the old theme brush
+
Form1.Canvas.FillRect(10,10,50,50); // tämä maalaa vanhan teeman brush:lla
Form1.Canvas.Brush.Color:=clRed;    // assigning a new color, old Handle invalid
+
Form1.Canvas.Brush.Color:=clRed;    // uuden värin määrittäminen, vanha Handle ei kelpaa
Form1.Canvas.Brush.Color:=clInfoBk; // assigning a new color, old Handle invalid
+
Form1.Canvas.Brush.Color:=clInfoBk; // uuden värin määrittäminen, vanha Handle ei kelpaa
Form1.Canvas.FillRect(10,10,50,50); // this will create a new handle and paint with the new theme</syntaxhighlight>
+
Form1.Canvas.FillRect(10,10,50,50); // tämä luo uuden handlen ja maalaa uuden teeman avulla
 +
</syntaxhighlight>
 +
 
  
===Table of system colors===
+
=== Taulukko järjestelmän väreistä ===
  
The following table lists the system colors and their meaning. Using them outside the scope of the definition is undefined and the result depends on the widgetset and theme. For example '''clDefault''' is the normal background brush of the used device context. If you want to paint button elements on your own custom controls use the drawing functions of the unit '''Themes'''.
+
Seuraavassa taulukossa luetellaan järjestelmän värit ja niiden merkitys. Niiden käyttäminen määritelmän soveltamisalan ulkopuolella on määrittelemätön ja tulos riippuu widgetetistä ja teemasta.  
 +
Esimerkiksi '''clDefault''' on normaali taustaväri on käytetyn laitteen taustakuvio. Jos halutaan maalata painikkeita omilla mukautetuilla ohjaimilla, käytä yksikön '''Themes''' piirustusfunktioita.
  
 
{| class="wikitable"
 
{| class="wikitable"
! Constant !! LCL definition !! Delphi notes !! Supported Widgetsets
+
! Vakio !! LCL määrittely !! Delphi huomiot !! Tuetut Widgetsets
 
|----
 
|----
|clNone||Indicates "do not paint". Using it as Control's color is undefined. The control will not get transparent.|| - || all
+
|clNone||Ilmaisee "ei piirretä". Sen käyttäminen kontrollin värinä on määrittelemätön. kontrolli ei tule läpinäkyväksi.|| - || kaikki
 
|----
 
|----
|clDefault||Using it for Brush will use the normal background brush of the target DC (device context).
+
|clDefault|| Käyttämällä sitä Brush-värinä niin käytetään tavallisen device context (DC, laitteen konteksti) normaalia taustaväriä
* On a Form's canvas a ''FillRect'' will paint a rectangular area filled with the normal background of a standard window. This is whatever the widgetset and theme defines. This might be the color gray or a gradient or a picture.  
+
* Lomakkeen canvas:ssa ''FillRect'' maalaa suorakulmaisen alueen, joka on täynnä normaalin ikkunan normaalia taustaa. Tämä on mitä widgetset ja teema määrittelevät. Tämä voi olla harmaa, liukuväri tai kuva.
* Using clDefault on the Canvas of a TListBox will paint with the normal background, which is normally white on Windows. So in a TListBox clDefault is the same as clWindow.  
+
* Käyttämällä clDefault TListBoxin canvasiin niin maalataan se normaalilla taustalla, joka on yleensä valkoinen Windowsissa. Joten TListBox clDefault on sama kuin clWindow.
* Using it as Pen color will use the default line color for the device context.  
+
* Käyttämällä sitä Pen color:na niin se on laitteeen oletusarvoinen viivan väri.  
* Using it as Font color will use the normal text color of the device context.  
+
* Käyttämällä sitä Font color:na niin se on laitteeen oletusarvoinen tekstin väri.  
|| - || all
+
|| - || kaikki
 
|----
 
|----
|clScrollBar|| Scrollbar body || - || all
+
|clScrollBar|| Vierityspalkin (Scrollbar) runko || - || kaikki
 
|----
 
|----
|clBackground|| Desktop background color || - || all
+
|clBackground|| Työpöydän taustaväri || - || kaikki
 
|----
 
|----
|clActiveCaption|| Active window titlebar || - || none
+
|clActiveCaption|| Aktiivinen ikkunan otsikkorivi || - || ei mikään
 
|----
 
|----
|clInactiveCaption|| Inactive window titlebar || - || none
+
|clInactiveCaption|| Ei-aktiivinen ikkunan otsikkorivi || - || ei mikään
 
|----
 
|----
|clMenu|| Regular menu item background color || - || none
+
|clMenu|| vakio valikkokohdan taustaväri || - || ei mikään
 
|----
 
|----
|clWindow|| The normal background brush of unselected text. Defined for controls like TEdit, TComboBox, TMemo, TListBox, TTreeView.|| - || none
+
|clWindow|| Valitsemattoman tekstin normaali taustaväri. Määritetty kontrolleille, kuten TEdit, TComboBox, TMemo, TListBox, TTreeView.|| - || ei mikään
 
|----
 
|----
|clWindowFrame|| Color of frame around the window || - || none
+
|clWindowFrame|| Kehyksen väri ikkunan ympärillä || - || ei mikään
 
|----
 
|----
|clMenuText|| The font color to use together with clMenu || - || none
+
|clMenuText|| Fontin väri, jota käytetään yhdessä clMenu:n kanssa || - || ei mikään
 
|----
 
|----
|clWindowText|| Font color to use together with clWindow || - || none
+
|clWindowText|| Fontin väri, jota käytetään yhdessä clWindow:n kanssa || - || ei mikään
 
|----
 
|----
|clCaptionText|| Active window titlebar text color || - || none
+
|clCaptionText|| Aktiivisen ikkunan otsikkorivin tekstin väri || - || ei mikään
 
|----
 
|----
|clActiveBorder||?|| - || none
+
|clActiveBorder||?|| - || ei mikään
 
|----
 
|----
|clInactiveBorder||?|| - || none
+
|clInactiveBorder||?|| - || ei mikään
 
|----
 
|----
|clAppWorkspace|| MDIMain form background || - || none
+
|clAppWorkspace|| MDIMain lomakkeen taustaväri || - || ei mikään
 
|----
 
|----
|clHighlight|| The brush color of selected element || - || none
+
|clHighlight|| brush color kun elementti on valittu || - || ei mikään
 
|----
 
|----
|clHighlightText|| Font color of selected text (to use together with clHighligh). || - || none
+
|clHighlightText|| Font color kun teksti on valittu (käytetään clHighligh kanssa). || - || ei mikään
 
|----
 
|----
|clBtnFace|| Button background || - || none
+
|clBtnFace|| Painikkeen taustaväri || - || ei mikään
 
|----
 
|----
|clBtnShadow|| Button shadow color (bottom right) used to achieve 3D effect || - || none
+
|clBtnShadow|| Painikkeen varjostusväri (Bottom Right) käytetään 3D-efektin saavuttamiseen || - || ei mikään
 
|----
 
|----
|clGrayText|| The font color of disabled element || - || none
+
|clGrayText|| font color kielletyillä elementeillä || - || ei mikään
 
|----
 
|----
|clBtnText|| Button font color to use together with clBtnFace || - || none
+
|clBtnText|| Painikkeen font color käytetään clBtnFace:n kanssa || - || ei mikään
 
|----
 
|----
|clInactiveCaptionText|| Inactive window titlebar text color || - || none
+
|clInactiveCaptionText|| Ei-aktiivinen ikkunan otsikkorivin tekstin väri || - || ei mikään
 
|----
 
|----
|clBtnHighlight|| Button highlight color (top left) used to achieve 3D effect || - || none
+
|clBtnHighlight|| BPainikkeen korostusväri (Top Left) käytetään 3D-efektin saavuttamiseen || - || ei mikään
 
|----
 
|----
|cl3DDkShadow||?|| - || none
+
|cl3DDkShadow||?|| - || ei mikään
 
|----
 
|----
|cl3DLight||?|| - || none
+
|cl3DLight||?|| - || ei mikään
 
|----
 
|----
|clInfoText|| Font color for hints. Use together with clInfoBk || - || all
+
|clInfoText|| Vihjeiden fontin väri. Käytä yhdessä clInfoBk:n kanssa  || - || kaikki
 
|----
 
|----
|clInfoBk|| Brush color for hints. Use together with clInfoText || - || all
+
|clInfoBk|| Brush väri vihjeitä varten. Käytä yhdessä clInfoText:n kanssa || - || kaikki
 
|----
 
|----
|clHotLight||?|| - || none
+
|clHotLight||?|| - || ei mikään
 
|----
 
|----
|clGradientActiveCaption|| The second color used to make gradient of active window titlebar || - || none
+
|clGradientActiveCaption|| Toinen väri, jota käytetään aktiivisen ikkunan otsikkorivin gradientin tekemiseen || - || ei mikään
 
|----
 
|----
|clGradientInactiveCaption|| The second color used to make gradient for inactive window titlebar || - || none
+
|clGradientInactiveCaption|| Toinen väri, jota käytetään ei-aktiivisen ikkunan otsikkorivin gradientin tekemiseen || - || ei mikään
 
|----
 
|----
|clMenuHighlight|| The background color of selected menu item || - || none
+
|clMenuHighlight|| Valitun valikkokohdan taustaväri || - || ei mikään
 
|----
 
|----
|clMenuBar|| The Backround color of menu bar || - || none
+
|clMenuBar|| Valikkokohdan taustaväri || - || ei mikään
 
|----
 
|----
|clForm||?|| - || none
+
|clForm||?|| - || ei mikään
 
|----
 
|----
|clColorDesktop||?|| - || none
+
|clColorDesktop||?|| - || ei mikään
 
|----
 
|----
|cl3DFace||?|| - || none
+
|cl3DFace||?|| - || ei mikään
 
|----
 
|----
|cl3DShadow||?|| - || none
+
|cl3DShadow||?|| - || ei mikään
 
|----
 
|----
|cl3DHiLight||?|| - || none
+
|cl3DHiLight||?|| - || ei mikään
 
|----
 
|----
|clBtnHiLight|| Same as clBtnHighlight || - || none
+
|clBtnHiLight|| Sama kuin clBtnHighlight || - || ei mikään
 
|}
 
|}
  
=== Finding the rgb values of a system color ===
+
=== Järjestelmävärin rgb-arvojen löytäminen ===
Use the function <tt>ColorToRGB</tt> (in unit <tt>Graphics</tt> to determine the rgb components of a system color. This functions detects whether a color is a system color and, if this is true, looks up the system color in the themes color. The returned [[Longint]] can be understood as a normal color:
+
Käytä funktiota <tt>ColorToRGB</tt> (in unit <tt>Graphics</tt> ) järjestelmän värin rgb-komponenttien määrittämiseksi.  
<syntaxhighlight lang="pascal">// This example has a TColorBox on a form and uses this OnChange handler for the TColorbox:
+
Tämä funktio havaitsee, onko väri värijärjestelmä, ja jos tämän arvo on true, näyttää palauttaa järjestelmän värin teeman värissä.
 +
Palautettu [[Longint]] voidaan ymmärtää tavalliseksi väriksi:
 +
<syntaxhighlight lang="pascal">// Tässä esimerkissä on TColorBox lomakkeellaa ja käyttää tämän OnChange-käsittelijää
 
procedure TForm1.ColorBox1Change(Sender: TObject);
 
procedure TForm1.ColorBox1Change(Sender: TObject);
 
var
 
var
Line 309: Line 300:
 
end; </syntaxhighlight>
 
end; </syntaxhighlight>
  
==Drawing theme elements on your custom controls==
+
===Piirrä teeman elementtejä mukautetuissa ohjauksissa (custom controls)===
  
The unit '''Themes''' provides functions to draw single elements of standard controls. For example to draw an expand sign like a [[TTreeView]] use the following code:
+
Käännösyksikkö (unit) '''Themes''' tarjoaa funktioita, joilla piirretään standardinhallinnan yksittäisiä elementtejä. Esimerkiksi piirtomerkin piirtäminen kuten [[TTreeView]] käyttää seuraavaa koodia:
  
 
<syntaxhighlight lang="pascal">uses Themes;
 
<syntaxhighlight lang="pascal">uses Themes;

Latest revision as of 20:16, 24 July 2020

Deutsch (de) English (en) español (es) suomi (fi) français (fr) 日本語 (ja) русский (ru) 中文(中国大陆)‎ (zh_CN)

Värit

LCL:ssä TColor on vakiovärityyppi. Se on yhteensopiva Delphin TColorin kanssa. TColor voi edustaa joko RGB (3x8bit) arvoa tai järjestelmän väriä kuten clDefault. LCL voi toimia myös fpImage-järjestelmän kanssa, joka käyttää TFPColor-tyyppiä (joka on RGBA (4x16bit), ei RGB (3x8bit) kuten TColor).

Muunnokset TColor- ja RGB-arvojen välillä

käännösyksikkö (eli unit)Graphics tarjoaa seuraavat toiminnot:

function Blue(rgb: TColor): BYTE; // does not work on system color
function Green(rgb: TColor): BYTE; // does not work on system color
function Red(rgb: TColor): BYTE; // does not work on system color
function RGBToColor(R, G, B: Byte): TColor;
procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte); // does not work on system color
function FPColorToTColor(const FPColor: TFPColor): TColor;
function TColorToFPColor(const c: TColor): TFPColor; // does not work on system color
function IsSysColor(AColor: TColorRef): Boolean;


TColor:n muunto merkkijonoksi ja päinvastoin

Seuraavat funktiot muuntaa merkkijonot kuten "25500", "$AA0088" tai "clNavy" TColoriksi:

  • StringToColor
  • StringToColorDef

Voit muuntaa TColorin arvon merkkijonoksi kuten "clNavy" tai "$AA0002":

  • ColorToString

Muunna TColor HTML-merkkijonoksi #rrggbb

Katso koodi kohdasta Convert color to/from HTML.

Taulukko vakioväreistä

Tarjotaan noin 20 ennalta määritettyä värivakiota, jotka ovat Delphi-yhteensopivia:

Värivakio Merkitys Heksadesimaalinen arvo käytettäväksi TColor:n kanssa Esimerkki
clBlack Black TColor($000000);
clMaroon Maroon TColor($000080);
clGreen Green TColor($008000);
clOlive Olive Green TColor($008080);
clNavy Navy Blue TColor($800000);
clPurple Purple TColor($800080);
clTeal Teal TColor($808000);
clGray Grey TColor($808080);
clSilver Silver TColor($C0C0C0);
clRed Red TColor($0000FF);
clLime Lime Green TColor($00FF00);
clYellow Yellow TColor($00FFFF);
clBlue Blue TColor($FF0000);
clFuchsia Fuchsia TColor($FF00FF);
clAqua Aqua TColor($FFFF00);
clLtGray Light Grey TColor($C0C0C0); clSilver alias
clDkGray Dark Grey TColor($808080); clGray alias
clWhite White TColor($FFFFFF);
clCream Cream TColor($F0FBFF); Lazarus 1.2 ja uudemmat
clMedGray Medium Grey TColor($A4A0A0); Lazarus 1.2 ja uudemmat
clMoneyGreen Mint Green TColor($C0DCC0); Lazarus 1.2 ja uudemmat
clSkyBlue Sky Blue TColor($F0CAA6); Lazarus 1.2 ja uudemmat

Järjestelmän värit

Esimerkki: clInfoBk, clInfoText

Järjestelmävärit ovat värivakioita, joilla on erityinen merkitys. Niiden todellinen arvo riippuu kontekstista ja teemasta. Ne eivät ole yksinkertaisia ​​värejä. Esimerkiksi clInfoBk:

Form1.Canvas.Brush.Color:=clInfoBk;  // // käytä vihje-ikkunan oletustaustaväriä
Form1.Canvas.FillRect(10,10,50,50);


Vihje-ikkunassa MS Windowsissa voi olla valkoinen tausta, joten yllä oleva piirtää valkoisella. Linuxissa / gtk2: ssa se voi olla metallinen tekstuuri, joten yllä oleva kuvioi kyseisellä tekstuurilla. Jos haluat laittaa tekstiä tähän, tarvitset vastaavan värin kuin clInfoText, muuten teksti voi olla käyttäjän kannalta lukukelvoton. Esimerkiksi:

Form1.Canvas.Brush.Color:=clInfoBk;  // käytä vihje-ikkunan oletustaustaväriä
Form1.Canvas.FillRect(10,10,50,50);
Form1.Canvas.Font.Color:=clInfoText;  // käytä vihjeikkunan oletustekstiväriä
Form1.Canvas.TextOut(10,10,'Hint');


Järjestelmän väriä clInfoBk ei voi käyttää Pen.Color:lla eikä Font.Color:lla. Jos näin tehdään, tulos on määrittelemätön ja riippuu widgetet- ja käyttäjäteemasta. Sama koskee myös väriä clInfoText: Sitä voidaan käyttää vain Font.Color:na. Sen käyttö Brush.Color:na ei ehkä toimi. Tällä hetkellä kaikki widgetit sallivat sen käytön myös Pen.Color:na.

Teeman muutokset

Kun käyttäjä vaihtaa teeman, järjestelmän värit muuttuvat. Väri clInfoBk saattaa muuttua valkoisesta siniseksi tai yhtenäisestä väristä tekstuuriksi. Tämä muutos tapahtuu, kun jaat uuden Brush Handle. Muista, että yksinkertainen tehtävä Brush.Color:=clInfoBk ei jaa Brush Handle. Brush Handle on jaettu käyttöön. Esimerkiksi:

Form1.Canvas.Brush.Color:=clInfoBk; // tämä ei luo uutta brush handle:a
Form1.Canvas.FillRect(10,10,50,50); // tämä luo brush handletällä hetkellä aktiivisen teeman brush vihjeikkunoita varten
...
...
// jos teema muuttuu niin tällä hetkellä Brush.Handle on edelleen varattu vanhojen arvojen kanssa
...
Form1.Canvas.FillRect(10,10,50,50); // tämä maalaa vanhan teeman brush:lla
Form1.Canvas.Brush.Color:=clInfoBk; // vanhan arvon liittäminen ei luo uutta brush handle:a
Form1.Canvas.FillRect(10,10,50,50); // tämä maalaa vanhan teeman brush:lla
Form1.Canvas.Brush.Color:=clRed;    // uuden värin määrittäminen, vanha Handle ei kelpaa
Form1.Canvas.Brush.Color:=clInfoBk; // uuden värin määrittäminen, vanha Handle ei kelpaa
Form1.Canvas.FillRect(10,10,50,50); // tämä luo uuden handlen ja maalaa uuden teeman avulla


Taulukko järjestelmän väreistä

Seuraavassa taulukossa luetellaan järjestelmän värit ja niiden merkitys. Niiden käyttäminen määritelmän soveltamisalan ulkopuolella on määrittelemätön ja tulos riippuu widgetetistä ja teemasta. Esimerkiksi clDefault on normaali taustaväri on käytetyn laitteen taustakuvio. Jos halutaan maalata painikkeita omilla mukautetuilla ohjaimilla, käytä yksikön Themes piirustusfunktioita.

Vakio LCL määrittely Delphi huomiot Tuetut Widgetsets
clNone Ilmaisee "ei piirretä". Sen käyttäminen kontrollin värinä on määrittelemätön. kontrolli ei tule läpinäkyväksi. - kaikki
clDefault Käyttämällä sitä Brush-värinä niin käytetään tavallisen device context (DC, laitteen konteksti) normaalia taustaväriä
  • Lomakkeen canvas:ssa FillRect maalaa suorakulmaisen alueen, joka on täynnä normaalin ikkunan normaalia taustaa. Tämä on mitä widgetset ja teema määrittelevät. Tämä voi olla harmaa, liukuväri tai kuva.
  • Käyttämällä clDefault TListBoxin canvasiin niin maalataan se normaalilla taustalla, joka on yleensä valkoinen Windowsissa. Joten TListBox clDefault on sama kuin clWindow.
  • Käyttämällä sitä Pen color:na niin se on laitteeen oletusarvoinen viivan väri.
  • Käyttämällä sitä Font color:na niin se on laitteeen oletusarvoinen tekstin väri.
- kaikki
clScrollBar Vierityspalkin (Scrollbar) runko - kaikki
clBackground Työpöydän taustaväri - kaikki
clActiveCaption Aktiivinen ikkunan otsikkorivi - ei mikään
clInactiveCaption Ei-aktiivinen ikkunan otsikkorivi - ei mikään
clMenu vakio valikkokohdan taustaväri - ei mikään
clWindow Valitsemattoman tekstin normaali taustaväri. Määritetty kontrolleille, kuten TEdit, TComboBox, TMemo, TListBox, TTreeView. - ei mikään
clWindowFrame Kehyksen väri ikkunan ympärillä - ei mikään
clMenuText Fontin väri, jota käytetään yhdessä clMenu:n kanssa - ei mikään
clWindowText Fontin väri, jota käytetään yhdessä clWindow:n kanssa - ei mikään
clCaptionText Aktiivisen ikkunan otsikkorivin tekstin väri - ei mikään
clActiveBorder ? - ei mikään
clInactiveBorder ? - ei mikään
clAppWorkspace MDIMain lomakkeen taustaväri - ei mikään
clHighlight brush color kun elementti on valittu - ei mikään
clHighlightText Font color kun teksti on valittu (käytetään clHighligh kanssa). - ei mikään
clBtnFace Painikkeen taustaväri - ei mikään
clBtnShadow Painikkeen varjostusväri (Bottom Right) käytetään 3D-efektin saavuttamiseen - ei mikään
clGrayText font color kielletyillä elementeillä - ei mikään
clBtnText Painikkeen font color käytetään clBtnFace:n kanssa - ei mikään
clInactiveCaptionText Ei-aktiivinen ikkunan otsikkorivin tekstin väri - ei mikään
clBtnHighlight BPainikkeen korostusväri (Top Left) käytetään 3D-efektin saavuttamiseen - ei mikään
cl3DDkShadow ? - ei mikään
cl3DLight ? - ei mikään
clInfoText Vihjeiden fontin väri. Käytä yhdessä clInfoBk:n kanssa - kaikki
clInfoBk Brush väri vihjeitä varten. Käytä yhdessä clInfoText:n kanssa - kaikki
clHotLight ? - ei mikään
clGradientActiveCaption Toinen väri, jota käytetään aktiivisen ikkunan otsikkorivin gradientin tekemiseen - ei mikään
clGradientInactiveCaption Toinen väri, jota käytetään ei-aktiivisen ikkunan otsikkorivin gradientin tekemiseen - ei mikään
clMenuHighlight Valitun valikkokohdan taustaväri - ei mikään
clMenuBar Valikkokohdan taustaväri - ei mikään
clForm ? - ei mikään
clColorDesktop ? - ei mikään
cl3DFace ? - ei mikään
cl3DShadow ? - ei mikään
cl3DHiLight ? - ei mikään
clBtnHiLight Sama kuin clBtnHighlight - ei mikään

Järjestelmävärin rgb-arvojen löytäminen

Käytä funktiota ColorToRGB (in unit Graphics ) järjestelmän värin rgb-komponenttien määrittämiseksi. Tämä funktio havaitsee, onko väri värijärjestelmä, ja jos tämän arvo on true, näyttää palauttaa järjestelmän värin teeman värissä. Palautettu Longint voidaan ymmärtää tavalliseksi väriksi:

// Tässä esimerkissä on TColorBox lomakkeellaa ja käyttää tämän OnChange-käsittelijää 
procedure TForm1.ColorBox1Change(Sender: TObject);
var
  c: TColor;
begin
  c := ColorToRGB(ColorBox1.Selected);
  Caption := Format('R%d G%d B%d', [Red(c), Green(c), Blue(c)]);
end;

Piirrä teeman elementtejä mukautetuissa ohjauksissa (custom controls)

Käännösyksikkö (unit) Themes tarjoaa funktioita, joilla piirretään standardinhallinnan yksittäisiä elementtejä. Esimerkiksi piirtomerkin piirtäminen kuten TTreeView käyttää seuraavaa koodia:

uses Themes;

...

procedure TYourCustomControl.Paint;
const
  PlusMinusDetail: array[Boolean {Hot}, Boolean {Expanded}] of TThemedTreeview =
  (
    (ttGlyphClosed, ttGlyphOpened),
    (ttHotGlyphClosed, ttHotGlyphOpened)
  );
var
  Details: TThemedElementDetails;
  R: TRect;
  Collapse: boolean;
begin
  ...
  //draw a themed expand sign.
  Details := ThemeServices.GetElementDetails(PlusMinusDetail[False, Collapse]);
  R := Rect(ALeft, ATop, ARight + 1, ABottom + 1);
  ThemeServices.DrawElement(Canvas.Handle, Details, R, nil);
  ...
end;