Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/Preview.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Sun Aug 27 10:18:37 2006 UTC (17 years, 7 months ago) by h677
Branch: MAIN
CVS Tags: v1_56_0_715, v1_56_0_707, v1_56_0_705, v1_56_0_704, v1_56_0_703, v1_56_0_702, v1_56_0_701, v1_56_0_700, v1_57_0_723, v1_57_0_720, v1_57_0_722, v1_57_0_719, v1_57_0_718, v1_56_0_716, v1_54_0_687, v1_56_0_710, v1_56_0_711, v1_56_1_717, v1_56_1_716, v1_54_0_688, v1_54_0_689, v1_54_0_684, v1_54_0_685, v1_55_0_692, v1_55_0_693, v1_55_0_696, v1_55_0_697, v1_55_0_694, v1_55_0_695, v1_54_1_691, v1_56_2_722, v1_55_1_697, v1_56_0_714, v1_54_0_686, v1_56_0_712, v1_56_0_713, v1_54_0_682, v1_56_0_721, v1_54_0_683, marged_bRESPOPUP, v1_56_0_706, v1_54_0_690, v1_56_0_709, v1_56_0_708, v1_56_0_699, v1_56_0_698
Branch point for: Bb56, Bb55, bRESPOPUP, bListSU, Bb54
Changes since 1.5: +8 -8 lines
File MIME type: text/x-pascal
プレビューの位置の計算で余分な計算をしていたのを修正

1 unit Preview;
2
3 interface
4 uses
5 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
6 ActiveX,
7 {$IF Defined(DELPRO) }
8 SHDocVw
9 {$ELSE}
10 SHDocVw_TLB
11 {$IFEND}
12 ;
13
14 type
15 TPreviewBrowser = class(TWebBrowser)
16 private
17 protected
18 procedure CreateParams(var Params: TCreateParams); override;
19 public
20 constructor Create(AOwner: TComponent); override;
21 destructor Destroy; override;
22 procedure PreviewImage(URL : String);
23 function GetWindowRect(Point: TPoint) : TRect;
24 end;
25
26 implementation
27 uses MojuUtils, GikoSystem, Setting;
28
29 const
30 //???????ャ?若???<?ゃ????
31 HTML_FILE_NAME = 'temp_preview.html';
32
33 constructor TPreviewBrowser.Create(AOwner: TComponent);
34 begin
35 inherited Create(AOwner);
36 end;
37
38 destructor TPreviewBrowser.Destroy;
39 begin
40 inherited Destroy;
41 end;
42
43 procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
44 begin
45 inherited;
46 end;
47 {
48 \brief ??絎???????URL?????????ャ??/span>
49 \param URL ???????ャ?若?????ゃ?<?若?吾??RL
50 }
51 procedure TPreviewBrowser.PreviewImage(URL : String);
52 var
53 html : string;
54 HtmlFileName : string;
55 sl : TStringList;
56 Protocol, Host, Path, Document, Port, Bookmark : string;
57 Referer : string;
58 Flags: OleVariant;
59 TargetFrameName: OleVariant;
60 PostData: OleVariant;
61 Headers: OleVariant;
62 begin
63 html := '<html><head>'#13#10
64 + '<SCRIPT>'#13#10
65 + 'function init() {'#13#10
66 + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
67 + ' } else {'#13#10
68 + ' var dh, ih;'#13#10
69 + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
70 + ' ih = Image1.width / Image1.height;'#13#10
71 + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
72 + ' if (ih > dh)'#13#10
73 + ' Image1.width = document.body.clientWidth;'#13#10
74 + ' else'#13#10
75 + ' Image1.height = document.body.clientHeight;'#13#10
76 + ' } else {'#13#10
77 + ' if (ih < dh)'#13#10
78 + ' Image1.height = document.body.clientHeight;'#13#10
79 + ' else'#13#10
80 + ' Image1.width = document.body.clientWidth;'#13#10
81 + ' }'#13#10
82 + ' }'#13#10
83 + ' Message.style.display = "none";'#13#10
84 + '}'#13#10
85 + '</SCRIPT>'#13#10
86 + '</head>'#13#10
87 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
88 + '<div align="center" id="Message">???????ャ?寂???筝?lt;/div>'#13#10
89 + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
90 + '</body></html>';
91
92 HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
93 sl := TStringList.Create;
94 try
95 try
96 sl.Text := MojuUtils.
97 CustomStringReplace(html, '%ImageURL%', URL, False);
98 sl.SaveToFile(HtmlFileName);
99 finally
100 sl.Free;
101 end;
102 except
103 end;
104
105 GikoSys.ParseURI(URL, Protocol, Host, Path, Document, Port, Bookmark);
106 Referer := Protocol + '://' + Host;
107 if Port <> '' then
108 Referer := Referer + ':' + Port;
109 Referer := Referer + Path;
110 Headers := 'Referer: ' + Referer;
111 Flags := 0;
112 TargetFrameName := '';
113 PostData := '';
114
115 Navigate(HtmlFileName,Flags, TargetFrameName, PostData, Headers);
116
117 end;
118 {
119 \breif 茵?ず???????c?潟?????泣?ゃ?冴????緇?????
120 \param Point ?????鴻???若?純????婚罔?
121 }
122 function TPreviewBrowser.GetWindowRect(Point: TPoint) : TRect;
123 var
124 WindowWidth, WindowHeight : Integer;
125 begin
126 // 荐?????????翫?????
127 case GikoSys.Setting.PreviewSize of
128 gpsXSmall: begin
129 WindowWidth := 128;
130 WindowHeight := 96;
131 end;
132 gpsSmall: begin
133 WindowWidth := 256;
134 WindowHeight := 192;
135 end;
136 gpsLarge: begin
137 WindowWidth := 512;
138 WindowHeight := 384;
139 end;
140 gpsXLarge: begin
141 WindowWidth := 640;
142 WindowHeight := 480;
143 end;
144 else begin //gpsMedium
145 WindowWidth := 384;
146 WindowHeight := 288;
147 end;
148 end;
149
150 Result := Rect(0, 0, WindowWidth, WindowHeight);
151
152 // ?冴??篏?臀???????茖?罩?/span>
153 case GikoSys.Setting.PopupPosition of
154 gppRightTop: OffsetRect(Result,
155 Point.x - WindowWidth - 15, Point.y - WindowHeight - 15);
156 gppRight: OffsetRect(Result,
157 Point.x - WindowWidth - 15, Point.y - (WindowHeight div 2));
158 gppRightBottom: OffsetRect(Result,
159 Point.x - WindowWidth - 15, Point.y + 15);
160 gppTop: OffsetRect(Result,
161 Point.x - (WindowWidth div 2), Point.y - WindowHeight - 15);
162 gppCenter: OffsetRect(Result,
163 Point.x - (WindowWidth div 2), Point.y - (WindowHeight div 2));
164 gppBottom: OffsetRect(Result,
165 Point.x - (WindowWidth div 2), Point.y + 15);
166 gppLeftTop: OffsetRect(Result,
167 Point.x + 15, Point.y - WindowHeight - 15);
168 gppLeft: OffsetRect(Result,
169 Point.x + 15, Point.y - (WindowHeight div 2));
170 gppLeftBottom: OffsetRect(Result, Point.x + 15, Point.y + 15); //???潟?????鴻? ???若??鐚???53羂????茗?
171 end;
172
173 end;
174 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26