File: UniCodeEditorReg.pas

package info (click to toggle)
mysql-query-browser 1.1.6-1sarge0
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 36,320 kB
  • ctags: 24,680
  • sloc: pascal: 203,479; xml: 136,561; ansic: 47,502; cpp: 28,926; sh: 12,433; objc: 4,823; java: 1,849; php: 1,485; python: 1,225; sql: 1,128; makefile: 872
file content (165 lines) | stat: -rw-r--r-- 5,925 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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
unit UniCodeEditorReg;

//----------------------------------------------------------------------------------------------------------------------
//
// UniCodeEditor, a Unicode Source Code Editor for Delphi.
//
// UniCodeEditor is released under the MIT license:
// Copyright (c) 1999-2004 Mike Lischke (support@soft-gems.net, www.soft-gems.net).
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// You are asked to give the author(s) the due credit. This means that you acknowledge the work of the author(s)
// in the product documentation, about box, help or wherever a prominent place is.
//
//----------------------------------------------------------------------------------------------------------------------
//
// Description
//   Registration unit for the UniCodeEditor control.
//
// Changes:
//   Version 2.0, 2003-08-17, Mike Zinner
//     Repackaged for D7
//   Version 1.0, 1999-03-10, Mike Lischke
//     Initial Version
//
//----------------------------------------------------------------------------------------------------------------------

interface

procedure Register;

//----------------------------------------------------------------------------------------------------------------------

implementation

uses
  DesignIntf, DesignWindows, DesignEditors, ComponentDesigner,
  VCLEditors,
  Dialogs, Forms, Graphics, Classes,
  UCEEditorKeyCommands,
  UCEKeyCommandsEditor,
  UCEDelphiHighlighter,
  UCECPPHighlighter,
  UCESQLHighlighter,
  UCEHTMLHighlighter,
  UCEDCGHighlighter,
  UniCodeEditor,
  UniCodeConsole;

type
  TUniCodeEditorFontProperty = class(TFontProperty)
  public
    procedure Edit; override;
  end;

//----------------------------------------------------------------------------------------------------------------------

procedure TUniCodeEditorFontProperty.Edit;

const
  // context ids for the Font editor
  hcDFontEditor = 25000;

var
  FontDialog: TFontDialog;

begin
  FontDialog := TFontDialog.Create(Application);
  try
    FontDialog.Font := TFont(GetOrdValue);
    FontDialog.HelpContext := hcDFontEditor;
    FontDialog.Options := FontDialog.Options + [fdShowHelp, fdForceFontExist, fdFixedPitchOnly];
    if FontDialog.Execute then
      SetOrdValue(Longint(FontDialog.Font));
  finally
    FontDialog.Free;
  end;
end;

//----------------------------------------------------------------------------------------------------------------------

type
  TUniCodeEditorCommandProperty = class(TIntegerProperty)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
    procedure GetValues(Proc: TGetStrProc); override;
    procedure SetValue(const Value: string); override;
  end;

//----------------- TUniCodeEditorCommandProperty -----------------------------------------------------------------------

procedure TUniCodeEditorCommandProperty.Edit;

begin
  ShowMessage('I''m thinking that this will show a dialog that has a list'#13#10 +
    'of all editor commands and a description of them to choose from.');
end;

//----------------------------------------------------------------------------------------------------------------------

function TUniCodeEditorCommandProperty.GetAttributes: TPropertyAttributes;

begin
  Result := [paMultiSelect, paDialog, paValueList, paRevertable];
end;

//----------------------------------------------------------------------------------------------------------------------

function TUniCodeEditorCommandProperty.GetValue: string;

begin
  Result := EditorCommandToCodeString(TEditorCommand(GetOrdValue));
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TUniCodeEditorCommandProperty.GetValues(Proc: TGetStrProc);

begin
  GetEditorCommandValues(Proc);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TUniCodeEditorCommandProperty.SetValue(const Value: string);

var
  NewValue: Longint;

begin
  if IdentToEditorCommand(Value, NewValue) then
    SetOrdValue(NewValue)
  else
    inherited SetValue(Value);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure Register;

begin
  RegisterComponents('UniCodeEditor', [TUniCodeEdit, TUCEDelphiHighlighter, TUCECPPHighlighter, TUCEHTMLHighlighter,
      TUCESQLHighlighter, TUCEDCGHighlighter, TUniCodeConsole]);
  RegisterPropertyEditor(TypeInfo(TFont), TUniCodeEdit, 'Font', TUniCodeEditorFontProperty);
  RegisterPropertyEditor(TypeInfo(TEditorCommand), nil, 'Command', TUniCodeEditorCommandProperty);
  RegisterPropertyEditor(TypeInfo(TKeystrokes), nil, '', TKeyStrokesProperty);
end;

//----------------------------------------------------------------------------------------------------------------------

end.