{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% osCommerce Product Manager for Windows (oscpmwin). Copyright ©2003,2004,2005 by Mario A. Valdez-Ramirez. You can contact Mario A. Valdez-Ramirez by email at mario@mariovaldez.org or paper mail at Olmos 809, San Nicolas, NL. 66495, Mexico. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} unit balloons; interface USES Windows, Forms, Controls, Classes; CONST mvHint_XMargin = 16; mvHint_YMargin = 16; mvHint_YInterMargin = 3; mvHint_MaxWidth = 300; mvHint_IconX = 20; mvHint_IconText = '?'; mvHint_Delay = 30000; mvHint_IniDelay = 500; mvHint_Separator = '|'; mvHint_MaxChars = 800; TYPE mvHint_Window = CLASS (THintWindow) CONSTRUCTOR Create (AOwner: TComponent); OVERRIDE; PRIVATE FActivating: BOOLEAN; PUBLIC TitleHeight : LONGINT; BodyHeight : LONGINT; HintTitle : STRING; HintBody : STRING; PROCEDURE ActivateHint (Rect: TRect; CONST AHint: STRING); OVERRIDE; PROTECTED PROCEDURE Paint; OVERRIDE; PUBLISHED PROPERTY Caption; END; PROCEDURE PRmvHint_EnableHints (UseHints : BOOLEAN); IMPLEMENTATION USES Graphics, SysUtils, gnugettext; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} CONSTRUCTOR mvHint_Window.Create (AOwner: TComponent); BEGIN TitleHeight := 0; BodyHeight := 0; INHERITED Create(AOwner); END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE mvHint_Window.Paint; VAR WArea, WLIcon, WTextArea : TRect; OldFontHeight : LONGINT; BEGIN WArea := ClientRect; WLIcon := WArea; WLIcon.Right := WLIcon.Left + mvHint_IconX; Canvas.Brush.Style := bsSolid; Canvas.Brush.Color := clInfoBk; Canvas.Pen.Color := clInfoText; Canvas.Rectangle (WArea); Canvas.Brush.Style := bsSolid; Canvas.Brush.Color := clActiveCaption; Canvas.Pen.Color := clBlack; Canvas.Rectangle (WLIcon); OldFontHeight := Canvas.Font.Height; Canvas.Font.Style := [fsBold]; Canvas.Font.Color := clCaptionText; Canvas.Font.Height := (mvHint_IconX); Canvas.TextOut (WLIcon.Right - ((WLIcon.Right - WLIcon.Left) DIV 2) - (Canvas.TextWidth (mvHint_IconText) DIV 2), 2, mvHint_IconText); WTextArea := WArea; IF (TitleHeight > 0) THEN BEGIN WTextArea.Top := WTextArea.Top + (mvHint_YMargin DIV 2) + mvHint_YInterMargin + TitleHeight; WTextArea.Bottom := WTextArea.Top + mvHint_YMargin + mvHint_YInterMargin + TitleHeight + BodyHeight; END ELSE BEGIN WTextArea.Top := WTextArea.Top + (mvHint_YMargin DIV 2); WTextArea.Bottom := WTextArea.Top + mvHint_YMargin + BodyHeight; END; WTextArea.Left := WTextArea.Left + (mvHint_XMargin DIV 2) + mvHint_IconX - 1; WTextArea.Right := WTextArea.Right - (mvHint_XMargin DIV 2) + 1; Color := clInfoBk; Canvas.Font.Style := []; Canvas.Font.Color := clInfoText; Canvas.Font.Height := OldFontHeight; Canvas.Brush.Color := clInfoBk; Canvas.Brush.Style := bsSolid; DrawText (Canvas.Handle, PCHAR (HintBody), -1, WTextArea, DT_WORDBREAK OR DT_LEFT); IF (TitleHeight > 0) THEN BEGIN WTextArea := WArea; WTextArea.Top := WTextArea.Top + (mvHint_YMargin DIV 2); WTextArea.Left := WTextArea.Left + (mvHint_XMargin DIV 2) + mvHint_IconX - 1; WTextArea.Bottom := WTextArea.Top + (mvHint_YMargin DIV 3) + mvHint_YInterMargin + TitleHeight; WTextArea.Right := WTextArea.Right - (mvHint_XMargin DIV 2) + 1; Color := clInfoBk; Canvas.Font.Style := [fsBold]; Canvas.Font.Color := clInfoText; Canvas.Font.Height := OldFontHeight; Canvas.Brush.Color := clInfoBk; Canvas.Brush.Style := bsSolid; DrawText (Canvas.Handle, PCHAR (HintTitle), -1, WTextArea, DT_WORDBREAK OR DT_LEFT); END; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE mvHint_Window.ActivateHint (Rect: TRect; CONST AHint: STRING); VAR WBodyY, WTitleY, WBodyX, WTitleX : LONGINT; TitleMsg, BodyMsg : STRING; BEGIN FActivating := TRUE; TRY TitleMsg := ''; IF ((GetLongHint (Application.Hint) <> '') AND (GetLongHint (Application.Hint) <> AHint)) THEN BodyMsg := ANSISTRING (_(AHint + '|' + GetLongHint (Application.Hint))) ELSE BodyMsg := ANSISTRING (_(AHint)); IF (ANSIPOS (mvHint_Separator, BodyMsg) > 0) THEN BEGIN TitleMsg := TRIM (COPY (BodyMsg, 1, (ANSIPOS (mvHint_Separator, BodyMsg) - 1))); BodyMsg := TRIM (COPY (BodyMsg, (ANSIPOS (mvHint_Separator, BodyMsg) + 1), mvHint_MaxChars)); END ELSE BodyMsg := TRIM (COPY (BodyMsg, 1, mvHint_MaxChars)); IF (TitleMsg = BodyMsg) THEN TitleMsg := ''; Caption := BodyMsg; HintTitle := TitleMsg; HintBody := BodyMsg; IF (TitleMsg <> '') THEN BEGIN Rect.Right := Rect.Left + mvHint_MaxWidth; WTitleY := DrawText (Canvas.Handle, PCHAR (TitleMsg), -1, Rect, DT_CALCRECT OR DT_WORDBREAK OR DT_LEFT); WTitleX := Rect.Right - Rect.Left; TitleHeight := WTitleY; END ELSE BEGIN WTitleY := 0; WTitleX := 0; TitleHeight := 0; END; Rect.Right := Rect.Left + mvHint_MaxWidth; WBodyY := DrawText (Canvas.Handle, PCHAR (BodyMsg), -1, Rect, DT_CALCRECT OR DT_WORDBREAK OR DT_LEFT); WBodyX := Rect.Right - Rect.Left; BodyHeight := WBodyY; IF (WTitleX > WBodyX) THEN Rect.Right := Rect.Left + WTitleX + mvHint_XMargin + mvHint_IconX ELSE Rect.Right := Rect.Left + WBodyX + mvHint_XMargin + mvHint_IconX; IF (TitleHeight > 0) THEN Rect.Bottom := Rect.Top + mvHint_YMargin + mvHint_YInterMargin + WTitleY + WBodyY ELSE Rect.Bottom := Rect.Top + mvHint_YMargin + WBodyY; UpdateBoundsRect (Rect); IF (Rect.Right > Screen.DesktopWidth) THEN Rect.Left := Screen.DesktopWidth - Width; IF (Rect.Bottom > Screen.DesktopHeight) THEN Rect.Top := Screen.DesktopHeight - Height; SetWindowPos (Handle, HWND_TOPMOST, Rect.Left, Rect.Top, Width, Height, SWP_SHOWWINDOW OR SWP_NOACTIVATE); Invalidate; FINALLY FActivating := FALSE; END; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE PRmvHint_EnableHints (UseHints : BOOLEAN); BEGIN Application.ShowHint := NOT (UseHints); Application.ShowHint := UseHints; Application.HintPause := mvHint_IniDelay; Application.HintShortPause := mvHint_IniDelay DIV 2; Application.HintHidePause := mvHint_Delay; END; INITIALIZATION HintWindowClass := mvHint_Window; PRmvHint_EnableHints (FALSE); end.