Colors/zh CN: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | 1 | =概述= | |
| 4 | 2 | ||
| 5 | 3 | 在[[LCL]],TColor是标准颜色类型。它和[[Delphi]]的TColor兼容。TColor 可以表示*要么*一个RGB (3x8比特)值,*要么*一个**system**颜色,像**clDefault**。LCL也可以和fpImage系统一起工作,使用TFPColor类型(它是RGBA(4x16比特),非 RGB(3x8比特),像TColor)。 | |
| 6 | 4 | ||
| 7 | 5 | ## 在TColor 和RGB值之间转换 | |
| 8 | 6 | ||
| 9 | 7 | **Graphics**单元提供提供下面的函数: | |
| 10 | 8 | ||
| 11 | 9 | ``` pascal | |
| 12 | 10 | function Blue(rgb: TColor): BYTE; // does not work on system color | |
| 13 | 11 | function Green(rgb: TColor): BYTE; // does not work on system color | |
| 14 | 12 | function Red(rgb: TColor): BYTE; // does not work on system color | |
| 15 | 13 | function RGBToColor(R, G, B: Byte): TColor; | |
| 16 | 14 | procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte); // does not work on system color | |
| 17 | 15 | function FPColorToTColor(const FPColor: TFPColor): TColor; | |
| 18 | 16 | function TColorToFPColor(const c: TColor): TFPColor; // does not work on system color | |
| 19 | 17 | function IsSysColor(AColor: TColorRef): Boolean; | |
| 20 | 18 | ``` | |
| 21 | 19 | ||
| 22 | 20 | ## 转换TColor到/来自字符串 | |
| 23 | 21 | ||
| 24 | 22 | 函数来转换字符串像"25500"或"\$AA0088"或"clNavy"到TColor: | |
| 25 | 23 | ||
| 26 | 24 | - StringToColor | |
| 27 | 25 | - StringToColorDef | |
| 28 | 26 | ||
| 29 | 27 | 转换TColor到一个友好的字符串像"clNavy"或"\$AA0002": | |
| 30 | 28 | ||
| 31 | 29 | - ColorToString | |
| 32 | 30 | ||
| 33 | 31 | ## 转换TColor到/来自HTML字符串 \#rrggbb | |
| 34 | 32 | ||
| 35 | 33 | 查看代码在[[转换颜色到/来自HTML]]。 | |
| 36 | 34 | ||
| 37 | 35 | # 标准颜色表 | |
| 38 | 36 | ||
| 39 | 37 | 大约20种预定义颜色常量被提供,它们是与Delphi-兼容的: | |
| 40 | 38 | ||
| 41 | 39 | | 颜色常量 | 意思 | TColor使用[[十六进制]]值 | 示例 | | |
| 42 | 40 | |----|----|----|----| | |
| 43 | 41 | | clBlack | 黑色 | TColor(\$000000); | | | |
| 44 | 42 | | clMaroon | 褐红色 | TColor(\$000080); | | | |
| 45 | 43 | | clGreen | 绿色 | TColor(\$008000); | | | |
| 46 | 44 | | clOlive | 橄榄绿 | TColor(\$008080); | | | |
| 47 | 45 | | clNavy | 深蓝色 | TColor(\$800000); | | | |
| 48 | 46 | | clPurple | 紫色 | TColor(\$800080); | | | |
| 49 | 47 | | clTeal | 蓝绿色 | TColor(\$808000); | | | |
| 50 | 48 | | clGray | 灰色 | TColor(\$808080); | | | |
| 51 | 49 | | clSilver | 银色 | TColor(\$C0C0C0); | | | |
| 52 | 50 | | clRed | 红色 | TColor(\$0000FF); | | | |
| 53 | 51 | | clLime | 酸橙绿 | TColor(\$00FF00); | | | |
| 54 | 52 | | clYellow | 黄色 | TColor(\$00FFFF); | | | |
| 55 | 53 | | clBlue | 蓝色 | TColor(\$FF0000); | | | |
| 56 | 54 | | clFuchsia | 紫红色 | TColor(\$FF00FF); | | | |
| 57 | 55 | | clAqua | 湖绿色 | TColor(\$FFFF00); | | | |
| 58 | 56 | | clLtGray | 浅灰色 | TColor(\$C0C0C0); | clSilver别名 | | |
| 59 | 57 | | clDkGray | 深灰色 | TColor(\$808080); | clGray别名 | | |
| 60 | 58 | | clWhite | 白色 | TColor(\$FFFFFF); | | | |
| 61 | 59 | | clCream | 奶油色 | TColor(\$F0FBFF); | Lazarus 1.2和较新的 | | |
| 62 | 60 | | clMedGray | 中灰色 | TColor(\$A4A0A0); | Lazarus 1.2和较新的 | | |
| 63 | 61 | | clMoneyGreen | 薄荷绿 | TColor(\$C0DCC0); | Lazarus 1.2和较新的 | | |
| 64 | 62 | | clSkyBlue | 天蓝色 | TColor(\$F0CAA6); | LLazarus 1.2和较新的 | | |
| 65 | 63 | ||
| 66 | 64 | # System colors | |
| 67 | 65 | ||
| 68 | 66 | ## Example: clInfoBk, clInfoText | |
| 69 | 67 | ||
| 70 | 68 | System colors are color constants with a special meaning. Their real value depends on the context and theme. They are not simple colors. For example **clInfoBk**: | |
| 71 | 69 | ||
| 72 | 70 | ``` pascal | |
| 73 | 71 | Form1.Canvas.Brush.Color:=clInfoBk; // use the default background brush of a hint window | |
| 74 | 72 | Form1.Canvas.FillRect(10,10,50,50); | |
| 75 | 73 | ``` | |
| 76 | 74 | ||
| 77 | 75 | 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: | |
| 78 | 76 | ||
| 79 | 77 | ``` pascal | |
| 80 | 78 | Form1.Canvas.Brush.Color:=clInfoBk; // use the default background brush of a hint window | |
| 81 | 79 | Form1.Canvas.FillRect(10,10,50,50); | |
| 82 | 80 | Form1.Canvas.Font.Color:=clInfoText; // use the default text color of a hint window | |
| 83 | 81 | Form1.Canvas.TextOut(10,10,'Hint'); | |
| 84 | 82 | ``` | |
| 85 | 83 | ||
| 86 | 84 | 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. | |
| 87 | 85 | ||
| 88 | 86 | ## Theme changes | |
| 89 | 87 | ||
| 90 | 88 | 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: | |
| 91 | 89 | ||
| 92 | 90 | ``` pascal | |
| 93 | 91 | Form1.Canvas.Brush.Color:=clInfoBk; // this will not create a new brush handle | |
| 94 | 92 | Form1.Canvas.FillRect(10,10,50,50); // this will create the brush handle with the currently active theme brush for hint windows | |
| 95 | 93 | ... | |
| 96 | 94 | // if the theme changes in this moment the Brush.Handle is still allocated with the old values | |
| 97 | 95 | ... | |
| 98 | 96 | Form1.Canvas.FillRect(10,10,50,50); // this will paint with the old theme brush | |
| 99 | 97 | Form1.Canvas.Brush.Color:=clInfoBk; // assigning the old value will not create a new brush handle | |
| 100 | 98 | Form1.Canvas.FillRect(10,10,50,50); // this will paint with the old theme brush | |
| 101 | 99 | Form1.Canvas.Brush.Color:=clRed; // assigning a new color, old Handle invalid | |
| 102 | 100 | Form1.Canvas.Brush.Color:=clInfoBk; // assigning a new color, old Handle invalid | |
| 103 | 101 | Form1.Canvas.FillRect(10,10,50,50); // this will create a new handle and paint with the new theme | |
| 104 | 102 | ``` | |
| 105 | 103 | ||
| 106 | 104 | ## Table of system colors | |
| 107 | 105 | ||
| 108 | 106 | 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**. | |
| 109 | 107 | ||
| 110 | - | ||
| 111 | - | ||
| 112 | - | ||
| 113 | - | ||
| 114 | - | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - | ||
| 118 | - | ||
| 119 | - | ||
| 120 | - | ||
| 121 | - | ||
| 122 | - | ||
| 123 | - | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - | ||
| 128 | - | ||
| 129 | - | ||
| 130 | - | ||
| 131 | - | ||
| 132 | - | ||
| 133 | - | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - | ||
| 137 | - | ||
| 138 | - | ||
| 139 | - | ||
| 140 | - | ||
| 141 | - | ||
| 142 | - | ||
| 143 | - | ||
| 144 | - | ||
| 145 | - | ||
| 146 | - | ||
| 147 | - | ||
| 148 | - | ||
| 149 | - | ||
| 150 | - | ||
| 151 | - | ||
| 152 | - | ||
| 153 | - | ||
| 154 | - | ||
| 155 | - | ||
| 156 | - | ||
| 157 | - | ||
| 158 | - | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - | ||
| 164 | - | ||
| 165 | - | ||
| 166 | - | ||
| 167 | - | ||
| 168 | - | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - | ||
| 172 | - | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - | ||
| 176 | - | ||
| 177 | - | ||
| 178 | - | ||
| 179 | - | ||
| 180 | - | ||
| 181 | - | ||
| 182 | - | ||
| 183 | - | ||
| 184 | - | ||
| 185 | - | ||
| 186 | - | ||
| 187 | - | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | - | ||
| 192 | - | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - | ||
| 197 | - | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - | ||
| 205 | - | ||
| 206 | - | ||
| 207 | - | ||
| 208 | - | ||
| 209 | - | ||
| 210 | - | ||
| 211 | - | ||
| 212 | - | ||
| 213 | - | ||
| 214 | - | ||
| 215 | - | ||
| 216 | - | ||
| 217 | - | ||
| 218 | - | ||
| 219 | - | ||
| 220 | - | ||
| 221 | - | ||
| 222 | - | ||
| 223 | - | ||
| 224 | - | ||
| 225 | - | ||
| 226 | - | ||
| 227 | - | ||
| 228 | - | ||
| 229 | - | ||
| 230 | - | ||
| 231 | - | ||
| 232 | - | ||
| 233 | - | ||
| 234 | - | ||
| 235 | - | ||
| 236 | - | ||
| 237 | - | ||
| 238 | - | ||
| 239 | - | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - | ||
| 243 | - | ||
| 244 | - | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - | ||
| 248 | - | ||
| 249 | - | ||
| 250 | - | ||
| 251 | - | ||
| 252 | - | ||
| 253 | - | ||
| 254 | - | ||
| 255 | - | ||
| 256 | - | ||
| 257 | - | ||
| 258 | - | ||
| 259 | - | ||
| 260 | - | ||
| 261 | - | ||
| 262 | - | ||
| 263 | - | ||
| 264 | - | ||
| 265 | - | ||
| 266 | - | ||
| 267 | - | ||
| 268 | - | ||
| 269 | - | ||
| 270 | - | ||
| 271 | - | ||
| 272 | - | ||
| 273 | - | ||
| 274 | - | ||
| 275 | - | ||
| 276 | - | ||
| 277 | - | ||
| 278 | - | ||
| 279 | - | ||
| 280 | - | ||
| 281 | - | ||
| 282 | - | ||
| 283 | - | ||
| 284 | - | ||
| 285 | - | ||
| 286 | - | ||
| 287 | - | ||
| 288 | - | ||
| 289 | - | ||
| 290 | - | ||
| 291 | - | ||
| 292 | - | ||
| 293 | - | ||
| 294 | - | ||
| 295 | - | ||
| 296 | - | ||
| 297 | - | ||
| 298 | - | ||
| 299 | - | ||
| 300 | - | ||
| 301 | - | ||
| 302 | - | ||
| 303 | - | ||
| 304 | - | ||
| 305 | - | ||
| 306 | - | ||
| 307 | - | ||
| 308 | - | ||
| 309 | - | ||
| 310 | - | ||
| 311 | - | ||
| 312 | - | ||
| 313 | - | ||
| 314 | - | ||
| 315 | - | ||
| 316 | - | ||
| 317 | - | ||
| 318 | - | ||
| 319 | - | ||
| 320 | - | ||
| 321 | - | ||
| 322 | - | ||
| 323 | - | ||
| 324 | - | ||
| 325 | - | ||
| 326 | - | ||
| 327 | - | ||
| 328 | - | ||
| 329 | - | ||
| 330 | - | ||
| 331 | - | ||
| 332 | - | ||
| 333 | - | ||
| 334 | - | ||
| 335 | - | ||
| 336 | - | ||
| 337 | - | ||
| 338 | - | ||
| 339 | - | ||
| 340 | - | ||
| 341 | - | ||
| 342 | - | ||
| 343 | - | ||
| 344 | - | ||
| 345 | - | ||
| 346 | - | ||
| 347 | - | ||
| 348 | - | ||
| 349 | - | ||
| 350 | - | ||
| 351 | - | ||
| 352 | - | ||
| 353 | - | ||
| 354 | - | ||
| 355 | - | ||
| 108 | + | **Constant** | |
| 109 | + | ||
| 110 | + | **LCL definition** | |
| 111 | + | ||
| 112 | + | **Delphi notes** | |
| 113 | + | ||
| 114 | + | **Supported Widgetsets** | |
| 115 | + | ||
| 116 | + | clNone | |
| 117 | + | ||
| 118 | + | Indicates "do not paint". Using it as Control's color is undefined. The control will not get transparent. | |
| 119 | + | ||
| 120 | + | \- | |
| 121 | + | ||
| 122 | + | all | |
| 123 | + | ||
| 124 | + | clDefault | |
| 125 | + | ||
| 126 | + | Using it for Brush will use the normal background brush of the target DC (device context). | |
| 127 | + | ||
| 128 | + | - 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. | |
| 129 | + | - 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. | |
| 130 | + | - Using it as Pen color will use the default line color for the device context. | |
| 131 | + | - Using it as Font color will use the normal text color of the device context. | |
| 132 | + | ||
| 133 | + | \| - | |
| 134 | + | ||
| 135 | + | all | |
| 136 | + | ||
| 137 | + | clScrollBar | |
| 138 | + | ||
| 139 | + | Scrollbar body | |
| 140 | + | ||
| 141 | + | \- | |
| 142 | + | ||
| 143 | + | all | |
| 144 | + | ||
| 145 | + | clBackground | |
| 146 | + | ||
| 147 | + | Desktop background color | |
| 148 | + | ||
| 149 | + | \- | |
| 150 | + | ||
| 151 | + | all | |
| 152 | + | ||
| 153 | + | clActiveCaption | |
| 154 | + | ||
| 155 | + | Active window titlebar | |
| 156 | + | ||
| 157 | + | \- | |
| 158 | + | ||
| 159 | + | none | |
| 160 | + | ||
| 161 | + | clInactiveCaption | |
| 162 | + | ||
| 163 | + | Inactive window titlebar | |
| 164 | + | ||
| 165 | + | \- | |
| 166 | + | ||
| 167 | + | none | |
| 168 | + | ||
| 169 | + | clMenu | |
| 170 | + | ||
| 171 | + | Regular menu item background color | |
| 172 | + | ||
| 173 | + | \- | |
| 174 | + | ||
| 175 | + | none | |
| 176 | + | ||
| 177 | + | clWindow | |
| 178 | + | ||
| 179 | + | The normal background brush of unselected text. Defined for controls like TEdit, TComboBox, TMemo, TListBox, TTreeView. | |
| 180 | + | ||
| 181 | + | \- | |
| 182 | + | ||
| 183 | + | none | |
| 184 | + | ||
| 185 | + | clWindowFrame | |
| 186 | + | ||
| 187 | + | Color of frame around the window | |
| 188 | + | ||
| 189 | + | \- | |
| 190 | + | ||
| 191 | + | none | |
| 192 | + | ||
| 193 | + | clMenuText | |
| 194 | + | ||
| 195 | + | The font color to use together with clMenu | |
| 196 | + | ||
| 197 | + | \- | |
| 198 | + | ||
| 199 | + | none | |
| 200 | + | ||
| 201 | + | clWindowText | |
| 202 | + | ||
| 203 | + | Font color to use together with clWindow | |
| 204 | + | ||
| 205 | + | \- | |
| 206 | + | ||
| 207 | + | none | |
| 208 | + | ||
| 209 | + | clCaptionText | |
| 210 | + | ||
| 211 | + | Active window titlebar text color | |
| 212 | + | ||
| 213 | + | \- | |
| 214 | + | ||
| 215 | + | none | |
| 216 | + | ||
| 217 | + | clActiveBorder | |
| 218 | + | ||
| 219 | + | ? | |
| 220 | + | ||
| 221 | + | \- | |
| 222 | + | ||
| 223 | + | none | |
| 224 | + | ||
| 225 | + | clInactiveBorder | |
| 226 | + | ||
| 227 | + | ? | |
| 228 | + | ||
| 229 | + | \- | |
| 230 | + | ||
| 231 | + | none | |
| 232 | + | ||
| 233 | + | clAppWorkspace | |
| 234 | + | ||
| 235 | + | MDIMain form background | |
| 236 | + | ||
| 237 | + | \- | |
| 238 | + | ||
| 239 | + | none | |
| 240 | + | ||
| 241 | + | clHighlight | |
| 242 | + | ||
| 243 | + | The brush color of selected element | |
| 244 | + | ||
| 245 | + | \- | |
| 246 | + | ||
| 247 | + | none | |
| 248 | + | ||
| 249 | + | clHighlightText | |
| 250 | + | ||
| 251 | + | Font color of selected text (to use together with clHighligh). | |
| 252 | + | ||
| 253 | + | \- | |
| 254 | + | ||
| 255 | + | none | |
| 256 | + | ||
| 257 | + | clBtnFace | |
| 258 | + | ||
| 259 | + | Button background | |
| 260 | + | ||
| 261 | + | \- | |
| 262 | + | ||
| 263 | + | none | |
| 264 | + | ||
| 265 | + | clBtnShadow | |
| 266 | + | ||
| 267 | + | Button shadow color (bottom right) used to achieve 3D effect | |
| 268 | + | ||
| 269 | + | \- | |
| 270 | + | ||
| 271 | + | none | |
| 272 | + | ||
| 273 | + | clGrayText | |
| 274 | + | ||
| 275 | + | The font color of disabled element | |
| 276 | + | ||
| 277 | + | \- | |
| 278 | + | ||
| 279 | + | none | |
| 280 | + | ||
| 281 | + | clBtnText | |
| 282 | + | ||
| 283 | + | Button font color to use together with clBtnFace | |
| 284 | + | ||
| 285 | + | \- | |
| 286 | + | ||
| 287 | + | none | |
| 288 | + | ||
| 289 | + | clInactiveCaptionText | |
| 290 | + | ||
| 291 | + | Inactive window titlebar text color | |
| 292 | + | ||
| 293 | + | \- | |
| 294 | + | ||
| 295 | + | none | |
| 296 | + | ||
| 297 | + | clBtnHighlight | |
| 298 | + | ||
| 299 | + | Button highlight color (top left) used to achieve 3D effect | |
| 300 | + | ||
| 301 | + | \- | |
| 302 | + | ||
| 303 | + | none | |
| 304 | + | ||
| 305 | + | cl3DDkShadow | |
| 306 | + | ||
| 307 | + | ? | |
| 308 | + | ||
| 309 | + | \- | |
| 310 | + | ||
| 311 | + | none | |
| 312 | + | ||
| 313 | + | cl3DLight | |
| 314 | + | ||
| 315 | + | ? | |
| 316 | + | ||
| 317 | + | \- | |
| 318 | + | ||
| 319 | + | none | |
| 320 | + | ||
| 321 | + | clInfoText | |
| 322 | + | ||
| 323 | + | Font color for hints. Use together with clInfoBk | |
| 324 | + | ||
| 325 | + | \- | |
| 326 | + | ||
| 327 | + | all | |
| 328 | + | ||
| 329 | + | clInfoBk | |
| 330 | + | ||
| 331 | + | Brush color for hints. Use together with clInfoText | |
| 332 | + | ||
| 333 | + | \- | |
| 334 | + | ||
| 335 | + | all | |
| 336 | + | ||
| 337 | + | clHotLight | |
| 338 | + | ||
| 339 | + | ? | |
| 340 | + | ||
| 341 | + | \- | |
| 342 | + | ||
| 343 | + | none | |
| 344 | + | ||
| 345 | + | clGradientActiveCaption | |
| 346 | + | ||
| 347 | + | The second color used to make gradient of active window titlebar | |
| 348 | + | ||
| 349 | + | \- | |
| 350 | + | ||
| 351 | + | none | |
| 352 | + | ||
| 353 | + | clGradientInactiveCaption | |
| 354 | + | ||
| 355 | + | The second color used to make gradient for inactive window titlebar | |
| 356 | + | ||
| 357 | + | \- | |
| 358 | + | ||
| 359 | + | none | |
| 360 | + | ||
| 361 | + | clMenuHighlight | |
| 362 | + | ||
| 363 | + | The background color of selected menu item | |
| 364 | + | ||
| 365 | + | \- | |
| 366 | + | ||
| 367 | + | none | |
| 368 | + | ||
| 369 | + | clMenuBar | |
| 370 | + | ||
| 371 | + | The Backround color of menu bar | |
| 372 | + | ||
| 373 | + | \- | |
| 374 | + | ||
| 375 | + | none | |
| 376 | + | ||
| 377 | + | clForm | |
| 378 | + | ||
| 379 | + | ? | |
| 380 | + | ||
| 381 | + | \- | |
| 382 | + | ||
| 383 | + | none | |
| 384 | + | ||
| 385 | + | clColorDesktop | |
| 386 | + | ||
| 387 | + | ? | |
| 388 | + | ||
| 389 | + | \- | |
| 390 | + | ||
| 391 | + | none | |
| 392 | + | ||
| 393 | + | cl3DFace | |
| 394 | + | ||
| 395 | + | ? | |
| 396 | + | ||
| 397 | + | \- | |
| 398 | + | ||
| 399 | + | none | |
| 400 | + | ||
| 401 | + | cl3DShadow | |
| 402 | + | ||
| 403 | + | ? | |
| 404 | + | ||
| 405 | + | \- | |
| 406 | + | ||
| 407 | + | none | |
| 408 | + | ||
| 409 | + | cl3DHiLight | |
| 410 | + | ||
| 411 | + | ? | |
| 412 | + | ||
| 413 | + | \- | |
| 414 | + | ||
| 415 | + | none | |
| 416 | + | ||
| 417 | + | clBtnHiLight | |
| 418 | + | ||
| 419 | + | Same as clBtnHighlight | |
| 420 | + | ||
| 421 | + | \- | |
| 422 | + | ||
| 423 | + | none | |
| 356 | 424 | ||
| 357 | 425 | ## Finding the rgb values of a system color | |
| 358 | 426 | ||
| 359 | 427 | Use the function `ColorToRGB` (in unit `Graphics` 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: | |
| 360 | 428 | ||
| 361 | 429 | ``` pascal | |
| 362 | 430 | // This example has a TColorBox on a form and uses this OnChange handler for the TColorbox: | |
| 363 | 431 | procedure TForm1.ColorBox1Change(Sender: TObject); | |
| 364 | 432 | var | |
| 365 | 433 | c: TColor; | |
| 366 | 434 | begin | |
| 367 | 435 | c := ColorToRGB(ColorBox1.Selected); | |
| 368 | 436 | Caption := Format('R%d G%d B%d', [Red(c), Green(c), Blue(c)]); | |
| 369 | 437 | end; | |
| 370 | 438 | ``` | |
| 371 | 439 | ||
| 372 | 440 | # Drawing theme elements on your custom controls | |
| 373 | 441 | ||
| 374 | 442 | 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: | |
| 375 | 443 | ||
| 376 | 444 | ``` pascal | |
| 377 | 445 | uses Themes; | |
| 378 | 446 | ||
| 379 | 447 | ... | |
| 380 | 448 | ||
| 381 | 449 | procedure TYourCustomControl.Paint; | |
| 382 | 450 | const | |
| 383 | 451 | PlusMinusDetail: array[Boolean {Hot}, Boolean {Expanded}] of TThemedTreeview = | |
| 384 | 452 | ( | |
| 385 | 453 | (ttGlyphClosed, ttGlyphOpened), | |
| 386 | 454 | (ttHotGlyphClosed, ttHotGlyphOpened) | |
| 387 | 455 | ); | |
| 388 | 456 | var | |
| 389 | 457 | Details: TThemedElementDetails; | |
| 390 | 458 | R: TRect; | |
| 391 | 459 | Collapse: boolean; | |
| 392 | 460 | begin | |
| 393 | 461 | ... | |
| 394 | 462 | //draw a themed expand sign. | |
| 395 | 463 | Details := ThemeServices.GetElementDetails(PlusMinusDetail[False, Collapse]); | |
| 396 | 464 | R := Rect(ALeft, ATop, ARight + 1, ABottom + 1); | |
| 397 | 465 | ThemeServices.DrawElement(Canvas.Handle, Details, R, nil); | |
| 398 | 466 | ... | |
| 399 | 467 | end; | |
| 400 | 468 | ``` | |
| 401 | 469 | ||
| 402 | 470 | ## 贡献者和更改 | |
| 403 | 471 | ||
| 404 | 472 | - 简体中文版本由 robsean 于 2019-07-17 创建。 | |
| 405 | 473 | ||
| 406 | 474 | --- | |
| 407 | 475 | *From the Free Pascal wiki, page "Colors/zh CN", as it stood on 2020-02-11 after a change by Trev, 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).* | |
| 408 | 476 | Category: Graphics |
