View Issue Details

IDProjectCategoryView StatusLast Update
0005395JEDI VCL00 JVCL Componentspublic2012-02-29 16:53
ReportermasonwheelerAssigned Toobones 
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.45 
Summary0005395: Exposing conversion routines in TJvxSlider
DescriptionSomething I ran into recently.

I had a TjvxSlider with several marks on it, representing a range of percentages. In order to keep track of where 100 and other values are, I used a handful of TLabels. They're easy enough to position correctly in the form designer, but if the form gets resized, I need a way to keep the labels lined up with the marks they correspond to.

I was able to add an OnResize event, but it was difficult calculating the right positions. I figured there had to be a way to calculate the position of a mark, since the control knows where to put them, so I looked and found the GetOffsetByValue method. Unfortunately, it and its reciprocal, GetValueByOffset, aren't public.

Moving them to the public section solved my problems easily. Since this is a simple calculation that doesn't change any internal state, there's no risk involved in exposing these methods.

Submitting my changes as per the MPL.
TagsNo tags attached.


2010-11-09 00:20


jvxSlider.diff (1,114 bytes)
Index: JvxSlider.pas
--- JvxSlider.pas	(revision 124)
+++ JvxSlider.pas	(working copy)
@@ -109,8 +109,6 @@
     procedure InternalDrawPoints(ACanvas: TCanvas; PointsStep, PointsHeight,
       ExtremePointsHeight: Longint);
     procedure DrawThumb(Canvas: TCanvas; Origin: TPoint; Highlight: Boolean);
-    function GetValueByOffset(Offset: Integer): Longint;
-    function GetOffsetByValue(Value: Longint): Integer;
     function GetRulerLength: Integer;
     procedure WMPaint(var Msg: TWMPaint); message WM_PAINT;
     procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
@@ -171,6 +169,8 @@
     destructor Destroy; override;
     procedure DefaultDrawPoints(PointsStep, PointsHeight,
       ExtremePointsHeight: Longint); virtual;
+    function GetValueByOffset(Offset: Integer): Longint;
+    function GetOffsetByValue(Value: Longint): Integer;
     property Canvas;
     property RulerLength: Integer read GetRulerLength;
     property Increment: Longint read FIncrement write SetIncrement default 10;
jvxSlider.diff (1,114 bytes)


2010-11-09 14:29

administrator   ~0018043

Thanks, this is now in SVN

Issue History

Date Modified Username Field Change
2010-11-09 00:20 masonwheeler New Issue
2010-11-09 00:20 masonwheeler File Added: jvxSlider.diff
2010-11-09 14:29 obones Note Added: 0018043
2010-11-09 14:29 obones Status new => resolved
2010-11-09 14:29 obones Fixed in Version => Daily / SVN
2010-11-09 14:29 obones Resolution open => fixed
2010-11-09 14:29 obones Assigned To => obones
2012-02-29 16:53 obones Fixed in Version Daily / SVN => 3.45