Browse CVS Repository
Contents of /gikonavigoeson/gikonavi/HintWindow.pas
Parent Directory
| Revision Log
| Revision Graph
Revision 1.4 -
( show annotations)
( download)
( as text)
Mon Apr 5 10:24:59 2004 UTC
(19 years, 11 months ago)
by h677
Branch: MAIN
CVS Tags: v1_59_0_771, v1_59_0_770, v1_59_0_773, v1_59_0_772, v1_59_0_775, v1_59_0_774, v1_59_0_777, v1_59_0_776, v1_56_0_715, v1_59_0_778, v1_63_1_819, b49, b48, v1_57_0_737, v1_62_0_812, v1_57_0_735, v1_57_0_734, v1_57_0_733, v1_57_0_732, v1_57_0_731, v1_57_0_730, v1_50_2_606, v1_51_0_612, v1_50_0_581, v1_50_0_580, v1_50_0_587, v1_50_0_586, v1_57_0_739, v1_57_0_738, v1_59_1_765, v1_51_1_639, v1_53_0_671, v1_50_0_595, v1_60_0_788, v1_60_0_789, v1_54_0_677, v1_54_0_676, v1_50_0_572, v1_58_0_748, marged-Bb50, v1_58_0_745, v1_60_0_781, v1_60_0_782, v1_58_0_746, v1_60_0_784, v1_54_0_678, v1_60_0_786, v1_60_0_787, v1_56_0_707, v1_59_0_767, v1_56_0_705, v1_56_0_704, v1_56_0_703, v1_56_0_702, v1_56_0_701, v1_56_0_700, v1_59_1_778, v1_51_0_626, v1_57_0_723, b51, v1_52_1_658, v1_51_0_622, v1_59_0_768, v1_59_0_769, v1_50_0_598, v1_57_0_725, v1_57_0_726, v1_57_0_727, v1_57_0_720, v1_57_0_722, v1_57_1_744, v1_50_0_590, bv1_49_0_564, v1_50_0_593, v1_57_0_728, v1_57_0_729, v1_50_0_596, bv1_49_0_563, v1_52_0_646, v1_50_0_557, v1_57_0_736, v1_50_0_585, v1_51_0_611, v1_51_0_620, v1_52_0_644, v1_58_0_752, v1_58_0_750, v1_58_0_751, v1_58_0_756, v1_58_0_757, v1_58_0_754, v1_58_0_755, v1_58_0_759, v1_52_0_643, v1_57_0_719, v1_57_0_718, v1_56_0_716, v1_54_0_687, v1_56_0_710, v1_56_0_711, v1_56_1_717, v1_56_1_716, v1_51_0_634, v1_51_0_635, v1_51_0_636, v1_51_0_637, v1_54_0_688, v1_54_0_689, v1_51_0_632, v1_51_0_633, v1_49_0_548, v1_50_0_603, v1_54_0_684, v1_50_0_582, v1_54_0_685, v1_49_0_540, v1_49_0_542, v1_49_0_545, v1_49_0_544, v1_49_0_547, v1_53_0_664, v1_61_0_796, v1_61_0_797, b47, v1_61_0_795, v1_52_0_647, v1_61_0_798, v1_61_0_799, v1_50_0_604, v1_51_0_638, v1_52_0_648, v1_53_0_661, v1_53_0_663, v1_53_0_662, v1_53_0_665, v1_53_0_667, v1_53_0_666, v1_53_0_669, v1_53_0_668, v1_48_0_530, v1_55_0_692, v1_55_0_693, v1_55_0_696, v1_55_0_697, v1_55_0_694, v1_55_0_695, v1_49_0_554, merged-remodeling, v1_50_0_577, v1_49_0_551, v1_52_0_645, v1_52_0_651, v1_54_1_691, v1_52_0_650, v1_56_2_724, v1_50_0_606, v1_56_2_722, v1_50_0_588, v1_52_0_652, v1_55_1_697, v1_52_0_642, v1_52_0_654, v1_51_0_616, v1_56_0_714, v1_51_0_614, v1_51_0_615, v1_53_0_672, v1_51_0_613, v1_53_0_670, v1_63_0_818, v1_63_0_817, v1_63_0_816, v1_63_0_815, v1_48_0_510, v1_51_1_640, v1_54_0_686, v1_51_0_618, v1_51_0_619, bv1_49_0_565, v1_54_0_680, v1_54_0_681, v1_62_0_805, v1_62_0_804, v1_62_0_807, v1_62_0_806, b50, v1_56_0_712, v1_62_0_803, v1_62_0_802, v1_48_0_535, v1_49_0_552, v1_56_0_713, v1_62_0_809, v1_50_0_574, v1_54_0_682, v1_49_0_553, v1_50_0_584, v_step1, v1_56_0_721, v1_49_0_546, v1_50_0_573, v1_48_0_539, v1_48_0_538, v1_50_0_600, v1_51_0_630, v1_48_0_533, v1_50_0_571, v1_54_0_683, v1_48_0_537, v1_51_0_631, v1_49_2_569, v1_60_0_780, v1_60_0_779, v1_62_0_810, v1_62_0_811, v1_58_0_747, v1_60_0_783, root-of-draw, v1_50_0_576, v1_54_0_679, v1_59_2_785, marged_bRESPOPUP, v1_50_2_604, v1_50_0_578, v1_54_0_675, v1_51_0_628, v1_50_0_579, v1_51_0_617, v1_48_0_536, root-of-Bb50, root-of-Bb51, v1_56_0_706, root-of-remodel, root-of-Bb53, v1_50_0_594, v1_49_0_541, v1_52_1_657, v1_54_0_674, v1_52_0_660, v1_60_1_793, v1_50_0_602, v1_51_0_629, v1_54_0_690, v1_51_0_627, v1_50_0_601, v1_58_0_763, v1_58_0_762, v1_58_0_761, v1_58_0_760, v1_51_0_625, v1_62_1_813, v1_51_0_623, v1_57_2_749, v1_50_0_605, v1_57_0_742, v1_57_0_743, v1_57_0_740, v1_57_0_741, v1_52_0_655, v1_56_0_709, v1_57_0_744, v1_52_0_656, v1_56_0_708, v1_52_0_649, v1_61_0_800, v1_53_1_673, v1_50_0_599, v1_56_0_699, v1_56_0_698, v1_50_0_561, v1_51_0_624, v1_51_1_641, v1_51_0_621, v1_60_0_793, v1_60_0_792, v1_60_0_791, v1_60_0_790, v1_60_2_794, v1_61_1_801, HEAD
Branch point for: Bb57, Bb56, Bb55, Bb53, Bb52, Bb51, Bb62, Bb63, Bb60, Bb61, remodeling, Bb59, Bb58, Bb50, bRESPOPUP, bListSU, BRANCH_TORA, Bb49, Bb54, Bdraw
Changes since 1.3: +5 -2 lines
File MIME type: text/x-pascal
Dispose、ャ、ヲ、゙、ッ、ヌ、ュ、ニ、ハ、ォ、テ、ソ、ホ、ヌス、タオ
| 1 |
unit HintWindow; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
| 7 |
GikoSystem; |
| 8 |
|
| 9 |
type |
| 10 |
TGikoPopupType = (gptRaw, gptThread); |
| 11 |
|
| 12 |
TResPopup = class(THintWindow) |
| 13 |
private |
| 14 |
FTitle: string; |
| 15 |
FResList: TList; |
| 16 |
FPopupType: TGikoPopupType; |
| 17 |
FHeaderBold: Boolean; |
| 18 |
protected |
| 19 |
procedure Paint; override; |
| 20 |
public |
| 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; |
| 30 |
end; |
| 31 |
|
| 32 |
PResDataRec = ^TResDataRec; |
| 33 |
TResDataRec = record |
| 34 |
FHeader: string; |
| 35 |
// FHeaderHeight: Integer; |
| 36 |
FBody: string; |
| 37 |
// FBodyHeight: Integer; |
| 38 |
end; |
| 39 |
|
| 40 |
implementation |
| 41 |
|
| 42 |
const |
| 43 |
BODY_INDENT = 5; //Body窶「窶昶?「ツェ窶堙姑辰ニ停?愴断ニ停?愴暖窶「?ス |
| 44 |
TITLE_SPACE = 8; //ニ耽ニ辰ニ暖ニ停?ケ窶堙??怒窶「ツカナ?テ披?堙鯉ソス窶壺?堋ウ |
| 45 |
RES_SPACE = 8; //ニ椎槌湛ナ?テ披?ケテウ窶昶?吮?堙鯉ソス窶壺?堋ウ |
| 46 |
HEADER_SPACE = 4; //ニ蜘ニ鍛ニ胆窶堙??怒窶「ツカナ?テ披?堙鯉ソス窶壺?堋ウ |
| 47 |
|
| 48 |
constructor TResPopup.Create(AOwner: TComponent); |
| 49 |
begin |
| 50 |
inherited Create(AOwner); |
| 51 |
FResList := TList.Create; |
| 52 |
FHeaderBold := True; |
| 53 |
end; |
| 54 |
|
| 55 |
destructor TResPopup.Destroy; |
| 56 |
begin |
| 57 |
ClearAllRes; |
| 58 |
FResList.Free; |
| 59 |
inherited Destroy; |
| 60 |
end; |
| 61 |
|
| 62 |
procedure TResPopup.Paint; |
| 63 |
var |
| 64 |
R: TRect; |
| 65 |
i: Integer; |
| 66 |
ResData: PResDataRec; |
| 67 |
H: Integer; |
| 68 |
begin |
| 69 |
R := ClientRect; |
| 70 |
Inc(R.Left, 2); |
| 71 |
Inc(R.Top, 2); |
| 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); |
| 78 |
end else begin |
| 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 |
| 85 |
else |
| 86 |
R.Top := R.Top + H; |
| 87 |
end; |
| 88 |
for i := 0 to FResList.Count - 1 do begin |
| 89 |
if i <> 0 then |
| 90 |
R.Top := R.Top + RES_SPACE; |
| 91 |
ResData := FResList[i]; |
| 92 |
//Header |
| 93 |
Canvas.Font.Style := []; |
| 94 |
if FHeaderBold then |
| 95 |
Canvas.Font.Style := [fsBold]; |
| 96 |
H := DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, R, |
| 97 |
DT_LEFT or DT_NOPREFIX or DT_WORDBREAK); |
| 98 |
R.Top := R.Top + H; |
| 99 |
//ニ湛ニ馳?ス[ニ湛 |
| 100 |
R.Top := R.Top + HEADER_SPACE; |
| 101 |
//Body |
| 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); |
| 106 |
R.Top := R.Top + H; |
| 107 |
R.Left := R.Left - BODY_INDENT; |
| 108 |
end; |
| 109 |
end; |
| 110 |
end; |
| 111 |
|
| 112 |
function TResPopup.CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; |
| 113 |
var |
| 114 |
i: Integer; |
| 115 |
ARect: TRect; |
| 116 |
ResData: PResDataRec; |
| 117 |
begin |
| 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); |
| 126 |
end else begin |
| 127 |
//Title |
| 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 |
| 137 |
else |
| 138 |
Result.Bottom := Result.Bottom + ARect.Bottom; |
| 139 |
end; |
| 140 |
for i := 0 to FResList.Count - 1 do begin |
| 141 |
if i <> 0 then |
| 142 |
Result.Bottom := Result.Bottom + RES_SPACE; |
| 143 |
ResData := FResList[i]; |
| 144 |
//Header |
| 145 |
Canvas.Font.Style := []; |
| 146 |
if FHeaderBold then |
| 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; |
| 154 |
//ニ湛ニ馳?ス[ニ湛 |
| 155 |
Result.Bottom := Result.Bottom + HEADER_SPACE; |
| 156 |
//Body |
| 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; |
| 164 |
end; |
| 165 |
end; |
| 166 |
Inc(Result.Right, 6); |
| 167 |
Inc(Result.Bottom, 2); |
| 168 |
end; |
| 169 |
|
| 170 |
procedure TResPopup.Add(AHeader: string; ABody: string); |
| 171 |
var |
| 172 |
ResData: PResDataRec; |
| 173 |
begin |
| 174 |
New(ResData); |
| 175 |
ResData.FHeader := AHeader; |
| 176 |
// ResData.FHeaderHeight := 0; |
| 177 |
ResData.FBody := ABody; |
| 178 |
// ResData.FBodyHeight := 0; |
| 179 |
FResList.Add(ResData); |
| 180 |
end; |
| 181 |
|
| 182 |
procedure TResPopup.ClearAllRes; |
| 183 |
var |
| 184 |
i: Integer; |
| 185 |
ResData: PResDataRec; |
| 186 |
begin |
| 187 |
for i := 0 to FResList.Count - 1 do begin |
| 188 |
ResData := FResList[i]; |
| 189 |
Dispose(ResData); |
| 190 |
end; |
| 191 |
FResList.Clear; |
| 192 |
FTitle := ''; |
| 193 |
Caption := ''; |
| 194 |
end; |
| 195 |
|
| 196 |
function TResPopup.ResCount: Integer; |
| 197 |
begin |
| 198 |
Result := FResList.Count; |
| 199 |
end; |
| 200 |
|
| 201 |
end. |
| |