From: Peter T. <pe...@us...> - 2004-05-11 07:14:21
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15785/run Modified Files: JvNavigationPane.pas Log Message: - Alignment and WordWrap added to TJvNavPanelHeader Index: JvNavigationPane.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvNavigationPane.pas,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** JvNavigationPane.pas 10 May 2004 13:46:58 -0000 1.28 --- JvNavigationPane.pas 11 May 2004 07:14:04 -0000 1.29 *************** *** 76,81 **** function WidgetFlags: Integer; override; {$ENDIF VisualCLX} - property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify; - property WordWrap: boolean read FWordWrap write SetWordWrap default False; public constructor Create(AOwner: TComponent); override; --- 76,79 ---- *************** *** 83,86 **** --- 81,85 ---- published property Align; + property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify; property Anchors; property Caption; *************** *** 101,104 **** --- 100,104 ---- property ShowHint; property Visible; + property WordWrap: boolean read FWordWrap write SetWordWrap default False; property ColorFrom: TColor read FColorFrom write SetColorFrom default $D68652; *************** *** 2778,2784 **** procedure TJvNavPanelHeader.Paint; var ! R: TRect; ! X, Y: Integer; function IsValidImage: boolean; begin --- 2778,2788 ---- procedure TJvNavPanelHeader.Paint; + const + cAlignment:array[TAlignment] of Cardinal = (DT_LEFT, DT_RIGHT, DT_CENTER); + cWordWrap:array[boolean] of Cardinal = (DT_SINGLELINE, DT_WORDBREAK); + var ! R, TempRect: TRect; ! X, Y, H: Integer; function IsValidImage: boolean; begin *************** *** 2788,2791 **** --- 2792,2796 ---- R := ClientRect; GradientFillRect(Canvas, R, ColorFrom, ColorTo, fdTopToBottom, 32); + H := Canvas.TextHeight(Caption); if Caption <> '' then begin *************** *** 2793,2803 **** InflateRect(R, -4, 0); SetBkMode(Canvas.Handle, TRANSPARENT); {$IFDEF VCL} DrawText(Canvas.Handle, PChar(Caption), Length(Caption), R, ! DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); {$ENDIF VCL} {$IFDEF VisualCLX} DrawText(Canvas, Caption, Length(Caption), R, ! DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); {$ENDIF VisualCLX} end; --- 2798,2821 ---- InflateRect(R, -4, 0); SetBkMode(Canvas.Handle, TRANSPARENT); + TempRect := R; + {$IFDEF VCL} + H := DrawText(Canvas.Handle, PChar(Caption), Length(Caption), TempRect, + DT_CALCRECT or cAlignment[Alignment] or cWordWrap[WordWrap] or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); + {$ENDIF VCL} + {$IFDEF VisualCLX} + DrawText(Canvas, Caption, Length(Caption), TempRect, + DT_CALCRECT or cAlignment[Alignment] or cWordWrap[WordWrap] or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); + {$ENDIF VisualCLX} + if WordWrap then + OffsetRect(R, 0, (Height - H) div 2); + if IsValidImage and (Alignment = taCenter) then + OffsetRect(R, 0, -Images.Height div 2); {$IFDEF VCL} DrawText(Canvas.Handle, PChar(Caption), Length(Caption), R, ! cAlignment[Alignment] or cWordWrap[WordWrap] or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); {$ENDIF VCL} {$IFDEF VisualCLX} DrawText(Canvas, Caption, Length(Caption), R, ! cAlignment[Alignment] or cWordWrap[WordWrap] or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS); {$ENDIF VisualCLX} end; *************** *** 2805,2809 **** begin Y := (Height - Images.Height) div 2; ! X := R.Right - Images.Width; TCustomImageListEx(Images).Draw(Canvas, X, Y, ImageIndex, {$IFDEF VisualCLX}itImage, {$ENDIF}True); --- 2823,2845 ---- begin Y := (Height - Images.Height) div 2; ! case Alignment of ! taLeftJustify: ! X := R.Right - Images.Width; ! taRightJustify: ! X := R.Left + 4; ! else // taCenter ! begin ! if Caption <> '' then ! begin ! if WordWrap then ! Y := R.Top + H + 4 ! else ! Y := (Height + Canvas.TextHeight('Wq')) div 2 + 4; ! end; ! X := (Width - Images.Width) div 2; ! end; ! end; ! if Y > Height - Images.Height - 4 then ! Y := Height - Images.Height - 4; TCustomImageListEx(Images).Draw(Canvas, X, Y, ImageIndex, {$IFDEF VisualCLX}itImage, {$ENDIF}True); |