6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
10 TGikoPopupType = (gptRaw, gptThread);
12 TResPopup = class(THintWindow)
16 FPopupType: TGikoPopupType;
19 procedure Paint; override;
21 constructor Create(AOwner: TComponent); override;
22 destructor Destroy; override;
23 procedure Add(AHeader: string; ABody: string);
24 procedure ClearAllRes;
25 function ResCount: Integer;
26 function CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; override;
27 property Title: string read FTitle write FTitle;
28 property PopupType: TGikoPopupType read FPopupType write FPopupType;
29 property HeaderBold: Boolean read FHeaderBold write FHeaderBold;
32 PResDataRec = ^TResDataRec;
35 // FHeaderHeight: Integer;
37 // FBodyHeight: Integer;
43 BODY_INDENT = 5; //Body
\95\94\95ª
\82Ì
\83C
\83\93\83f
\83\93\83g
\95\9d
44 TITLE_SPACE = 8; //
\83^
\83C
\83g
\83\8b\82Æ
\96{
\95¶
\8aÔ
\82Ì
\8d\82\82³
45 RES_SPACE = 8; //
\83\8c\83X
\8aÔ
\8bó
\94\92\82Ì
\8d\82\82³
46 HEADER_SPACE = 4; //
\83w
\83b
\83_
\82Æ
\96{
\95¶
\8aÔ
\82Ì
\8d\82\82³
48 constructor TResPopup.Create(AOwner: TComponent);
50 inherited Create(AOwner);
51 FResList := TList.Create;
55 destructor TResPopup.Destroy;
62 procedure TResPopup.Paint;
72 Canvas.Font.Color := Font.Color;
73 Canvas.Font.Name := Font.Name;
74 Canvas.Font.Size := Font.Size;
75 if FPopupType = gptRaw then begin
76 Canvas.Font.Style := [];
77 DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
79 if FTitle <> '' then begin
80 Canvas.Font.Style := [fsBold];
81 H := DrawText(Canvas.Handle, PChar(FTitle), -1, R,
82 DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
83 if FResList.Count > 0 then
84 R.Top := R.Top + H + TITLE_SPACE
88 for i := 0 to FResList.Count - 1 do begin
90 R.Top := R.Top + RES_SPACE;
91 ResData := FResList[i];
93 Canvas.Font.Style := [];
95 Canvas.Font.Style := [fsBold];
96 H := DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, R,
97 DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
100 R.Top := R.Top + HEADER_SPACE;
102 Canvas.Font.Style := [];
103 R.Left := R.Left + BODY_INDENT;
104 H := DrawText(Canvas.Handle, PChar(ResData.FBody), -1, R,
105 DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
107 R.Left := R.Left - BODY_INDENT;
112 function TResPopup.CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect;
116 ResData: PResDataRec;
118 Result := Rect(0, 0, 0, 0);
119 Canvas.Font.Name := Font.Name;
120 Canvas.Font.Size := Font.Size;
121 if FPopupType = gptRaw then begin
122 Canvas.Font.Style := [fsBold];
123 Result := Rect(0, 0, MaxWidth, 0);
124 DrawText(Canvas.Handle, PChar(AHint), -1, Result,
125 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
128 if FTitle <> '' then begin
129 Canvas.Font.Style := [fsBold];
130 ARect := Rect(0, 0, MaxWidth, 0);
131 DrawText(Canvas.Handle, PChar(FTitle), -1, ARect,
132 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
133 if Result.Right < ARect.Right then
134 Result.Right := ARect.Right;
135 if FResList.Count > 0 then
136 Result.Bottom := Result.Bottom + ARect.Bottom + TITLE_SPACE
138 Result.Bottom := Result.Bottom + ARect.Bottom;
140 for i := 0 to FResList.Count - 1 do begin
142 Result.Bottom := Result.Bottom + RES_SPACE;
143 ResData := FResList[i];
145 Canvas.Font.Style := [];
147 Canvas.Font.Style := [fsBold];
148 ARect := Rect(0, 0, MaxWidth, 0);
149 DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, ARect,
150 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
151 if Result.Right < ARect.Right then
152 Result.Right := ARect.Right;
153 Result.Bottom := Result.Bottom + ARect.Bottom;
155 Result.Bottom := Result.Bottom + HEADER_SPACE;
157 Canvas.Font.Style := [];
158 ARect := Rect(0, 0, MaxWidth, 0);
159 DrawText(Canvas.Handle, PChar(ResData.FBody), -1, ARect,
160 DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
161 if Result.Right < (ARect.Right + BODY_INDENT) then
162 Result.Right := ARect.Right + BODY_INDENT;
163 Result.Bottom := Result.Bottom + ARect.Bottom;
166 Inc(Result.Right, 6);
167 Inc(Result.Bottom, 2);
170 procedure TResPopup.Add(AHeader: string; ABody: string);
172 ResData: PResDataRec;
175 ResData.FHeader := AHeader;
176 // ResData.FHeaderHeight := 0;
177 ResData.FBody := ABody;
178 // ResData.FBodyHeight := 0;
179 FResList.Add(ResData);
182 procedure TResPopup.ClearAllRes;
185 ResData: PResDataRec;
187 for i := 0 to FResList.Count - 1 do begin
188 ResData := FResList[i];
196 function TResPopup.ResCount: Integer;
198 Result := FResList.Count;