root/trunk/Forms/frm_editor.pas
| 225 | 436 | ||
|---|---|---|---|
1 | (* ***************************************************************************** | ||
2 | * | ||
3 | * MyHomeLib | ||
4 | * | ||
5 | * Copyright (C) 2008-2010 Aleksey Penkov | ||
6 | * | ||
7 | * Authors Aleksey Penkov alex.penkov@gmail.com | ||
8 | * Nick Rymanov nrymanov@gmail.com | ||
9 | ****************************************************************************** *) | ||
10 | |||
1 | unit frm_editor; | 11 | unit frm_editor; |
2 | 12 | ||
3 | interface | 13 | interface |
... | ... | ||
4 | 14 | ||
5 | uses | 15 | uses |
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | 16 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 | Dialogs, RzButton, StdCtrls, ExtCtrls, RzPanel; | 17 | Dialogs, StdCtrls, ExtCtrls; |
8 | 18 | ||
9 | type | 19 | type |
10 | TfrmEditor = class(TForm) | 20 | TfrmEditor = class(TForm) |
11 | mmMemo: TMemo; | 21 | mmMemo: TMemo; |
12 | RzBitBtn1: TRzBitBtn; | 22 | RzGroupBox4: TPanel; |
13 | RzGroupBox4: TRzGroupBox; | 23 | btnLike: TButton; |
14 | btnInsertFilterTemplate: TRzToolButton; | 24 | btnNotEq: TButton; |
15 | RzToolButton3: TRzToolButton; | 25 | btnBraket: TButton; |
16 | RzToolButton6: TRzToolButton; | 26 | btnGreat: TButton; |
17 | RzToolButton5: TRzToolButton; | 27 | btnLess: TButton; |
18 | RzToolButton4: TRzToolButton; | 28 | btnAnd: TButton; |
19 | RzToolButton7: TRzToolButton; | 29 | btnOr: TButton; |
20 | RzToolButton8: TRzToolButton; | 30 | btnNot: TButton; |
21 | RzToolButton9: TRzToolButton; | 31 | btnCommas: TButton; |
22 | RzToolButton1: TRzToolButton; | 32 | pnButtons: TPanel; |
23 | procedure RzBitBtn1Click(Sender: TObject); | 33 | btnOk: TButton; |
24 | procedure btnInsertFilterTemplateClick(Sender: TObject); | 34 | btnCancel: TButton; |
35 | procedure btnLikeClick(Sender: TObject); | ||
25 | private | 36 | private |
26 | { Private declarations } | ||
27 | procedure SetText(Value: string); | 37 | procedure SetText(Value: string); |
28 | function GetText:string; | 38 | function GetText: string; |
29 | 39 | ||
30 | public | 40 | public |
31 | { Public declarations } | 41 | property Text: string read GetText write SetText; |
32 | property Text:string read GetText write SetText; | ||
33 | |||
34 | end; | 42 | end; |
35 | 43 | ||
36 | var | 44 | var |
... | ... | ||
40 | 48 | ||
41 | {$R *.dfm} | 49 | {$R *.dfm} |
42 | 50 | ||
43 | procedure TfrmEditor.btnInsertFilterTemplateClick(Sender: TObject); | 51 | procedure TfrmEditor.btnLikeClick(Sender: TObject); |
44 | var | 52 | var |
45 | OldText: string; | 53 | p: integer; |
46 | p: integer; | 54 | AddText: string; |
47 | AddText: string; | 55 | Offset: integer; |
48 | Offset : integer; | ||
49 | begin | 56 | begin |
50 | OldText := mmMemo.Lines.Text; | ||
51 | |||
52 | p := mmMemo.SelStart; | 57 | p := mmMemo.SelStart; |
53 | 58 | ||
54 | case (Sender as TrzToolButton).Tag of | 59 | if Sender = btnLike then |
55 | 50: begin | 60 | begin |
56 | AddText := 'LIKE "%%"'; | 61 | AddText := 'LIKE "%%"'; |
57 | OffSet := P + 7; | 62 | Offset := p + 7; |
58 | end; | 63 | end |
59 | 51: begin | 64 | { |
60 | AddText := '=""'; | 65 | else if Sender = btnEq then |
61 | OffSet := P + 2; | 66 | begin |
62 | end; | 67 | AddText := '=""'; |
63 | 52: begin | 68 | Offset := p + 2; |
64 | AddText := '<> ""'; | 69 | end |
65 | OffSet := P + 4; | 70 | } |
66 | end; | 71 | else if Sender = btnNotEq then |
67 | 53: begin | 72 | begin |
68 | AddText := '<""'; | 73 | AddText := '<> ""'; |
69 | OffSet := P + 2; | 74 | Offset := p + 4; |
70 | end; | 75 | end |
71 | 54: begin | 76 | else if Sender = btnLess then |
72 | AddText := '>""'; | 77 | begin |
73 | OffSet := P + 2; | 78 | AddText := '<""'; |
74 | end; | 79 | Offset := p + 2; |
75 | 55: begin | 80 | end |
76 | AddText := '("")'; | 81 | else if Sender = btnGreat then |
77 | OffSet := P + 2; | 82 | begin |
78 | end; | 83 | AddText := '>""'; |
79 | 56: begin | 84 | Offset := p + 2; |
80 | AddText := ' AND '; | 85 | end |
81 | OffSet := P + 5; | 86 | else if Sender = btnBraket then |
82 | end; | 87 | begin |
83 | 57: begin | 88 | AddText := '("")'; |
84 | AddText := ' OR '; | 89 | Offset := p + 2; |
85 | OffSet := P + 4; | 90 | end |
86 | end; | 91 | else if Sender = btnAnd then |
87 | 58: begin | 92 | begin |
88 | AddText := ' NOT '; | 93 | AddText := ' AND '; |
89 | OffSet := P + 5; | 94 | Offset := p + 5; |
90 | end; | 95 | end |
91 | 59: begin | 96 | else if Sender = btnOr then |
92 | AddText := '""'; | 97 | begin |
93 | OffSet := P + 1; | 98 | AddText := ' OR '; |
94 | end; | 99 | Offset := p + 4; |
95 | end; | 100 | end |
96 | Insert(AddText + ' ',OldText, P + 1); | 101 | else if Sender = btnNot then |
97 | 102 | begin | |
98 | mmMemo.Lines.Text := OldText; | 103 | AddText := ' NOT '; |
104 | Offset := p + 5; | ||
105 | end | ||
106 | else if Sender = btnCommas then | ||
107 | begin | ||
108 | AddText := '""'; | ||
109 | Offset := p + 1; | ||
110 | end; | ||
111 | mmMemo.SelText := AddText; | ||
99 | mmMemo.SelStart := Offset; | 112 | mmMemo.SelStart := Offset; |
100 | mmMemo.SelLength := 0; | 113 | mmMemo.SelLength := 0; |
114 | mmMemo.SetFocus; | ||
101 | end; | 115 | end; |
102 | 116 | ||
103 | function TfrmEditor.GetText: string; | 117 | function TfrmEditor.GetText: string; |
... | ... | ||
105 | Result := mmMemo.Lines.Text; | 119 | Result := mmMemo.Lines.Text; |
106 | end; | 120 | end; |
107 | 121 | ||
108 | procedure TfrmEditor.RzBitBtn1Click(Sender: TObject); | ||
109 | begin | ||
110 | Close; | ||
111 | end; | ||
112 | |||
113 | procedure TfrmEditor.SetText(Value: string); | 122 | procedure TfrmEditor.SetText(Value: string); |
114 | begin | 123 | begin |
115 | mmMemo.Lines.Text := Value; | 124 | mmMemo.Lines.Text := Value; |
Download diff