From 3416b940e12c4ade7a40d478199972fc436812be Mon Sep 17 00:00:00 2001 From: lazarus Date: Tue, 27 Mar 2001 11:11:13 +0000 Subject: [PATCH] MG: fixed mouse msg, added filedialog initialdir git-svn-id: trunk@241 - --- ide/editoroptions.pp | 14 +++++++++ ide/environmentopts.pp | 16 ++++++++++ ide/main.pp | 25 ++++++++++++---- lcl/dialogs.pp | 23 ++++++++++----- lcl/include/filedialog.inc | 29 ++++++++++++++---- lcl/interfaces/gtk/gtkcallback.inc | 42 ++++++++++++++++++--------- lcl/interfaces/gtk/gtkwinapiwindow.pp | 16 ++++++---- 7 files changed, 127 insertions(+), 38 deletions(-) diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index fde96d6a8e..4ac08cf28b 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -532,6 +532,16 @@ end; { TEditorOptions } constructor TEditorOptions.Create; + + function CreateConfigPath(Path: string): boolean; + begin + // ToDo: use ForceDirectory + if not DirectoryExists(Path) then + Result:=CreateDir(Path) + else + Result:=true; + end; + var ConfFileName,SecConfFileName:string; begin inherited Create; @@ -546,6 +556,10 @@ begin ConfFileName:=SecConfFileName; end; end; + + if not CreateConfigPath(ExtractFilePath(ConfFilename)) then + writeln('WARNING: config path "'+ExtractFilePath(ConfFilename) + +'" does not exist'); XMLConfig:=TXMLConfig.Create(ConfFileName); // set defaults diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index 7b03f5652f..bd0f28e29d 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -76,6 +76,7 @@ type // recent files and directories // ToDo + FLastOpenDialogDir: string; procedure SetFileName(NewFilename: string); public @@ -129,6 +130,10 @@ type read FBackupInfoRepositoryFiles write FBackupInfoRepositoryFiles; property BackupInfoOtherFiles: TBackupInfo read FBackupInfoOtherFiles write FBackupInfoOtherFiles; + + // recent files and directories + property LastOpenDialogDir: string + read FLastOpenDialogDir write FLastOpenDialogDir; end; //---------------------------------------------------------------------------- @@ -259,6 +264,9 @@ begin MaxCounter:=9; // for bakCounter SubDirectory:='backup'; end; + + // recent files and directories + FLastOpenDialogDir:=''; end; destructor TEnvironmentOptions.Destroy; @@ -380,6 +388,10 @@ begin ,'EnvironmentOptions/BackupOtherFiles/'); end; + // recent files and directories + FLastOpenDialogDir:=XMLConfig.GetValue( + 'EnvironmentOptions/Recent/LastOpenDialogDir/Value',FLastOpenDialogDir); + XMLConfig.Free; // object inspector @@ -472,6 +484,10 @@ begin ,'EnvironmentOptions/BackupOtherFiles/'); end; + // recent files and directories + XMLConfig.SetValue('EnvironmentOptions/Recent/LastOpenDialogDir/Value' + ,FLastOpenDialogDir); + XMLConfig.Flush; XMLConfig.Free; diff --git a/ide/main.pp b/ide/main.pp index c73d6cf13a..d416cd00af 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -277,8 +277,8 @@ var ObjectInspector1 : TObjectInspector; PropertyEditorHook1 : TPropertyEditorHook; - // ...> SourceNotebook : TSourceNotebook; + TagInc : Integer; @@ -1160,12 +1160,16 @@ end; procedure TMainIDE.mnuOpenClicked(Sender : TObject); var OpenDialog:TOpenDialog; + AFilename: string; begin OpenDialog:=TOpenDialog.Create(Application); try OpenDialog.Title:='Open file'; + OpenDialog.InitialDir:=EnvironmentOptions.LastOpenDialogDir; if OpenDialog.Execute then begin - DoOpenEditorFile(ExpandFilename(OpenDialog.Filename),false); + AFilename:=ExpandFilename(OpenDialog.Filename); + EnvironmentOptions.LastOpenDialogDir:=ExtractFilePath(AFilename); + DoOpenEditorFile(AFilename,false); end; finally OpenDialog.Free; @@ -1398,12 +1402,16 @@ end; Procedure TMainIDE.mnuOpenProjectClicked(Sender : TObject); var OpenDialog:TOpenDialog; + AFileName: string; begin OpenDialog:=TOpenDialog.Create(Application); try OpenDialog.Title:='Open Project File (*.lpi)'; + OpenDialog.InitialDir:=EnvironmentOptions.LastOpenDialogDir; if OpenDialog.Execute then begin - DoOpenProjectFile(ExpandFilename(OpenDialog.Filename)); + AFilename:=ExpandFilename(OpenDialog.Filename); + EnvironmentOptions.LastOpenDialogDir:=ExtractFilePath(AFilename); + DoOpenProjectFile(AFilename); end; finally OpenDialog.Free; @@ -1700,8 +1708,10 @@ writeln('TMainIDE.DoSaveCurUnit 1'); try SaveDialog.Title:='Save '+ActiveUnitInfo.UnitName; SaveDialog.FileName:=lowercase(ActiveUnitInfo.UnitName)+'.pp'; + SaveDialog.InitialDir:=EnvironmentOptions.LastOpenDialogDir; if SaveDialog.Execute then begin NewFilename:=ExpandFilename(SaveDialog.Filename); + EnvironmentOptions.LastOpenDialogDir:=ExtractFilePath(NewFilename); if ExtractFileExt(NewFilename)='' then NewFilename:=NewFilename+'.pp'; if FileExists(NewFilename) then begin @@ -2323,8 +2333,10 @@ writeln('TMainIDE.DoSaveProject 1'); else if SaveDialog.Filename='' then SaveDialog.Filename:='Project1.lpi'; repeat + SaveDialog.InitialDir:=EnvironmentOptions.LastOpenDialogDir; if SaveDialog.Execute then begin NewFilename:=ExpandFilename(SaveDialog.Filename); + EnvironmentOptions.LastOpenDialogDir:=ExtractFilePath(NewFilename); if ExtractFileExt(NewFilename)='' then NewFilename:=NewFilename+'.lpi'; NewProgramFilename:=ChangeFileExt( @@ -2842,8 +2854,8 @@ function TMainIDE.DoJumpToCompilerMessage(Index:integer; Result:=(TheFilename<>'') and (TheFilename[1]='/'); {$ELSE} // windows - Result:=(length(TheFilename)<3) or (copy(TheFilename,1,2)='\\') - or ((upcase(TheFilename[1]) in ['A'..'Z']) and (copy(TheFilename,2,2)=':\')); + Result:=(copy(TheFilename,1,2)='\\') or ((length(TheFilename)>3) and + (upcase(TheFilename[1]) in ['A'..'Z']) and (copy(TheFilename,2,2)=':\')); {$ENDIF} end; @@ -3022,6 +3034,9 @@ end. { ============================================================================= $Log$ + Revision 1.82 2001/03/27 11:11:13 lazarus + MG: fixed mouse msg, added filedialog initialdir + Revision 1.81 2001/03/26 14:52:30 lazarus MG: TSourceLog + compiling bugfixes diff --git a/lcl/dialogs.pp b/lcl/dialogs.pp index 6f2cfe0b07..3af32b971f 100644 --- a/lcl/dialogs.pp +++ b/lcl/dialogs.pp @@ -58,10 +58,10 @@ type FTitle : string; FUserChoice: integer; protected + function DoExecute : boolean; virtual; public FCompStyle : LongInt; constructor Create (AOwner : TComponent); override; - function DoExecute : boolean; virtual; function Execute : boolean; virtual; property Handle : integer read FHandle write FHandle; property Title : string read FTitle write FTitle; @@ -72,15 +72,19 @@ type TFileDialog = class(TCommonDialog) private - FFileName : String; - FFilter: String; + FFileName : String; + FFilter: String; + FInitialDir: string; + FOldWorkingDir: string; protected - procedure SetFileName(value :String); - procedure SetFilter(value :String); + function DoExecute : boolean; override; + procedure SetFileName(value :String); + procedure SetFilter(value :String); public - function DoExecute : boolean; override; - property FileName : String read FFileName write SetFileName; - property Filter : String read FFilter write SetFilter; + function Execute : boolean; override; + property FileName : String read FFileName write SetFileName; + property Filter : String read FFilter write SetFilter; + property InitialDir: string read FInitialDir write FInitialDir; end; TOpenDialog = class(TFileDialog) @@ -199,6 +203,9 @@ end. { ============================================================================= $Log$ + Revision 1.5 2001/03/27 11:11:13 lazarus + MG: fixed mouse msg, added filedialog initialdir + Revision 1.4 2001/03/03 00:48:03 lazarus + added support for message dialogs stoppok diff --git a/lcl/include/filedialog.inc b/lcl/include/filedialog.inc index 03f9395934..a846e4dae9 100644 --- a/lcl/include/filedialog.inc +++ b/lcl/include/filedialog.inc @@ -5,13 +5,29 @@ {------------------------------------------------------------------------------} { TFileDialog Execute } {------------------------------------------------------------------------------} +function TFileDialog.Execute : boolean; +begin + FOldWorkingDir:=GetCurrentDir; + if FInitialDir<>'' then SetCurrentDir(FInitialDir); + try + FUserChoice := mrNone; + CNSendMessage(LM_CREATE, Self, nil); + Result:= DoExecute; + CNSendMessage(LM_DESTROY, Self, nil); + FHandle := 0; + finally + SetCurrentDir(FOldWorkingDir); + end; +end; + +{------------------------------------------------------------------------------} +{ TFileDialog DoExecute } +{------------------------------------------------------------------------------} function TFileDialog.DoExecute : boolean; begin - CNSendMessage(LM_SETFILTER, Self, nil); CNSendMessage(LM_SETFILENAME, Self, nil); Result:= inherited DoExecute; - end; {------------------------------------------------------------------------------} @@ -59,14 +75,17 @@ end; ------------------------------------------------------------------------------} constructor TSaveDialog.Create (AOwner : TComponent); begin - inherited Create(AOwner); - fCompStyle := csFileDialog; - FTitle:= 'Save file as:'; + inherited Create(AOwner); + fCompStyle := csFileDialog; + FTitle:= 'Save file as:'; end; { ============================================================================= $Log$ + Revision 1.2 2001/03/27 11:11:13 lazarus + MG: fixed mouse msg, added filedialog initialdir + Revision 1.1 2000/07/13 10:28:25 michael + Initial import diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index 0656d4c525..aa56cdc5ee 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -379,23 +379,34 @@ begin MessE.UserData := Data; Result := DeliverPostMessage(Data, MessE); end - else - begin - case event^.Button of - 1 : if event^.thetype = gdk_button_press then MessI.Msg := LM_LBUTTONDOWN - else - MessI.Msg := LM_LBUTTONDBLCLK; - 2 : if event^.thetype = gdk_button_press then MessI.Msg := LM_MBUTTONDOWN - else - MessI.Msg := LM_MBUTTONDBLCLK; - 3 : if event^.thetype = gdk_button_press then MessI.Msg := LM_RBUTTONDOWN - else - MessI.Msg := LM_RBUTTONDBLCLK; + else begin + MessI.Keys := 0; + case event^.Button of + 1 : begin + MessI.Keys := MessI.Keys or MK_LBUTTON; + if event^.thetype = gdk_button_press then begin + MessI.Msg := LM_LBUTTONDOWN; + end else + MessI.Msg := LM_LBUTTONDBLCLK; + end; + 2 : begin + MessI.Keys := MessI.Keys or MK_MBUTTON; + if event^.thetype = gdk_button_press then + MessI.Msg := LM_MBUTTONDOWN + else + MessI.Msg := LM_MBUTTONDBLCLK; + end; + 3 : begin + MessI.Keys := MessI.Keys or MK_RBUTTON; + if event^.thetype = gdk_button_press then + MessI.Msg := LM_RBUTTONDOWN + else + MessI.Msg := LM_RBUTTONDBLCLK; + end; else MessI.Msg := LM_NULL; - end; //case + end; //case MessI.XPos := Trunc(Event^.X); MessI.YPos := Trunc(Event^.Y); - MessI.Keys := 0; if ssShift in ShiftState then MessI.Keys := MessI.Keys or MK_SHIFT; if ssCtrl in ShiftState then MessI.Keys := MessI.Keys or MK_CONTROL; if ssLeft in ShiftState then MessI.Keys := MessI.Keys or MK_LBUTTON; @@ -1105,6 +1116,9 @@ end; { ============================================================================= $Log$ + Revision 1.29 2001/03/27 11:11:13 lazarus + MG: fixed mouse msg, added filedialog initialdir + Revision 1.28 2001/03/26 14:58:31 lazarus MG: setwindowpos + bugfixes diff --git a/lcl/interfaces/gtk/gtkwinapiwindow.pp b/lcl/interfaces/gtk/gtkwinapiwindow.pp index d95517eb56..d1cd4e97f8 100644 --- a/lcl/interfaces/gtk/gtkwinapiwindow.pp +++ b/lcl/interfaces/gtk/gtkwinapiwindow.pp @@ -316,18 +316,19 @@ begin if BackPixmap = nil then BackPixmap := gdk_pixmap_new(Widget^.Window, Width, Height, -1); - if BackPixmap <> nil + if (BackPixmap <> nil) and (Widget<>nil) and (PGTKStyle(Widget^.theStyle)<>nil) then gdk_draw_pixmap( BackPixmap, PGTKStyle(Widget^.theStyle)^.bg_gc[GTK_STATE_NORMAL], Widget^.Window, X, Y, 0, 0, Width, Height ); - gdk_draw_rectangle( - PGTKWidget(Client)^.Window, - PGTKStyle(PGTKWidget(Client)^.theStyle)^.fg_gc[GC_STATE[Integer(Pixmap) <> 1]], - 1, X, Y, Width, Height - ); + if PGTKStyle(PGTKWidget(Client)^.theStyle)<>nil then + gdk_draw_rectangle( + PGTKWidget(Client)^.Window, + PGTKStyle(PGTKWidget(Client)^.theStyle)^.fg_gc[GC_STATE[Integer(Pixmap) <> 1]], + 1, X, Y, Width, Height + ); IsDrawn := True; if Timer = 0 then Timer := gtk_timeout_add(500, @GTKAPIWidgetClient_Timer, Client); @@ -545,6 +546,9 @@ end. { ============================================================================= $Log$ + Revision 1.6 2001/03/27 11:11:13 lazarus + MG: fixed mouse msg, added filedialog initialdir + Revision 1.5 2001/03/26 14:58:32 lazarus MG: setwindowpos + bugfixes