6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
10 TGikoPopupType = (gptRaw, gptThread);
12 TResPopup = class(THintWindow)
16 FPopupType: TGikoPopupType;
18 procedure Paint; override;
20 constructor Create(AOwner: TComponent); override;
21 destructor Destroy; override;
22 procedure Add(AHeader: string; ABody: string);
23 procedure ClearAllRes;
24 function ResCount: Integer;
25 function CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; override;
26 property Title: string read FTitle write FTitle;
27 property PopupType: TGikoPopupType read FPopupType write FPopupType;
30 PResDataRec = ^TResDataRec;
33 FHeaderHeight: Integer;
41 BODY_INDENT = 5; //Body
\95\94\95ª
\82Ì
\83C
\83\93\83f
\83\93\83g
\95\9d
42 TITLE_SPACE = 8; //
\83^
\83C
\83g
\83\8b\82Æ
\96{
\95¶
\8aÔ
\82Ì
\8d\82\82³
43 RES_SPACE = 8; //
\83\8c\83X
\8aÔ
\8bó
\94\92\82Ì
\8d\82\82³
44 HEADER_SPACE = 4; //
\83w
\83b
\83_
\82Æ
\96{
\95¶
\8aÔ
\82Ì
\8d\82\82³
46 constructor TResPopup.Create(AOwner: TComponent);
48 inherited Create(AOwner);
49 FResList := TList.Create;
52 destructor TResPopup.Destroy;
59 procedure TResPopup.Paint;
69 Canvas.Font.Color := Font.Color;
70 Canvas.Font.Name := Font.Name;
71 Canvas.Font.Size := Font.Size;
72 if FPopupType = gptRaw then begin
73 Canvas.Font.Style := [];
74 DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT or DT_NOPREFIX);
76 if FTitle <> '' then begin
77 Canvas.Font.Style := [fsBold];
78 DrawText(Canvas.Handle, PChar(FTitle), -1, R,
79 DT_LEFT or DT_NOPREFIX);
80 ARect := Rect(0, 0, 0, 0);
81 DrawText(Canvas.Handle, PChar(FTitle), -1, ARect,
82 DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
83 R.Top := R.Top + ARect.Bottom + TITLE_SPACE;
85 for i := 0 to FResList.Count - 1 do begin
87 R.Top := R.Top + RES_SPACE;
88 ResData := FResList[i];
90 Canvas.Font.Style := [fsBold];
91 DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, R,
92 DT_LEFT or DT_NOPREFIX);
93 R.Top := R.Top + ResData.FHeaderHeight;
95 R.Top := R.Top + HEADER_SPACE;
97 Canvas.Font.Style := [];
98 R.Left := R.Left + BODY_INDENT;
99 DrawText(Canvas.Handle, PChar(ResData.FBody), -1, R,
100 DT_LEFT or DT_NOPREFIX);
101 R.Top := R.Top + ResData.FBodyHeight;
102 R.Left := R.Left - BODY_INDENT;
107 function TResPopup.CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect;
111 ResData: PResDataRec;
113 Result := Rect(0, 0, 0, 0);
114 Canvas.Font.Name := Font.Name;
115 Canvas.Font.Size := Font.Size;
116 if FPopupType = gptRaw then begin
117 Canvas.Font.Style := [fsBold];
118 Result := Rect(0, 0, MaxWidth, 0);
119 DrawText(Canvas.Handle, PChar(AHint), -1, Result,
120 DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
123 if FTitle <> '' then begin
124 Canvas.Font.Style := [fsBold];
125 ARect := Rect(0, 0, MaxWidth, 0);
126 DrawText(Canvas.Handle, PChar(FTitle), -1, ARect,
127 DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
128 if Result.Right < ARect.Right then
129 Result.Right := ARect.Right;
130 Result.Bottom := Result.Bottom + ARect.Bottom + TITLE_SPACE;
132 for i := 0 to FResList.Count - 1 do begin
134 Result.Bottom := Result.Bottom + RES_SPACE;
135 ResData := FResList[i];
137 Canvas.Font.Style := [fsBold];
138 ARect := Rect(0, 0, MaxWidth, 0);
139 DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, ARect,
140 DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
141 if Result.Right < ARect.Right then
142 Result.Right := ARect.Right;
143 Result.Bottom := Result.Bottom + ARect.Bottom;
144 ResData.FHeaderHeight := ARect.Bottom;
146 Result.Bottom := Result.Bottom + HEADER_SPACE;
148 Canvas.Font.Style := [];
149 ARect := Rect(0, 0, MaxWidth, 0);
150 DrawText(Canvas.Handle, PChar(ResData.FBody), -1, ARect,
151 DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
152 if Result.Right < (ARect.Right + BODY_INDENT) then
153 Result.Right := ARect.Right + BODY_INDENT;
154 Result.Bottom := Result.Bottom + ARect.Bottom;
155 ResData.FBodyHeight := ARect.Bottom;
158 Inc(Result.Right, 6);
159 Inc(Result.Bottom, 2);
162 procedure TResPopup.Add(AHeader: string; ABody: string);
164 ResData: PResDataRec;
167 ResData.FHeader := AHeader;
168 ResData.FHeaderHeight := 0;
169 ResData.FBody := ABody;
170 ResData.FBodyHeight := 0;
171 FResList.Add(ResData);
174 procedure TResPopup.ClearAllRes;
178 for i := 0 to FResList.Count - 1 do
179 Dispose(FResList[i]);
185 function TResPopup.ResCount: Integer;
187 Result := FResList.Count;