| 1 |
unit UMain; |
|---|
| 2 |
|
|---|
| 3 |
interface |
|---|
| 4 |
|
|---|
| 5 |
uses |
|---|
| 6 |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
|---|
| 7 |
ComCtrls, Menus, Workspaces, Projects, ImgList; |
|---|
| 8 |
|
|---|
| 9 |
const |
|---|
| 10 |
ObjHeaderText = 'Object Files'; |
|---|
| 11 |
ErrorHeaderText = 'Errors'; { node.data points to this } |
|---|
| 12 |
|
|---|
| 13 |
type |
|---|
| 14 |
TmainForm = class(TForm) |
|---|
| 15 |
treeView: TTreeView; |
|---|
| 16 |
wsMenu: TMainMenu; |
|---|
| 17 |
Workspace1: TMenuItem; |
|---|
| 18 |
New1: TMenuItem; |
|---|
| 19 |
Load1: TMenuItem; |
|---|
| 20 |
Save1: TMenuItem; |
|---|
| 21 |
Settings1: TMenuItem; |
|---|
| 22 |
Quit1: TMenuItem; |
|---|
| 23 |
FileDialog: TOpenDialog; |
|---|
| 24 |
Close1: TMenuItem; |
|---|
| 25 |
WorkspacePopup: TPopupMenu; |
|---|
| 26 |
PMNewProject: TMenuItem; |
|---|
| 27 |
ProjectPopup: TPopupMenu; |
|---|
| 28 |
Add1: TMenuItem; |
|---|
| 29 |
BuildLibMenu: TMenuItem; |
|---|
| 30 |
Settings2: TMenuItem; |
|---|
| 31 |
Close2: TMenuItem; |
|---|
| 32 |
SaveProject1: TMenuItem; |
|---|
| 33 |
PMSettings: TMenuItem; |
|---|
| 34 |
PMClose: TMenuItem; |
|---|
| 35 |
PMLoadProject: TMenuItem; |
|---|
| 36 |
SaveAll1: TMenuItem; |
|---|
| 37 |
SourcePopup: TPopupMenu; |
|---|
| 38 |
Compile1: TMenuItem; |
|---|
| 39 |
Remove1: TMenuItem; |
|---|
| 40 |
PMSave: TMenuItem; |
|---|
| 41 |
Edit1: TMenuItem; |
|---|
| 42 |
Refresh1: TMenuItem; |
|---|
| 43 |
SaveDialog: TSaveDialog; |
|---|
| 44 |
StatusBar: TStatusBar; |
|---|
| 45 |
Build1: TMenuItem; |
|---|
| 46 |
About1: TMenuItem; |
|---|
| 47 |
FullBuild1: TMenuItem; |
|---|
| 48 |
VersionSubmenu: TMenuItem; |
|---|
| 49 |
BuildRun1: TMenuItem; |
|---|
| 50 |
Options1: TMenuItem; |
|---|
| 51 |
StayonTopMenu: TMenuItem; |
|---|
| 52 |
IconImages: TImageList; |
|---|
| 53 |
procedure Quit1Click(Sender: TObject); |
|---|
| 54 |
procedure Settings1Click(Sender: TObject); |
|---|
| 55 |
procedure FormCreate(Sender: TObject); |
|---|
| 56 |
procedure New1Click(Sender: TObject); |
|---|
| 57 |
procedure Load1Click(Sender: TObject); |
|---|
| 58 |
procedure Close1Click(Sender: TObject); |
|---|
| 59 |
procedure treeViewMouseDown(Sender: TObject; Button: TMouseButton; |
|---|
| 60 |
Shift: TShiftState; X, Y: Integer); |
|---|
| 61 |
procedure PMNewProjectClick(Sender: TObject); |
|---|
| 62 |
procedure Settings2Click(Sender: TObject); |
|---|
| 63 |
procedure Save1Click(Sender: TObject); |
|---|
| 64 |
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
|---|
| 65 |
procedure PMSettingsClick(Sender: TObject); |
|---|
| 66 |
procedure PMCloseClick(Sender: TObject); |
|---|
| 67 |
procedure PMLoadProjectClick(Sender: TObject); |
|---|
| 68 |
procedure Close2Click(Sender: TObject); |
|---|
| 69 |
procedure Add1Click(Sender: TObject); |
|---|
| 70 |
procedure SaveAll1Click(Sender: TObject); |
|---|
| 71 |
procedure Remove1Click(Sender: TObject); |
|---|
| 72 |
procedure Compile1Click(Sender: TObject); |
|---|
| 73 |
procedure PMSaveClick(Sender: TObject); |
|---|
| 74 |
procedure Edit1Click(Sender: TObject); |
|---|
| 75 |
procedure treeViewDblClick(Sender: TObject); |
|---|
| 76 |
procedure SaveProject1Click(Sender: TObject); |
|---|
| 77 |
procedure BuildMenuClick(Sender: TObject); |
|---|
| 78 |
procedure BuildLibMenuClick(Sender: TObject); |
|---|
| 79 |
procedure Refresh1Click(Sender: TObject); |
|---|
| 80 |
procedure BuildSubMenuClick(Sender: TObject); |
|---|
| 81 |
procedure Build1Click(Sender: TObject); |
|---|
| 82 |
procedure About1Click(Sender: TObject); |
|---|
| 83 |
procedure FullBuild1Click(Sender: TObject); |
|---|
| 84 |
procedure BuildRun1Click(Sender: TObject); |
|---|
| 85 |
procedure StayonTopMenuClick(Sender: TObject); |
|---|
| 86 |
private |
|---|
| 87 |
{ Private declarations } |
|---|
| 88 |
public |
|---|
| 89 |
{ Public declarations } |
|---|
| 90 |
|
|---|
| 91 |
procedure ToggleMenuItem(Sender: TObject); |
|---|
| 92 |
|
|---|
| 93 |
procedure SelectWorkspace() ; |
|---|
| 94 |
procedure EditWorkspace() ; |
|---|
| 95 |
procedure CreateWorkspace() ; |
|---|
| 96 |
procedure SaveWorkspace() ; |
|---|
| 97 |
function CloseWorkspace() : boolean; |
|---|
| 98 |
procedure UpdateTreeview(); |
|---|
| 99 |
|
|---|
| 100 |
procedure ApplicationMessage( var Msg:TMsg; var handled:boolean ); |
|---|
| 101 |
end; |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
var |
|---|
| 105 |
mainForm: TmainForm; |
|---|
| 106 |
|
|---|
| 107 |
implementation |
|---|
| 108 |
|
|---|
| 109 |
uses FileCtrl, UWsConfigDlg, UProjConfigDlg, |
|---|
| 110 |
UOutputDlg, Clipbrd, MyUtils, SourceFiles, SimpleXML; |
|---|
| 111 |
|
|---|
| 112 |
{$R *.DFM} |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
var |
|---|
| 116 |
homedir : string; |
|---|
| 117 |
emptyNode : TTreeNode; |
|---|
| 118 |
wsNode : TTreeNode; |
|---|
| 119 |
workspace : TWorkspace; |
|---|
| 120 |
lastWorkspace : string; |
|---|
| 121 |
sourceFileClicked : string; |
|---|
| 122 |
stayOnTop : boolean; |
|---|
| 123 |
lastProjectClicked : TProject; |
|---|
| 124 |
defaultWs : TWorkspaceCfg; { default Workspace Config } |
|---|
| 125 |
defaultProj : TProjectCfg; { default Project Config } |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
procedure UpdateProjectPopup; forward; |
|---|
| 129 |
procedure LoadConfig; forward; |
|---|
| 130 |
procedure SaveConfig ; forward; |
|---|
| 131 |
|
|---|
| 132 |
procedure TMainForm.ApplicationMessage(var Msg: TMsg; var Handled: Boolean); |
|---|
| 133 |
var |
|---|
| 134 |
xp, yp : Integer; |
|---|
| 135 |
begin |
|---|
| 136 |
case Msg.Message of |
|---|
| 137 |
WM_MOVE, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED : begin |
|---|
| 138 |
xp := LoWord( Msg.lParam ); |
|---|
| 139 |
yp := LoWord( Msg.lParam ); |
|---|
| 140 |
|
|---|
| 141 |
if xp < 20 then xp := 0; |
|---|
| 142 |
if yp < 20 then yp := 0; |
|---|
| 143 |
|
|---|
| 144 |
SetWindowPos( Self.Handle, 0, |
|---|
| 145 |
xp , yp , mainForm.Width, mainForm.Height, |
|---|
| 146 |
SWP_NOZORDER + SWP_NOSIZE ); |
|---|
| 147 |
handled:=true; |
|---|
| 148 |
end; |
|---|
| 149 |
end; |
|---|
| 150 |
end; |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
procedure TmainForm.FormCreate(Sender: TObject); |
|---|
| 154 |
//var nx,ny : Integer; |
|---|
| 155 |
begin |
|---|
| 156 |
homedir := SysUtils.ExtractFilePath( ParamStr(0) ); |
|---|
| 157 |
Application.OnMessage := MainForm.ApplicationMessage; |
|---|
| 158 |
{ |
|---|
| 159 |
nx := Screen.Width - ( Self.Width + 1 ); |
|---|
| 160 |
ny := Screen.Height - ( Self.Height+1 ); |
|---|
| 161 |
SetWindowPos( Self.Handle, 0, nx, ny, 0, 0, SWP_NOSIZE or SWP_NOZORDER ); |
|---|
| 162 |
} |
|---|
| 163 |
LoadConfig; |
|---|
| 164 |
UpdateTreeview(); |
|---|
| 165 |
end; |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
function ConfigFilename() : string; |
|---|
| 172 |
begin |
|---|
| 173 |
Result := homedir + '.cfgx' ; |
|---|
| 174 |
end; |
|---|
| 175 |
|
|---|
| 176 |
function SelProject : boolean; |
|---|
| 177 |
begin |
|---|
| 178 |
result:= Assigned( lastProjectClicked ); |
|---|
| 179 |
end; |
|---|
| 180 |
|
|---|
| 181 |
function CurrentProject : TProject; |
|---|
| 182 |
begin |
|---|
| 183 |
result:= lastProjectClicked; |
|---|
| 184 |
end; |
|---|
| 185 |
|
|---|
| 186 |
procedure SetCurrentProject(proj :TProject ); |
|---|
| 187 |
begin |
|---|
| 188 |
lastProjectClicked := proj; |
|---|
| 189 |
UpdateProjectPopup; |
|---|
| 190 |
end; |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
procedure SetOnTop( b : boolean ); |
|---|
| 194 |
begin |
|---|
| 195 |
if b then |
|---|
| 196 |
SetWindowPos( mainForm.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE) |
|---|
| 197 |
else |
|---|
| 198 |
SetWindowPos( mainForm.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE ); |
|---|
| 199 |
StayOnTop := b; |
|---|
| 200 |
mainForm.StayonTopMenu.Checked := b; |
|---|
| 201 |
end; |
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
procedure TMainForm.ToggleMenuItem(Sender: TObject); |
|---|
| 205 |
var |
|---|
| 206 |
menu : TMenuItem; |
|---|
| 207 |
N : Integer; |
|---|
| 208 |
begin |
|---|
| 209 |
if not SelProject then Exit; |
|---|
| 210 |
menu := TMenuItem( Sender ); |
|---|
| 211 |
N := VersionSubmenu.IndexOf( menu ); |
|---|
| 212 |
if N<0 then Exit; |
|---|
| 213 |
menu.Checked := not menu.Checked; |
|---|
| 214 |
if menu.Checked then |
|---|
| 215 |
CurrentProject.enableVersion( N ) |
|---|
| 216 |
else |
|---|
| 217 |
CurrentProject.disableVersion( N ); |
|---|
| 218 |
|
|---|
| 219 |
CurrentProject.Save; |
|---|
| 220 |
end; |
|---|
| 221 |
|
|---|
| 222 |
|
|---|
| 223 |
procedure UpdateProjectPopup; |
|---|
| 224 |
var |
|---|
| 225 |
vmenu, item : TMenuItem; |
|---|
| 226 |
proj : TProject; |
|---|
| 227 |
N : Integer; |
|---|
| 228 |
ver : string; |
|---|
| 229 |
begin |
|---|
| 230 |
vmenu := mainForm.versionSubmenu; |
|---|
| 231 |
proj := CurrentProject; |
|---|
| 232 |
|
|---|
| 233 |
for N:=vmenu.Count-1 downto 0 do |
|---|
| 234 |
begin |
|---|
| 235 |
item := vmenu[N]; |
|---|
| 236 |
vmenu.Remove( item ); |
|---|
| 237 |
item.Free; |
|---|
| 238 |
end; |
|---|
| 239 |
|
|---|
| 240 |
vmenu.Enabled := SelProject and (proj.config.versions.Count > 0) ; |
|---|
| 241 |
if not SelProject then Exit; |
|---|
| 242 |
for N:=0 to proj.config.versions.Count-1 do |
|---|
| 243 |
begin |
|---|
| 244 |
ver := proj.config.versions[N]; |
|---|
| 245 |
item:=NewItem( ver, 0, proj.CheckVersion(N), true, mainForm.ToggleMenuItem, 0, '' ); |
|---|
| 246 |
vmenu.Add( item ); |
|---|
| 247 |
end; |
|---|
| 248 |
end; |
|---|
| 249 |
|
|---|
| 250 |
{ |
|---|
| 251 |
NewSubMenu(const ACaption: string; hCtx: Word; const AName: string; Items: array of TMenuItem; AEnabled: Boolean) |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
procedure LoadConfig; |
|---|
| 256 |
var |
|---|
| 257 |
xml : Node; |
|---|
| 258 |
str : string; |
|---|
| 259 |
top : boolean; |
|---|
| 260 |
begin |
|---|
| 261 |
if FileExists( ConfigFilename() ) then begin |
|---|
| 262 |
xml := LoadXML( ConfigFilename() ); |
|---|
| 263 |
if not Assigned( xml ) then Exit; |
|---|
| 264 |
|
|---|
| 265 |
lastWorkspace := xml.FindText( 'LastWorkspace' ); |
|---|
| 266 |
|
|---|
| 267 |
str := xml.FindText( 'StayOnTop' ); |
|---|
| 268 |
top := LowerCase(str) = 'true' ; |
|---|
| 269 |
SetOnTop( top ); |
|---|
| 270 |
xml.Free; |
|---|
| 271 |
end; |
|---|
| 272 |
|
|---|
| 273 |
if FileExists( lastWorkspace ) and mainForm.CloseWorkspace then begin |
|---|
| 274 |
workspace := LoadWorkspace( lastWorkspace ); |
|---|
| 275 |
if not Assigned( workspace ) then Exit; |
|---|
| 276 |
with mainForm do UpdatetreeView; |
|---|
| 277 |
end; |
|---|
| 278 |
end; |
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
procedure SaveConfig ; |
|---|
| 282 |
var |
|---|
| 283 |
xml : Node; |
|---|
| 284 |
begin |
|---|
| 285 |
xml := Node.Create( 'Defaults' ); |
|---|
| 286 |
xml.Add( 'LastWorkspace', lastWorkspace ); |
|---|
| 287 |
xml.AddBool( 'StayOnTop', StayOnTop ); |
|---|
| 288 |
SaveXML( xml, ConfigFilename() ); |
|---|
| 289 |
xml.Free; |
|---|
| 290 |
end; |
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
function SaveProject( proj: TProject ) : boolean; |
|---|
| 294 |
begin |
|---|
| 295 |
if FileExists(proj.filename) then begin |
|---|
| 296 |
proj.Save; |
|---|
| 297 |
result:= true; |
|---|
| 298 |
Exit; |
|---|
| 299 |
end; |
|---|
| 300 |
|
|---|
| 301 |
Result:= false; |
|---|
| 302 |
with mainForm do begin |
|---|
| 303 |
SaveDialog.Filter:= 'Project Files(*.prx)|*.prx'; |
|---|
| 304 |
SaveDialog.InitialDir := proj.basepath; |
|---|
| 305 |
SaveDialog.Filename := proj.name ; |
|---|
| 306 |
SaveDialog.Options := [ofHideReadOnly,ofPathMustExist,ofNoReadOnlyReturn]; |
|---|
| 307 |
SaveDialog.Title:='Save Project File'; |
|---|
| 308 |
if not SaveDialog.Execute then Exit; |
|---|
| 309 |
proj.SaveAs( ChangeFileExt( SaveDialog.Filename, '.prx' ) ); |
|---|
| 310 |
end; |
|---|
| 311 |
result:= true; |
|---|
| 312 |
end; |
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
procedure TMainForm.CreateWorkspace ; |
|---|
| 316 |
begin |
|---|
| 317 |
if Assigned(workspace) and ( not CloseWorkspace() ) then Exit; |
|---|
| 318 |
|
|---|
| 319 |
workspace := TWorkspace.Create; |
|---|
| 320 |
defaultWS.fromXML( workspace.config.toXML ); |
|---|
| 321 |
wsConfigDlg.name.Text := ''; |
|---|
| 322 |
wsConfigDlg.defaultCheckbox.Checked := false; |
|---|
| 323 |
wsConfigDlg.LoadOptions( workspace ); |
|---|
| 324 |
if wsConfigDlg.ShowModal <> mrOk then begin |
|---|
| 325 |
workspace.Free; |
|---|
| 326 |
workspace:=nil; |
|---|
| 327 |
Exit; |
|---|
| 328 |
end; |
|---|
| 329 |
wsConfigDlg.SaveOptions( workspace ); |
|---|
| 330 |
|
|---|
| 331 |
SaveDialog.InitialDir := homedir; |
|---|
| 332 |
SaveDialog.Filter := 'Workspace files(*.wsx)|*.wsx'; |
|---|
| 333 |
SaveDialog.Options := [ofHideReadOnly,ofPathMustExist,ofNoReadOnlyReturn]; |
|---|
| 334 |
SaveDialog.Title:='Save Workspace File'; |
|---|
| 335 |
if not SaveDialog.Execute then begin |
|---|
| 336 |
workspace.Free; |
|---|
| 337 |
workspace := nil; |
|---|
| 338 |
end; |
|---|
| 339 |
|
|---|
| 340 |
workspace.SaveAs( ChangeFileExt( SaveDialog.FileName, '.wsx' ) ); |
|---|
| 341 |
|
|---|
| 342 |
lastWorkspace := workspace.filename; |
|---|
| 343 |
mainForm.UpdateTreeview; |
|---|
| 344 |
if wsConfigDlg.defaultCheckbox.Checked then begin |
|---|
| 345 |
workspace.config.fromXML( defaultWs.toXML ); |
|---|
| 346 |
end; |
|---|
| 347 |
SaveConfig; |
|---|
| 348 |
end; |
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
procedure TMainForm.EditWorkspace ; |
|---|
| 352 |
begin |
|---|
| 353 |
if not Assigned(workspace) then Exit; |
|---|
| 354 |
wsConfigDlg.defaultCheckbox.Checked :=false; |
|---|
| 355 |
wsConfigDlg.LoadOptions( workspace ); |
|---|
| 356 |
if wsConfigDlg.ShowModal <> mrOk then Exit; |
|---|
| 357 |
wsConfigDlg.SaveOptions( workspace ); |
|---|
| 358 |
SaveWorkspace(); |
|---|
| 359 |
|
|---|
| 360 |
if wsConfigDlg.defaultCheckbox.Checked then begin |
|---|
| 361 |
workspace.config.fromXML( defaultWS.toXML ); |
|---|
| 362 |
SaveConfig; |
|---|
| 363 |
end; |
|---|
| 364 |
|
|---|
| 365 |
UpdateTreeview; |
|---|
| 366 |
end; |
|---|
| 367 |
|
|---|
| 368 |
function TMainForm.CloseWorkspace : boolean; |
|---|
| 369 |
var |
|---|
| 370 |
msg : string; |
|---|
| 371 |
N : LongInt; |
|---|
| 372 |
begin |
|---|
| 373 |
Result := true; |
|---|
| 374 |
if not Assigned( workspace ) then Exit; |
|---|
| 375 |
|
|---|
| 376 |
if not workspace.saved Then begin |
|---|
| 377 |
msg := 'Save Current Workspace (' + workspace.name + ') ?'; |
|---|
| 378 |
N :=Application.MessageBox( PChar(msg) , 'Save Workspace', MB_YESNOCANCEL ); |
|---|
| 379 |
case N of |
|---|
| 380 |
IDYES : workspace.Save; |
|---|
| 381 |
|
|---|
| 382 |
IDNO : ; |
|---|
| 383 |
|
|---|
| 384 |
IDCANCEL : begin |
|---|
| 385 |
Result:=false; |
|---|
| 386 |
Exit; |
|---|
| 387 |
end; |
|---|
| 388 |
end; |
|---|
| 389 |
end; |
|---|
| 390 |
|
|---|
| 391 |
workspace.Free; |
|---|
| 392 |
workspace := nil; |
|---|
| 393 |
UpdateTreeview; |
|---|
| 394 |
Result := true; |
|---|
| 395 |
end; |
|---|
| 396 |
|
|---|
| 397 |
procedure TMainForm.SaveWorkspace; |
|---|
| 398 |
begin |
|---|
| 399 |
workspace.Save; |
|---|
| 400 |
end; |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
procedure TMainForm.SelectWorkspace ; |
|---|
| 404 |
var |
|---|
| 405 |
filename : string; |
|---|
| 406 |
dir : string; |
|---|
| 407 |
begin |
|---|
| 408 |
dir := homedir; |
|---|
| 409 |
if Assigned( workspace ) then |
|---|
| 410 |
begin |
|---|
| 411 |
dir := ExtractFilePath( workspace.filename ); |
|---|
| 412 |
if not DirectoryExists( dir ) then dir := homedir; |
|---|
| 413 |
if ( not CloseWorkspace ) then Exit; |
|---|
| 414 |
end; |
|---|
| 415 |
with( FileDialog) do begin |
|---|
| 416 |
InitialDir := dir; |
|---|
| 417 |
Filter := 'Workspace files(*.wsx)|*.wsx' ; |
|---|
| 418 |
Title := 'Load Workspace'; |
|---|
| 419 |
end; |
|---|
| 420 |
if not FileDialog.Execute then Exit; |
|---|
| 421 |
filename := FileDialog.FileName; |
|---|
| 422 |
if not FileExists( filename ) then Exit; |
|---|
| 423 |
workspace := LoadWorkspace( filename ); |
|---|
| 424 |
if not Assigned( workspace ) then Exit; |
|---|
| 425 |
lastWorkspace := workspace.filename ; |
|---|
| 426 |
SaveConfig; |
|---|
| 427 |
UpdateTreeview(); |
|---|
| 428 |
end; |
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
function EditProject( pr : TProject ) : boolean; |
|---|
| 432 |
begin |
|---|
| 433 |
Result:=false; |
|---|
| 434 |
if not Assigned( pr ) then Exit; |
|---|
| 435 |
ProjConfigDlg.projDir := pr.basepath; |
|---|
| 436 |
|
|---|
| 437 |
ProjConfigDlg.defaultCheckbox.Checked := false; |
|---|
| 438 |
ProjConfigDlg.LoadOptions( pr ); |
|---|
| 439 |
if ProjConfigDlg.ShowModal <> mrOk then Exit; |
|---|
| 440 |
|
|---|
| 441 |
if Empty(pr.filename) then begin |
|---|
| 442 |
with MainForm.SaveDialog do begin |
|---|
| 443 |
Filter := 'Project files (*.prx)|*.prx'; |
|---|
| 444 |
InitialDir := ProjConfigDlg.projectPath.Text; |
|---|
| 445 |
Title := 'Save Project File as...'; |
|---|
| 446 |
Options := [ofOverwritePrompt,ofPathMustExist,ofEnableSizing]; |
|---|
| 447 |
end; |
|---|
| 448 |
if not mainform.SaveDialog.Execute then Exit; |
|---|
| 449 |
pr.filename := ChangeFileExt( mainForm.SaveDialog.FileName, '.prx' ); |
|---|
| 450 |
end; |
|---|
| 451 |
|
|---|
| 452 |
Result:= true; |
|---|
| 453 |
ProjConfigDlg.SaveOptions( pr ); |
|---|
| 454 |
pr.Save; |
|---|
| 455 |
|
|---|
| 456 |
if ProjConfigDlg.defaultCheckbox.Checked then begin |
|---|
| 457 |
pr.config.CopyTo( defaultProj ); |
|---|
| 458 |
SaveConfig; |
|---|
| 459 |
end; |
|---|
| 460 |
|
|---|
| 461 |
end; |
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
|
|---|
| 465 |
procedure TmainForm.Quit1Click(Sender: TObject); |
|---|
| 466 |
begin |
|---|
| 467 |
if CloseWorkspace = false then Exit; |
|---|
| 468 |
Application.Terminate; |
|---|
| 469 |
end; |
|---|
| 470 |
|
|---|
| 471 |
procedure TmainForm.Settings1Click(Sender: TObject); |
|---|
| 472 |
begin |
|---|
| 473 |
EditWorkspace ; |
|---|
| 474 |
end; |
|---|
| 475 |
|
|---|
| 476 |
{ |
|---|
| 477 |
procedure TmainForm.New2Click(Sender: TObject); |
|---|
| 478 |
} |
|---|
| 479 |
|
|---|
| 480 |
function ExtractErrorMessage( line : string ) : string ; |
|---|
| 481 |
var |
|---|
| 482 |
N : Integer; |
|---|
| 483 |
begin |
|---|
| 484 |
result:= line; |
|---|
| 485 |
N := Pos( '):', line ); |
|---|
| 486 |
if N>0 then result := Copy( line, N+2, Length(line)-N ); |
|---|
| 487 |
if Length(result)>100 then result:=Copy(result,1,100 ); |
|---|
| 488 |
end; |
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 |
procedure BuildTree( pnode : TTreeNode ; sources: TSourceFiles ); |
|---|
| 492 |
var |
|---|
| 493 |
tnode, fnode, enode : TTreeNode; { title node, file node, error node } |
|---|
| 494 |
I,N : Integer; |
|---|
| 495 |
str : string; |
|---|
| 496 |
elist : TStringList; |
|---|
| 497 |
begin |
|---|
| 498 |
elist := TStringList.Create; |
|---|
| 499 |
|
|---|
| 500 |
with mainForm.treeview, sources do begin |
|---|
| 501 |
for N:= 0 to dfiles.Count-1 do begin |
|---|
| 502 |
str := ExtractFileName( dfiles[N] ); |
|---|
| 503 |
if not FileExists( dfiles[N] ) then str := str + ' (missing) '; |
|---|
| 504 |
fnode :=Items.AddChild( pnode, str ); |
|---|
| 505 |
//fnode.Hint := dfiles[N]; |
|---|
| 506 |
fnode.ImageIndex:= 3; |
|---|
| 507 |
fnode.SelectedIndex := 3 ; |
|---|
| 508 |
fnode.data := Pointer( dfiles[N] ); |
|---|
| 509 |
|
|---|
| 510 |
elist.Clear; |
|---|
| 511 |
if GetErrors( dfiles[N], elist ) then begin |
|---|
| 512 |
fnode.Text := Format( fnode.Text + ' (Errors:%d)', [elist.Count]) ; |
|---|
| 513 |
fnode.OverlayIndex := 2; |
|---|
| 514 |
for I:=0 to elist.Count-1 do begin |
|---|
| 515 |
enode :=Items.AddChild( fnode, ExtractErrorMessage( elist[I] ) ); |
|---|
| 516 |
enode.ImageIndex := 2; |
|---|
| 517 |
enode.SelectedIndex :=2; |
|---|
| 518 |
enode.data := PChar(elist[I]); |
|---|
| 519 |
end; |
|---|
| 520 |
fnode.Collapse( true ); |
|---|
| 521 |
end; |
|---|
| 522 |
end; |
|---|
| 523 |
|
|---|
| 524 |
N:= objfiles.Count + libfiles.Count; |
|---|
| 525 |
if N<1 then Exit; |
|---|
| 526 |
tnode := Items.AddChild( pnode, ObjHeaderText ); |
|---|
| 527 |
tnode.ImageIndex := 1; |
|---|
| 528 |
tnode.SelectedIndex := 1; |
|---|
| 529 |
for N:= 0 to objfiles.Count-1 do begin |
|---|
| 530 |
str := ExtractFileName( objfiles[N] ); |
|---|
| 531 |
if not FileExists( objfiles[N] ) then str := str + ' (missing) '; |
|---|
| 532 |
fnode :=Items.AddChild( tnode, str ); |
|---|
| 533 |
//fnode.Hint := objfiles[N]; |
|---|
| 534 |
fnode.data := Pointer( objfiles[N] ); |
|---|
| 535 |
fnode.ImageIndex := 5; |
|---|
| 536 |
fnode.SelectedIndex :=5 ; |
|---|
| 537 |
end; |
|---|
| 538 |
for N:= 0 to libfiles.Count-1 do begin |
|---|
| 539 |
str := ExtractFileName( libfiles[N] ); |
|---|
| 540 |
if not FileExists( libfiles[N] ) then str := str + ' (missing) '; |
|---|
| 541 |
fnode :=Items.AddChild( tnode, str ); |
|---|
| 542 |
//fnode.Hint := libfiles[N]; |
|---|
| 543 |
fnode.data := Pointer( libfiles[N] ); |
|---|
| 544 |
fnode.ImageIndex := 5; |
|---|
| 545 |
fnode.SelectedIndex := 5; |
|---|
| 546 |
end; |
|---|
| 547 |
tnode.Collapse( true ); |
|---|
| 548 |
end; |
|---|
| 549 |
|
|---|
| 550 |
|
|---|
| 551 |
end; |
|---|
| 552 |
|
|---|
| 553 |
procedure TMainForm.UpdateTreeview(); |
|---|
| 554 |
var |
|---|
| 555 |
N : Integer; |
|---|
| 556 |
proj : TProject; |
|---|
| 557 |
prjnode: TTreeNode; |
|---|
| 558 |
title, name : string; |
|---|
| 559 |
begin |
|---|
| 560 |
|
|---|
| 561 |
if not Assigned( workspace ) then begin |
|---|
| 562 |
SaveAll1.Enabled := false; |
|---|
| 563 |
Settings1.Enabled := false; |
|---|
| 564 |
Save1.Enabled := false; |
|---|
| 565 |
Close1.Enabled := false; |
|---|
| 566 |
|
|---|
| 567 |
treeview.Items.BeginUpdate; |
|---|
| 568 |
treeview.items.Clear; |
|---|
| 569 |
emptyNode := treeview.Items.Add( nil, 'No Workspace Loaded' ); |
|---|
| 570 |
emptyNode.ImageIndex := -1; |
|---|
| 571 |
emptyNode.SelectedIndex := -1; |
|---|
| 572 |
treeview.items.EndUpdate; |
|---|
| 573 |
Exit; |
|---|
| 574 |
end; |
|---|
| 575 |
|
|---|
| 576 |
SaveAll1.Enabled := true; |
|---|
| 577 |
Settings1.Enabled := true; |
|---|
| 578 |
Save1.Enabled := true; |
|---|
| 579 |
Close1.Enabled := true; |
|---|
| 580 |
|
|---|
| 581 |
title := 'Workspace : ' + workspace.name ; |
|---|
| 582 |
title := Format( title, [ workspace.projects.Count ] ); |
|---|
| 583 |
|
|---|
| 584 |
treeView.Items.BeginUpdate; |
|---|
| 585 |
treeview.items.Clear; |
|---|
| 586 |
wsNode := treeview.Items.Add( nil, title ); |
|---|
| 587 |
wsNode.ImageIndex := 0; |
|---|
| 588 |
wsNode.SelectedIndex := 0; |
|---|
| 589 |
wsNode.Data := workspace; |
|---|
| 590 |
|
|---|
| 591 |
for N:= 0 to workspace.projects.Count-1 do |
|---|
| 592 |
begin |
|---|
| 593 |
proj := workspace.projects[N]; |
|---|
| 594 |
title := 'Project : ' + proj.name ; |
|---|
| 595 |
prjnode := treeview.Items.AddChild( wsNode, title ); |
|---|
| 596 |
prjnode.data := proj; |
|---|
| 597 |
prjnode.ImageIndex := 1; |
|---|
| 598 |
prjnode.SelectedIndex := 1; |
|---|
| 599 |
BuildTree( prjnode, proj.sources ); |
|---|
| 600 |
if proj = CurrentProject then prjnode.Expand( true ); |
|---|
| 601 |
end; |
|---|
| 602 |
|
|---|
| 603 |
for N:= 0 to workspace.failed.Count-1 do begin |
|---|
| 604 |
name := workspace.failed[N]; |
|---|
| 605 |
title := ExtractFileName( name ); |
|---|
| 606 |
title := ChangeFileExt( title, '' ) + ' (failed to load)'; |
|---|
| 607 |
prjnode := treeview.Items.AddChild( wsNode, title ); |
|---|
| 608 |
prjnode.ImageIndex := 1; |
|---|
| 609 |
prjnode.SelectedIndex := 1; |
|---|
| 610 |
prjnode.data := nil; |
|---|
| 611 |
end; |
|---|
| 612 |
|
|---|
| 613 |
wsNode.Expanded := True; |
|---|
| 614 |
treeview.items.EndUpdate; |
|---|
| 615 |
end; |
|---|
| 616 |
|
|---|
| 617 |
|
|---|
| 618 |
|
|---|
| 619 |
procedure TmainForm.New1Click(Sender: TObject); |
|---|
| 620 |
begin |
|---|
| 621 |
CreateWorkspace(); |
|---|
| 622 |
end; |
|---|
| 623 |
|
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 |
|
|---|
| 627 |
procedure TmainForm.Load1Click(Sender: TObject); |
|---|
| 628 |
begin |
|---|
| 629 |
if not CloseWorkspace then Exit; |
|---|
| 630 |
SelectWorkspace; |
|---|
| 631 |
end; |
|---|
| 632 |
|
|---|
| 633 |
procedure TmainForm.Close1Click(Sender: TObject); |
|---|
| 634 |
begin |
|---|
| 635 |
CloseWorkspace; |
|---|
| 636 |
lastWorkspace := ''; |
|---|
| 637 |
SaveConfig; |
|---|
| 638 |
end; |
|---|
| 639 |
|
|---|
| 640 |
|
|---|
| 641 |
|
|---|
| 642 |
|
|---|
| 643 |
|
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 |
procedure TmainForm.treeViewMouseDown(Sender: TObject; |
|---|
| 647 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
|---|
| 648 |
var |
|---|
| 649 |
node : TTreeNode; |
|---|
| 650 |
canEdit : boolean; |
|---|
| 651 |
begin |
|---|
| 652 |
{ workspace must be loaded, right clicks only } |
|---|
| 653 |
if (not Assigned(workspace)) or (Button <> mbRight) then Exit; |
|---|
| 654 |
sourceFileClicked := ''; |
|---|
| 655 |
SetCurrentProject( nil ); |
|---|
| 656 |
|
|---|
| 657 |
node := treeview.GetNodeAt( X, Y ); |
|---|
| 658 |
if not Assigned( node ) then Exit; |
|---|
| 659 |
treeview.Selected := node; |
|---|
| 660 |
|
|---|
| 661 |
{ user clicks the workspace } |
|---|
| 662 |
if node = wsNode then begin |
|---|
| 663 |
SetCurrentProject( nil ); |
|---|
| 664 |
with( Mouse.CursorPos ) do WorkspacePopup.Popup( X, Y ); |
|---|
| 665 |
Exit; |
|---|
| 666 |
end; |
|---|
| 667 |
|
|---|
| 668 |
{ User clicks a project } |
|---|
| 669 |
if node.Level=1 then begin |
|---|
| 670 |
SetCurrentProject( node.Data ); |
|---|
| 671 |
if not Assigned(Node.data) then Exit; |
|---|
| 672 |
FullBuild1.Checked := CurrentProject.fullbuild; |
|---|
| 673 |
with( Mouse.CursorPos ) do ProjectPopup.Popup( X, Y ); |
|---|
| 674 |
Exit; |
|---|
| 675 |
end; |
|---|
| 676 |
|
|---|
| 677 |
{ user clicks a source file } |
|---|
| 678 |
if node.level = 2 then begin |
|---|
| 679 |
SetCurrentProject( node.parent.data ); |
|---|
| 680 |
|
|---|
| 681 |
if node.text = ObjHeaderText then begin |
|---|
| 682 |
{ TODO Add Popup here } |
|---|
| 683 |
Exit; |
|---|
| 684 |
end; |
|---|
| 685 |
sourceFileClicked := string( node.data ); |
|---|
| 686 |
canEdit := FileExists( sourceFileClicked ); |
|---|
| 687 |
with SourcePopup do |
|---|
| 688 |
begin |
|---|
| 689 |
Compile1.Visible := canEdit; |
|---|
| 690 |
Edit1.Visible := canEdit; |
|---|
| 691 |
Remove1.Visible := true; |
|---|
| 692 |
end; |
|---|
| 693 |
with Mouse.CursorPos do SourcePopup.Popup( X, Y ); |
|---|
| 694 |
Exit; |
|---|
| 695 |
end; |
|---|
| 696 |
|
|---|
| 697 |
{ User clicks an Object file } |
|---|
| 698 |
if (node.Level = 3) and (node.parent.text = ObjHeaderText) then begin |
|---|
| 699 |
SetCurrentProject( TProject(node.parent.parent.data) ); |
|---|
| 700 |
sourceFileClicked := string( node.data ); |
|---|
| 701 |
with SourcePopup do |
|---|
| 702 |
begin |
|---|
| 703 |
Compile1.Visible := false; |
|---|
| 704 |
Edit1.Visible := false; |
|---|
| 705 |
Remove1.Visible := true; |
|---|
| 706 |
end; |
|---|
| 707 |
with Mouse.CursorPos do SourcePopup.Popup( X, Y ); |
|---|
| 708 |
end; |
|---|
| 709 |
|
|---|
| 710 |
{ user clicks a Source File Error } |
|---|
| 711 |
if (node.Level = 3) and (string(node.data) = ErrorHeaderText) then |
|---|
| 712 |
begin |
|---|
| 713 |
with SourcePopup do |
|---|
| 714 |
begin |
|---|
| 715 |
Compile1.Visible := false; |
|---|
| 716 |
Edit1.Visible := true; |
|---|
| 717 |
Remove1.Visible := true; |
|---|
| 718 |
end; |
|---|
| 719 |
with Mouse.CursorPos do SourcePopup.Popup( X, Y ); |
|---|
| 720 |
end; |
|---|
| 721 |
end; |
|---|
| 722 |
|
|---|
| 723 |
|
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 |
|
|---|
| 727 |
procedure ExtractErrorInfo( line : string ; var fname : string; var lineno : Integer ); |
|---|
| 728 |
var |
|---|
| 729 |
num : string; |
|---|
| 730 |
lparen, rparen : Integer; |
|---|
| 731 |
|
|---|
| 732 |
begin |
|---|
| 733 |
line := Trim( line ); |
|---|
| 734 |
lineno := -1; |
|---|
| 735 |
if Length( line ) < 1 then Exit; // don't add blanks |
|---|
| 736 |
lparen := Pos( '(', line ); |
|---|
| 737 |
rparen := Pos( ')', line ); |
|---|
| 738 |
if (lparen<1) or (rparen<1) or (lparen>rparen) then Exit; |
|---|
| 739 |
num := Copy( line, lparen+1, rparen-lparen-1 ); |
|---|
| 740 |
MyUtils.ParseInt( num, lineno ) ; |
|---|
| 741 |
fname := Copy( line, 1, lparen-1 ); |
|---|
| 742 |
end; |
|---|
| 743 |
|
|---|
| 744 |
|
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 |
procedure TmainForm.treeViewDblClick(Sender: TObject); |
|---|
| 750 |
var |
|---|
| 751 |
node :TTreeNode; |
|---|
| 752 |
lineno : Integer; |
|---|
| 753 |
line, fname : string; |
|---|
| 754 |
begin |
|---|
| 755 |
if not Assigned( workspace ) then Exit; |
|---|
| 756 |
|
|---|
| 757 |
node := treeview.Selected; |
|---|
| 758 |
if not Assigned( node ) then Exit; |
|---|
| 759 |
if node.level = 2 then |
|---|
| 760 |
begin |
|---|
| 761 |
if node.Text = ObjHeaderText then Exit; |
|---|
| 762 |
sourceFileClicked := string(node.Data); |
|---|
| 763 |
workspace.EditFile( sourceFileClicked, -1 ); |
|---|
| 764 |
//Self.WindowState := wsMinimized; |
|---|
| 765 |
Exit; |
|---|
| 766 |
end; |
|---|
| 767 |
|
|---|
| 768 |
{ user clicks a File } |
|---|
| 769 |
if (node.Level = 3) and (node.parent.text <> ObjHeaderText) then |
|---|
| 770 |
begin |
|---|
| 771 |
sourceFileClicked := string(node.parent.data); |
|---|
| 772 |
SetCurrentProject( TProject( node.parent.parent.data ) ); |
|---|
| 773 |
line := PChar( node.data ); |
|---|
| 774 |
ExtractErrorInfo( line, fname, lineno ); |
|---|
| 775 |
if not FileExists( fname ) then fname := sourceFileClicked; |
|---|
| 776 |
workspace.EditFile( fname, lineno ); |
|---|
| 777 |
//Self.WindowState := wsMinimized; |
|---|
| 778 |
end; |
|---|
| 779 |
end; |
|---|
| 780 |
|
|---|
| 781 |
|
|---|
| 782 |
procedure TmainForm.PMNewProjectClick(Sender: TObject); |
|---|
| 783 |
var |
|---|
| 784 |
proj : TProject; |
|---|
| 785 |
begin |
|---|
| 786 |
proj := TProject.Create; |
|---|
| 787 |
proj.basepath := homedir; |
|---|
| 788 |
defaultProj.CopyTo( proj.config ); |
|---|
| 789 |
if EditProject( proj ) then begin |
|---|
| 790 |
workspace.Add( proj ); |
|---|
| 791 |
SaveWorkspace; |
|---|
| 792 |
UpdateTreeview; |
|---|
| 793 |
end |
|---|
| 794 |
else proj.Free; |
|---|
| 795 |
end; |
|---|
| 796 |
|
|---|
| 797 |
|
|---|
| 798 |
procedure TmainForm.Settings2Click(Sender: TObject); |
|---|
| 799 |
var |
|---|
| 800 |
proj : TProject; |
|---|
| 801 |
begin |
|---|
| 802 |
proj := treeview.Selected.Data; |
|---|
| 803 |
if EditProject( proj ) then proj.Save; |
|---|
| 804 |
UpdateTreeview; |
|---|
| 805 |
end; |
|---|
| 806 |
|
|---|
| 807 |
procedure TmainForm.Save1Click(Sender: TObject); |
|---|
| 808 |
begin |
|---|
| 809 |
if not Assigned(workspace) then Exit; |
|---|
| 810 |
workspace.Save; |
|---|
| 811 |
end; |
|---|
| 812 |
|
|---|
| 813 |
procedure TmainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
|---|
| 814 |
begin |
|---|
| 815 |
CanClose := CloseWorkspace ; |
|---|
| 816 |
end; |
|---|
| 817 |
|
|---|
| 818 |
procedure TmainForm.PMSettingsClick(Sender: TObject); |
|---|
| 819 |
begin |
|---|
| 820 |
if not Assigned( workspace ) then Exit; |
|---|
| 821 |
EditWorkspace; |
|---|
| 822 |
end; |
|---|
| 823 |
|
|---|
| 824 |
procedure TmainForm.PMCloseClick(Sender: TObject); |
|---|
| 825 |
begin |
|---|
| 826 |
if not CloseWorkspace then Exit; |
|---|
| 827 |
lastWorkspace := ''; |
|---|
| 828 |
SaveConfig; |
|---|
| 829 |
end; |
|---|
| 830 |
|
|---|
| 831 |
procedure TmainForm.PMLoadProjectClick(Sender: TObject); |
|---|
| 832 |
var |
|---|
| 833 |
proj : TProject; |
|---|
| 834 |
filename : string; |
|---|
| 835 |
begin |
|---|
| 836 |
if not Assigned( workspace ) then Exit; |
|---|
| 837 |
with( FileDialog ) do |
|---|
| 838 |
begin |
|---|
| 839 |
InitialDir := ExtractFilePath( workspace.filename ); |
|---|
| 840 |
FileName:= ''; |
|---|
| 841 |
Filter := 'Project files(*.prx)|*.prx' ; |
|---|
| 842 |
Title := 'Add Project'; |
|---|
| 843 |
end; |
|---|
| 844 |
if not FileDialog.Execute then Exit; |
|---|
| 845 |
filename := FileDialog.FileName; |
|---|
| 846 |
if not FileExists( filename ) then Exit; |
|---|
| 847 |
proj := workspace.FindProject( filename ); |
|---|
| 848 |
if Assigned( proj ) then Exit; |
|---|
| 849 |
proj := LoadProject( filename ); |
|---|
| 850 |
if not Assigned( proj ) then Exit; |
|---|
| 851 |
workspace.Add( proj ); |
|---|
| 852 |
workspace.Save; |
|---|
| 853 |
//workspace.saved := false; |
|---|
| 854 |
UpdateTreeview(); |
|---|
| 855 |
end; |
|---|
| 856 |
|
|---|
| 857 |
procedure TmainForm.Close2Click(Sender: TObject); |
|---|
| 858 |
var |
|---|
| 859 |
node : TTreeNode; |
|---|
| 860 |
proj : TProject; |
|---|
| 861 |
begin |
|---|
| 862 |
node := treeview.Selected; |
|---|
| 863 |
if node.Parent <> wsNode then Exit; |
|---|
| 864 |
proj := node.Data; |
|---|
| 865 |
if workspace.projects.IndexOf( proj ) < 0 then Exit; |
|---|
| 866 |
workspace.projects.Remove( proj ); |
|---|
| 867 |
workspace.Save; |
|---|
| 868 |
proj.Free; |
|---|
| 869 |
UpdateTreeview; |
|---|
| 870 |
end; |
|---|
| 871 |
|
|---|
| 872 |
procedure TmainForm.Add1Click(Sender: TObject); |
|---|
| 873 |
var |
|---|
| 874 |
proj :TProject; |
|---|
| 875 |
node :TTreeNode; |
|---|
| 876 |
N : Integer; |
|---|
| 877 |
begin |
|---|
| 878 |
node := treeview.Selected; |
|---|
| 879 |
if not Assigned( node ) then Exit; |
|---|
| 880 |
proj := node.Data; |
|---|
| 881 |
FileDialog.FileName := ''; |
|---|
| 882 |
FileDialog.InitialDir := proj.basepath; |
|---|
| 883 |
FileDialog.DefaultExt := ''; |
|---|
| 884 |
FileDialog.Options := []; |
|---|
| 885 |
FileDialog.Title := 'Add Files to Project'; |
|---|
| 886 |
FileDialog.Filter := 'D Source Files|*.d|OBJ Files|*.obj|LIB Files|*.lib'; |
|---|
| 887 |
FileDialog.Options := [ofAllowMultiSelect , ofPathMustExist , ofCreatePrompt, ofHideReadOnly]; |
|---|
| 888 |
|
|---|
| 889 |
if not FileDialog.Execute then Exit; |
|---|
| 890 |
with FileDialog do |
|---|
| 891 |
for N:= 0 to FileDialog.Files.Count-1 do begin |
|---|
| 892 |
if Not proj.sources.HasFile( Files[N] ) then proj.Add( Files[N] ); |
|---|
| 893 |
end; |
|---|
| 894 |
proj.Save; |
|---|
| 895 |
UpdateTreeview; |
|---|
| 896 |
end; |
|---|
| 897 |
|
|---|
| 898 |
|
|---|
| 899 |
|
|---|
| 900 |
procedure TmainForm.SaveAll1Click(Sender: TObject); |
|---|
| 901 |
var |
|---|
| 902 |
N : Integer; |
|---|
| 903 |
proj : TProject; |
|---|
| 904 |
begin |
|---|
| 905 |
SaveWorkspace; |
|---|
| 906 |
for N:=0 to workspace.projects.Count-1 do begin |
|---|
| 907 |
proj:= workspace.projects[N]; |
|---|
| 908 |
proj.Save; |
|---|
| 909 |
end; |
|---|
| 910 |
end; |
|---|
| 911 |
|
|---|
| 912 |
|
|---|
| 913 |
procedure TmainForm.Remove1Click(Sender: TObject); |
|---|
| 914 |
begin |
|---|
| 915 |
if not SelProject then Exit; |
|---|
| 916 |
if Empty( sourceFileClicked ) then Exit; |
|---|
| 917 |
with CurrentProject do |
|---|
| 918 |
if not sources.HasFile( sourceFileClicked ) then Exit; |
|---|
| 919 |
|
|---|
| 920 |
if Application.MessageBox( PChar('Remove file from Project? (file will not be deleted)'), |
|---|
| 921 |
'Confirm Remove', MB_YESNO ) <> ID_YES then Exit; |
|---|
| 922 |
|
|---|
| 923 |
CurrentProject.sources.Remove( sourceFileClicked ); |
|---|
| 924 |
SaveProject( CurrentProject ); |
|---|
| 925 |
UpdateTreeview; |
|---|
| 926 |
sourceFileClicked := ''; |
|---|
| 927 |
end; |
|---|
| 928 |
|
|---|
| 929 |
|
|---|
| 930 |
|
|---|
| 931 |
procedure TmainForm.Compile1Click(Sender: TObject); |
|---|
| 932 |
var |
|---|
| 933 |
msg : string; |
|---|
| 934 |
destfile : string; |
|---|
| 935 |
begin |
|---|
| 936 |
if not Assigned( workspace ) then Exit; |
|---|
| 937 |
if not SelProject then exit; |
|---|
| 938 |
if Empty( sourceFileClicked ) then Exit; |
|---|
| 939 |
|
|---|
| 940 |
if not FileExists(sourceFileClicked) then |
|---|
| 941 |
begin |
|---|
| 942 |
msg := 'File ' + sourceFileClicked + ' could not be found'; |
|---|
| 943 |
Application.MessageBox( PChar( msg ), 'File not found', MB_OK ); |
|---|
| 944 |
Exit; |
|---|
| 945 |
end; |
|---|
| 946 |
|
|---|
| 947 |
if not FileExists(workspace.config.compiler) then |
|---|
| 948 |
begin |
|---|
| 949 |
msg := 'Compiler ' + workspace.config.compiler + ' could not be found'; |
|---|
| 950 |
Application.MessageBox( PChar( msg ), 'D Compiler not found', MB_OK ); |
|---|
| 951 |
Exit; |
|---|
| 952 |
end; |
|---|
| 953 |
|
|---|
| 954 |
destfile := CurrentProject.GetResultFile( sourcefileclicked ); |
|---|
| 955 |
workspace.CompileFile( CurrentProject, sourceFileClicked ); |
|---|
| 956 |
UpdateTreeview; |
|---|
| 957 |
StatusBar.SimpleText:=''; |
|---|
| 958 |
StatusBar.SimplePanel := true; |
|---|
| 959 |
if FileExists( destfile ) then StatusBar.SimpleText := 'Compile successful'; |
|---|
| 960 |
end; |
|---|
| 961 |
|
|---|
| 962 |
procedure TmainForm.PMSaveClick(Sender: TObject); |
|---|
| 963 |
begin |
|---|
| 964 |
SaveWorkspace; |
|---|
| 965 |
end; |
|---|
| 966 |
|
|---|
| 967 |
procedure TmainForm.Edit1Click(Sender: TObject); |
|---|
| 968 |
var |
|---|
| 969 |
msg : string; |
|---|
| 970 |
begin |
|---|
| 971 |
if not Assigned( workspace ) then Exit; |
|---|
| 972 |
if not SelProject then Exit; |
|---|
| 973 |
if FileExists(sourceFileClicked) then |
|---|
| 974 |
begin |
|---|
| 975 |
workspace.EditFile( sourceFileClicked, -1 ); |
|---|
| 976 |
//Self.WindowState := wsMinimized; |
|---|
| 977 |
end |
|---|
| 978 |
else begin |
|---|
| 979 |
msg := 'File ' + sourceFileClicked + ' could not be found.'; |
|---|
| 980 |
Application.MessageBox( PChar(msg), 'File not found', MB_OK ) |
|---|
| 981 |
end; |
|---|
| 982 |
end; |
|---|
| 983 |
|
|---|
| 984 |
|
|---|
| 985 |
procedure TmainForm.SaveProject1Click(Sender: TObject); |
|---|
| 986 |
begin |
|---|
| 987 |
if not Assigned(workspace) then Exit; |
|---|
| 988 |
if not SelProject then Exit; |
|---|
| 989 |
SaveProject( CurrentProject ); |
|---|
| 990 |
end; |
|---|
| 991 |
|
|---|
| 992 |
procedure TmainForm.BuildMenuClick(Sender: TObject); |
|---|
| 993 |
begin |
|---|
| 994 |
if not Assigned( workspace ) then Exit; |
|---|
| 995 |
if not SelProject then Exit; |
|---|
| 996 |
workspace.BuildProjectEXE( CurrentProject ) ; |
|---|
| 997 |
UpdateTreeview; |
|---|
| 998 |
OutputDlg.Listbox.Items.Clear; |
|---|
| 999 |
OutputDlg.ShowOutput( CurrentProject, workspace.output, 'Build EXE Results' ); |
|---|
| 1000 |
end; |
|---|
| 1001 |
|
|---|
| 1002 |
procedure TmainForm.BuildSubMenuClick(Sender: TObject); |
|---|
| 1003 |
begin |
|---|
| 1004 |
if not Assigned( workspace ) then Exit; |
|---|
| 1005 |
if not SelProject then Exit; |
|---|
| 1006 |
workspace.BuildProjectEXE( CurrentProject ); |
|---|
| 1007 |
UpdateTreeview; |
|---|
| 1008 |
OutputDlg.Listbox.Items.Clear; |
|---|
| 1009 |
OutputDlg.ShowOutput( CurrentProject, workspace.output, 'Build EXE Results' ); |
|---|
| 1010 |
end; |
|---|
| 1011 |
|
|---|
| 1012 |
procedure TmainForm.BuildLibMenuClick(Sender: TObject); |
|---|
| 1013 |
begin |
|---|
| 1014 |
if not SelProject then Exit; |
|---|
| 1015 |
if FileExists( CurrentProject.LibName ) then DeleteFile( CurrentProject.LibName ); |
|---|
| 1016 |
workspace.BuildProjectLIB( CurrentProject ); |
|---|
| 1017 |
UpdateTreeview; |
|---|
| 1018 |
OutputDlg.Listbox.Items.Clear; |
|---|
| 1019 |
OutputDlg.ShowOutput( CurrentProject, workspace.output, 'Build LIB Results' ); |
|---|
| 1020 |
end; |
|---|
| 1021 |
|
|---|
| 1022 |
procedure TmainForm.Refresh1Click(Sender: TObject); |
|---|
| 1023 |
begin |
|---|
| 1024 |
UpdateTreeview; |
|---|
| 1025 |
end; |
|---|
| 1026 |
|
|---|
| 1027 |
|
|---|
| 1028 |
|
|---|
| 1029 |
procedure TmainForm.Build1Click(Sender: TObject); |
|---|
| 1030 |
begin |
|---|
| 1031 |
if not SelProject then Exit; |
|---|
| 1032 |
if FileExists( CurrentProject.ExeName ) then DeleteFile( CurrentProject.ExeName ); |
|---|
| 1033 |
workspace.BuildProjectEXE( CurrentProject ) ; |
|---|
| 1034 |
UpdateTreeview; |
|---|
| 1035 |
OutputDlg.Listbox.Clear; |
|---|
| 1036 |
OutputDlg.ShowOutput( CurrentProject, workspace.output, 'Build EXE Results' ); |
|---|
| 1037 |
end; |
|---|
| 1038 |
|
|---|
| 1039 |
|
|---|
| 1040 |
|
|---|
| 1041 |
procedure TmainForm.About1Click(Sender: TObject); |
|---|
| 1042 |
begin |
|---|
| 1043 |
Application.MessageBox( PChar( 'DManager Beta (c) David Medlock, 2005' ), 'About', 0 ); |
|---|
| 1044 |
end; |
|---|
| 1045 |
|
|---|
| 1046 |
procedure TmainForm.FullBuild1Click(Sender: TObject); |
|---|
| 1047 |
begin |
|---|
| 1048 |
if not SelProject then Exit; |
|---|
| 1049 |
CurrentProject.fullbuild := not FullBuild1.Checked; |
|---|
| 1050 |
FullBuild1.Checked := not FullBuild1.Checked; |
|---|
| 1051 |
CurrentProject.Save; |
|---|
| 1052 |
end; |
|---|
| 1053 |
|
|---|
| 1054 |
procedure TmainForm.BuildRun1Click(Sender: TObject); |
|---|
| 1055 |
var |
|---|
| 1056 |
output : TStringList; |
|---|
| 1057 |
begin |
|---|
| 1058 |
if not SelProject then Exit; |
|---|
| 1059 |
workspace.BuildProjectEXE( CurrentProject ) ; |
|---|
| 1060 |
UpdateTreeview; |
|---|
| 1061 |
|
|---|
| 1062 |
if not FileExists( CurrentProject.ExeName ) then |
|---|
| 1063 |
begin |
|---|
| 1064 |
workspace.output.Add( '**** Executable could not be built. Correct errors or try a full build' ); |
|---|
| 1065 |
OutputDlg.ShowOutput( CurrentProject, workspace.output, 'Build EXE Results' ); |
|---|
| 1066 |
Exit; |
|---|
| 1067 |
end; |
|---|
| 1068 |
|
|---|
| 1069 |
output := TStringList.Create; |
|---|
| 1070 |
output.AddStrings( workspace.output ); |
|---|
| 1071 |
mainForm.WindowState := wsMinimized ; |
|---|
| 1072 |
ConsoleApp( CurrentProject.ExeName, '', output ); |
|---|
| 1073 |
mainForm.WindowState := wsNormal ; |
|---|
| 1074 |
OutputDlg.Listbox.Clear; |
|---|
| 1075 |
OutputDlg.ShowOutput( CurrentProject, output, 'Build/Run of ' + CurrentProject.ExeName ); |
|---|
| 1076 |
output.Free; |
|---|
| 1077 |
end; |
|---|
| 1078 |
|
|---|
| 1079 |
procedure TmainForm.StayonTopMenuClick(Sender: TObject); |
|---|
| 1080 |
begin |
|---|
| 1081 |
SetOnTop( not UMain.StayonTop ); |
|---|
| 1082 |
SaveConfig; |
|---|
| 1083 |
end; |
|---|
| 1084 |
|
|---|
| 1085 |
initialization |
|---|
| 1086 |
lastWorkspace:= ''; |
|---|
| 1087 |
defaultWs := TWorkspaceCfg.Create; |
|---|
| 1088 |
defaultProj := TProjectCfg.Create; |
|---|
| 1089 |
|
|---|
| 1090 |
finalization |
|---|
| 1091 |
if Assigned( workspace ) then workspace.Free; |
|---|
| 1092 |
defaultWs.Free; |
|---|
| 1093 |
defaultProj.Free; |
|---|
| 1094 |
|
|---|
| 1095 |
end. |
|---|