OSDN Git Service

1.59.1.778
[gikonavigoeson/gikonavi.git] / HintWindow.pas
index 07daf72..743e61c 100644 (file)
@@ -14,6 +14,7 @@ type
                FTitle: string;
                FResList: TList;
                FPopupType: TGikoPopupType;
+               FHeaderBold: Boolean;
        protected
                procedure Paint; override;
        public
@@ -25,14 +26,15 @@ type
                function CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; override;
                property Title: string read FTitle write FTitle;
                property PopupType: TGikoPopupType read FPopupType write FPopupType;
+               property HeaderBold: Boolean read FHeaderBold write FHeaderBold;
        end;
 
        PResDataRec = ^TResDataRec;
        TResDataRec = record
                FHeader: string;
-               FHeaderHeight: Integer;
+//             FHeaderHeight: Integer;
                FBody: string;
-               FBodyHeight: Integer;
+//             FBodyHeight: Integer;
        end;
 
 implementation
@@ -47,6 +49,7 @@ constructor TResPopup.Create(AOwner: TComponent);
 begin
        inherited Create(AOwner);
        FResList := TList.Create;
+       FHeaderBold := True;
 end;
 
 destructor TResPopup.Destroy;
@@ -61,7 +64,7 @@ var
        R: TRect;
        i: Integer;
        ResData: PResDataRec;
-       ARect: TRect;
+       H: Integer;
 begin
        R := ClientRect;
        Inc(R.Left, 2);
@@ -71,34 +74,36 @@ begin
        Canvas.Font.Size := Font.Size;
        if FPopupType = gptRaw then begin
                Canvas.Font.Style := [];
-               DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT or DT_NOPREFIX);
+               DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
        end else begin
                if FTitle <> '' then begin
                        Canvas.Font.Style := [fsBold];
-                       DrawText(Canvas.Handle, PChar(FTitle), -1, R,
-                                                        DT_LEFT or DT_NOPREFIX);
-                       ARect := Rect(0, 0, 0, 0);
-                       DrawText(Canvas.Handle, PChar(FTitle), -1, ARect,
-                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
-                       R.Top := R.Top + ARect.Bottom + TITLE_SPACE;
+                       H := DrawText(Canvas.Handle, PChar(FTitle), -1, R,
+                                                                               DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
+                       if FResList.Count > 0 then
+                               R.Top := R.Top + H + TITLE_SPACE
+                       else
+                               R.Top := R.Top + H;
                end;
                for i := 0 to FResList.Count - 1 do begin
                        if i <> 0 then
                                R.Top := R.Top + RES_SPACE;
                        ResData := FResList[i];
                        //Header
-                       Canvas.Font.Style := [fsBold];
-                       DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, R,
-                                                        DT_LEFT or DT_NOPREFIX);
-                       R.Top := R.Top + ResData.FHeaderHeight;
+                       Canvas.Font.Style := [];
+                       if FHeaderBold then
+                               Canvas.Font.Style := [fsBold];
+                       H := DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, R,
+                                                                                       DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
+                       R.Top := R.Top + H;
                        //\83X\83y\81[\83X
                        R.Top := R.Top + HEADER_SPACE;
                        //Body
                        Canvas.Font.Style := [];
                        R.Left := R.Left + BODY_INDENT;
-                       DrawText(Canvas.Handle, PChar(ResData.FBody), -1, R,
-                                                        DT_LEFT or DT_NOPREFIX);
-                       R.Top := R.Top + ResData.FBodyHeight;
+                       H := DrawText(Canvas.Handle, PChar(ResData.FBody), -1, R,
+                                                                               DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
+                       R.Top := R.Top + H;
                        R.Left := R.Left - BODY_INDENT;
                end;
        end;
@@ -117,42 +122,45 @@ begin
                Canvas.Font.Style := [fsBold];
                Result := Rect(0, 0, MaxWidth, 0);
                DrawText(Canvas.Handle, PChar(AHint), -1, Result,
-                                                DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
+                                                DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
        end else begin
                //Title
                if FTitle <> '' then begin
                        Canvas.Font.Style := [fsBold];
                        ARect := Rect(0, 0, MaxWidth, 0);
                        DrawText(Canvas.Handle, PChar(FTitle), -1, ARect,
-                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
+                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
                        if Result.Right < ARect.Right then
                                Result.Right := ARect.Right;
-                       Result.Bottom := Result.Bottom + ARect.Bottom + TITLE_SPACE;
+                       if FResList.Count > 0 then
+                               Result.Bottom := Result.Bottom + ARect.Bottom + TITLE_SPACE
+                       else
+                               Result.Bottom := Result.Bottom + ARect.Bottom;
                end;
                for i := 0 to FResList.Count - 1 do begin
                        if i <> 0 then
                                Result.Bottom := Result.Bottom + RES_SPACE;
                        ResData := FResList[i];
                        //Header
-                       Canvas.Font.Style := [fsBold];
+                       Canvas.Font.Style := [];
+                       if FHeaderBold then
+                               Canvas.Font.Style := [fsBold];
                        ARect := Rect(0, 0, MaxWidth, 0);
                        DrawText(Canvas.Handle, PChar(ResData.FHeader), -1, ARect,
-                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
+                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
                        if Result.Right < ARect.Right then
                                Result.Right := ARect.Right;
                        Result.Bottom := Result.Bottom + ARect.Bottom;
-                       ResData.FHeaderHeight := ARect.Bottom;
                        //\83X\83y\81[\83X
                        Result.Bottom := Result.Bottom + HEADER_SPACE;
                        //Body
                        Canvas.Font.Style := [];
                        ARect := Rect(0, 0, MaxWidth, 0);
                        DrawText(Canvas.Handle, PChar(ResData.FBody), -1, ARect,
-                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX);
+                                                        DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
                        if Result.Right < (ARect.Right + BODY_INDENT) then
                                Result.Right := ARect.Right + BODY_INDENT;
                        Result.Bottom := Result.Bottom + ARect.Bottom;
-                       ResData.FBodyHeight := ARect.Bottom;
                end;
        end;
        Inc(Result.Right, 6);
@@ -165,18 +173,21 @@ var
 begin
        New(ResData);
        ResData.FHeader := AHeader;
-       ResData.FHeaderHeight := 0;
+//     ResData.FHeaderHeight := 0;
        ResData.FBody := ABody;
-       ResData.FBodyHeight := 0;
+//     ResData.FBodyHeight := 0;
        FResList.Add(ResData);
 end;
 
 procedure TResPopup.ClearAllRes;
 var
        i: Integer;
+    ResData: PResDataRec;
 begin
-       for i := 0 to FResList.Count - 1 do
-               Dispose(FResList[i]);
+       for i := 0 to FResList.Count - 1 do begin
+        ResData := FResList[i];
+               Dispose(ResData);
+    end;
        FResList.Clear;
        FTitle := '';
        Caption := '';