Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Preview.pas

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

revision 1.4 by h677, Thu Sep 4 08:22:07 2003 UTC revision 1.5 by h677, Sun Aug 13 01:14:19 2006 UTC
# Line 19  type Line 19  type
19          public          public
20                  constructor Create(AOwner: TComponent); override;                  constructor Create(AOwner: TComponent); override;
21                  destructor Destroy; override;                  destructor Destroy; override;
22            procedure PreviewImage(URL : String);
23            function GetWindowRect(Point: TPoint) : TRect;
24          end;          end;
25    
26  implementation  implementation
27    uses MojuUtils, GikoSystem, Setting;
28    
29    const
30            //プレビューファイル名
31            HTML_FILE_NAME  = 'temp_preview.html';
32    
33  constructor TPreviewBrowser.Create(AOwner: TComponent);  constructor TPreviewBrowser.Create(AOwner: TComponent);
 {  
 var  
 //      Style: Longint;  
 }  
34  begin  begin
35          inherited Create(AOwner);          inherited Create(AOwner);
 //      Style := GetWindowLong(Self.Handle, GWL_EXSTYLE);  
 //      SetWindowLong(Self.Handle, GWL_EXSTYLE, Style or WS_EX_APPWINDOW);  
36  end;  end;
37    
38  destructor TPreviewBrowser.Destroy;  destructor TPreviewBrowser.Destroy;
# Line 42  end; Line 43  end;
43  procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);  procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
44  begin  begin
45          inherited;          inherited;
 //      Params.Style := WS_POPUP or  {or WS_BORDER};  
 //      Params.WindowClass.Style := Params.WindowClass.Style or CS_SAVEBITS;  
 //      Params.ExStyle := WS_EX_TOOLWINDOW;  
 //      AddBiDiModeExStyle(Params.ExStyle);  
46  end;  end;
47    {
48    \brief  指定されたURLのプレビュー
49    \param  URL プレビューするイメージのURL
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">プレビュー作成中</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 表示するウィンドウサイズを取得する
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        // 出し位置による補正
153            case GikoSys.Setting.PopupPosition of
154                    gppRightTop:            OffsetRect(Result,
155                Point.x - (Result.Right - Result.Left) - 15, Point.y - (Result.Bottom - Result.Top) -       15);
156                    gppRight:                       OffsetRect(Result,
157                Point.x - (Result.Right - Result.Left) - 15, Point.y - ((Result.Bottom - Result.Top) div 2));
158                    gppRightBottom: OffsetRect(Result,
159                Point.x - (Result.Right - Result.Left) - 15, Point.y + 15);
160                    gppTop:                         OffsetRect(Result,
161                Point.x - ((Result.Right - Result.Left) div 2), Point.y - (Result.Bottom - Result.Top) -    15);
162                    gppCenter:                      OffsetRect(Result,
163                Point.x - ((Result.Right - Result.Left) div 2), Point.y - ((Result.Bottom - Result.Top) div 2));
164                    gppBottom:                      OffsetRect(Result,
165                Point.x - ((Result.Right - Result.Left) div 2), Point.y + 15);
166                    gppLeftTop:                     OffsetRect(Result,
167                Point.x + 15, Point.y - (Result.Bottom - Result.Top) -      15);
168                    gppLeft:                        OffsetRect(Result,
169                Point.x + 15, Point.y - ((Result.Bottom - Result.Top) div 2));
170                    gppLeftBottom:  OffsetRect(Result, Point.x + 15, Point.y + 15);         //ギコナビスレ パート1の453氏に感謝
171            end;
172    
173    end;
174  end.  end.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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