From 144b365596a4463151041acf253f4b23eb45a21b Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 26 Aug 2015 12:02:38 +0200 Subject: [PATCH] added about box --- lazproj/coedit.lpi | 9 ++- lazproj/coedit.lpr | 8 +- src/ce_infos.lfm | 73 ++++++++++++++++++ src/ce_infos.pas | 179 +++++++++++++++++++++++++++++++++++++++++++++ src/ce_main.pas | 6 +- 5 files changed, 269 insertions(+), 6 deletions(-) create mode 100644 src/ce_infos.lfm create mode 100644 src/ce_infos.pas diff --git a/lazproj/coedit.lpi b/lazproj/coedit.lpi index dd084833..bdc8e50e 100644 --- a/lazproj/coedit.lpi +++ b/lazproj/coedit.lpi @@ -135,7 +135,7 @@ - + @@ -334,6 +334,13 @@ + + + + + + + diff --git a/lazproj/coedit.lpr b/lazproj/coedit.lpr index aab157a5..56f2a8d6 100644 --- a/lazproj/coedit.lpr +++ b/lazproj/coedit.lpr @@ -6,10 +6,10 @@ uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} - Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, - ce_sharedres, ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, - ce_writableComponent, ce_symstring, ce_staticmacro, ce_inspectors, - ce_editoroptions, ce_dockoptions, ce_shortcutseditor, ce_mru, ce_processes; + Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_sharedres, + ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent, + ce_symstring, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_dockoptions, + ce_shortcutseditor, ce_mru, ce_processes; {$R *.res} diff --git a/src/ce_infos.lfm b/src/ce_infos.lfm new file mode 100644 index 00000000..96ebfd56 --- /dev/null +++ b/src/ce_infos.lfm @@ -0,0 +1,73 @@ +inherited CEInfoWidget: TCEInfoWidget + Left = 714 + Height = 282 + Top = 271 + Width = 337 + BorderIcons = [biSystemMenu, biMinimize, biMaximize] + Caption = 'About' + ClientHeight = 282 + ClientWidth = 337 + inherited Back: TPanel + Height = 282 + Width = 337 + ClientHeight = 282 + ClientWidth = 337 + inherited Content: TPanel + Height = 282 + Width = 337 + ClientHeight = 282 + ClientWidth = 337 + object GroupBox1: TGroupBox[0] + Left = 4 + Height = 105 + Top = 4 + Width = 329 + Align = alTop + BorderSpacing.Around = 4 + Caption = 'about' + ClientHeight = 85 + ClientWidth = 325 + TabOrder = 0 + object Label1: TLabel + Left = 0 + Height = 85 + Top = 0 + Width = 325 + Align = alClient + Alignment = taCenter + AutoSize = False + Caption = 'Coedit 1 - update 2' + Font.Height = -16 + Font.Style = [fsBold] + Layout = tlCenter + ParentColor = False + ParentFont = False + end + end + object GroupBox2: TGroupBox[1] + Left = 4 + Height = 165 + Top = 113 + Width = 329 + Align = alClient + BorderSpacing.Around = 4 + Caption = 'tools status' + ClientHeight = 145 + ClientWidth = 325 + TabOrder = 1 + object boxTools: TScrollBox + Left = 4 + Height = 137 + Top = 4 + Width = 317 + HorzScrollBar.Page = 1 + VertScrollBar.Page = 1 + Align = alClient + BorderSpacing.Around = 4 + BorderStyle = bsNone + TabOrder = 0 + end + end + end + end +end diff --git a/src/ce_infos.pas b/src/ce_infos.pas new file mode 100644 index 00000000..a3425f33 --- /dev/null +++ b/src/ce_infos.pas @@ -0,0 +1,179 @@ +unit ce_infos; + +{$I ce_defines.inc} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, + StdCtrls, ExtCtrls, Buttons, Menus,ce_widget, ce_common; + +type + + TToolInfoKind = (tikRunning, tikFindable); + + TToolInfo = class(TWinControl) + private + fLabel: TLabel; + fStatus: TStaticText; + fKind: TToolInfoKind; + fToolName: string; + fIco: TSpeedButton; + procedure buttonClick(sender: TObject); + protected + procedure SetVisible(Value: Boolean); override; + public + constructor Construct(TheOwner: TComponent; kind: TToolInfoKind;const toolName: string); + procedure refreshStatus; + procedure Update; override; + end; + + + { TCEInfoWidget } + + TCEInfoWidget = class(TCEWidget) + boxTools: TScrollBox; + GroupBox1: TGroupBox; + GroupBox2: TGroupBox; + Label1: TLabel; + private + public + constructor create(aOwner: TComponent); override; + end; + +implementation + +{$R *.lfm} + +constructor TToolInfo.Construct(TheOwner: TComponent; kind: TToolInfoKind;const toolName: string); +begin + Inherited create(TheOwner); + Align := alTop; + height := 26; + width := 200; + // + fLabel := TLabel.Create(self); + fLabel.AutoSize:=false; + fLabel.Parent := self; + fLabel.Align:= alLeft; + fLabel.Width:= 60; + fLabel.BorderSpacing.Around := 2; + // + fIco := TSpeedButton.Create(self); + fIco.Parent := self; + fIco.Align:= alLeft; + fIco.Width:= 22; + fIco.Flat:=true; + fIco.BorderSpacing.Around := 2; + fIco.OnClick:= @buttonClick; + fIco.Hint:= 'refresh the status'; + fIco.ShowHint:= true; + // + fStatus := TStaticText.Create(self); + fStatus.Parent:=self; + fStatus.Align:= alClient; + fStatus.BorderSpacing.Around := 2; + fStatus.BorderStyle := sbsSunken; + fStatus.AutoSize:=false; + // + fKind:=kind; + fToolName:=toolName; + refreshStatus; +end; + +procedure TToolInfo.SetVisible(Value: Boolean); +begin + inherited; + refreshStatus; +end; + +procedure TToolInfo.Update; +begin + inherited; + refreshStatus; +end; + +procedure TToolInfo.buttonClick(sender: TObject); +begin + refreshStatus; +end; + +procedure TToolInfo.refreshStatus; +var + pth: string; + png: TPortableNetworkGraphic; +begin + if (fLabel = nil) or (fStatus = nil) then exit; + // + fLabel.Caption:= fToolName; + png := TPortableNetworkGraphic.Create; + try case fKind of + tikFindable: + begin + pth := exeFullName(fToolName + exeExt); + if pth = '' then + begin + fStatus.Caption:= 'the tool cannot be found'; + png.LoadFromLazarusResource('bullet_red'); + end + else + begin + fStatus.Caption:= 'the tool is available'; + png.LoadFromLazarusResource('bullet_green'); + end; + end; + tikRunning: + begin + pth := exeFullName(fToolName + exeExt); + if pth = '' then + begin + fStatus.Caption:= 'the tool cannot be found'; + png.LoadFromLazarusResource('bullet_red'); + end + else if AppIsRunning(fToolName + exeExt) then + begin + fStatus.Caption:= 'the tool is available and running'; + png.LoadFromLazarusResource('bullet_green'); + end + else + begin + fStatus.Caption:= 'the tool is available but is not running'; + png.LoadFromLazarusResource('bullet_yellow'); + end; + end; + end; + finally + fIco.Glyph.Assign(png); + png.Free; + end; +end; + +constructor TCEInfoWidget.create(aOwner: TComponent); +var + toolItem: TToolInfo; +begin + inherited; + fModal := true; + fDockable := false; + // + toolItem := TToolInfo.Construct(self, tikRunning, 'dcd-server'); + toolItem.Parent := boxTools; + toolItem.ReAlign; + toolItem := TToolInfo.Construct(self, tikFindable, 'dcd-client'); + toolItem.Parent := boxTools; + toolItem.ReAlign; + toolItem := TToolInfo.Construct(self, tikFindable, 'cesyms'); + toolItem.Parent := boxTools; + toolItem.ReAlign; + toolItem := TToolInfo.Construct(self, tikFindable, 'cetodo'); + toolItem.Parent := boxTools; + toolItem.ReAlign; + toolItem := TToolInfo.Construct(self, tikFindable, 'dmd'); + toolItem.Parent := boxTools; + toolItem.ReAlign; + // + Realign; +end; + +end. + diff --git a/src/ce_main.pas b/src/ce_main.pas index 630c3bc1..8217a710 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -11,7 +11,8 @@ uses ce_common, ce_dmdwrap, ce_nativeproject, ce_dcd, ce_synmemo, ce_writableComponent, ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf, ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer, - ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru, ce_processes; + ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru, ce_processes, + ce_infos; type @@ -205,6 +206,7 @@ type fTodolWidg: TCETodoListWidget; fOptEdWidg: TCEOptionEditorWidget; fSymlWidg: TCESymbolListWidget; + fInfoWidg: TCEInfoWidget; fInitialized: boolean; fRunnableSw: string; @@ -509,6 +511,7 @@ begin fTodolWidg:= TCETodoListWidget.create(self); fOptEdWidg:= TCEOptionEditorWidget.create(self); fSymlWidg := TCESymbolListWidget.create(self); + fInfoWidg := TCEInfoWidget.create(self); getMessageDisplay(fMsgs); @@ -524,6 +527,7 @@ begin fWidgList.addWidget(@fTodolWidg); fWidgList.addWidget(@fOptEdWidg); fWidgList.addWidget(@fSymlWidg); + fWidgList.addWidget(@fInfoWidg); fWidgList.sort(@CompareWidgCaption); for widg in fWidgList do