OSDN Git Service

リリース日修正
[gikonavigoeson/gikonavi.git] / ResPopupBrowser.pas
index 4ae2fe7..d186b4c 100644 (file)
@@ -66,6 +66,8 @@ begin
     RawDocument := '';
     FEvent := nil;
     ShowWindow(Self.Handle, SW_HIDE);
+    GikoSys.ShowRefCount('ResPop Create', Self.ControlInterface);
+    GikoSys.ShowRefCount('ResPop.Document Create', Self.ControlInterface.Document);
 end;
 
 destructor TResPopupBrowser.Destroy;
@@ -84,6 +86,10 @@ begin
         FEvent := nil;
     end;
     FThread := nil;
+
+    GikoSys.ShowRefCount('ResPop Desctroy', Self.ControlInterface);
+    GikoSys.ShowRefCount('ResPop.Document Create', Self.ControlInterface.Document);
+
        inherited Destroy;
 end;
 
@@ -136,7 +142,7 @@ begin
 end;
 procedure TResPopupBrowser.NavigateBlank(Forced: Boolean);
 begin
-    if (not Assigned(Self.Document)) or (Forced) then begin
+    if (not Assigned(Self.ControlInterface.Document)) or (Forced) then begin
         Self.Navigate('about:blank');
     end;
     while (Self.ReadyState <> READYSTATE_COMPLETE) and
@@ -151,14 +157,22 @@ begin
 end;
 procedure TResPopupBrowser.Popup;
 begin
-    Write(Self.RawDocument, false);
+    if (GetAsyncKeyState(VK_SHIFT) = Smallint($8001)) then begin
+        // \83V\83t\83g\89\9f\82µ\82Ä\82é\8fê\8d\87\82Í\82»\82Ì\82Ü\82Ü\8fo\82·
+        Write(Self.RawDocument, false);
+    end else begin
+        // éx\82µ\8aG\82ª\8c©\82¦\82é\82æ\82¤\82É\94¼\8ap\83X\83y\81[\83X*2\82ð&nbsp;*2\82É\92u\8a·\82·\82é
+        Write(
+            MojuUtils.CustomStringReplace(
+                Self.RawDocument, '  ', '&nbsp;&nbsp;'),
+            false);
+    end;
 end;
 procedure TResPopupBrowser.Write(ADocument: String; OnlyTitle: Boolean = False);
 var
        p: TPoint;
-    doc: Variant;
+    doc: OleVariant;
        ARect: TRect;
-    FDispHtmlDocument: DispHTMLDocument;
 begin
     try
         // \83^\83X\83N\83o\81[\82©\82ç\8fÁ\82·
@@ -168,7 +182,7 @@ begin
         SetWindowPos(Self.Handle, HWND_BOTTOM,
             p.X, p.Y, 50 , 50,
             SWP_NOACTIVATE or SWP_HIDEWINDOW);
-        doc := Idispatch( olevariant(Self.ControlInterface).Document) as IHTMLDocument2;
+        doc := Self.OleObject.Document;
         doc.open;
         doc.charset := 'Shift_JIS';
         doc.Write('<html><head>'#13#10 +
@@ -180,11 +194,11 @@ begin
                 + ADocument + '<a name="bottom"></a></body></html>');
 
         doc.Close;
+        // \83}\83\8b\83`\83\82\83j\83^\91Î\89\9e
+        ARect := CalcRect(Screen.MonitorFromPoint(p).WorkareaRect,
+                        not OnlyTitle);
 
-        ARect := CalcRect(Screen.WorkAreaRect, not OnlyTitle);
-
-        FDispHtmlDocument := Idispatch(OleVariant(Self.ControlInterface).Document) as DispHTMLDocument;
-        FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
+        FEvent := THTMLDocumentEventSink.Create(Self, Self.OleObject.Document, HTMLDocumentEvents2);
         FEvent.OnClick := ResPopupBrowserClick;
         FEvent.OnDoubleClick := ResPopupBrowserDbClick;
         Self.Visible := True;
@@ -264,7 +278,7 @@ var
     DIV_X, DIV_Y: Integer;
 begin
        GetCursorpos(p);
-    ele := ((Self.Document as IHTMLDocument2).body as IHTMLElement2);
+    ele := ((Self.ControlInterface.Document as IHTMLDocument2).body as IHTMLElement2);
     if Scroll then begin
         h := GetWindowHeight + 10;
         w := ele.scrollWidth + 25
@@ -331,22 +345,22 @@ begin
     // \88È\89º\81A\8f\89\8aú\88Ê\92u\82É\96â\91è\82ª\82 \82é\82Æ\82«\82Ì\88Ú\93®
     if (Result.Left < WorkArea.Left) then begin
         // \8bt\83T\83C\83h\82É\97]\97T\82ª\82 \82ê\82Î\81A\8fo\97Í\88Ê\92u\82Ì\8d\89E\93]\8a·
-        if (p.X * 2 < MaxWidth) then begin
+        if ((p.X - WorkArea.Left) * 2 < MaxWidth) then begin
             if ( (GikoSys.Setting.PopupPosition = gppTop) or
                 (GikoSys.Setting.PopupPosition = gppBottom)) then begin
-                OffsetRect(Result, -Result.Left, WorkArea.Left);
+                OffsetRect(Result, -Result.Left, 0);
             end else begin
                 OffsetRect(Result, - (dx1 + 2 * dx2), 0);
             end;
         end else begin
             // \89æ\96Ê\92[\82Ü\82Å\89æ\96Ê\95\9d\82ð\8f¬\82³\82­\82·\82é
-            Result := Rect(0, Result.Top,
+            Result := Rect(WorkArea.Left, Result.Top,
                 Result.Right, Result.Bottom);
         end;
     end;
     if (Result.Top < WorkArea.Top) then begin
         // \92ê\91¤\82É\97]\97T\82ª\82 \82ê\82Î\81A\8fo\97Í\88Ê\92u\82Ì\8fã\89º\93]\8a·
-        if (p.Y * 2 < MaxHeight) then begin
+        if ((p.Y - WorkArea.Top) * 2 < MaxHeight) then begin
             OffsetRect(Result, 0, - (dy1 + 2 * dy2));
         end else begin
             // \89æ\96Ê\92[\82Ü\82Å\89æ\96Ê\8d\82\82ð\8f¬\82³\82­\82·\82é
@@ -356,7 +370,7 @@ begin
     end;
     if (Result.Right > WorkArea.Right) then begin
         // \8bt\83T\83C\83h\82É\97]\97T\82ª\82 \82ê\82Î\81A\8fo\97Í\88Ê\92u\82Ì\8d\89E\93]\8a·
-        if (p.X * 2 > WorkArea.Right) then begin
+        if ((p.X - WorkArea.Left) * 2 > WorkArea.Right) then begin
             if( (GikoSys.Setting.PopupPosition = gppTop) or
                 (GikoSys.Setting.PopupPosition = gppBottom)) then begin
                 OffsetRect(Result, -(Result.Right - WorkArea.Right), 0);
@@ -376,7 +390,7 @@ begin
     end;
     if (Result.Bottom > WorkArea.Bottom) then begin
         // \8fã\91¤\82É\97]\97T\82ª\82 \82ê\82Î\81A\8fo\97Í\88Ê\92u\82Ì\8fã\89º\93]\8a·
-        if (p.Y * 2 > WorkArea.Bottom) then begin
+        if ((p.Y - WorkArea.Top) * 2 > WorkArea.Bottom) then begin
             OffsetRect(Result, 0, -h - (dy1 + 2 * dy2));
             // \8fã\82É\8aÑ\82¢\82½\8fê\8d\87\82Í\81A
             if (Result.Top < WorkArea.Top) then begin
@@ -405,8 +419,7 @@ begin
 
     try
         top := 0;
-        item := OleVariant( Self.Document as IHTMLDocument2)
-                .anchors.item(OleVariant('bottom'));
+        item := Self.OleObject.Document.anchors.item(OleVariant('bottom'));
         item.focus();
         repeat
             top := top + item.offsetTop;