HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,
ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem,
- ShellAPI;
+ ShellAPI,Preview;
const
NGWORDNAME_PANEL = 3;
FClickNode: TTreeNode;
FHttpState: Boolean;
FHint: TResPopup;
- FPreviewBrowser: TWebBrowser;
+ FPreviewBrowser: TPreviewBrowser;
FPreviewURL: string;
FBrowserSizeHeight: Integer;
FBrowserSizeWidth: Integer;
GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
YofUtils, ToolBarUtil, ToolBarSetting,
GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
- FavoriteArrange, AddressHistory, Preview, Gesture,
+ FavoriteArrange, AddressHistory, Gesture,
About, Option, Round, Splash, Sort, ListSelect, Imm,
NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
- InputAssistDataModule;
+ InputAssistDataModule, Types;
const
BLANK_HTML: string = 'about:blank';
var
p: TPoint;
ARect: TRect;
- sl: TStringList;
- html: string;
- HtmlFileName: string;
-
- NavURL: OleVariant;
- Flags: OleVariant;
- TargetFrameName: OleVariant;
- PostData: OleVariant;
- Headers: OleVariant;
- WindowHeight: Integer;
- WindowWidth: Integer;
-
-// Style: Longint;
- Referer: string;
- Protocol, Host, Path, Document, Port, Bookmark: string;
begin
PreviewTimer.Enabled := False;
GetCursorpos(p);
- case GikoSys.Setting.PreviewSize of
- gpsXSmall: begin
- WindowWidth := 128;
- WindowHeight := 96;
- end;
- gpsSmall: begin
- WindowWidth := 256;
- WindowHeight := 192;
- end;
- gpsLarge: begin
- WindowWidth := 512;
- WindowHeight := 384;
- end;
- gpsXLarge: begin
- WindowWidth := 640;
- WindowHeight := 480;
- end;
- else begin //gpsMedium
- WindowWidth := 384;
- WindowHeight := 288;
- end;
- end;
-
- ARect := Rect(0, 0, WindowWidth, WindowHeight);
-
- case GikoSys.Setting.PopupPosition of
- gppRightTop: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) - 15);
- gppRight: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
- gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
- gppTop: OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) - 15);
- gppCenter: OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
- gppBottom: OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
- gppLeftTop: OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) - 15);
- gppLeft: OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
- gppLeftBottom: OffsetRect(ARect, p.x + 15, p.y + 15); //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g\82P\82Ì453\8e\81\82É\8a´\8eÓ
- end;
-
- html := '<html><head>'#13#10
- + '<SCRIPT>'#13#10
- + 'function init() {'#13#10
- + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
- + ' } else {'#13#10
- + ' var dh, ih;'#13#10
- + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
- + ' ih = Image1.width / Image1.height;'#13#10
- + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
- + ' if (ih > dh)'#13#10
- + ' Image1.width = document.body.clientWidth;'#13#10
- + ' else'#13#10
- + ' Image1.height = document.body.clientHeight;'#13#10
- + ' } else {'#13#10
- + ' if (ih < dh)'#13#10
- + ' Image1.height = document.body.clientHeight;'#13#10
- + ' else'#13#10
- + ' Image1.width = document.body.clientWidth;'#13#10
- + ' }'#13#10
- + ' }'#13#10
- + ' Message.style.display = "none";'#13#10
- + '}'#13#10
- + '</SCRIPT>'#13#10
- + '</head>'#13#10
- + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
- + '<div align="center" id="Message">\83v\83\8c\83r\83\85\81[\8dì\90¬\92\86</div>'#13#10
- + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
- + '</body></html>';
- sl := TStringList.Create;
- try
- try
- HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
- sl.Text := AnsiReplaceStr(html, '%ImageURL%', FPreviewURL);
- sl.SaveToFile(HtmlFileName);
- finally
- sl.Free;
- end;
- except
- end;
+ ARect := FPreviewBrowser.GetWindowRect(p);
+
+ FPreviewBrowser.PreviewImage(FPreviewURL);
- NavURL := HtmlFileName;
- Flags := 0;
- TargetFrameName := '';
- PostData := '';
-
- GikoSys.ParseURI(FPreviewURL, Protocol, Host, Path, Document, Port, Bookmark);
- Referer := Protocol + '://' + Host;
- if Port <> '' then
- Referer := Referer + ':' + Port;
- Referer := Referer + Path;
- Headers := 'Referer: ' + Referer;
- FPreviewBrowser.Navigate(NavURL, Flags, TargetFrameName, PostData, Headers);
- if ARect.Top + WindowHeight > Screen.DesktopHeight then
- ARect.Top := Screen.DesktopHeight - WindowHeight;
- if ARect.Left + WindowWidth > Screen.DesktopWidth then
- ARect.Left := Screen.DesktopWidth - WindowWidth;
+ if ARect.Bottom > Screen.DesktopHeight then
+ ARect.Top := Screen.DesktopHeight - (ARect.Bottom - ARect.Top);
+ if ARect.Right > Screen.DesktopWidth then
+ ARect.Left := Screen.DesktopWidth - (ARect.Right - ARect.Left);
if ARect.Left < Screen.DesktopLeft then ARect.Left := Screen.DesktopLeft;
if ARect.Bottom < Screen.DesktopTop then ARect.Bottom := Screen.DesktopTop;
- SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST, ARect.Left, ARect.Top, WindowWidth, WindowHeight, SWP_NOACTIVATE or SWP_HIDEWINDOW);
+ SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST,
+ ARect.Left, ARect.Top,
+ (ARect.Right - ARect.Left), (ARect.Bottom - ARect.Top),
+ SWP_NOACTIVATE or SWP_HIDEWINDOW);
+
ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
FPreviewBrowserRect := ARect;
-// Style := GetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE);
-// SetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE, Style xor WS_EX_APPWINDOW);
-
end;
procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
+ procedure PreviewImage(URL : String);
+ function GetWindowRect(Point: TPoint) : TRect;
end;
implementation
+uses MojuUtils, GikoSystem, Setting;
+
+const
+ //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
+ HTML_FILE_NAME = 'temp_preview.html';
constructor TPreviewBrowser.Create(AOwner: TComponent);
-{
-var
-// Style: Longint;
-}
begin
inherited Create(AOwner);
-// Style := GetWindowLong(Self.Handle, GWL_EXSTYLE);
-// SetWindowLong(Self.Handle, GWL_EXSTYLE, Style or WS_EX_APPWINDOW);
end;
destructor TPreviewBrowser.Destroy;
procedure TPreviewBrowser.CreateParams(var Params: TCreateParams);
begin
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);
end;
+{
+\brief \8ew\92è\82³\82ê\82½URL\82Ì\83v\83\8c\83r\83\85\81[
+\param URL \83v\83\8c\83r\83\85\81[\82·\82é\83C\83\81\81[\83W\82ÌURL
+}
+procedure TPreviewBrowser.PreviewImage(URL : String);
+var
+ html : string;
+ HtmlFileName : string;
+ sl : TStringList;
+ Protocol, Host, Path, Document, Port, Bookmark : string;
+ Referer : string;
+ Flags: OleVariant;
+ TargetFrameName: OleVariant;
+ PostData: OleVariant;
+ Headers: OleVariant;
+begin
+ html := '<html><head>'#13#10
+ + '<SCRIPT>'#13#10
+ + 'function init() {'#13#10
+ + ' if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
+ + ' } else {'#13#10
+ + ' var dh, ih;'#13#10
+ + ' dh = document.body.clientWidth / document.body.clientHeight;'#13#10
+ + ' ih = Image1.width / Image1.height;'#13#10
+ + ' if (document.body.clientWidth < document.body.clientHeight) {'#13#10
+ + ' if (ih > dh)'#13#10
+ + ' Image1.width = document.body.clientWidth;'#13#10
+ + ' else'#13#10
+ + ' Image1.height = document.body.clientHeight;'#13#10
+ + ' } else {'#13#10
+ + ' if (ih < dh)'#13#10
+ + ' Image1.height = document.body.clientHeight;'#13#10
+ + ' else'#13#10
+ + ' Image1.width = document.body.clientWidth;'#13#10
+ + ' }'#13#10
+ + ' }'#13#10
+ + ' Message.style.display = "none";'#13#10
+ + '}'#13#10
+ + '</SCRIPT>'#13#10
+ + '</head>'#13#10
+ + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
+ + '<div align="center" id="Message">\83v\83\8c\83r\83\85\81[\8dì\90¬\92\86</div>'#13#10
+ + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
+ + '</body></html>';
+
+ HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
+ sl := TStringList.Create;
+ try
+ try
+ sl.Text := MojuUtils.
+ CustomStringReplace(html, '%ImageURL%', URL, False);
+ sl.SaveToFile(HtmlFileName);
+ finally
+ sl.Free;
+ end;
+ except
+ end;
+
+ GikoSys.ParseURI(URL, Protocol, Host, Path, Document, Port, Bookmark);
+ Referer := Protocol + '://' + Host;
+ if Port <> '' then
+ Referer := Referer + ':' + Port;
+ Referer := Referer + Path;
+ Headers := 'Referer: ' + Referer;
+ Flags := 0;
+ TargetFrameName := '';
+ PostData := '';
+
+ Navigate(HtmlFileName,Flags, TargetFrameName, PostData, Headers);
+
+end;
+{
+\breif \95\\8e¦\82·\82é\83E\83B\83\93\83h\83E\83T\83C\83Y\82ð\8eæ\93¾\82·\82é
+\param Point \83}\83E\83X\83J\81[\83\\83\8b\82Ì\8dÀ\95W
+}
+function TPreviewBrowser.GetWindowRect(Point: TPoint) : TRect;
+var
+ WindowWidth, WindowHeight : Integer;
+begin
+ // \90Ý\92è\82É\82æ\82é\8fê\8d\87\82í\82¯
+ case GikoSys.Setting.PreviewSize of
+ gpsXSmall: begin
+ WindowWidth := 128;
+ WindowHeight := 96;
+ end;
+ gpsSmall: begin
+ WindowWidth := 256;
+ WindowHeight := 192;
+ end;
+ gpsLarge: begin
+ WindowWidth := 512;
+ WindowHeight := 384;
+ end;
+ gpsXLarge: begin
+ WindowWidth := 640;
+ WindowHeight := 480;
+ end;
+ else begin //gpsMedium
+ WindowWidth := 384;
+ WindowHeight := 288;
+ end;
+ end;
+
+ Result := Rect(0, 0, WindowWidth, WindowHeight);
+ // \8fo\82µ\88Ê\92u\82É\82æ\82é\95â\90³
+ case GikoSys.Setting.PopupPosition of
+ gppRightTop: OffsetRect(Result,
+ Point.x - (Result.Right - Result.Left) - 15, Point.y - (Result.Bottom - Result.Top) - 15);
+ gppRight: OffsetRect(Result,
+ Point.x - (Result.Right - Result.Left) - 15, Point.y - ((Result.Bottom - Result.Top) div 2));
+ gppRightBottom: OffsetRect(Result,
+ Point.x - (Result.Right - Result.Left) - 15, Point.y + 15);
+ gppTop: OffsetRect(Result,
+ Point.x - ((Result.Right - Result.Left) div 2), Point.y - (Result.Bottom - Result.Top) - 15);
+ gppCenter: OffsetRect(Result,
+ Point.x - ((Result.Right - Result.Left) div 2), Point.y - ((Result.Bottom - Result.Top) div 2));
+ gppBottom: OffsetRect(Result,
+ Point.x - ((Result.Right - Result.Left) div 2), Point.y + 15);
+ gppLeftTop: OffsetRect(Result,
+ Point.x + 15, Point.y - (Result.Bottom - Result.Top) - 15);
+ gppLeft: OffsetRect(Result,
+ Point.x + 15, Point.y - ((Result.Bottom - Result.Top) div 2));
+ gppLeftBottom: OffsetRect(Result, Point.x + 15, Point.y + 15); //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g\82P\82Ì453\8e\81\82É\8a´\8eÓ
+ end;
+
+end;
end.