diff --git a/tools/apiwizz/apiwizard.lfm b/tools/apiwizz/apiwizard.lfm index 02c4a647f8..61c6cd38b3 100644 --- a/tools/apiwizz/apiwizard.lfm +++ b/tools/apiwizz/apiwizard.lfm @@ -1,39 +1,42 @@ object ApiWizForm: TApiWizForm - Left = 396 - Height = 383 - Top = 170 - Width = 583 + Left = 303 + Height = 518 + Top = 154 + Width = 872 HorzScrollBar.Page = 582 VertScrollBar.Page = 382 ActiveControl = txtLazarus Caption = 'ApiWiZZ' + ClientHeight = 518 + ClientWidth = 872 OnCreate = ApiWizFormCreate + OnDestroy = FormDestroy Position = poDefaultPosOnly + LCLVersion = '0.9.29' object lblDeclare: TLabel + AnchorSideTop.Side = asrBottom Left = 4 - Height = 13 - Top = 56 - Width = 404 - Anchors = [akTop, akLeft, akRight] + Height = 18 + Top = 288 + Width = 424 + Anchors = [akLeft, akRight, akBottom] Caption = 'Declaration (each line is a separate entry):' - Color = clNone ParentColor = False end object lblLazarus: TLabel Left = 4 - Height = 13 + Height = 18 Top = 8 - Width = 66 + Width = 78 Caption = 'Lazarus dir:' - Color = clNone ParentColor = False end object cmdGenerate: TButton - Left = 416 + Left = 700 Height = 28 - Top = 299 - Width = 162 - Anchors = [akTop, akRight] + Top = 482 + Width = 167 + Anchors = [akRight, akBottom] BorderSpacing.InnerBorder = 4 Caption = 'Generate' OnClick = cmdGenerateClick @@ -42,18 +45,18 @@ object ApiWizForm: TApiWizForm object txtLazarus: TEdit Tag = 493 Left = 4 - Height = 24 + Height = 27 Top = 24 - Width = 404 + Width = 693 Anchors = [akTop, akLeft, akRight] TabOrder = 0 end object rdgApiType: TRadioGroup - Left = 416 + Left = 519 Height = 72 - Top = 219 - Width = 162 - Anchors = [akTop, akRight] + Top = 438 + Width = 178 + Anchors = [akRight, akBottom] AutoFill = True Caption = 'Api type' ChildSizing.LeftRightSpacing = 6 @@ -64,6 +67,8 @@ object ApiWizForm: TApiWizForm ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 + ClientHeight = 53 + ClientWidth = 174 ItemIndex = 0 Items.Strings = ( 'win32 compatibility' @@ -73,19 +78,20 @@ object ApiWizForm: TApiWizForm TabOrder = 2 end object Groupbox1: TGroupBox - Left = 416 - Height = 208 - Top = 8 - Width = 162 - Anchors = [akTop, akRight] + Left = 519 + Height = 144 + Top = 288 + Width = 348 + Anchors = [akRight, akBottom] Caption = 'LCL Widgetset' - ParentCtl3D = False + ClientHeight = 125 + ClientWidth = 344 TabOrder = 3 object rbIndependent: TRadioButton Left = 10 - Height = 20 + Height = 21 Top = 3 - Width = 96 + Width = 109 AllowGrayed = True Caption = 'Independent' Checked = True @@ -95,9 +101,9 @@ object ApiWizForm: TApiWizForm end object cbgLCLPlatform: TCheckGroup Left = 26 - Height = 154 - Top = 30 - Width = 128 + Height = 77 + Top = 43 + Width = 308 AutoFill = True ChildSizing.LeftRightSpacing = 6 ChildSizing.TopBottomSpacing = 6 @@ -105,42 +111,105 @@ object ApiWizForm: TApiWizForm ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 + ChildSizing.Layout = cclTopToBottomThenLeftToRight + ChildSizing.ControlsPerLine = 3 + ColumnLayout = clVerticalThenHorizontal + Columns = 3 Enabled = False Items.Strings = ( 'carbon' + 'cocoa' 'fpgui' 'gtk' 'gtk2' + 'nogui' 'qt' 'win32' 'wince' ) TabOrder = 2 Data = { - 0700000002020202020202 + 09000000020202020202020202 } end object rbDependent: TRadioButton Left = 10 - Height = 20 - Top = 30 - Width = 88 + Height = 21 + Top = 23 + Width = 100 AllowGrayed = True Caption = 'Dependent' OnClick = rbPlatformDependencyClick TabOrder = 1 + TabStop = False end end object txtDeclarations: TMemo + AnchorSideTop.Side = asrBottom Left = 4 - Height = 303 - Top = 72 - Width = 404 - Anchors = [akTop, akLeft, akRight, akBottom] + Height = 199 + Top = 311 + Width = 509 + Anchors = [akLeft, akRight, akBottom] ScrollBars = ssBoth TabOrder = 4 WordWrap = False end + object cmdScan: TButton + Left = 700 + Height = 25 + Top = 24 + Width = 167 + Anchors = [akTop, akRight] + Caption = 'Scan' + OnClick = cmdScanClick + TabOrder = 5 + end + object lvExisting: TListView + Left = 4 + Height = 232 + Top = 52 + Width = 863 + Anchors = [akTop, akLeft, akRight, akBottom] + Columns = < + item + AutoSize = True + Caption = 'name' + MinWidth = 250 + Width = 250 + end + item + Alignment = taCenter + AutoSize = True + Caption = 'api' + Width = 29 + end + item + Alignment = taCenter + AutoSize = True + Caption = 'indep' + Width = 46 + end + item + Alignment = taCenter + AutoSize = True + Caption = 'base' + Width = 517 + end> + ItemIndex = -1 + ReadOnly = True + RowSelect = True + TabOrder = 6 + ViewStyle = vsReport + end + object cmdCopy: TButton + Left = 436 + Height = 25 + Top = 284 + Width = 75 + Anchors = [akRight, akBottom] + Caption = 'Copy' + OnClick = cmdCopyClick + TabOrder = 7 + end end diff --git a/tools/apiwizz/apiwizard.lrs b/tools/apiwizz/apiwizard.lrs index 1a22432949..361f3ed4d2 100644 --- a/tools/apiwizz/apiwizard.lrs +++ b/tools/apiwizz/apiwizard.lrs @@ -1,48 +1,65 @@ -{ Это - файл ресурсов, автоматически созданный lazarus } +{ This is an automatically generated lazarus resource file } LazarusResources.Add('TApiWizForm','FORMDATA',[ - 'TPF0'#11'TApiWizForm'#10'ApiWizForm'#4'Left'#3#140#1#6'Height'#3''#1#3'Top' - +#3#170#0#5'Width'#3'G'#2#18'HorzScrollBar.Page'#3'F'#2#18'VertScrollBar.Page' - +#3'~'#1#13'ActiveControl'#7#10'txtLazarus'#7'Caption'#6#7'ApiWiZZ'#8'OnCreat' - +'e'#7#16'ApiWizFormCreate'#8'Position'#7#16'poDefaultPosOnly'#0#6'TLabel'#10 - +'lblDeclare'#4'Left'#2#4#6'Height'#2#13#3'Top'#2'8'#5'Width'#3#148#1#7'Ancho' - +'rs'#11#5'akTop'#6'akLeft'#7'akRight'#0#7'Caption'#6',Declaration (each line' - +' is a separate entry):'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6'TLabel' - +#10'lblLazarus'#4'Left'#2#4#6'Height'#2#13#3'Top'#2#8#5'Width'#2'B'#7'Captio' - +'n'#6#12'Lazarus dir:'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#7'TButton' - +#11'cmdGenerate'#4'Left'#3#160#1#6'Height'#2#28#3'Top'#3'+'#1#5'Width'#3#162 - +#0#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpacing.InnerBorder'#2#4#7'C' - +'aption'#6#8'Generate'#7'OnClick'#7#16'cmdGenerateClick'#8'TabOrder'#2#1#0#0 - +#5'TEdit'#10'txtLazarus'#3'Tag'#3#237#1#4'Left'#2#4#6'Height'#2#24#3'Top'#2 - +#24#5'Width'#3#148#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrde' - +'r'#2#0#0#0#11'TRadioGroup'#10'rdgApiType'#4'Left'#3#160#1#6'Height'#2'H'#3 - +'Top'#3#219#0#5'Width'#3#162#0#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoFil' - +'l'#9#7'Caption'#6#8'Api type'#28'ChildSizing.LeftRightSpacing'#2#6#28'Child' - +'Sizing.TopBottomSpacing'#2#6#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomo' - +'genousChildResize'#27'ChildSizing.EnlargeVertical'#7#24'crsHomogenousChildR' - +'esize'#28'ChildSizing.ShrinkHorizontal'#7#14'crsScaleChilds'#26'ChildSizing' - +'.ShrinkVertical'#7#14'crsScaleChilds'#18'ChildSizing.Layout'#7#29'cclLeftTo' - +'RightThenTopToBottom'#27'ChildSizing.ControlsPerLine'#2#1#9'ItemIndex'#2#0 + 'TPF0'#11'TApiWizForm'#10'ApiWizForm'#4'Left'#3'/'#1#6'Height'#3#6#2#3'Top'#3 + +#154#0#5'Width'#3'h'#3#18'HorzScrollBar.Page'#3'F'#2#18'VertScrollBar.Page'#3 + +'~'#1#13'ActiveControl'#7#10'txtLazarus'#7'Caption'#6#7'ApiWiZZ'#12'ClientHe' + +'ight'#3#6#2#11'ClientWidth'#3'h'#3#8'OnCreate'#7#16'ApiWizFormCreate'#9'OnD' + +'estroy'#7#11'FormDestroy'#8'Position'#7#16'poDefaultPosOnly'#10'LCLVersion' + +#6#6'0.9.29'#0#6'TLabel'#10'lblDeclare'#18'AnchorSideTop.Side'#7#9'asrBottom' + +#4'Left'#2#4#6'Height'#2#18#3'Top'#3' '#1#5'Width'#3#168#1#7'Anchors'#11#6'a' + +'kLeft'#7'akRight'#8'akBottom'#0#7'Caption'#6',Declaration (each line is a s' + +'eparate entry):'#11'ParentColor'#8#0#0#6'TLabel'#10'lblLazarus'#4'Left'#2#4 + +#6'Height'#2#18#3'Top'#2#8#5'Width'#2'N'#7'Caption'#6#12'Lazarus dir:'#11'Pa' + +'rentColor'#8#0#0#7'TButton'#11'cmdGenerate'#4'Left'#3#188#2#6'Height'#2#28#3 + +'Top'#3#226#1#5'Width'#3#167#0#7'Anchors'#11#7'akRight'#8'akBottom'#0#25'Bor' + +'derSpacing.InnerBorder'#2#4#7'Caption'#6#8'Generate'#7'OnClick'#7#16'cmdGen' + +'erateClick'#8'TabOrder'#2#1#0#0#5'TEdit'#10'txtLazarus'#3'Tag'#3#237#1#4'Le' + +'ft'#2#4#6'Height'#2#27#3'Top'#2#24#5'Width'#3#181#2#7'Anchors'#11#5'akTop'#6 + +'akLeft'#7'akRight'#0#8'TabOrder'#2#0#0#0#11'TRadioGroup'#10'rdgApiType'#4'L' + +'eft'#3#7#2#6'Height'#2'H'#3'Top'#3#182#1#5'Width'#3#178#0#7'Anchors'#11#7'a' + +'kRight'#8'akBottom'#0#8'AutoFill'#9#7'Caption'#6#8'Api type'#28'ChildSizing' + +'.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'ChildSizing.' + +'EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'ChildSizing.EnlargeVer' + +'tical'#7#24'crsHomogenousChildResize'#28'ChildSizing.ShrinkHorizontal'#7#14 + +'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChilds'#18'Chil' + +'dSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizing.Controls' + +'PerLine'#2#1#12'ClientHeight'#2'5'#11'ClientWidth'#3#174#0#9'ItemIndex'#2#0 +#13'Items.Strings'#1#6#19'win32 compatibility'#6#13'LCL interface'#0#7'OnCli' +'ck'#7#15'rdgApiTypeClick'#8'TabOrder'#2#2#0#0#9'TGroupBox'#9'Groupbox1'#4'L' - +'eft'#3#160#1#6'Height'#3#208#0#3'Top'#2#8#5'Width'#3#162#0#7'Anchors'#11#5 - +'akTop'#7'akRight'#0#7'Caption'#6#13'LCL Widgetset'#11'ParentCtl3D'#8#8'TabO' - +'rder'#2#3#0#12'TRadioButton'#13'rbIndependent'#4'Left'#2#10#6'Height'#2#20#3 - +'Top'#2#3#5'Width'#2'`'#11'AllowGrayed'#9#7'Caption'#6#11'Independent'#7'Che' - +'cked'#9#7'OnClick'#7#25'rbPlatformDependencyClick'#5'State'#7#9'cbChecked'#8 - +'TabOrder'#2#0#0#0#11'TCheckGroup'#14'cbgLCLPlatform'#4'Left'#2#26#6'Height' - +#3#154#0#3'Top'#2#30#5'Width'#3#128#0#8'AutoFill'#9#28'ChildSizing.LeftRight' - +'Spacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'ChildSizing.EnlargeHor' - +'izontal'#7#24'crsHomogenousChildResize'#27'ChildSizing.EnlargeVertical'#7#24 - +'crsHomogenousChildResize'#28'ChildSizing.ShrinkHorizontal'#7#14'crsScaleChi' - +'lds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChilds'#18'ChildSizing.Lay' - +'out'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizing.ControlsPerLine'#2#1 - +#7'Enabled'#8#13'Items.Strings'#1#6#6'carbon'#6#5'fpgui'#6#3'gtk'#6#4'gtk2'#6 - +#2'qt'#6#5'win32'#6#5'wince'#0#8'TabOrder'#2#2#4'Data'#10#11#0#0#0#7#0#0#0#2 - +#2#2#2#2#2#2#0#0#12'TRadioButton'#11'rbDependent'#4'Left'#2#10#6'Height'#2#20 - +#3'Top'#2#30#5'Width'#2'X'#11'AllowGrayed'#9#7'Caption'#6#9'Dependent'#7'OnC' - +'lick'#7#25'rbPlatformDependencyClick'#8'TabOrder'#2#1#0#0#0#5'TMemo'#15'txt' - +'Declarations'#4'Left'#2#4#6'Height'#3'/'#1#3'Top'#2'H'#5'Width'#3#148#1#7'A' - +'nchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#10'ScrollBars'#7#6's' - +'sBoth'#8'TabOrder'#2#4#8'WordWrap'#8#0#0#0 + +'eft'#3#7#2#6'Height'#3#144#0#3'Top'#3' '#1#5'Width'#3'\'#1#7'Anchors'#11#7 + +'akRight'#8'akBottom'#0#7'Caption'#6#13'LCL Widgetset'#12'ClientHeight'#2'}' + +#11'ClientWidth'#3'X'#1#8'TabOrder'#2#3#0#12'TRadioButton'#13'rbIndependent' + +#4'Left'#2#10#6'Height'#2#21#3'Top'#2#3#5'Width'#2'm'#11'AllowGrayed'#9#7'Ca' + +'ption'#6#11'Independent'#7'Checked'#9#7'OnClick'#7#25'rbPlatformDependencyC' + +'lick'#5'State'#7#9'cbChecked'#8'TabOrder'#2#0#0#0#11'TCheckGroup'#14'cbgLCL' + +'Platform'#4'Left'#2#26#6'Height'#2'M'#3'Top'#2'+'#5'Width'#3'4'#1#8'AutoFil' + +'l'#9#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2 + +#6#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'Child' + +'Sizing.EnlargeVertical'#7#24'crsHomogenousChildResize'#28'ChildSizing.Shrin' + +'kHorizontal'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsSc' + +'aleChilds'#18'ChildSizing.Layout'#7#29'cclTopToBottomThenLeftToRight'#27'Ch' + +'ildSizing.ControlsPerLine'#2#3#12'ColumnLayout'#7#24'clVerticalThenHorizont' + +'al'#7'Columns'#2#3#7'Enabled'#8#13'Items.Strings'#1#6#6'carbon'#6#5'cocoa'#6 + +#5'fpgui'#6#3'gtk'#6#4'gtk2'#6#5'nogui'#6#2'qt'#6#5'win32'#6#5'wince'#0#8'Ta' + +'bOrder'#2#2#4'Data'#10#13#0#0#0#9#0#0#0#2#2#2#2#2#2#2#2#2#0#0#12'TRadioButt' + +'on'#11'rbDependent'#4'Left'#2#10#6'Height'#2#21#3'Top'#2#23#5'Width'#2'd'#11 + +'AllowGrayed'#9#7'Caption'#6#9'Dependent'#7'OnClick'#7#25'rbPlatformDependen' + +'cyClick'#8'TabOrder'#2#1#7'TabStop'#8#0#0#0#5'TMemo'#15'txtDeclarations'#18 + +'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#4#6'Height'#3#199#0#3'Top'#3'7' + +#1#5'Width'#3#253#1#7'Anchors'#11#6'akLeft'#7'akRight'#8'akBottom'#0#10'Scro' + +'llBars'#7#6'ssBoth'#8'TabOrder'#2#4#8'WordWrap'#8#0#0#7'TButton'#7'cmdScan' + +#4'Left'#3#188#2#6'Height'#2#25#3'Top'#2#24#5'Width'#3#167#0#7'Anchors'#11#5 + +'akTop'#7'akRight'#0#7'Caption'#6#4'Scan'#7'OnClick'#7#12'cmdScanClick'#8'Ta' + +'bOrder'#2#5#0#0#9'TListView'#10'lvExisting'#4'Left'#2#4#6'Height'#3#232#0#3 + +'Top'#2'4'#5'Width'#3'_'#3#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akB' + +'ottom'#0#7'Columns'#14#1#8'AutoSize'#9#7'Caption'#6#4'name'#8'MinWidth'#3 + +#250#0#5'Width'#3#250#0#0#1#9'Alignment'#7#8'taCenter'#8'AutoSize'#9#7'Capti' + +'on'#6#3'api'#5'Width'#2#29#0#1#9'Alignment'#7#8'taCenter'#8'AutoSize'#9#7'C' + +'aption'#6#5'indep'#5'Width'#2'.'#0#1#9'Alignment'#7#8'taCenter'#8'AutoSize' + +#9#7'Caption'#6#4'base'#5'Width'#3#5#2#0#0#9'ItemIndex'#2#255#8'ReadOnly'#9#9 + +'RowSelect'#9#8'TabOrder'#2#6#9'ViewStyle'#7#8'vsReport'#0#0#7'TButton'#7'cm' + +'dCopy'#4'Left'#3#180#1#6'Height'#2#25#3'Top'#3#28#1#5'Width'#2'K'#7'Anchors' + +#11#7'akRight'#8'akBottom'#0#7'Caption'#6#4'Copy'#7'OnClick'#7#12'cmdCopyCli' + +'ck'#8'TabOrder'#2#7#0#0#0 ]); diff --git a/tools/apiwizz/apiwizard.pp b/tools/apiwizz/apiwizard.pp index ebfdb3bc7c..f360d8a55c 100644 --- a/tools/apiwizz/apiwizard.pp +++ b/tools/apiwizz/apiwizard.pp @@ -1,10 +1,10 @@ { $Id$ } { /*************************************************************************** - APIWiZZard.pp + APIWizard.pp ------------------- - APIWiZZ is an API wizzard to generate WINAPI - Templates for GTK. + APIWiZZ is an API wizard to generate WINAPI + Templates for the LCL widgetsets. Initial Revision : 05-02-2000 @@ -32,13 +32,19 @@ interface uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, - StdCtrls, Buttons, ExtCtrls; + StdCtrls, Buttons, ExtCtrls, LCLproc, ComCtrls; type + + { TApiWizForm } + TApiWizForm = class(TForm) + cmdCopy: TButton; + cmdScan: TButton; cbgLCLPlatform: TCHECKGROUP; cmdGenerate: TButton; Groupbox1: TGROUPBOX; + lvExisting: TListView; txtDeclarations: TMemo; rbIndependent: TRADIOBUTTON; rbDependent: TRADIOBUTTON; @@ -46,16 +52,31 @@ type lblDeclare: TLabel; txtLazarus: TEdit; lblLazarus: TLabel; + procedure cmdCopyClick(Sender: TObject); procedure cmdGenerateClick(Sender: TObject); procedure ApiWizFormCreate(Sender: TObject); + procedure cmdScanClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure rbPlatformDependencyClick(Sender: TObject); procedure rdgApiTypeClick (Sender: TObject ); private + FLineInfo: TStringList; public end; TProcType = (ptFunction, ptProcedure); + TApiWidgetset = (awCarbon, awCocoa, awFpgui, awGtk, awGtk2, awNoGui, awQt, awWin32, awWinCE); + TApiWidgetsets = set of TApiWidgetset; + + TApiLine = class + Declaration: String; + Independent: Boolean; + WinApi: Boolean; + Widgetsets: TApiWidgetsets; + Base: Boolean; + end; + var ApiWizForm: TApiWizForm; @@ -64,32 +85,9 @@ implementation const DECL_OFFSET: array[TProctype] of Integer = (9, 10); -{ TApiWizForm } - -procedure TApiWizForm.ApiWizFormCreate(Sender: TObject); -var - n: Integer; - S: String; -begin - S := ParamStrUTF8(1); - // find the lazarus dir - if S = '' - then begin - S := ExtractFilePath(ParamStrUTF8(0)); - n := Pos('apiwizz', S); - if n <> 0 - then S := Copy(S, 1, n - 7) - else S := ''; - end; - - if S = '' - then begin - S := GetCurrentDirUTF8; - n := Pos('apiwizz', S); - if n <> 0 then S := Copy(S, 1, n - 7); - end; - txtLazarus.Text := S; -end; + WS_NAME: array[TApiWidgetset] of string = ( + 'carbon', 'cocoa', 'fpgui', 'gtk', 'gtk2', 'nogui', 'qt', 'win32', 'wince' + ); function GetName(const ADeclaration: String): String; var @@ -309,8 +307,6 @@ begin end; end else Result := -1 - - end; procedure InsertLines(const Idx: Integer; const TargetLines, SourceLines: TStringList); @@ -323,6 +319,150 @@ begin end; end; +procedure Scan(const AFileName, ATag: String; AResult: TStringList); +var + StartFound: Boolean; + StartTag, EndTag: String; + Line, LineName: String; + Lines: TStringList; + n: Integer; +begin + AResult.Clear; + if not FileExistsUTF8(AFileName) then Exit; + + Lines := TStringList.Create; + Lines.LoadFromFile(UTF8ToSys(AFileName)); + + StartFound := False; + StartTag := Format('##apiwiz##s%s##', [ATag]); + EndTag := Format('##apiwiz##e%s##', [ATag]); + + for n := 0 to Lines.Count - 1 do + begin + Line := Lines[n]; + if not StartFound + then begin + StartFound := Pos(StartTag, Line) <> 0; + Continue; + end; + + if Pos(EndTag, Line) <> 0 + then begin + Break; + end; + + if (Line = '') or (Line[1] = ' ') then Continue; + LineName := GetName(Line); + if LineName = '' then Continue; + Line := GetPart([], ['{$'], Line); + + AResult.Add(line); + end; + + Lines.Free; +end; + +{ TApiWizForm } + +procedure TApiWizForm.ApiWizFormCreate(Sender: TObject); +var + n: Integer; + S: String; + WS: TApiWidgetset; + C: TListColumn; +begin + cbgLCLPlatform.Items.Clear; + for WS := Low(WS) to High(Ws) do + cbgLCLPlatform.Items.Add(WS_NAME[WS]); + + lvExisting.Columns.BeginUpdate; + for WS := Low(WS) to High(Ws) do + begin + C := lvExisting.Columns.Add; + C.Caption := WS_NAME[WS]; + C.Alignment := taCenter; + C.AutoSize := True; + end; + // add dummy + C := lvExisting.Columns.Add; + C.Caption := ''; + C.AutoSize := True; + lvExisting.Columns.EndUpdate; + + FLineInfo := TStringList.Create; + FLineInfo.Sorted := True; + FLineInfo.Duplicates := dupIgnore; + FLineInfo.CaseSensitive := False; + + S := ParamStrUTF8(1); + // find the lazarus dir + if S = '' + then begin + S := ExtractFilePath(ParamStrUTF8(0)); + n := Pos('apiwizz', S); + if n <> 0 + then S := Copy(S, 1, n - 7) + else S := ''; + end; + + if S = '' + then begin + S := GetCurrentDirUTF8; + n := Pos('apiwizz', S); + if n <> 0 then S := Copy(S, 1, n - 7); + end; + txtLazarus.Text := S; +end; + +procedure TApiWizForm.cmdCopyClick(Sender: TObject); +var + Line: TApiLine; + WS: TApiWidgetset; +begin + if lvExisting.Selected = nil then Exit; + + Line := TApiLine(lvExisting.Selected.Data); + if Line = nil then Exit; //??? + + if txtDeclarations.Lines.Count = 0 + then begin + txtDeclarations.Lines.Add(Line.Declaration); + + if Line.WinApi + then rdgApiType.ItemIndex := 0 + else rdgApiType.ItemIndex := 1; + + rbIndependent.Checked := Line.Independent; + rbDependent.Checked := not Line.Independent; + + for WS := Low(WS) to High(Ws) do + begin + cbgLCLPlatform.Checked[Ord(WS)] := not(WS in Line.Widgetsets); + end; + Exit; + end; + + // Check match + if Line.WinApi <> (rdgApiType.ItemIndex = 0) + then begin + ShowMessage('API type mismatch'); + Exit; + end; + + if rbIndependent.Checked <> Line.Independent + then begin + ShowMessage('Dependency mismatch'); + Exit; + end; + + txtDeclarations.Lines.Add(Line.Declaration); + for WS := Low(WS) to High(Ws) do + begin + if (WS in Line.Widgetsets) then Continue; + cbgLCLPlatform.Checked[Ord(WS)] := True; + end; +end; + procedure TApiWizForm.cmdGenerateClick(Sender: TObject); const RETURN_PROC: array[TProcType] of String = ('', ' Nothing'); @@ -333,8 +473,9 @@ var S, DeclarationText: String; ProcName, FileName, IntfBase: String; PlatformPrefix, PlatformDir, PlatformObject: String; - Line, LineCount, n, Idx, PlatformIdx: Integer; + Line, LineCount, n, Idx: Integer; ProcType: TProcType; + WS: TApiWidgetset; procedure CreateLeadingCR; var @@ -517,14 +658,13 @@ begin ApiText.SaveToFile(UTF8ToSys(txtLazarus.text + '/lcl/include/' + IntfBase)); end; - for PlatformIdx := 0 to cbgLCLPlatform.Items.Count - 1 do + for WS := Low(WS) to High(Ws) do begin - if not cbgLCLPlatform.Checked[PlatformIdx] then Continue; + if not cbgLCLPlatform.Checked[Ord(WS)] then Continue; - // for now they can all be based on the check caption - PlatformPrefix := cbgLCLPlatform.Items[PlatformIdx]; - PlatformDir := PlatformPrefix; - PlatformObject := 'T' + PlatformPrefix + 'WidgetSet'; + PlatformPrefix := WS_NAME[WS]; + PlatformDir := WS_NAME[WS]; + PlatformObject := 'T' + WS_NAME[WS] + 'WidgetSet'; PlatformObject[2] := UpCase(PlatformObject[2]); //------------------ @@ -589,6 +729,157 @@ begin end; end; +procedure TApiWizForm.cmdScanClick(Sender: TObject); +var + Lines: TStringlist; + S: String; + n, idx: Integer; + Line: TApiLine; + Item: TListItem; + WS: TApiWidgetset; +begin + FLineInfo.Clear; + + Lines := TStringList.Create; + Scan(txtLazarus.text + '/lcl/include/winapih.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + Line := TApiLine.Create; + Line.Declaration := Lines[n]; + Line.WinApi := True; + S := GetName(Lines[n]); + FLineInfo.AddObject(S, Line); + end; + + Scan(txtLazarus.text + '/lcl/include/winapih.inc', 'pi', Lines); + for n := 0 to Lines.Count - 1 do + begin + Line := TApiLine.Create; + Line.Independent := True; + Line.WinApi := True; + Line.Declaration := Lines[n]; + S := GetName(Lines[n]); + FLineInfo.AddObject(S, Line); + end; + + Scan(txtLazarus.text + '/lcl/include/lclintfh.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + Line := TApiLine.Create; + Line.Declaration := Lines[n]; + S := GetName(Lines[n]); + FLineInfo.AddObject(S, Line); + end; + + Scan(txtLazarus.text + '/lcl/include/lclintfh.inc', 'pi', Lines); + for n := 0 to Lines.Count - 1 do + begin + Line := TApiLine.Create; + Line.Independent := True; + Line.Declaration := Lines[n]; + S := GetName(Lines[n]); + FLineInfo.AddObject(S, Line); + end; + + // implementations + + + Scan(txtLazarus.text + '/lcl/include/intfbasewinapi.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + S := GetName(Lines[n]); + idx := FLineInfo.IndexOf(S); + if idx = -1 then Continue; + + Line := TApiLine(FLineInfo.Objects[idx]); + Line.Base := True; + end; + + Scan(txtLazarus.text + '/lcl/include/intfbaselcl.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + S := GetName(Lines[n]); + idx := FLineInfo.IndexOf(S); + if idx = -1 then Continue; + + Line := TApiLine(FLineInfo.Objects[idx]); + Line.Base := True; + end; + + for WS := Low(WS) to High(Ws) do + begin + Scan(txtLazarus.text + '/lcl/interfaces/' + WS_NAME[WS] + '/' + WS_NAME[WS] + 'winapih.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + S := GetName(Lines[n]); + idx := FLineInfo.IndexOf(S); + if idx = -1 then Continue; + + Line := TApiLine(FLineInfo.Objects[idx]); + Include(Line.Widgetsets, WS); + end; + + Scan(txtLazarus.text + '/lcl/interfaces/' + WS_NAME[WS] + '/' + WS_NAME[WS] + 'lclintfh.inc', 'ps', Lines); + for n := 0 to Lines.Count - 1 do + begin + S := GetName(Lines[n]); + idx := FLineInfo.IndexOf(S); + if idx = -1 then Continue; + + Line := TApiLine(FLineInfo.Objects[idx]); + Include(Line.Widgetsets, WS); + end; + end; + + lvExisting.BeginUpdate; + lvExisting.Clear; + + for n := 0 to FLineInfo.Count - 1 do + begin + Item := lvExisting.Items.Add; + Item.Caption := FLineInfo[n]; + Line := TApiLine(FLineInfo.Objects[n]); + Item.Data := Line; + + if Line.WinApi + then Item.SubItems.Add('Win') + else Item.SubItems.Add('LCL'); + + if Line.Independent + then Item.SubItems.Add('X') + else Item.SubItems.Add(''); + + if Line.Base + then Item.SubItems.Add('X') + else begin + if Line.Independent + then Item.SubItems.Add('-') + else Item.SubItems.Add(''); + end; + + for WS := Low(WS) to High(Ws) do + begin + if WS in Line.Widgetsets + then Item.SubItems.Add('X') + else begin + if Line.Independent + then Item.SubItems.Add('-') + else Item.SubItems.Add(''); + end; + end; + end; + + lvExisting.EndUpdate; + + + Lines.Free; +end; + +procedure TApiWizForm.FormDestroy(Sender: TObject); +begin + FreeAndNil(FLineInfo); +end; + procedure TApiWizForm.rbPlatformDependencyClick (Sender: TObject ); begin cbgLCLPlatform.Enabled := rbDependent.Checked; diff --git a/tools/apiwizz/apiwizz.lpi b/tools/apiwizz/apiwizz.lpi index eb97c55e48..33c0884e3a 100644 --- a/tools/apiwizz/apiwizz.lpi +++ b/tools/apiwizz/apiwizz.lpi @@ -2,8 +2,11 @@ - + + + + @@ -20,7 +23,8 @@ - + + @@ -37,11 +41,8 @@ - + - - - @@ -52,5 +53,6 @@ +