~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to ide/frames/compiler_messages_options.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
interface
6
6
 
7
7
uses
8
 
  Classes, SysUtils, FileUtil, Forms, StdCtrls, CheckLst, LCLProc,
9
 
  Dialogs,
10
 
  IDEOptionsIntf, Project,
11
 
  LazarusIDEStrConsts,
12
 
  EnvironmentOpts, CompilerOptions, IDEMsgIntf;
 
8
  Classes, SysUtils, FileUtil, ListFilterEdit, StdCtrls, CheckLst, Dialogs,
 
9
  IDEOptionsIntf, LazarusIDEStrConsts, EnvironmentOpts, CompilerOptions,
 
10
  IDEMsgIntf, IDEDialogs;
13
11
 
14
12
type
15
13
 
17
15
 
18
16
  TCompilerMessagesOptionsFrame = class(TAbstractIDEOptionsEditor)
19
17
    chklistCompMsg: TCheckListBox;
20
 
    editMsgFilter: TEdit;
 
18
    editMsgFilter: TListFilterEdit;
21
19
    grpCompilerMessages: TGroupBox;
22
20
    lblFilter: TLabel;
23
 
    procedure btnBrowseMsgClick(Sender: TObject);
 
21
    MsgFileBrowseButton: TButton;
 
22
    MsgFileEdit: TEdit;
 
23
    UseMsgFileCheckBox: TCheckBox;
24
24
    procedure chklistCompMsgItemClick(Sender: TObject; Index: integer);
25
 
    procedure chkUseMsgFileChange(Sender: TObject);
26
 
    procedure editMsgFilterChange(Sender: TObject);
 
25
    function CheckItem(Item: TObject): Boolean;
 
26
    procedure MsgFileBrowseButtonClick(Sender: TObject);
 
27
    procedure UseMsgFileCheckBoxChange(Sender: TObject);
27
28
  private
28
 
    { private declarations }
29
29
    TempMessages: TCompilerMessagesList;
30
 
    procedure UpdateMessages;
31
 
    procedure UpdateFilter;
32
30
  public
33
 
    { public declarations }
34
31
    constructor Create(TheOwner: TComponent); override;
35
32
    destructor Destroy; override;
36
33
 
47
44
 
48
45
{ TCompilerMessagesOptionsFrame }
49
46
 
50
 
procedure TCompilerMessagesOptionsFrame.chkUseMsgFileChange(Sender: TObject);
51
 
begin
52
 
  UpdateMessages;
53
 
end;
54
 
 
55
 
procedure TCompilerMessagesOptionsFrame.editMsgFilterChange(Sender: TObject);
56
 
begin
57
 
  UpdateFilter;
58
 
end;
59
 
 
60
 
procedure TCompilerMessagesOptionsFrame.chklistCompMsgItemClick(
61
 
  Sender: TObject; Index: integer);
62
 
begin
63
 
  if (Index >= 0) and (Index < chklistCompMsg.Items.Count) then
64
 
    TCompilerMessageConfig(chklistCompMsg.Items.Objects[Index]).Ignored :=
65
 
      not chklistCompMsg.Checked[Index];
66
 
end;
67
 
 
68
 
procedure TCompilerMessagesOptionsFrame.btnBrowseMsgClick(Sender: TObject);
69
 
var
70
 
  dlg : TOpenDialog;
71
 
begin
72
 
  dlg := TOpenDialog.Create(Self);
73
 
  try
74
 
    dlg.Filter := dlgBrowseMsgFilter;
75
 
    if not dlg.Execute then Exit;
76
 
    editMsgFilter.Caption := dlg.FileName;
77
 
    UpdateMessages;
78
 
  finally
79
 
    dlg.Free
80
 
  end;
81
 
end;
82
 
 
83
 
procedure TCompilerMessagesOptionsFrame.UpdateMessages;
84
 
const
85
 
  MaxIndexLen = 5;
86
 
var
87
 
  topidx    : Integer;
88
 
begin
89
 
  topidx := chklistCompMsg.TopIndex;
90
 
  chklistCompMsg.Items.BeginUpdate;
91
 
  try
92
 
    //debugln(['TCompilerMessagesOptionsFrame.UpdateMessages ',EnvironmentOptions.CompilerMessagesFilename]);
93
 
    if FileExistsUTF8(EnvironmentOptions.CompilerMessagesFilename) then begin
94
 
      try
95
 
        // FPC messages file is expected to be UTF8 encoded, no matter for the current code page is
96
 
        TempMessages.LoadMsgFile(EnvironmentOptions.CompilerMessagesFilename);
97
 
      except
98
 
        TempMessages.SetDefault;
99
 
      end;
100
 
    end else
101
 
      TempMessages.SetDefault;
102
 
 
103
 
    chklistCompMsg.Clear;
104
 
    chklistCompMsg.Items.Clear;
105
 
    
106
 
    UpdateFilter;
107
 
 
108
 
  finally
109
 
    chklistCompMsg.Items.EndUpdate;
110
 
    chkListCompMsg.TopIndex := topidx;
111
 
  end;
112
 
end;
113
 
 
114
 
procedure TCompilerMessagesOptionsFrame.UpdateFilter; 
115
 
var
116
 
  i     : Integer;
117
 
  j     : Integer;
118
 
  m     : TCompilerMessageConfig;
119
 
  add   : Boolean;
120
 
  srch  : AnsiString;
121
 
const
122
 
  //todo: should be translated
123
 
  MsgTypeStr : array [TFPCErrorType] of String = ('-','H','N','W','E','F','P');
124
 
begin
125
 
  chklistCompMsg.Items.BeginUpdate;
126
 
  try
127
 
    chklistCompMsg.Clear;
128
 
    srch:=UTF8UpperCase(editMsgFilter.Text);
129
 
    for i := 0 to TempMessages.Count - 1 do
130
 
    begin
131
 
      m := TempMessages.Msg[i];
132
 
      add:=m.MsgType in [etNote, etHint, etWarning];
133
 
      
134
 
      if add and (srch<>'') then 
135
 
        add:=UTF8Pos(srch, UTF8UpperCase(m.GetUserText))>0;
136
 
        
137
 
      if add then
138
 
      begin
139
 
        j := chklistCompMsg.Items.AddObject( Format('(%s) %s', [MsgTypeStr[m.MsgType], m.GetUserText([])]), m);
140
 
        chklistCompMsg.Checked[j] := not m.Ignored;
141
 
      end;
142
 
    end;
143
 
  finally            
144
 
    chklistCompMsg.Items.EndUpdate;
145
 
  end;
 
47
procedure TCompilerMessagesOptionsFrame.chklistCompMsgItemClick(Sender: TObject; Index: integer);
 
48
const
 
49
  BoolToMessageState: array[Boolean] of TCompilerMessageState = (msOff, msOn);
 
50
var
 
51
  m: TCompilerMessageConfig;
 
52
begin
 
53
  if (Index >= 0) and (Index < chklistCompMsg.Items.Count) then begin
 
54
    m := TCompilerMessageConfig(chklistCompMsg.Items.Objects[Index]);
 
55
    if (m.DefIgnored <> chklistCompMsg.Checked[Index]) then
 
56
      m.State := msDefault
 
57
    else
 
58
      m.State := BoolToMessageState[chklistCompMsg.Checked[Index]];
 
59
  end;
 
60
end;
 
61
 
 
62
function TCompilerMessagesOptionsFrame.CheckItem(Item: TObject): Boolean;
 
63
var
 
64
  m: TCompilerMessageConfig;
 
65
begin
 
66
  m := Item as TCompilerMessageConfig;
 
67
  if m.State = msDefault then
 
68
    Result := not m.DefIgnored
 
69
  else
 
70
    Result := m.State = msOn;
 
71
end;
 
72
 
 
73
procedure TCompilerMessagesOptionsFrame.MsgFileBrowseButtonClick(Sender: TObject
 
74
  );
 
75
var
 
76
  OpenDialog: TOpenDialog;
 
77
begin
 
78
  OpenDialog:=TOpenDialog.Create(nil);
 
79
  try
 
80
    InitIDEFileDialog(OpenDialog);
 
81
    OpenDialog.Title:=lisChooseAnFPCMessageFile;
 
82
    OpenDialog.Options:=OpenDialog.Options+[ofFileMustExist];
 
83
    OpenDialog.Filter:=lisFPCMessageFile+' (*.msg)|*.msg|'+dlgAllFiles+'|'+
 
84
      GetAllFilesMask;
 
85
    if OpenDialog.Execute then
 
86
      MsgFileEdit.Text:=OpenDialog.FileName;
 
87
  finally
 
88
    OpenDialog.Free;
 
89
  end;
 
90
end;
 
91
 
 
92
procedure TCompilerMessagesOptionsFrame.UseMsgFileCheckBoxChange(Sender: TObject
 
93
  );
 
94
begin
 
95
  MsgFileEdit.Enabled:=UseMsgFileCheckBox.Checked;
 
96
  MsgFileBrowseButton.Enabled:=UseMsgFileCheckBox.Checked;
146
97
end;
147
98
 
148
99
constructor TCompilerMessagesOptionsFrame.Create(TheOwner: TComponent);
153
104
 
154
105
destructor TCompilerMessagesOptionsFrame.Destroy;
155
106
begin
 
107
  editMsgFilter.Data.Clear;
 
108
  chklistCompMsg.Clear;
 
109
  chklistCompMsg.Items.Clear;
156
110
  TempMessages.Free;
157
111
  inherited Destroy;
158
112
end;
164
118
 
165
119
procedure TCompilerMessagesOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
166
120
begin
167
 
  editMsgFilter.Caption := '';
168
121
  grpCompilerMessages.Caption:=dlgCompilerMessage;
169
122
  lblFilter.Caption:=lisFilter;
 
123
  UseMsgFileCheckBox.Caption:=lisUseMessageFile;
 
124
  MsgFileBrowseButton.Caption:=lisPathEditBrowse;
170
125
end;
171
126
 
172
127
procedure TCompilerMessagesOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
 
128
const     // todo: should be translated
 
129
  MsgTypeStr: array [TFPCErrorType] of String = ('-','H','N','W','E','F','P');
 
130
var
 
131
  topidx, i: Integer;
 
132
  m: TCompilerMessageConfig;
 
133
  s: String;
 
134
  CompOpts: TBaseCompilerOptions;
173
135
begin
174
 
  with AOptions as TBaseCompilerOptions do 
 
136
  CompOpts:=AOptions as TBaseCompilerOptions;
 
137
  TempMessages.Assign(CompOpts.CompilerMessages);
 
138
  topidx := chklistCompMsg.TopIndex;
 
139
  UseMsgFileCheckBox.Checked:=CompOpts.UseMsgFile;
 
140
  MsgFileEdit.Text:=CompOpts.MsgFileName;
 
141
  MsgFileEdit.Enabled:=UseMsgFileCheckBox.Checked;
 
142
  MsgFileBrowseButton.Enabled:=UseMsgFileCheckBox.Checked;
 
143
 
 
144
  // Copy data to filter component
 
145
  editMsgFilter.Data.Clear;
 
146
  for i := 0 to TempMessages.Count - 1 do
175
147
  begin
176
 
    TempMessages.Assign(CompilerMessages);
177
 
    UpdateMessages;
 
148
    m := TempMessages.Msg[i];
 
149
    if m.MsgType in [etNote, etHint, etWarning] then
 
150
    begin
 
151
      s := Format('(%s) %s', [MsgTypeStr[m.MsgType], m.GetUserText([])]);
 
152
      editMsgFilter.Data.AddObject(s, m);
 
153
    end;
178
154
  end;
 
155
  editMsgFilter.InvalidateFilter;
 
156
  chkListCompMsg.TopIndex := topidx;
179
157
end;
180
158
 
181
159
procedure TCompilerMessagesOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
182
160
begin
183
161
  with AOptions as TBaseCompilerOptions do
184
162
  begin
185
 
    UseMsgFile:=True;
186
 
    MsgFileName:=EnvironmentOptions.CompilerMessagesFilename;
 
163
    UseMsgFile:=UseMsgFileCheckBox.Checked;
 
164
    MsgFileName:=MsgFileEdit.Text;
187
165
    CompilerMessages.Assign(TempMessages);
188
166
  end;
189
167
end;
190
168
 
191
169
class function TCompilerMessagesOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
192
170
begin
193
 
  Result := TBaseCompilerOptions;
 
171
  Result:=TBaseCompilerOptions;
194
172
end;
195
173
 
196
174
initialization
197
175
  RegisterIDEOptionsEditor(GroupCompiler, TCompilerMessagesOptionsFrame, CompilerOptionsMessages);
 
176
  RegisterIDEOptionsEditor(GroupPkgCompiler, TCompilerMessagesOptionsFrame, CompilerOptionsMessages);
198
177
 
199
178
end.
200
179