diff --git a/Project1.dpr b/Project1.dpr index 284ef77..0206a57 100644 --- a/Project1.dpr +++ b/Project1.dpr @@ -9,7 +9,9 @@ uses UnitFormEstado in 'UnitFormEstado.pas' {FormEstado}, UnitFormPais in 'UnitFormPais.pas' {FormPais}, UnitFormGrid in 'UnitFormGrid.pas' {FormGrid}, - UnitDados in 'UnitDados.pas'; + UnitDados in 'UnitDados.pas', + Vcl.Themes, + Vcl.Styles; {$R *.res} diff --git a/Project1.dproj b/Project1.dproj index 8cb1a38..668fcab 100644 --- a/Project1.dproj +++ b/Project1.dproj @@ -46,6 +46,7 @@ true + Amakrits|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Amakrits.vsf;"Amethyst Kamri|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\AmethystKamri.vsf";"Aqua Graphite|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\AquaGraphite.vsf";"Aqua Light Slate|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\AquaLightSlate.vsf";Auric|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Auric.vsf;Carbon|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Carbon.vsf;"Charcoal Dark Slate|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\CharcoalDarkSlate.vsf";"Cobalt XEMedia|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\CobaltXEMedia.vsf";"Cyan Dusk|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\CyanDusk.vsf";"Cyan Night|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\CyanNight.vsf";"Emerald Light Slate|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\EmeraldLightSlate.vsf";Glossy|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Glossy.vsf;Glow|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Glow.vsf;"Golden Graphite|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\GoldenGraphite.vsf";"Iceberg Classico|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\IcebergClassico.vsf";"Lavender Classico|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\LavenderClassico.vsf";Light|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Light.vsf;Luna|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Luna.vsf;"Metropolis UI Black|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\MetropolisUIBlack.vsf";"Metropolis UI Blue|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\MetropolisUIBlue.vsf";"Metropolis UI Dark|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\MetropolisUIDark.vsf";"Metropolis UI Green|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\MetropolisUIGreen.vsf";Obsidian|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Obsidian.vsf;"Onyx Blue|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\OnyxBlue.vsf";"Ruby Graphite|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\RubyGraphite.vsf";"Sapphire Kamri|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\SapphireKamri.vsf";Silver|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Silver.vsf;Sky|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Sky.vsf;"Slate Classico|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\SlateClassico.vsf";"Smokey Quartz Kamri|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\SmokeyQuartzKamri.vsf";"Tablet Light|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\TabletLight.vsf";TabletDark|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\TabletDark.vsf;"Turquoise Gray|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\TurquoiseGray.vsf";Windows10|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Windows10.vsf;"Windows10 Blue|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Windows10Blue.vsf";"Windows10 Dark|VCLSTYLE|$(PUBLIC)\Documents\Embarcadero\Studio\17.0\Styles\Windows10Dark.vsf" Project1 $(BDS)\bin\delphi_PROJECTICON.ico System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) @@ -157,12 +158,27 @@ true - + + + 0 + .dll;.bpl + 1 + .dylib + + + Contents\MacOS + 1 + .dylib 1 + .dylib + + + 1 + .dylib @@ -516,27 +532,12 @@ 1 - - - 0 - .dll;.bpl - + 1 - .dylib - - - Contents\MacOS - 1 - .dylib 1 - .dylib - - - 1 - .dylib diff --git a/Project1.stat b/Project1.stat index 5d746b5..9c7ecf0 100644 --- a/Project1.stat +++ b/Project1.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=62163 -DesignerSecs=6844 -InspectorSecs=2376 -CompileSecs=373514 -OtherSecs=2081 +EditorSecs=62883 +DesignerSecs=7804 +InspectorSecs=3050 +CompileSecs=388395 +OtherSecs=2182 StartTime=03/08/2018 07:57:26 RealKeys=0 EffectiveKeys=0 -DebugSecs=28213 +DebugSecs=28776 diff --git a/UnitFormCidade.dfm b/UnitFormCidade.dfm index 4e0c21f..49da92f 100644 --- a/UnitFormCidade.dfm +++ b/UnitFormCidade.dfm @@ -7,6 +7,7 @@ inherited FormCidade: TFormCidade TextHeight = 18 inherited ToolBar1: TToolBar Width = 600 + ExplicitWidth = 600 inherited btAnterior: TButton TabOrder = 2 OnClick = btAnteriorClick @@ -33,42 +34,42 @@ inherited FormCidade: TFormCidade end inherited Panel1: TPanel Width = 600 - ExplicitHeight = 260 + ExplicitWidth = 600 DesignSize = ( 600 243) inherited Panel2: TPanel object Label1: TLabel [0] - Left = 70 + Left = 75 Top = 20 - Width = 50 - Height = 25 + Width = 45 + Height = 18 Alignment = taRightJustify Anchors = [] Caption = 'C'#243'digo:' end object Label2: TLabel [1] - Left = 70 + Left = 75 Top = 70 - Width = 50 - Height = 25 + Width = 45 + Height = 18 Alignment = taRightJustify Anchors = [] Caption = 'Cidade:' end object Label3: TLabel [2] - Left = 70 + Left = 92 Top = 120 - Width = 50 - Height = 25 + Width = 28 + Height = 18 Alignment = taRightJustify Caption = 'Pa'#237's:' end object Label4: TLabel [3] - Left = 300 + Left = 330 Top = 120 - Width = 50 - Height = 25 + Width = 20 + Height = 18 Alignment = taRightJustify Anchors = [] Caption = 'UF:' @@ -126,6 +127,7 @@ inherited FormCidade: TFormCidade Text = 'Aguardando' Width = 50 end> - ExplicitTop = 293 + ExplicitTop = 284 + ExplicitWidth = 600 end end diff --git a/UnitFormCidade.pas b/UnitFormCidade.pas index c05cbe7..bdd3ccc 100644 --- a/UnitFormCidade.pas +++ b/UnitFormCidade.pas @@ -28,7 +28,6 @@ type procedure btExportarClick(Sender: TObject); procedure btImportarClick(Sender: TObject); procedure btContarClick(Sender: TObject); - procedure Button1Click(Sender: TObject); procedure edCodExit(Sender: TObject); procedure edFinalKeyPress(Sender: TObject; var Key: Char); procedure limpaCampos(); @@ -127,12 +126,6 @@ begin end; end; -procedure TFormCidade.Button1Click(Sender: TObject); -begin - inherited; - ShowMessage('teste'); -end; - procedure TFormCidade.cbLimparCamposClick(Sender: TObject); begin inherited; diff --git a/UnitFormGrid.dfm b/UnitFormGrid.dfm index 0fe3923..9b331fd 100644 --- a/UnitFormGrid.dfm +++ b/UnitFormGrid.dfm @@ -1,8 +1,8 @@ object FormGrid: TFormGrid Left = 0 Top = 0 - Width = 448 - Height = 418 + Width = 350 + Height = 350 AutoScroll = True Caption = 'FormGrid' Color = clBtnFace @@ -16,30 +16,36 @@ object FormGrid: TFormGrid Visible = True OnClose = FormClose OnCreate = FormCreate + OnKeyPress = FormKeyPress PixelsPerInch = 96 TextHeight = 18 object StringGrid1: TStringGrid Left = 0 - Top = 59 - Width = 265 - Height = 222 + Top = 41 + Width = 334 + Height = 247 + Align = alClient ColCount = 4 DrawingStyle = gdsClassic FixedCols = 0 FixedRows = 0 - Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing] + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected] ParentShowHint = False ShowHint = True TabOrder = 0 + OnKeyPress = StringGrid1KeyPress + ExplicitTop = 36 + ExplicitHeight = 251 end object ToolBar1: TToolBar Left = 0 Top = 0 - Width = 432 - Height = 29 + Width = 334 + Height = 41 ButtonHeight = 30 Caption = 'ToolBar1' TabOrder = 1 + ExplicitWidth = 384 object btExcluir: TButton Left = 0 Top = 0 @@ -71,13 +77,21 @@ object FormGrid: TFormGrid TabOrder = 1 OnClick = btEscolherClick end + object edKeyPress: TEdit + Left = 150 + Top = 0 + Width = 111 + Height = 30 + Enabled = False + TabOrder = 2 + TextHint = 'Pesquisa' + end end - object edPesquisa: TEdit - Left = 64 - Top = 35 - Width = 70 - Height = 26 - TabOrder = 2 - OnChange = edPesquisaChange + object StatusBar1: TStatusBar + Left = 0 + Top = 288 + Width = 334 + Height = 23 + Panels = <> end end diff --git a/UnitFormGrid.pas b/UnitFormGrid.pas index f232c2f..bbbe092 100644 --- a/UnitFormGrid.pas +++ b/UnitFormGrid.pas @@ -13,16 +13,20 @@ type ToolBar1: TToolBar; btExcluir: TButton; btEscolher: TButton; - edPesquisa: TEdit; + edKeyPress: TEdit; + StatusBar1: TStatusBar; procedure geraGrid(Lista: TLista; Classe: TClass); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure btExcluirClick(Sender: TObject); procedure btEscolherClick(Sender: TObject); - procedure edPesquisaChange(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure FormKeyPress(Sender: TObject; var Key: Char); + procedure StringGrid1KeyPress(Sender: TObject; var Key: Char); + procedure limpaGrid(); private { Private declarations } palavra: string; + palavraPesquisa: string; public { Public declarations } end; @@ -37,6 +41,16 @@ implementation {$R *.dfm} uses UnitFormCidade; +procedure TFormGrid.limpaGrid; +var + linha: integer; +begin + for linha:= 1 to StringGrid1.RowCount -1 do + begin + StringGrid1.Rows[linha].Clear; //Cells[coluna,linha]:=''; + end; +end; + procedure TFormGrid.btEscolherClick(Sender: TObject); var wObj: TObject; @@ -69,142 +83,6 @@ begin end; -procedure TFormGrid.edPesquisaChange(Sender: TObject); -var - wCont: integer; - wObj: TObject; - wLista: TLista; - linha: integer; -begin - palavra := edPesquisa.Text; - if palavra <> '' then - begin - wLista := TLista.Create; - for wCont := 0 to FLista.Count-1 do - begin - wObj := FLista.getObjectByIndex(wCont); - if wObj.ClassType = TCidade then - begin - with wObj as TCidade do - begin - if ContainsText(wCidade, palavra) then - begin - wLista.Inserir(wObj, TCidade); - end; - end; - end - else - if wObj.ClassType = TEstado then - begin - with wObj as TEstado do - begin - if ContainsText (wEstado, palavra) then - begin - wLista.Inserir(wObj, TEstado); - end; - end; - end - else - if wObj.ClassType = TPais then - begin - with wObj as TPais do - begin - if ContainsText (wPais, palavra) then - begin - wLista.Inserir(wObj, TPais); - end; - end; - end; - - end; - - if wLista.Count > 0 then - begin - for linha:= 1 to StringGrid1.RowCount -1 do - begin - StringGrid1.Rows[linha].Clear; //Cells[coluna,linha]:=''; - end; - StringGrid1.RowCount := wLista.Count; - for wCont := 0 to wLista.Count-1 do - begin - wObj := wLista.getObjectByIndex(wCont); - if wObj.ClassType = TCidade then - begin - with wObj as TCidade do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wCidade; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := wUF; - end; - end - else - if wObj.ClassType = TEstado then - begin - with wObj as TEstado do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wEstado; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := inttostr(wAliquota); - end; - end - else - if wObj.ClassType = TPais then - begin - with wObj as Tpais do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wPais; - StringGrid1.Cells[2, wCont] := wNacionalidade; - StringGrid1.Cells[3, wCont] := inttostr(wCodfed); - end; - end; - end; - end; - end - else - begin - StringGrid1.RowCount := Flista.Count; - for wCont := 0 to FLista.Count-1 do - begin - wObj := FLista.getObjectByIndex(wCont); - if wObj.ClassType = TCidade then - begin - with wObj as TCidade do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wCidade; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := wUF; - end; - end - else - if wObj.ClassType = TEstado then - begin - with wObj as TEstado do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wEstado; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := inttostr(wAliquota); - end; - end - else - if wObj.ClassType = TPais then - begin - with wObj as TPais do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wPais; - StringGrid1.Cells[2, wCont] := wNacionalidade; - StringGrid1.Cells[3, wCont] := inttostr(wCodFed); - end; - end; - end; - end; -end; - procedure TFormGrid.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; @@ -215,6 +93,13 @@ begin checkList := true; end; +procedure TFormGrid.FormKeyPress(Sender: TObject; var Key: Char); +begin + edKeyPress.Text := Key; + ShowMessage(key); + ShowMessage('teste'); +end; + procedure TFormGrid.geraGrid(Lista: TLista; Classe: TClass); var wCont: integer; @@ -238,24 +123,147 @@ begin StringGrid1.Cells[1, wCont] := wCidade; StringGrid1.Cells[2, wCont] := wPais; StringGrid1.Cells[3, wCont] := wUF; + end + else + if wObj.ClassType = TEstado then + with wObj as TEstado do + begin + StringGrid1.Cells[0, wCont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wEstado; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := inttostr(wAliquota); + end + else + if wObj.ClassType = TPais then + with wObj as TPais do + begin + StringGrid1.Cells[0, wCont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wPais; + StringGrid1.Cells[2, wCont] := wNacionalidade; + StringGrid1.Cells[3, wCont] := inttostr(wCodFed); + end; + end; +end; + +procedure TFormGrid.StringGrid1KeyPress(Sender: TObject; var Key: Char); +var + wObj: TObject; + wCol: integer; + wLista: TLista; + wCont: Integer; +begin + if ord(Key) = 8 then + begin + edKeyPress.Text := ''; + limpaGrid(); + StringGrid1.RowCount := FLista.Count; + for wCont := 0 to Flista.Count-1 do + begin + wObj := FLista.getObjectByIndex(wCont); + if wObj.ClassType = TCidade then + begin + with wObj as TCidade do + begin + StringGrid1.Cells[0, wcont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wCidade; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := wUF; + end; + end + else + if wObj.ClassType = TEstado then + begin + with wObj as TEstado do + begin + StringGrid1.Cells[0, wcont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wEstado; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := inttostr(wAliquota); + end; + end + else + if wObj.ClassType = TPais then + begin + with wObj as TPais do + begin + StringGrid1.Cells[0, wcont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wPais; + StringGrid1.Cells[2, wCont] := wNacionalidade; + StringGrid1.Cells[3, wCont] := inttostr(wCodFed); + end; + end; + end; + end + else + begin + edKeyPress.Text := edKeyPress.Text + key; + wCol :=StringGrid1.Col; + wLista := TLista.Create; + for wCont := 0 to FLista.Count-1 do + begin + wObj := FLista.getObjectByIndex(wCont); + if wObj.ClassType = TCidade then + begin + with wObj as TCidade do + if (wCol = 0) and (ContainsText (inttostr(wCod), edKeyPress.Text)) then + wLista.Inserir(wObj, TCidade) + else + if (wCol = 1) and (ContainsText (wCidade, edKeyPress.Text)) then + wLista.Inserir(wObj, TCidade) + else + if (wCol = 2) and (ContainsText (wPais, edKeyPress.Text)) then + wLista.Inserir(wObj, TCidade) + else + if (wCol = 3) and (ContainsText (wUF, edKeyPress.Text)) then + wLista.Inserir(wObj, TCidade); + end + else + if wObj.ClassType = TEstado then + begin + with wObj as TEstado do + if (wCol =0) and (ContainsText (inttostr(wCod), edKeypress.Text)) then + wLista.Inserir(wObj, TEstado) + else + if (wCol =1) and (ContainsText(wEstado, edkeyPress.Text)) then + wLista.Inserir(wObj, TEstado) + else + if (wCol =2) and (ContainsText(wPais, edKeyPress.Text)) then + wLista.Inserir(wObj, TEstado) + else + if (wCol =3) and (ContainsText(inttostr(wAliquota), edKeyPress.Text)) then + wLista.Inserir(wObj, TEstado); + end + else + if wObj.ClassType = TPais then + begin + + end; + + + end; + + if wLista.Count > 0 then + begin + limpaGrid(); + StringGrid1.RowCount := wLista.Count; + for wCont := 0 to wLista.Count-1 do + begin + wObj := wLista.getObjectByIndex(wCont); + if wObj.ClassType = TCidade then + begin + with wObj as TCidade do + begin + StringGrid1.Cells[0, wCont] := inttostr(wCod); + StringGrid1.Cells[1, wCont] := wCidade; + StringGrid1.Cells[2, wCont] := wPais; + StringGrid1.Cells[3, wCont] := wUF; + end; + end; + end; end; - if wObj.ClassType = TEstado then - with wObj as TEstado do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wEstado; - StringGrid1.Cells[2, wCont] := wPais; - StringGrid1.Cells[3, wCont] := inttostr(wAliquota); - end; - if wObj.ClassType = TPais then - with wObj as TPais do - begin - StringGrid1.Cells[0, wCont] := inttostr(wCod); - StringGrid1.Cells[1, wCont] := wPais; - StringGrid1.Cells[2, wCont] := wNacionalidade; - StringGrid1.Cells[3, wCont] := inttostr(wCodFed); - end; - end; + + end; + end; end. diff --git a/Win32/Debug/Project1.exe b/Win32/Debug/Project1.exe index 04a7563..d3fda3d 100644 Binary files a/Win32/Debug/Project1.exe and b/Win32/Debug/Project1.exe differ diff --git a/Win32/Debug/UnitFormCidade.dcu b/Win32/Debug/UnitFormCidade.dcu index 46ddf41..e77fd60 100644 Binary files a/Win32/Debug/UnitFormCidade.dcu and b/Win32/Debug/UnitFormCidade.dcu differ diff --git a/Win32/Debug/UnitFormEstado.dcu b/Win32/Debug/UnitFormEstado.dcu index d0cfe9e..491fa2c 100644 Binary files a/Win32/Debug/UnitFormEstado.dcu and b/Win32/Debug/UnitFormEstado.dcu differ diff --git a/Win32/Debug/UnitFormGrid.dcu b/Win32/Debug/UnitFormGrid.dcu index 97af53a..92badcd 100644 Binary files a/Win32/Debug/UnitFormGrid.dcu and b/Win32/Debug/UnitFormGrid.dcu differ diff --git a/Win32/Debug/UnitFormPais.dcu b/Win32/Debug/UnitFormPais.dcu index bf10b35..937a08f 100644 Binary files a/Win32/Debug/UnitFormPais.dcu and b/Win32/Debug/UnitFormPais.dcu differ