1 (* 2 This Source Code Form is subject to the terms of the Mozilla Public 3 License, v. 2.0. If a copy of the MPL was not distributed with this 4 file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 Copyright (c) Alexey Torgashin 7 *) 8 unit formlexerstyle; 9 10 {$mode objfpc}{$H+} 11 12 interface 13 14 uses 15 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 16 ColorBox, StdCtrls, ButtonPanel, IniFiles, 17 ec_SyntAnal, 18 ec_syntax_format, 19 proc_colors, 20 proc_globdata, 21 proc_msg; 22 23 type 24 { TfmLexerStyle } 25 26 TfmLexerStyle = class(TForm) 27 ButtonPanel1: TButtonPanel; 28 cbBorderB: TComboBox; 29 cbBorderL: TComboBox; 30 cbBorderR: TComboBox; 31 cbBorderT: TComboBox; 32 chkBold: TCheckBox; 33 chkItalic: TCheckBox; 34 chkStrik: TCheckBox; 35 chkUnder: TCheckBox; 36 edColorBG: TColorBox; 37 edColorBorder: TColorBox; 38 edColorFont: TColorBox; 39 edStyleType: TComboBox; 40 LabelBorder: TLabel; 41 LabelBorderB: TLabel; 42 LabelBorderL: TLabel; 43 LabelBorderR: TLabel; 44 LabelBorderT: TLabel; 45 LabelColorBg: TLabel; 46 LabelColorBorder: TLabel; 47 LabelColorFont: TLabel; 48 LabelFontStyles: TLabel; 49 LabelStyleType: TLabel; 50 Panel1: TPanel; 51 procedure edStyleTypeChange(Sender: TObject); 52 procedure FormCreate(Sender: TObject); 53 procedure FormShow(Sender: TObject); 54 private 55 procedure InitBorder(cb: TCombobox); 56 procedure Localize; 57 procedure UpdateStyleEn; 58 { private declarations } 59 public 60 { public declarations } 61 end; 62 63 var 64 fmLexerStyle: TfmLexerStyle; 65 66 implementation 67 68 {$R *.lfm} 69 70 var 71 msgBorderTypeNone: string = 'none'; 72 msgBorderTypeSolid: string = 'solid'; 73 msgBorderTypeDash: string = 'dash'; 74 msgBorderTypeDot: string = 'dot'; 75 msgBorderTypeDashDot: string = 'dash dot'; 76 msgBorderTypeDashDotDot: string = 'dash dot dot'; 77 msgBorderTypeSolid2: string = 'solid2'; 78 msgBorderTypeSolid3: string = 'solid3'; 79 msgBorderTypeWave: string = 'wave'; 80 msgBorderTypeDouble: string = 'double'; 81 82 procedure DoLocString(var AStr: string; ini: TIniFile; const ASection, AKey: string); 83 begin 84 AStr:= ini.ReadString(ASection, AKey, AStr); 85 end; 86 87 procedure TfmLexerStyle.Localize; 88 const 89 section = 'd_lex_prop'; 90 var 91 ini: TIniFile; 92 fn: string; 93 begin 94 fn:= GetAppLangFilename; 95 if not FileExists(fn) then exit; 96 ini:= TIniFile.Create(fn); 97 try 98 Caption:= ini.ReadString(section, '_style', Caption); 99 with ButtonPanel1.OKButton do Caption:= msgButtonOk; 100 with ButtonPanel1.CancelButton do Caption:= msgButtonCancel; 101 102 with LabelColorBg do Caption:= ini.ReadString(section, 'col_bg', Caption); 103 with LabelColorFont do Caption:= ini.ReadString(section, 'col_fon', Caption); 104 with LabelColorBorder do Caption:= ini.ReadString(section, 'col_bor', Caption); 105 106 with LabelBorder do Caption:= ini.ReadString(section, 'bor', Caption); 107 with LabelBorderL do Caption:= ini.ReadString(section, 'bor_l', Caption); 108 with LabelBorderR do Caption:= ini.ReadString(section, 'bor_r', Caption); 109 with LabelBorderT do Caption:= ini.ReadString(section, 'bor_t', Caption); 110 with LabelBorderB do Caption:= ini.ReadString(section, 'bor_b', Caption); 111 112 with LabelFontStyles do Caption:= ini.ReadString(section, 'fon_st', Caption); 113 with chkBold do Caption:= ini.ReadString(section, 'fon_b', Caption); 114 with chkItalic do Caption:= ini.ReadString(section, 'fon_i', Caption); 115 with chkUnder do Caption:= ini.ReadString(section, 'fon_u', Caption); 116 with chkStrik do Caption:= ini.ReadString(section, 'fon_s', Caption); 117 118 with LabelStyleType do Caption:= ini.ReadString(section, 'typ_', Caption); 119 with edStyleType do Items[0]:= ini.ReadString(section, 'typ_mi', Items[0]); 120 with edStyleType do Items[1]:= ini.ReadString(section, 'typ_col_st', Items[1]); 121 with edStyleType do Items[2]:= ini.ReadString(section, 'typ_col', Items[2]); 122 with edStyleType do Items[3]:= ini.ReadString(section, 'typ_col_bg', Items[3]); 123 124 DoLocString(msgBorderTypeNone, ini, section, 'bty_none'); 125 DoLocString(msgBorderTypeSolid, ini, section, 'bty_solid'); 126 DoLocString(msgBorderTypeDash, ini, section, 'bty_dash'); 127 DoLocString(msgBorderTypeDot, ini, section, 'bty_dot'); 128 DoLocString(msgBorderTypeDashDot, ini, section, 'bty_dashdot'); 129 DoLocString(msgBorderTypeDashDotDot, ini, section, 'bty_dashdotdot'); 130 DoLocString(msgBorderTypeSolid2, ini, section, 'bty_solid2'); 131 DoLocString(msgBorderTypeSolid3, ini, section, 'bty_solid3'); 132 DoLocString(msgBorderTypeWave, ini, section, 'bty_wave'); 133 DoLocString(msgBorderTypeDouble, ini, section, 'bty_double'); 134 finally 135 FreeAndNil(ini); 136 end; 137 end; 138 139 procedure TfmLexerStyle.FormCreate(Sender: TObject); 140 begin 141 Localize; 142 InitBorder(cbBorderL); 143 InitBorder(cbBorderT); 144 InitBorder(cbBorderR); 145 InitBorder(cbBorderB); 146 end; 147 148 procedure TfmLexerStyle.edStyleTypeChange(Sender: TObject); 149 begin 150 UpdateStyleEn; 151 end; 152 153 procedure TfmLexerStyle.FormShow(Sender: TObject); 154 begin 155 UpdateFormOnTop(Self); 156 FormCreate(nil); 157 UpdateStyleEn; 158 end; 159 160 procedure TfmLexerStyle.InitBorder(cb: TCombobox); 161 var 162 n: integer; 163 begin 164 n:= cb.ItemIndex; 165 with cb.Items do 166 begin 167 Clear; 168 Add(msgBorderTypeNone); 169 Add(msgBorderTypeSolid); 170 Add(msgBorderTypeDash); 171 Add(msgBorderTypeDot); 172 Add(msgBorderTypeDashDot); 173 Add(msgBorderTypeDashDotDot); 174 Add(msgBorderTypeSolid2); 175 Add(msgBorderTypeSolid3); 176 Add(msgBorderTypeWave); 177 Add(msgBorderTypeDouble); 178 end; 179 cb.ItemIndex:= n; 180 end; 181 182 183 procedure TfmLexerStyle.UpdateStyleEn; 184 var 185 fmt: TecFormatType; 186 begin 187 fmt:= TecFormatType(edStyleType.ItemIndex); 188 edColorFont.Enabled:= fmt in [ftCustomFont, ftFontAttr, ftColor]; 189 edColorBG.Enabled:= true; 190 191 chkBold.Enabled:= fmt in [ftCustomFont, ftFontAttr]; 192 chkItalic.Enabled:= chkBold.Enabled; 193 chkUnder.Enabled:= chkBold.Enabled; 194 chkStrik.Enabled:= chkBold.Enabled; 195 end; 196 197 end. 198 199