diff --git a/components/lazmapviewer/examples/fulldemo/main.lfm b/components/lazmapviewer/examples/fulldemo/main.lfm index 6a69db37b..f5c02f952 100644 --- a/components/lazmapviewer/examples/fulldemo/main.lfm +++ b/components/lazmapviewer/examples/fulldemo/main.lfm @@ -6,11 +6,11 @@ object MainForm: TMainForm Caption = 'LazMapViewer' ClientHeight = 640 ClientWidth = 883 + ShowHint = True + LCLVersion = '3.99.0.0' OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow - ShowHint = True - LCLVersion = '2.3.0.0' object MapView: TMapView Left = 0 Height = 640 @@ -59,9 +59,9 @@ object MainForm: TMainForm Width = 263 Max = 19 Min = 1 - OnChange = ZoomTrackBarChange Position = 1 TickMarks = tmBoth + OnChange = ZoomTrackBarChange Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 2 BorderSpacing.Right = 2 @@ -332,10 +332,10 @@ object MainForm: TMainForm 'km' 'miles' ) - OnChange = CbDistanceUnitsChange Style = csDropDownList TabOrder = 4 Text = 'km' + OnChange = CbDistanceUnitsChange end object GbSearch: TGroupBox AnchorSideLeft.Control = GbScreenSize @@ -385,8 +385,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Right = 6 Caption = 'Search' - OnClick = BtnSearchClick TabOrder = 1 + OnClick = BtnSearchClick end object LblSelectLocation: TLabel AnchorSideLeft.Control = CbLocations @@ -413,8 +413,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Bottom = 8 Caption = 'Go to' + TabOrder = 3 OnClick = BtnGoToClick - TabOrder = 2 end object CbFoundLocations: TComboBox AnchorSideLeft.Control = LblSelectLocation @@ -432,11 +432,11 @@ object MainForm: TMainForm DropDownCount = 24 ItemHeight = 15 ItemWidth = -2 - OnDrawItem = CbFoundLocationsDrawItem ParentShowHint = False ShowHint = True Style = csOwnerDrawFixed - TabOrder = 3 + TabOrder = 2 + OnDrawItem = CbFoundLocationsDrawItem end end object GbGPS: TGroupBox @@ -469,8 +469,8 @@ object MainForm: TMainForm BorderSpacing.Left = 6 BorderSpacing.Right = 6 Caption = 'List...' - OnClick = BtnGPSPointsClick TabOrder = 0 + OnClick = BtnGPSPointsClick end object InfoBtnGPSPoints: TLabel AnchorSideLeft.Control = GbGPS @@ -519,8 +519,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Top = 8 Caption = 'Save map to file' - OnClick = BtnSaveToFileClick TabOrder = 7 + OnClick = BtnSaveToFileClick end object BtnLoadGPXFile: TButton AnchorSideLeft.Control = BtnSaveToFile @@ -533,8 +533,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Left = 8 Caption = 'Load GPX file...' - OnClick = BtnLoadGPXFileClick TabOrder = 8 + OnClick = BtnLoadGPXFileClick end object BtnPrintMap: TButton AnchorSideLeft.Control = BtnSaveToFile @@ -549,8 +549,8 @@ object MainForm: TMainForm Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 8 Caption = 'Print...' - OnClick = BtnPrintMapClick TabOrder = 9 + OnClick = BtnPrintMapClick end end object PgConfig: TTabSheet @@ -562,9 +562,9 @@ object MainForm: TMainForm AnchorSideTop.Control = PgConfig Left = 6 Height = 15 - Top = 8 + Top = 12 Width = 52 - BorderSpacing.Top = 8 + BorderSpacing.Top = 12 Caption = 'Providers:' FocusControl = CbProviders ParentColor = False @@ -576,26 +576,26 @@ object MainForm: TMainForm AnchorSideRight.Control = BtnLoadMapProviders Left = 6 Height = 23 - Top = 25 - Width = 199 + Top = 29 + Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 2 BorderSpacing.Right = 4 DropDownCount = 24 ItemHeight = 15 - OnChange = CbProvidersChange Style = csDropDownList TabOrder = 0 + OnChange = CbProvidersChange end object BtnLoadMapProviders: TSpeedButton AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = CbProviders AnchorSideTop.Side = asrCenter AnchorSideRight.Control = BtnSaveMapProviders - Left = 209 + Left = 211 Height = 22 - Top = 25 + Top = 29 Width = 23 Anchors = [akTop, akRight] BorderSpacing.Right = 4 @@ -644,12 +644,12 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter AnchorSideRight.Control = PgConfig AnchorSideRight.Side = asrBottom - Left = 236 + Left = 238 Height = 22 - Top = 25 + Top = 29 Width = 23 Anchors = [akTop, akRight] - BorderSpacing.Right = 8 + BorderSpacing.Right = 6 Glyph.Data = { 36040000424D3604000000000000360000002800000010000000100000000100 2000000000000004000064000000640000000000000000000000A4653455A465 @@ -694,15 +694,15 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 81 + Top = 296 Width = 79 BorderSpacing.Left = 6 BorderSpacing.Top = 6 Caption = 'Use threads' Checked = True - OnChange = CbUseThreadsChange State = cbChecked - TabOrder = 1 + TabOrder = 4 + OnChange = CbUseThreadsChange end object CbDoubleBuffer: TCheckBox AnchorSideLeft.Control = CbUseThreads @@ -710,15 +710,15 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 106 + Top = 321 Width = 85 BorderSpacing.Top = 6 BorderSpacing.Right = 9 Caption = 'DblBuffering' Checked = True - OnChange = CbDoubleBufferChange State = cbChecked - TabOrder = 2 + TabOrder = 6 + OnChange = CbDoubleBufferChange end object CbDebugTiles: TCheckBox AnchorSideLeft.Control = CbDoubleBuffer @@ -726,12 +726,12 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 131 + Top = 346 Width = 77 BorderSpacing.Top = 6 Caption = 'Debug tiles' + TabOrder = 7 OnChange = CbDebugTilesChange - TabOrder = 3 end object BtnPOITextFont: TButton AnchorSideLeft.Control = rgPOIMode @@ -739,13 +739,13 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 25 - Top = 286 + Top = 501 Width = 93 AutoSize = True BorderSpacing.Top = 12 Caption = 'POI text font' + TabOrder = 9 OnClick = BtnPOITextFontClick - TabOrder = 4 end object cbPOITextBgColor: TColorBox AnchorSideLeft.Control = LblPOITextBgColor @@ -755,15 +755,15 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 154 Height = 22 - Top = 287 + Top = 502 Width = 107 NoneColorColor = clWhite Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 ItemHeight = 16 + TabOrder = 10 OnChange = cbPOITextBgColorChange - TabOrder = 5 end object LblPOITextBgColor: TLabel AnchorSideLeft.Control = BtnPOITextFont @@ -772,7 +772,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter Left = 107 Height = 15 - Top = 291 + Top = 506 Width = 39 BorderSpacing.Left = 8 Caption = 'Backgr.' @@ -785,7 +785,7 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 6 Height = 4 - Top = 158 + Top = 373 Width = 255 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 8 @@ -797,7 +797,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 104 - Top = 170 + Top = 385 Width = 159 AutoFill = True AutoSize = True @@ -820,25 +820,25 @@ object MainForm: TMainForm 'image from imagelist' 'custom drawing' ) + TabOrder = 8 OnClick = rgPOIModeClick - TabOrder = 6 end object CbZoomToCursor: TCheckBox AnchorSideLeft.Control = PgConfig - AnchorSideTop.Control = CbProviders + AnchorSideTop.Control = gbProxy AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 56 + Top = 271 Width = 100 BorderSpacing.Left = 6 - BorderSpacing.Top = 8 + BorderSpacing.Top = 12 BorderSpacing.Right = 24 Caption = 'Zoom to cursor' Checked = True - OnChange = CbZoomToCursorChange State = cbChecked - TabOrder = 7 + TabOrder = 2 + OnChange = CbZoomToCursorChange end object cbCyclicView: TCheckBox AnchorSideLeft.Control = CbZoomToCursor @@ -846,13 +846,13 @@ object MainForm: TMainForm AnchorSideTop.Control = CbZoomToCursor Left = 130 Height = 19 - Top = 56 + Top = 271 Width = 77 Caption = 'Cyclic view' Checked = True - OnChange = cbCyclicViewChange State = cbChecked - TabOrder = 8 + TabOrder = 3 + OnChange = cbCyclicViewChange end object clbBackColor: TColorButton AnchorSideLeft.Control = cbCyclicView @@ -860,7 +860,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter Left = 130 Height = 25 - Top = 103 + Top = 318 Width = 105 BorderWidth = 2 ButtonColorAutoSize = False @@ -875,13 +875,177 @@ object MainForm: TMainForm AnchorSideTop.Control = CbUseThreads Left = 130 Height = 19 - Top = 81 + Top = 296 Width = 83 Caption = 'Preview tiles' Checked = True - OnChange = CbPreviewTilesChange State = cbChecked - TabOrder = 9 + TabOrder = 5 + OnChange = CbPreviewTilesChange + end + object gbProxy: TGroupBox + AnchorSideLeft.Control = PgConfig + AnchorSideTop.Control = CbProviders + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = PgConfig + AnchorSideRight.Side = asrBottom + Left = 6 + Height = 195 + Top = 64 + Width = 255 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Top = 6 + BorderSpacing.Around = 6 + Caption = 'Proxy' + ClientHeight = 175 + ClientWidth = 251 + TabOrder = 1 + object lblProxyHost: TLabel + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = edProxyHost + AnchorSideTop.Side = asrCenter + Left = 32 + Height = 15 + Top = 67 + Width = 28 + BorderSpacing.Left = 16 + Caption = 'Host:' + end + object edProxyHost: TEdit + AnchorSideLeft.Control = edProxyUserName + AnchorSideTop.Control = rbProxyData + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 99 + Height = 23 + Top = 63 + Width = 144 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Right = 8 + TabOrder = 3 + OnChange = rbProxyChange + end + object lblProxyPort: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = seProxyPort + AnchorSideTop.Side = asrCenter + Left = 32 + Height = 15 + Top = 94 + Width = 22 + Caption = 'Port' + end + object seProxyPort: TSpinEdit + AnchorSideLeft.Control = lblProxyUserName + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = edProxyHost + AnchorSideTop.Side = asrBottom + Left = 99 + Height = 23 + Top = 90 + Width = 104 + BorderSpacing.Top = 4 + MaxValue = 65535 + TabOrder = 4 + OnChange = rbProxyChange + end + object lblProxyUserName: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = edProxyUserName + AnchorSideTop.Side = asrCenter + Left = 32 + Height = 15 + Top = 121 + Width = 59 + BorderSpacing.Right = 8 + Caption = 'User name:' + end + object edProxyUserName: TEdit + AnchorSideLeft.Control = lblProxyUserName + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = seProxyPort + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 99 + Height = 23 + Top = 117 + Width = 144 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + TabOrder = 5 + OnChange = rbProxyChange + end + object lblProxyPassword: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = edProxyPassword + AnchorSideTop.Side = asrCenter + Left = 32 + Height = 15 + Top = 148 + Width = 50 + Caption = 'Password' + end + object edProxyPassword: TEdit + AnchorSideLeft.Control = edProxyUserName + AnchorSideTop.Control = edProxyUserName + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 99 + Height = 23 + Top = 144 + Width = 144 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + TabOrder = 6 + OnChange = rbProxyChange + end + object rbProxyData: TRadioButton + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = rbSystemProxy + AnchorSideTop.Side = asrBottom + Left = 16 + Height = 19 + Top = 44 + Width = 74 + BorderSpacing.Top = 3 + Caption = 'Proxy data' + TabOrder = 2 + OnChangeBounds = rbProxyChange + end + object rbNoProxy: TRadioButton + AnchorSideLeft.Control = gbProxy + AnchorSideTop.Control = gbProxy + Left = 16 + Height = 19 + Top = 0 + Width = 67 + BorderSpacing.Left = 16 + Caption = 'No proxy' + TabOrder = 0 + OnChange = rbProxyChange + end + object rbSystemProxy: TRadioButton + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = rbNoProxy + AnchorSideTop.Side = asrBottom + Left = 16 + Height = 19 + Top = 22 + Width = 110 + BorderSpacing.Top = 3 + Caption = 'Use system proxy' + Checked = True + TabOrder = 1 + TabStop = True + OnChange = rbProxyChange + end end end end diff --git a/components/lazmapviewer/examples/fulldemo/main.pas b/components/lazmapviewer/examples/fulldemo/main.pas index 5ba67d2f8..beae98ef3 100644 --- a/components/lazmapviewer/examples/fulldemo/main.pas +++ b/components/lazmapviewer/examples/fulldemo/main.pas @@ -5,8 +5,8 @@ unit Main; interface uses - Classes, SysUtils, Types, Forms, Controls, Graphics, Dialogs, - ExtCtrls, StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, PrintersDlgs, + Classes, SysUtils, Types, Forms, Controls, Graphics, Dialogs, ExtCtrls, + StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, Spin, PrintersDlgs, mvGeoNames, mvMapViewer, mvTypes, mvGpsObj, mvDrawingEngine; type @@ -26,6 +26,9 @@ type CbFoundLocations: TComboBox; CbLocations: TComboBox; CbProviders: TComboBox; + rbSystemProxy: TRadioButton; + rbNoProxy: TRadioButton; + rbProxyData: TRadioButton; CbUseThreads: TCheckBox; CbMouseCoords: TGroupBox; CbDistanceUnits: TComboBox; @@ -35,18 +38,26 @@ type cbCyclicView: TCheckBox; CbPreviewTiles: TCheckBox; clbBackColor: TColorButton; + edProxyHost: TEdit; + edProxyUserName: TEdit; + edProxyPassword: TEdit; FontDialog: TFontDialog; GbCenterCoords: TGroupBox; GbScreenSize: TGroupBox; GbSearch: TGroupBox; GbGPS: TGroupBox; + gbProxy: TGroupBox; InfoCenterLatitude: TLabel; InfoViewportHeight: TLabel; InfoCenterLongitude: TLabel; InfoBtnGPSPoints: TLabel; GPSPointInfo: TLabel; InfoViewportWidth: TLabel; + lblProxyUserName: TLabel; + lblProxyPort: TLabel; + lblProxyHost: TLabel; LblPOITextBgColor: TLabel; + lblProxyPassword: TLabel; LblSelectLocation: TLabel; LblCenterLatitude: TLabel; LblViewportHeight: TLabel; @@ -69,6 +80,7 @@ type POIImages: TImageList; PrintDialog1: TPrintDialog; rgPOIMode: TRadioGroup; + seProxyPort: TSpinEdit; ZoomTrackBar: TTrackBar; procedure BtnGoToClick(Sender: TObject); procedure BtnLoadGPXFileClick(Sender: TObject); @@ -85,6 +97,7 @@ type procedure cbPOITextBgColorChange(Sender: TObject); procedure CbPreviewTilesChange(Sender: TObject); procedure CbProvidersChange(Sender: TObject); + procedure rbProxyChange(Sender: TObject); procedure CbShowPOIImageChange(Sender: TObject); procedure CbUseThreadsChange(Sender: TObject); procedure CbDistanceUnitsChange(Sender: TObject); @@ -112,6 +125,7 @@ type POIImage: TCustomBitmap; procedure ClearFoundLocations; procedure UpdateCoords(X, Y: Integer); + procedure UpdateDownloadEngineProxy; procedure UpdateDropdownWidth(ACombobox: TCombobox); procedure UpdateLocationHistory(ALocation: String); procedure UpdateViewportSize; @@ -391,6 +405,11 @@ begin MapView.MapProvider := CbProviders.Text; end; +procedure TMainForm.rbProxyChange(Sender: TObject); +begin + UpdateDownloadEngineProxy; +end; + procedure TMainForm.CbShowPOIImageChange(Sender: TObject); begin { @@ -773,6 +792,19 @@ begin List.Free; end; + i := ini.ReadInteger('Proxy', 'UseProxy', 0); + case i of + 0: rbNoProxy.Checked := true; + 1: rbSystemProxy.Checked := true; + 2: rbProxyData.Checked := true; + end; + edProxyHost.Text := ini.ReadString('Proxy', 'ProxyHost', edProxyHost.Text); + seProxyPort.Value := ini.ReadInteger('Proxy', 'ProxyPort', seProxyPort.Value); + edProxyUserName.Text := ini.ReadString('Proxy', 'ProxyName', edProxyUserName.Text); + edProxyPassword.Text := ini.ReadString('Proxy', 'ProxyPassword', edProxyPassword.Text); + + UpdateDownloadEngineProxy; + finally ini.Free; end; @@ -815,6 +847,26 @@ begin end; end; +procedure TMainForm.UpdateDownloadEngineProxy; +begin + if MapView.DownloadEngine.HasProxySupport then + begin + MapView.DownloadEngine.SetProxy( + rbSystemProxy.Checked, rbProxyData.Checked, + edProxyHost.Name, seProxyPort.Value, edProxyUserName.Text, edProxyPassword.Text + ); + rbSystemProxy.Enabled := MapView.DownloadEngine.SupportsSystemProxy; + lblProxyHost.Enabled := rbProxyData.Checked; + edProxyHost.Enabled := rbProxyData.Checked; + lblProxyPort.Enabled := rbProxyData.Checked; + seProxyPort.Enabled := rbProxyData.Checked; + lblProxyUserName.Enabled := rbProxyData.Checked; + edProxyUserName.Enabled := rbProxyData.Checked; + lblProxyPassword.Enabled := rbProxyData.Checked; + edProxyPassword.Enabled := rbProxyData.Checked; + end; +end; + procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox); var cnv: TControlCanvas; @@ -913,6 +965,19 @@ begin for i := 0 to CbLocations.Items.Count-1 do ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]); + if rbSystemProxy.Checked then + i := 1 + else if rbProxyData.Checked then + i := 2 + else + i := 0; + ini.EraseSection('Proxy'); + ini.WriteInteger('Proxy', 'UseProxy', i); + ini.WriteString('Proxy', 'ProxyHost', edProxyHost.Text); + ini.WriteInteger('Proxy', 'ProxyPort', seProxyPort.Value); + ini.WriteString('Proxy', 'ProxyName', edProxyUserName.Text); + ini.WriteString('Proxy', 'ProxyPassword', edProxyPassword.Text); + finally ini.Free; end; diff --git a/components/lazmapviewer/examples/fulldemo_with_addons/main.lfm b/components/lazmapviewer/examples/fulldemo_with_addons/main.lfm index fceb8844d..f634a70db 100644 --- a/components/lazmapviewer/examples/fulldemo_with_addons/main.lfm +++ b/components/lazmapviewer/examples/fulldemo_with_addons/main.lfm @@ -6,11 +6,11 @@ object MainForm: TMainForm Caption = 'LazMapViewer' ClientHeight = 640 ClientWidth = 883 + ShowHint = True + LCLVersion = '3.99.0.0' OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow - ShowHint = True - LCLVersion = '2.3.0.0' object MapView: TMapView Left = 0 Height = 640 @@ -57,9 +57,9 @@ object MainForm: TMainForm Width = 263 Max = 19 Min = 1 - OnChange = ZoomTrackBarChange Position = 1 TickMarks = tmBoth + OnChange = ZoomTrackBarChange Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 2 BorderSpacing.Right = 2 @@ -317,10 +317,10 @@ object MainForm: TMainForm 'km' 'miles' ) - OnChange = CbDistanceUnitsChange Style = csDropDownList TabOrder = 4 Text = 'km' + OnChange = CbDistanceUnitsChange end object GbSearch: TGroupBox AnchorSideLeft.Control = GbScreenSize @@ -370,8 +370,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Right = 6 Caption = 'Search' - OnClick = BtnSearchClick TabOrder = 1 + OnClick = BtnSearchClick end object LblSelectLocation: TLabel AnchorSideLeft.Control = CbLocations @@ -397,8 +397,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Bottom = 8 Caption = 'Go to' - OnClick = BtnGoToClick TabOrder = 2 + OnClick = BtnGoToClick end object CbFoundLocations: TComboBox AnchorSideLeft.Control = LblSelectLocation @@ -416,11 +416,11 @@ object MainForm: TMainForm DropDownCount = 24 ItemHeight = 15 ItemWidth = -2 - OnDrawItem = CbFoundLocationsDrawItem ParentShowHint = False ShowHint = True Style = csOwnerDrawFixed TabOrder = 3 + OnDrawItem = CbFoundLocationsDrawItem end end object GbGPS: TGroupBox @@ -453,8 +453,8 @@ object MainForm: TMainForm BorderSpacing.Left = 6 BorderSpacing.Right = 6 Caption = 'List...' - OnClick = BtnGPSPointsClick TabOrder = 0 + OnClick = BtnGPSPointsClick end object InfoBtnGPSPoints: TLabel AnchorSideLeft.Control = GbGPS @@ -501,8 +501,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Top = 8 Caption = 'Save map to file' - OnClick = BtnSaveToFileClick TabOrder = 7 + OnClick = BtnSaveToFileClick end object BtnLoadGPXFile: TButton AnchorSideLeft.Control = BtnSaveToFile @@ -515,8 +515,8 @@ object MainForm: TMainForm AutoSize = True BorderSpacing.Left = 8 Caption = 'Load GPX file...' - OnClick = BtnLoadGPXFileClick TabOrder = 8 + OnClick = BtnLoadGPXFileClick end end object PgConfig: TTabSheet @@ -528,9 +528,9 @@ object MainForm: TMainForm AnchorSideTop.Control = PgConfig Left = 6 Height = 15 - Top = 6 + Top = 12 Width = 86 - BorderSpacing.Top = 6 + BorderSpacing.Top = 12 Caption = 'Drawing engine:' end object CbDrawingEngine: TComboBox @@ -541,7 +541,7 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 6 Height = 23 - Top = 23 + Top = 29 Width = 255 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -554,18 +554,18 @@ object MainForm: TMainForm 'RGBGraphics' 'BGRABitmap' ) - OnChange = CbDrawingEngineChange Style = csDropDownList TabOrder = 0 Text = 'default' + OnChange = CbDrawingEngineChange end object LblProviders: TLabel AnchorSideLeft.Control = CbProviders - AnchorSideTop.Control = CbDownloadEngine + AnchorSideTop.Control = gbProxy AnchorSideTop.Side = asrBottom Left = 6 Height = 15 - Top = 102 + Top = 315 Width = 52 BorderSpacing.Top = 8 Caption = 'Providers:' @@ -578,26 +578,26 @@ object MainForm: TMainForm AnchorSideRight.Control = BtnLoadMapProviders Left = 6 Height = 23 - Top = 119 - Width = 199 + Top = 332 + Width = 201 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 2 BorderSpacing.Right = 4 DropDownCount = 24 ItemHeight = 15 - OnChange = CbProvidersChange Style = csDropDownList TabOrder = 1 + OnChange = CbProvidersChange end object BtnLoadMapProviders: TSpeedButton AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = CbProviders AnchorSideTop.Side = asrCenter AnchorSideRight.Control = BtnSaveMapProviders - Left = 209 + Left = 211 Height = 22 - Top = 119 + Top = 332 Width = 23 Anchors = [akTop, akRight] BorderSpacing.Right = 4 @@ -646,12 +646,12 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter AnchorSideRight.Control = PgConfig AnchorSideRight.Side = asrBottom - Left = 236 + Left = 238 Height = 22 - Top = 119 + Top = 332 Width = 23 Anchors = [akTop, akRight] - BorderSpacing.Right = 8 + BorderSpacing.Right = 6 Glyph.Data = { 36040000424D3604000000000000360000002800000010000000100000000100 2000000000000004000064000000640000000000000000000000A4653455A465 @@ -696,15 +696,15 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 175 + Top = 394 Width = 79 BorderSpacing.Left = 6 - BorderSpacing.Top = 6 + BorderSpacing.Top = 12 Caption = 'Use threads' Checked = True - OnChange = CbUseThreadsChange State = cbChecked TabOrder = 2 + OnChange = CbUseThreadsChange end object CbDoubleBuffer: TCheckBox AnchorSideLeft.Control = CbUseThreads @@ -712,15 +712,15 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 200 + Top = 419 Width = 85 BorderSpacing.Top = 6 BorderSpacing.Right = 9 Caption = 'DblBuffering' Checked = True - OnChange = CbDoubleBufferChange State = cbChecked TabOrder = 3 + OnChange = CbDoubleBufferChange end object CbDebugTiles: TCheckBox AnchorSideLeft.Control = CbDoubleBuffer @@ -728,12 +728,12 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 225 + Top = 444 Width = 77 BorderSpacing.Top = 6 Caption = 'Debug tiles' - OnChange = CbDebugTilesChange TabOrder = 4 + OnChange = CbDebugTilesChange end object CbShowPOIImage: TCheckBox AnchorSideLeft.Control = CbDebugTiles @@ -741,25 +741,25 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 262 + Top = 481 Width = 105 BorderSpacing.Top = 6 Caption = 'Show POI image' - OnChange = CbShowPOIImageChange TabOrder = 5 + OnChange = CbShowPOIImageChange end object BtnPOITextFont: TButton AnchorSideTop.Control = CbShowPOIImage AnchorSideTop.Side = asrBottom Left = 6 Height = 25 - Top = 289 + Top = 508 Width = 93 AutoSize = True BorderSpacing.Top = 8 Caption = 'POI text font' - OnClick = BtnPOITextFontClick TabOrder = 6 + OnClick = BtnPOITextFontClick end object cbPOITextBgColor: TColorBox AnchorSideLeft.Control = LblPOITextBgColor @@ -770,15 +770,15 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 154 Height = 22 - Top = 290 + Top = 509 Width = 107 NoneColorColor = clWhite Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 ItemHeight = 16 - OnChange = cbPOITextBgColorChange TabOrder = 7 + OnChange = cbPOITextBgColorChange end object LblPOITextBgColor: TLabel AnchorSideLeft.Control = BtnPOITextFont @@ -787,7 +787,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter Left = 107 Height = 15 - Top = 294 + Top = 513 Width = 39 BorderSpacing.Left = 8 Caption = 'Backgr.' @@ -800,7 +800,7 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 6 Height = 4 - Top = 252 + Top = 471 Width = 255 Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 8 @@ -812,15 +812,15 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 19 - Top = 150 + Top = 363 Width = 100 BorderSpacing.Left = 6 BorderSpacing.Top = 8 Caption = 'Zoom to cursor' Checked = True - OnChange = CbZoomToCursorChange State = cbChecked TabOrder = 8 + OnChange = CbZoomToCursorChange end object Label2: TLabel AnchorSideLeft.Control = CbDownloadEngine @@ -828,7 +828,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrBottom Left = 6 Height = 15 - Top = 54 + Top = 60 Width = 96 BorderSpacing.Top = 8 Caption = 'Download engine:' @@ -841,7 +841,7 @@ object MainForm: TMainForm AnchorSideRight.Side = asrBottom Left = 6 Height = 23 - Top = 71 + Top = 77 Width = 255 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 @@ -855,10 +855,10 @@ object MainForm: TMainForm 'FpHTTPClient' 'WinInet' ) - OnChange = CbDownloadEngineChange Style = csDropDownList TabOrder = 9 Text = 'default' + OnChange = CbDownloadEngineChange end object CbCyclic: TCheckBox AnchorSideLeft.Control = CbZoomToCursor @@ -866,14 +866,14 @@ object MainForm: TMainForm AnchorSideTop.Control = CbZoomToCursor Left = 130 Height = 19 - Top = 150 + Top = 363 Width = 77 BorderSpacing.Left = 24 Caption = 'Cyclic view' Checked = True - OnChange = CbCyclicChange State = cbChecked TabOrder = 10 + OnChange = CbCyclicChange end object CbPreviewTiles: TCheckBox AnchorSideLeft.Control = CbCyclic @@ -881,13 +881,13 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter Left = 130 Height = 19 - Top = 175 + Top = 394 Width = 83 Caption = 'Preview tiles' Checked = True - OnChange = CbPreviewTilesChange State = cbChecked TabOrder = 11 + OnChange = CbPreviewTilesChange end object clbBackColor: TColorButton AnchorSideLeft.Control = CbPreviewTiles @@ -895,7 +895,7 @@ object MainForm: TMainForm AnchorSideTop.Side = asrCenter Left = 130 Height = 25 - Top = 197 + Top = 416 Width = 105 BorderWidth = 2 ButtonColorAutoSize = False @@ -905,6 +905,171 @@ object MainForm: TMainForm Margin = 4 OnColorChanged = clbBackColorColorChanged end + object gbProxy: TGroupBox + AnchorSideLeft.Control = PgConfig + AnchorSideTop.Control = CbDownloadEngine + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = PgConfig + AnchorSideRight.Side = asrBottom + Left = 6 + Height = 197 + Top = 110 + Width = 255 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Top = 4 + BorderSpacing.Around = 6 + Caption = 'Proxy' + ClientHeight = 177 + ClientWidth = 251 + TabOrder = 12 + object lblProxyHost: TLabel + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = edProxyHost + AnchorSideTop.Side = asrCenter + Left = 28 + Height = 15 + Top = 69 + Width = 28 + BorderSpacing.Left = 18 + Caption = 'Host:' + end + object edProxyHost: TEdit + AnchorSideLeft.Control = edProxyUserName + AnchorSideTop.Control = rbProxyData + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 95 + Height = 23 + Top = 65 + Width = 148 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Right = 8 + TabOrder = 0 + OnChange = rbProxyChange + end + object lblProxyPort: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = seProxyPort + AnchorSideTop.Side = asrCenter + Left = 28 + Height = 15 + Top = 96 + Width = 22 + Caption = 'Port' + end + object seProxyPort: TSpinEdit + AnchorSideLeft.Control = lblProxyUserName + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = edProxyHost + AnchorSideTop.Side = asrBottom + Left = 95 + Height = 23 + Top = 92 + Width = 104 + BorderSpacing.Top = 4 + MaxValue = 65535 + TabOrder = 1 + OnChange = rbProxyChange + end + object lblProxyUserName: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = edProxyUserName + AnchorSideTop.Side = asrCenter + Left = 28 + Height = 15 + Top = 123 + Width = 59 + BorderSpacing.Right = 8 + Caption = 'User name:' + end + object edProxyUserName: TEdit + AnchorSideLeft.Control = lblProxyUserName + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = seProxyPort + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 95 + Height = 23 + Top = 119 + Width = 148 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + TabOrder = 2 + OnChange = rbProxyChange + end + object lblProxyPassword: TLabel + AnchorSideLeft.Control = lblProxyHost + AnchorSideTop.Control = edProxyPassword + AnchorSideTop.Side = asrCenter + Left = 28 + Height = 15 + Top = 150 + Width = 50 + Caption = 'Password' + end + object edProxyPassword: TEdit + AnchorSideLeft.Control = edProxyUserName + AnchorSideTop.Control = edProxyUserName + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = gbProxy + AnchorSideRight.Side = asrBottom + Left = 95 + Height = 23 + Top = 146 + Width = 148 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + TabOrder = 3 + OnChange = rbProxyChange + end + object rbNoProxy: TRadioButton + AnchorSideLeft.Control = gbProxy + AnchorSideTop.Control = gbProxy + Left = 10 + Height = 19 + Top = 0 + Width = 67 + BorderSpacing.Left = 10 + Caption = 'No proxy' + TabOrder = 4 + OnChange = rbProxyChange + end + object rbSystemProxy: TRadioButton + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = rbNoProxy + AnchorSideTop.Side = asrBottom + Left = 10 + Height = 19 + Top = 23 + Width = 110 + BorderSpacing.Top = 4 + Caption = 'Use system proxy' + Checked = True + Enabled = False + TabOrder = 5 + TabStop = True + OnChange = rbProxyChange + end + object rbProxyData: TRadioButton + AnchorSideLeft.Control = rbNoProxy + AnchorSideTop.Control = rbSystemProxy + AnchorSideTop.Side = asrBottom + Left = 10 + Height = 19 + Top = 46 + Width = 74 + BorderSpacing.Top = 4 + Caption = 'Proxy data' + TabOrder = 6 + OnChange = rbProxyChange + end + end end end object GeoNames: TMVGeoNames @@ -921,7 +1086,7 @@ object MainForm: TMainForm object FontDialog: TFontDialog MinFontSize = 0 MaxFontSize = 0 - Left = 808 - Top = 216 + Left = 800 + Top = 472 end end diff --git a/components/lazmapviewer/examples/fulldemo_with_addons/main.pas b/components/lazmapviewer/examples/fulldemo_with_addons/main.pas index ee5f2ed4e..0a6eb8633 100644 --- a/components/lazmapviewer/examples/fulldemo_with_addons/main.pas +++ b/components/lazmapviewer/examples/fulldemo_with_addons/main.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, Types, Forms, Controls, Graphics, Dialogs, - ExtCtrls, StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, + ExtCtrls, StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, Spin, mvGeoNames, mvMapViewer, mvTypes, mvGpsObj, mvDrawingEngine, mvDE_RGBGraphics, mvDE_BGRA, mvDLEFPC, mvDLEWin, mvDLESynapse; @@ -27,6 +27,8 @@ type CbFoundLocations: TComboBox; CbLocations: TComboBox; CbProviders: TComboBox; + rbProxyData: TRadioButton; + rbSystemProxy: TRadioButton; CbUseThreads: TCheckBox; CbMouseCoords: TGroupBox; CbDistanceUnits: TComboBox; @@ -38,8 +40,12 @@ type CbCyclic: TCheckBox; CbPreviewTiles: TCheckBox; clbBackColor: TColorButton; + edProxyHost: TEdit; + edProxyPassword: TEdit; + edProxyUserName: TEdit; FontDialog: TFontDialog; GbCenterCoords: TGroupBox; + gbProxy: TGroupBox; GbScreenSize: TGroupBox; GbSearch: TGroupBox; GbGPS: TGroupBox; @@ -52,6 +58,10 @@ type Label1: TLabel; Label2: TLabel; LblPOITextBgColor: TLabel; + lblProxyHost: TLabel; + lblProxyPassword: TLabel; + lblProxyPort: TLabel; + lblProxyUserName: TLabel; LblSelectLocation: TLabel; LblCenterLatitude: TLabel; LblViewportHeight: TLabel; @@ -71,6 +81,8 @@ type PageControl: TPageControl; PgData: TTabSheet; PgConfig: TTabSheet; + rbNoProxy: TRadioButton; + seProxyPort: TSpinEdit; ZoomTrackBar: TTrackBar; procedure BtnGoToClick(Sender: TObject); procedure BtnLoadGPXFileClick(Sender: TObject); @@ -108,6 +120,7 @@ type procedure MapViewZoomChange(Sender: TObject); procedure BtnLoadMapProvidersClick(Sender: TObject); procedure BtnSaveMapProvidersClick(Sender: TObject); + procedure rbProxyChange(Sender: TObject); procedure ZoomTrackBarChange(Sender: TObject); private @@ -121,6 +134,7 @@ type POIImage: TCustomBitmap; procedure ClearFoundLocations; procedure UpdateCoords(X, Y: Integer); + procedure UpdateDownloadEngineProxy; procedure UpdateDropdownWidth(ACombobox: TCombobox); procedure UpdateLocationHistory(ALocation: String); procedure UpdateViewportSize; @@ -187,6 +201,11 @@ begin MapView.Engine.WriteProvidersToXML(Application.Location + MAP_PROVIDER_FILENAME); end; +procedure TMainForm.rbProxyChange(Sender: TObject); +begin + UpdateDownloadEngineProxy; +end; + procedure TMainForm.BtnSearchClick(Sender: TObject); begin ClearFoundLocations; @@ -291,6 +310,7 @@ begin {$ENDIF} end; end; + UpdateDownloadEngineProxy; end; procedure TMainForm.CbDrawingEngineChange(Sender: TObject); @@ -659,6 +679,19 @@ begin List.Free; end; + i := ini.ReadInteger('Proxy', 'UseProxy', 0); + case i of + 0: rbNoProxy.Checked := true; + 1: rbSystemProxy.Checked := true; + 2: rbProxyData.Checked := true; + end; + edProxyHost.Text := ini.ReadString('Proxy', 'ProxyHost', edProxyHost.Text); + seProxyPort.Value := ini.ReadInteger('Proxy', 'ProxyPort', seProxyPort.Value); + edProxyUserName.Text := ini.ReadString('Proxy', 'ProxyName', edProxyUserName.Text); + edProxyPassword.Text := ini.ReadString('Proxy', 'ProxyPassword', edProxyPassword.Text); + + UpdateDownloadEngineProxy; + finally ini.Free; end; @@ -682,6 +715,26 @@ begin end; end; +procedure TMainForm.UpdateDownloadEngineProxy; +begin + if MapView.DownloadEngine.HasProxySupport then + begin + MapView.DownloadEngine.SetProxy( + rbSystemProxy.Checked, rbProxyData.Checked, + edProxyHost.Name, seProxyPort.Value, edProxyUserName.Text, edProxyPassword.Text + ); + rbSystemProxy.Enabled := MapView.DownloadEngine.SupportsSystemProxy; + lblProxyHost.Enabled := rbProxyData.Checked; + edProxyHost.Enabled := rbProxyData.Checked; + lblProxyPort.Enabled := rbProxyData.Checked; + seProxyPort.Enabled := rbProxyData.Checked; + lblProxyUserName.Enabled := rbProxyData.Checked; + edProxyUserName.Enabled := rbProxyData.Checked; + lblProxyPassword.Enabled := rbProxyData.Checked; + edProxyPassword.Enabled := rbProxyData.Checked; + end; +end; + procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox); var cnv: TControlCanvas; @@ -782,6 +835,16 @@ begin for i := 0 to CbLocations.Items.Count-1 do ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]); + ini.EraseSection('Proxy'); + if rbSystemProxy.Checked then i := 1 + else if rbProxyData.Checked then i := 2 + else i := 0; + ini.WriteInteger('Proxy', 'UseProxy', i); + ini.WriteString('Proxy', 'ProxyHost', edProxyHost.Text); + ini.WriteInteger('Proxy', 'ProxyPort', seProxyPort.Value); + ini.WriteString('Proxy', 'ProxyName', edProxyUserName.Text); + ini.WriteString('Proxy', 'ProxyPassword', edProxyPassword.Text); + finally ini.Free; end; diff --git a/components/lazmapviewer/source/addons/synapse_downloadengine/mvdlesynapse.pas b/components/lazmapviewer/source/addons/synapse_downloadengine/mvdlesynapse.pas index cb6c38d59..a4b36f4bc 100644 --- a/components/lazmapviewer/source/addons/synapse_downloadengine/mvdlesynapse.pas +++ b/components/lazmapviewer/source/addons/synapse_downloadengine/mvdlesynapse.pas @@ -31,7 +31,10 @@ type FUseProxy: Boolean; protected procedure InternalDownloadFile(const Url: string; str: TStream); override; - + public + constructor Create(AOwner: TComponent); override; + procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); override; published property UseProxy: Boolean read FUseProxy write FUseProxy default false; property ProxyHost: string read FProxyHost write FProxyHost; @@ -55,6 +58,13 @@ end; { TMvDESynapse } +constructor TMvDESynapse.Create(AOwner: TComponent); +begin + inherited; + FProxySupport := true; + FSystemProxySupport := false; +end; + procedure TMvDESynapse.InternalDownloadFile(const Url: string; str: TStream); var FHttp: THTTPSend; @@ -99,4 +109,14 @@ begin end; end; +procedure TMvDESynapse.SetProxy(AUseSystemProxy, AUseProxy: Boolean; + AProxyHost: String; AProxyPort: Word; AProxyUserName, AProxyPassword: String); +begin + FUseProxy := AUseProxy; + FProxyHost := AProxyHost; + FProxyPort := AProxyPort; + FProxyUserName := AProxyUserName; + FProxyPassword := AProxyPassword; +end; + end. diff --git a/components/lazmapviewer/source/mvdlefpc.pas b/components/lazmapviewer/source/mvdlefpc.pas index 7f692954d..38a2be134 100644 --- a/components/lazmapviewer/source/mvdlefpc.pas +++ b/components/lazmapviewer/source/mvdlefpc.pas @@ -40,6 +40,9 @@ type protected procedure InternalDownloadFile(const Url: string; AStream: TStream); override; public + constructor Create(AOwner: TComponent); override; + procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); override; {$IF FPC_FullVersion >= 30101} published property UseProxy: Boolean read FUseProxy write FUseProxy default false; @@ -64,6 +67,15 @@ uses { TMVDEFPC } +constructor TMvDEFpc.Create(AOwner: TComponent); +begin + inherited; + {$IF FPC_FullVersion >= 30200} + FProxySupport := true; + {$IFEND} + FSystemProxySupport := false; +end; + procedure TMVDEFPC.InternalDownloadFile(const Url: string; AStream: TStream); var http: TFpHttpClient; @@ -98,4 +110,16 @@ begin end; end; +procedure TMvDEFPC.SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); +begin + {$IF FPC_FullVersion >= 30101} + FUseProxy := AUseProxy; + FProxyHost := AProxyHost; + FProxyPort := AProxyPort; + FProxyUserName := AProxyUserName; + FProxyPassword := AProxyPassword; + {$ENDIF} +end; + end. diff --git a/components/lazmapviewer/source/mvdlewin.pas b/components/lazmapviewer/source/mvdlewin.pas index 1150c23c0..dc3bfc033 100644 --- a/components/lazmapviewer/source/mvdlewin.pas +++ b/components/lazmapviewer/source/mvdlewin.pas @@ -22,8 +22,25 @@ uses type TMVDEWin = class(TMvCustomDownloadEngine) + private + FUseSystemProxy: Boolean; + FUseProxy: Boolean; + FProxyHost: string; + FProxyPort: Word; + FProxyUserName: String; + FProxyPassWord: String; protected procedure InternalDownloadFile(const Url: string; AStream: TStream); override; + public + constructor Create(AOwner: TComponent); override; + procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); override; + property UseProxy: Boolean read FUseProxy write FUseProxy default false; + property UseSystemProxy: Boolean read FUseSystemProxy write FUseSystemproxy default true; + property ProxyHost: String read FProxyHost write FProxyHost; + property ProxyPort: Word read FProxyPort write FProxyPort; + property ProxyUsername: String read FProxyUserName write FProxyUserName; + property ProxyPassword: String read FProxyPassword write FProxyPassword; end; {$ENDIF} @@ -31,10 +48,17 @@ type implementation {$IFDEF MSWindows} - uses windows, wininet; +constructor TMVDEWin.Create(AOwner: TComponent); +begin + inherited; + FProxySupport := true; + FSystemProxySupport := true; + FUseSystemProxy := true; +end; + procedure TMVDEWin.InternalDownloadFile(const Url: string; AStream: TStream); const KB = 1024; @@ -43,15 +67,47 @@ var urlHandle: HInternet; buffer: array[0..4*KB-1] of Char; bytesRead: dWord = 0; - errCode: Integer = 0; header: String; + accessType: Integer; + proxy: String = ''; + username: WideString = ''; + pwd: WideString = ''; begin - NetHandle := InternetOpen('Mozilla/5.0(compatible; WinInet)', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); + if FUseSystemProxy then + accessType := INTERNET_OPEN_TYPE_PRECONFIG + else + begin + accessType := INTERNET_OPEN_TYPE_DIRECT; + if FUseProxy then + begin + if FProxyPort <> 0 then + proxy := Format('%s:%d', [FProxyHost, FProxyPort]) + else + proxy := FProxyHost; + if proxy <> '' then + accessType := INTERNET_OPEN_TYPE_PROXY; + end; + end; + netHandle := InternetOpen('Mozilla/5.0(compatible; WinInet)', accessType, PChar(proxy), nil, 0); // NetHandle valid? if netHandle = nil then exit; + if FUseProxy then + begin + if FProxyUsername <> '' then + begin + userName := WideString(FProxyUsername); + InternetSetOptionW(netHandle, INTERNET_OPTION_PROXY_USERNAME, PWideChar(userName), Length(userName)); + end; + if FProxyPassword <> '' then + begin + pwd := WideString(FProxyPassword); + InternetSetOptionW(netHandle, INTERNET_OPTION_PROXY_PASSWORD, PWideChar(pwd), Length(pwd)); + end; + end; + try header := ''; urlHandle := InternetOpenUrl(netHandle, PChar(URL), PChar(header), Length(header), INTERNET_FLAG_RELOAD, 0); @@ -75,6 +131,17 @@ begin end; end; +procedure TMvDEWin.SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); +begin + FUseSystemProxy := AUseSystemProxy; + FUseProxy := AUseProxy; + FProxyHost := AProxyHost; + FProxyPort := AProxyPort; + FProxyUserName := AProxyUserName; + FProxyPassword := AProxyPassword; +end; + {$ENDIF} end. diff --git a/components/lazmapviewer/source/mvdownloadengine.pas b/components/lazmapviewer/source/mvdownloadengine.pas index 91513d800..fa318cc11 100644 --- a/components/lazmapviewer/source/mvdownloadengine.pas +++ b/components/lazmapviewer/source/mvdownloadengine.pas @@ -24,10 +24,16 @@ type TMvCustomDownloadEngine = class(TComponent) protected + FProxySupport: Boolean; + FSystemProxySupport: Boolean; procedure InternalDownloadFile(const Url: String; AStream: TStream); virtual; abstract; procedure LoadFromLocalFile(const AFileName: String; AStream: TStream); public procedure DownloadFile(const Url: string; AStream: TStream); virtual; + procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String; + AProxyPort: Word; AProxyUserName, AProxyPassword: String); virtual; abstract; + property HasProxySupport: Boolean read FProxySupport; + property SupportsSystemProxy: Boolean read FSystemProxySupport; end;