Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006600 [JEDI VCL] 00 JVCL Components feature N/A 2017-10-21 15:57 2018-07-18 15:59
Reporter tetardd View Status public  
Assigned To
Priority normal Resolution open Platform
Status acknowledged   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 3.48
  Target Version Product Build
Summary 0006600: Changed to TJvArrowButton to make it easy to ownerdraw
Description I have made some changes to the JvArrowButton unit (quite trivial ones) to allow a descendant of TJvArrowButton to be owner drawn (caption and glyph).

The changes are all marked with my name "David Tetard" and some explanation why I made these changes are included in the uploaded file.

Steps To Reproduce
Additional Information
Tags No tags attached.
Attached Files ? file icon JvArrayButton.pas [^] (19,650 bytes) 2017-10-21 15:57

- Relationships
related to 0006601acknowledged TJvArrowButton - Glyph and caption not properly drawn when using Margin 

-  Notes
tetardd (reporter)
2017-10-21 16:01

I forgot to add, now to owner draw, simply create a descendant of TGlyphButton and override the DrawText and/or DrawGlyph methods (now made protected and virtual) and override the new procedure CreateGlyphButton to use:

FGlyphButton := TMyGlyphButton.Create(Self).

Here is an example:

unit Unit4;


  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Buttons, JvExControls, JvArrowButton;

  TDTButtonGlyph = Class(TButtonGlyph)
       procedure DrawButtonText(Canvas: TCanvas; const Caption: string;
      TextBounds: TRect; State: TButtonState; Alignment: TAlignment;
      VerticalAlignment: TVerticalAlignment); Override;

  TDTArrowButton = Class(TJvArrowButton)
       Procedure CreateButtonGlyph; Override;

  TForm4 = class(TForm)
    procedure FormCreate(Sender: TObject);
    id_DTArrowButton : TDTArrowButton;
    { Public declarations }

  Form4: TForm4;


Uses JvJCLUtils;

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
     id_DTArrowButton := TDTArrowButton.Create(Self);
     id_DTArrowButton.Parent := Self;
     id_DTArrowButton.SetBounds(10, 10, 300, 50);

     id_DTArrowButton.Caption := Blah Blah Blah;

{ TDTArrowButton }

procedure TDTArrowButton.CreateButtonGlyph;
     FGlyph := TDTButtonGlyph.Create(Self);

{ TDTButtonGlyph }

procedure TDTButtonGlyph.DrawButtonText(Canvas: TCanvas; const Caption: string; TextBounds: TRect;
  State: TButtonState; Alignment: TAlignment; VerticalAlignment: TVerticalAlignment);
  AlignFlags: array[TAlignment] of Integer = (DT_LEFT, DT_RIGHT, DT_CENTER);
  VerticalAlignFlags: array[TVerticalAlignment] of Integer = (DT_TOP, DT_BOTTOM, DT_VCENTER);
  S: string;
  S := Caption;
  with Canvas do
    Brush.Style := bsClear;
    // Just to test that it works, all captions will be drawn in blue:
    Font.Color := clBlue;

    if State = bsDisabled then
      OffsetRect(TextBounds, 1, 1);

      DrawText(Canvas, S, -1, TextBounds, AlignFlags[Alignment] or VerticalAlignFlags[VerticalAlignment] or DT_SINGLELINE);
      OffsetRect(TextBounds, -1, -1);
      Font.Color := clBtnShadow;
      DrawText(Canvas, S, -1, TextBounds, AlignFlags[Alignment] or VerticalAlignFlags[VerticalAlignment] or DT_SINGLELINE);
      DrawText(Canvas, S, -1, TextBounds, AlignFlags[Alignment] or VerticalAlignFlags[VerticalAlignment] or DT_SINGLELINE);

- Issue History
Date Modified Username Field Change
2017-10-21 15:57 tetardd New Issue
2017-10-21 15:57 tetardd File Added: JvArrayButton.pas
2017-10-21 16:01 tetardd Note Added: 0021437
2018-07-18 15:59 obones Relationship added related to 0006601
2018-07-18 15:59 obones Status new => acknowledged

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker