76 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
76 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; |
77 begin |
77 begin |
78 WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0); |
78 WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0); |
79 end;*) |
79 end;*) |
80 |
80 |
81 function IsTooDarkToRead(TextColor: LongWord): boolean; |
81 function IsTooDarkToRead(TextColor: LongWord): boolean; inline; |
82 var clr: TSDL_Color; |
82 var clr: TSDL_Color; |
83 begin |
83 begin |
84 clr.r:= (TextColor shr 16) and $FF; |
84 clr.r:= (TextColor shr 16) and $FF; |
85 clr.g:= (TextColor shr 8) and $FF; |
85 clr.g:= (TextColor shr 8) and $FF; |
86 clr.b:= TextColor and $FF; |
86 clr.b:= TextColor and $FF; |
87 IsTooDarkToRead:= ((clr.r >= cInvertTextColorAt) or (clr.g >= cInvertTextColorAt) or (clr.b >= cInvertTextColorAt)); |
87 IsTooDarkToRead:= not ((clr.r >= cInvertTextColorAt) or (clr.g >= cInvertTextColorAt) or (clr.b >= cInvertTextColorAt)); |
88 end; |
|
89 |
|
90 function IsTooDarkToRead(TextColor: TSDL_COLOR): boolean; |
|
91 begin |
|
92 IsTooDarkToRead:= (not ((TextColor.r >= cInvertTextColorAt) or (TextColor.g >= cInvertTextColorAt) or (TextColor.b >= cInvertTextColorAt))); |
|
93 end; |
88 end; |
94 |
89 |
95 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect; |
90 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect; |
96 var w, h: Longword; |
91 var w, h: Longword; |
97 tmpsurf: PSDL_Surface; |
92 tmpsurf: PSDL_Surface; |
109 textRect.w:= w; |
104 textRect.w:= w; |
110 textRect.h:= h; |
105 textRect.h:= h; |
111 clr.r:= (Color shr 16) and $FF; |
106 clr.r:= (Color shr 16) and $FF; |
112 clr.g:= (Color shr 8) and $FF; |
107 clr.g:= (Color shr 8) and $FF; |
113 clr.b:= Color and $FF; |
108 clr.b:= Color and $FF; |
114 if (not IsTooDarkToRead(clr)) then |
109 if (not IsTooDarkToRead(Color)) then |
115 DrawRoundRect(@finalRect, cWhiteColor, cNearBlackColor, Surface, true) |
110 DrawRoundRect(@finalRect, cWhiteColor, cNearBlackColor, Surface, true) |
116 else |
111 else |
117 DrawRoundRect(@finalRect, cNearBlackColor, cWhiteColor, Surface, true); |
112 DrawRoundRect(@finalRect, cNearBlackColor, cWhiteColor, Surface, true); |
118 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr); |
113 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr); |
119 finalRect.x:= X + cFontBorder + cFontPadding; |
114 finalRect.x:= X + cFontBorder + cFontPadding; |