Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/ResPopupBrowser.pas

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

revision 1.1.2.13 by h677, Sun May 27 13:11:20 2007 UTC revision 1.1.2.14 by h677, Wed May 30 15:48:21 2007 UTC
# Line 27  type Line 27  type
27          function GetBodyStyle(OnlyTitle: Boolean = False): string;          function GetBodyStyle(OnlyTitle: Boolean = False): string;
28          function GetWindowHeight : Integer;          function GetWindowHeight : Integer;
29          function GetTitle(OnlyTitle: Boolean): string;          function GetTitle(OnlyTitle: Boolean): string;
30                  function CalcRect(MaxHeight: Integer; MaxWidth: Integer; Scroll: Boolean): TRect;                  function CalcRect(WorkArea: TRect; Scroll: Boolean): TRect;
31          function ResPopupBrowserClick(Sender: TObject): WordBool;          function ResPopupBrowserClick(Sender: TObject): WordBool;
32          function GetThread: TThreadItem;          function GetThread: TThreadItem;
33          protected          protected
# Line 181  begin Line 181  begin
181    
182          doc.Close;          doc.Close;
183    
184          ARect := CalcRect(Screen.WorkAreaHeight, Screen.WorkAreaWidth,          ARect := CalcRect(Screen.WorkAreaRect, not OnlyTitle);
              not OnlyTitle);  
185    
186          FDispHtmlDocument := Idispatch(OleVariant(Self.ControlInterface).Document) as DispHTMLDocument;          FDispHtmlDocument := Idispatch(OleVariant(Self.ControlInterface).Document) as DispHTMLDocument;
187          FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);          FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
# Line 256  begin Line 255  begin
255      end;      end;
256  end;  end;
257    
258  function TResPopupBrowser.CalcRect(MaxHeight: Integer; MaxWidth: Integer; Scroll: Boolean): TRect;  function TResPopupBrowser.CalcRect(WorkArea: TRect; Scroll: Boolean): TRect;
259  var  var
260          p: TPoint;          p: TPoint;
261      ele: IHTMLElement2;      ele: IHTMLElement2;
262      h, w, dx1, dx2, dy1, dy2: Integer;      h, w, dx1, dx2, dy1, dy2: Integer;
263        MaxWidth, MaxHeight: Integer;
264  begin  begin
265          GetCursorpos(p);          GetCursorpos(p);
266      ele := ((Self.Document as IHTMLDocument2).body as IHTMLElement2);      ele := ((Self.Document as IHTMLDocument2).body as IHTMLElement2);
# Line 279  begin Line 279  begin
279      case GikoSys.Setting.PopupPosition of      case GikoSys.Setting.PopupPosition of
280          gppRightTop:          gppRightTop:
281          begin          begin
282              dx1 := -w; dx2 := -2;              dx1 := 0; dx2 := -2;
283              dy1 := -h; dy2 := -2;              dy1 := -h; dy2 := -2;
284          end;          end;
285          gppRight:          gppRight:
286          begin          begin
287              dx1 := -w; dx2 := -2;              dx1 := 0; dx2 := -2;
288              dy1 := - (h div 2); dy2 := 0;              dy1 := - (h div 2); dy2 := 0;
289          end;          end;
290          gppRightBottom:          gppRightBottom:
291          begin          begin
292              dx1 := -w; dx2 := -2;              dx1 := 0; dx2 := -2;
293              dy1 := 0; dy2 := +2;              dy1 := 0; dy2 := +2;
294          end;          end;
295          gppTop:          gppTop:
# Line 305  begin Line 305  begin
305          end;          end;
306          gppLeftTop:          gppLeftTop:
307          begin          begin
308              dx1 := 0; dx2 := +2;              dx1 := -w; dx2 := +2;
309              dy1 := -h; dy2 := -2;              dy1 := -h; dy2 := -2;
310          end;          end;
311          gppLeft:          gppLeft:
312          begin          begin
313              dx1 := 0; dx2 := +2;              dx1 := -w; dx2 := +2;
314              dy1 := - (h div 2); dy2 := 0;              dy1 := - (h div 2); dy2 := 0;
315          end;          end;
316          gppLeftBottom:          gppLeftBottom:
317          begin          begin
318              dx1 := 0; dx2 := +2;              dx1 := -w; dx2 := +2;
319              dy1 := 0; dy2 := +2;              dy1 := 0; dy2 := +2;
320          end;          end;
321      end;      end;
322      // 初期位置に移動      // 初期位置に移動
323      OffsetRect(Result, p.x + dx1 + dx2, p.y + dy1 + dy2);      OffsetRect(Result, p.x + dx1 + dx2, p.y + dy1 + dy2);
324    
325        MaxWidth := WorkArea.Right - WorkArea.Left;
326        MaxHeight := WorkArea.Bottom - WorkArea.Top;
327      // 以下、初期位置に問題があるときの移動      // 以下、初期位置に問題があるときの移動
328      if (Result.Left < 0) then begin      if (Result.Left < WorkArea.Left) then begin
329          // 逆サイドに余裕があれば、出力位置の左右転換          // 逆サイドに余裕があれば、出力位置の左右転換
330          if (p.X * 2 < MaxWidth) then begin          if (p.X * 2 < MaxWidth) then begin
331              if ( (GikoSys.Setting.PopupPosition = gppTop) or              if ( (GikoSys.Setting.PopupPosition = gppTop) or
332                  (GikoSys.Setting.PopupPosition = gppBottom)) then begin                  (GikoSys.Setting.PopupPosition = gppBottom)) then begin
333                  OffsetRect(Result, -Result.Left, 0);                  OffsetRect(Result, -Result.Left, WorkArea.Left);
334              end else begin              end else begin
335                  OffsetRect(Result, - (dx1 + 2 * dx2), 0);                  OffsetRect(Result, - (dx1 + 2 * dx2), 0);
336              end;              end;
# Line 338  begin Line 340  begin
340                  Result.Right, Result.Bottom);                  Result.Right, Result.Bottom);
341          end;          end;
342      end;      end;
343      if (Result.Top < 0) then begin      if (Result.Top < WorkArea.Top) then begin
344          // 底側に余裕があれば、出力位置の上下転換          // 底側に余裕があれば、出力位置の上下転換
345          if (p.Y * 2 < MaxHeight) then begin          if (p.Y * 2 < MaxHeight) then begin
346              OffsetRect(Result, 0, - (dy1 + 2 * dy2));              OffsetRect(Result, 0, - (dy1 + 2 * dy2));
347          end else begin          end else begin
348              // 画面端まで画面高を小さくする              // 画面端まで画面高を小さくする
349              Result := Rect(Result.Left, 0,              Result := Rect(Result.Left, WorkArea.Top,
350                  Result.Right, Result.Bottom);                  Result.Right, Result.Bottom);
351          end;          end;
352      end;      end;
353      if (Result.Right > MaxWidth) then begin      if (Result.Right > WorkArea.Right) then begin
354          // 逆サイドに余裕があれば、出力位置の左右転換          // 逆サイドに余裕があれば、出力位置の左右転換
355          if (p.X * 2 > MaxWidth) then begin          if (p.X * 2 > WorkArea.Right) then begin
356              if( (GikoSys.Setting.PopupPosition = gppTop) or              if( (GikoSys.Setting.PopupPosition = gppTop) or
357                  (GikoSys.Setting.PopupPosition = gppBottom)) then begin                  (GikoSys.Setting.PopupPosition = gppBottom)) then begin
358                  OffsetRect(Result, -(Result.Right - MaxWidth), 0);                  OffsetRect(Result, -(Result.Right - WorkArea.Right), 0);
359              end else begin              end else begin
360                  OffsetRect(Result, -w - (dx1 + 2 * dx2), 0);                  OffsetRect(Result, -w - (dx1 + 2 * dx2), 0);
361              end;              end;
362                // 逆サイドにオーバーした場合は画面端まで幅を小さくする
363                if (Result.Left < WorkArea.Left) then begin
364                    Result := Rect(WorkArea.Left, Result.Top,
365                        Result.Right, Result.Bottom);
366                end;
367          end else begin          end else begin
368              // 画面端まで画面幅を小さくする              // 画面端まで画面幅を小さくする
369              Result := Rect(Result.Left, Result.Top,              Result := Rect(Result.Left, Result.Top,
370                  MaxWidth, Result.Bottom);                  WorkArea.Right, Result.Bottom);
371          end;          end;
372      end;      end;
373      if (Result.Bottom > MaxHeight) then begin      if (Result.Bottom > WorkArea.Bottom) then begin
374          // 上側に余裕があれば、出力位置の上下転換          // 上側に余裕があれば、出力位置の上下転換
375          if (p.Y * 2 > MaxHeight) then begin          if (p.Y * 2 > WorkArea.Bottom) then begin
376              OffsetRect(Result, 0, -h - (dy1 + 2 * dy2));              OffsetRect(Result, 0, -h - (dy1 + 2 * dy2));
377                // 上に貫いた場合は、
378                if (Result.Top < WorkArea.Top) then begin
379                    Result := Rect(Result.Left, WorkArea.Top,
380                        Result.Right, Result.Bottom);
381                end;
382          end else begin          end else begin
383              // 画面端まで画面高を小さくする              // 画面端まで画面高を小さくする
384              Result := Rect(Result.Left, Result.Top,              Result := Rect(Result.Left, Result.Top,
385                  Result.Right, 0);                  Result.Right, WorkArea.Bottom);
386          end;          end;
387      end;      end;
388  end;  end;

Legend:
Removed from v.1.1.2.13  
changed lines
  Added in v.1.1.2.14

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