Faceți căutări pe acest blog

marți, 17 mai 2016

Resizer class v.2.0

Resizer and Zooming classes Version 2.0

New behaviour
-  stop resizing objects by changing one property (lresize)
- restore the form in it's original state
- do not resize grid's component objects (columns a.s.o) by changing one property (lgrid)

1. MyResize is a custom-based class
Just drop an instance to your form.
The class will bind it's DoResize1() method to the form's Resize event, and the Resize() event of each column of every grid to myresize()

Object members:
- myCol
    Collection
    Public
    Contains fontsize for each object, columns width for every grid, rowheight and headerheight for every grid. Used as a basis to calculte the corresponding new values of the same properties
- myDefa
    Collection
    Public
    Contains fontsize, position and dimension for each object, rowheight and headerheight for every grid. Used to restore the form in its initial state

Properties:
- lgrid
    Logical
    Public
    .T. (default) the grid's columns width, row and header height and fontsize will be also changed (scaled accordingly)
    .F. only the grid's height and width will be changed
- lResize
    Logical
    Public
    .T. when the form changes its dimensions, the objects are scaled
    .F.only the form changes dimensions, objects remains untouched
- lScan    Logical
    Public
    .F. (default) the form's object wasn't yet scanned. They will be processed at the first changing in form's dimensions, and lScan will become .T.
    .T. the form's object's were processed
    When lgrid = .T. and the user manually change the width of some grid's column, then lScan become .F.
- lScanD
    Logical
    Public
    .F. (default) the form's object wasn't yet scanned. They will be processed at the first changing in form's dimensions, and lScanD will become .T.
    .T. the form's object's were processed
    used to store the initial state of the form (dimensions, positions and fontsize of every object)
- nAmount
    Numeric
    Public
    1 (= 100% default) the scale factor for width
- nAmountH
    Numeric
    Public
    1 (= 100% default) the scale factor for height

Methods:
- Init
    Bind the Resize() event of the form to DoResize1() method
- lResize_assign
    Public
    - If lResize, bind the Resize() event of the form to DoResize1() method, otherwise unbinde them
    - If Not lResize and lScan, call DoStopResizing()
- myresize
    Public
    - set lScan = .F.
    - binded to each grid column's Resize() event (when lgrid = .T.)
- DoCollect1    Public
    - If Not lScand and MyDefa collection is empty Collects the current fontsize, position and dimension of form's objects and store them to MyDefa collection
    Call DoCollectD()
    - If lResize = .T. Collects the current fontsize, position and dimension of form's objects and store them to MyCol collection
    Depending on the value of the lGrid property, calls DoCollect(), respectivelly DoCollectG()
    - If lResize = .F. clear the Anchor property of every object
    Call DoStopResizing()
- DoCollect    Public
    Recursive procedure to get and store fontsize, position and dimension of form's objects.
    Called by DoCollect1, when lResize = .T. and lGrid = .T.
    Binds the Resize() event of each column of every grid to MyResize() method
- DoCollectG    Public
    Recursive procedure to get and store fontsize, position and dimension of form's objects (grid's components are not changed).
    Called by DoCollect1, when lResize = .T. and lGrid = .F.
- DoCollectD    Public
    Recursive procedure to get and store fontsize, position and dimension of form's objects.
    Called by DoCollect1, when lResize = .T. and lGrid = .T.
- DoResize1    Public
    - If lResize = .T. calculate the new values for fontsize, position and dimension of the form, based upon the values from MyCol collection
    Depending on the value of the lGrid property, calls DoResize(), respectivelly DoResizeG()
    - If lResize = .F. clear the Anchor property of every object
    Call DoStopResizing() and unbind the Resize() event of the form to DoResize1() method
- DoResize    Public
    Recursive procedure to calculate the new values for fontsize, position and dimension of form's objects, based upon the values from MyCol collection
    Called by DoResize1, when lResize = .T. and lGrid = .T.
- DoResizeG    Public
    Recursive procedure to calculate the new values for fontsize, position and dimension of form's objects, based upon the values from MyCol collection (grid's components are not changed)
    Called by DoResize1, when lResize = .T. and lGrid = .T.
- DoResize2    Public
    - If lResize = .T. calculate the new values for fontsize, position and dimension of the form, based upon the values from MyCol collection
    Depending on the value of the lGrid property, calls DoResize(), respectivelly DoResizeG()
    - If lResize = .F. clear the Anchor property of every object
    Call DoStopResizing() and unbind the Resize() event of the form to DoResize1() method
    * Unlike DoResize1, the width and height are resized proportionalli (the same factor of scalling for noth dimensions)
    Called from myMagnifier object
- DoResize3    Public
    - restore form's objects using values from the myDefa collection
    Call DoResized()
- DoResizeD    Public
    Recursive procedure to restore form's objects using values from the myDefa collection
    Called from DoResize3()
- DoStopResizing    Public
    Recursive method used to clear the Anchor property of form's objects
    Called from DoColect1, DoResize1,DoResize2 and lResize_assign

2. MyMagnifier is a ComboBox-based classDrop an instance on your form and add in the form's init() event a line like:
This.MyMagnifier1.oMyResize = This.MyResize1

Properties:- oMyResize    Pointer
    Public
    Pointer to the form's Myresize object
Methods
- InterActiveChange    Call DoResize2() method from the MyResize object, based on the value selected from the list
- Valid    Call DoResize2() method from the MyResize object, based on the value typed

See
Resizer 2.0

The archive contains:
- res.prg        the two classes (prg style)
- demo.prg        demo prg (for prg style)

- res.vcx        the two classes (class lybrary)
- res.scx        demo form
- res.prg        demo project

Related posts 
http://praisachion.blogspot.com/2016/05/resizer-class-v20.html
http://praisachion.blogspot.com/2016/05/how-to-create-resizer-class-and-zooming.html

Niciun comentariu:

Trimiteți un comentariu