;;step to target number
(defun sttn (tar cur ch / out)
(setq out ((if (minusp (- cur tar)) + -) cur ch))
(cond ((= cur tar) tar);; if current is equal to target, return target.
((minusp out) tar);; current value is larger than target, and change ends up negative (return target)
((> out tar)(if (> cur tar) out tar));if out is larger than target and current is also larger, number should be safely shrinking (return out), otherwise it has gone past into negative value therefore (return target)
(T out); any other condition (most likely growing or same) return out
)
);d
;; move objects func.
;; use: (odcl:slideobjects (list (object left top width height)) movespeed_as_int move_in_sync_or_in_order(as boolean) functiontoapplytoobjectoneachstep)
;; example2: (odcl:slideobjects (list (list MControl_Main_buttonrefreshjob 16 136 62 24) (list MControl_Main_Buttonrefreshdatagrid 935 136 88 24)) 5 T (lambda (x) (dcl_Control_SetCaption x (apply 'strcat (mapcar '(lambda (xx) (strcat (itoa xx) ", ")) (dcl_Control_Getpos x))))))
(defun odcl:slideobjects (objdlist smoothspeed sync objfunc / cform x1)
(setq cform (eval (read (strcat (vl-princ-to-string (car (setq cform (dcl_GetFocus)))) "_" (cadr cform)))));cant think of a better way to get the form of the object, so insead i get the focused form, therefore form must have focus for this to work.
;(setq cform (strcat (setq x1 (substr (setq cform (car (car objdlist))) 1 (1- (vl-string-search "_" cform)))) (substr (vl-string-subst "" x1 cform) 1 (1- (vl-string-search "_" cform)))))
(cond (sync (while (not (vl-every '(lambda (a) (equal (dcl_Control_GetPos (car a)) (cdr a))) objdlist))
(mapcar '(lambda (b) (apply 'dcl_Control_SetPos b) (if objfunc (objfunc (car b))) (dcl_Control_Redraw (car b)))
(mapcar '(lambda (c / nl pos) (mapcar '(lambda (d) (if (numberp d) (sttn d (nth (setq nl (if nl (1+ nl) 0)) pos) smoothspeed) (setq pos (dcl_Control_GetPos d) d d))) c))
objdlist
)
)
(dcl_Control_Redraw cform);;**** redraw entire form (little slower but looks much better)
);w
);cond sync
(T (foreach o objdlist ;;any other cond than sync being true (move objects 1 at a time)
(while (not (equal (dcl_Control_GetPos (car o))(cdr o)))
(apply 'dcl_Control_SetPos
(mapcar (function (lambda (a) (if (numberp a) (sttn a (nth (setq nl (if nl (1+ nl) 0)) pos) smoothspeed) (setq pos (dcl_Control_GetPos a) a a))))
o
)
);apply
(if objfunc (objfunc (car o)))
(dcl_Control_Redraw cform)
(setq nl nil pos nil)
);w
);fe
);cond sync nil
);cond
(mapcar '(lambda (x) (cons (car x) (dcl_Control_GetPos (car x)))) objdlist);return all items with new current data.
);d
;extra's (stack objects together)
(defun odcl:stackobjects (objlist startpoint rowheight columnwidth maxrows padding smoothspeed sync func / rowcount columncount)
(setq rowcount 0
columncount 0
objlist
(mapcar '(lambda (x / xx)
(setq xx (list x (+ (car startpoint) (+ (* columnwidth columncount) (* columncount padding))) (+ (cadr startpoint) (+ (* rowheight rowcount) (* rowcount padding))) columnwidth rowheight));; create object position list
(if (>= (1+ rowcount) maxrows)(setq rowcount 0 columncount (1+ columncount))(setq rowcount (1+ rowcount))) ;;set new points
xx ;return xx
)
objlist
);mapcar
)
(odcl:slideobjects objlist smoothspeed sync func)
)
;(lambda (x) (dcl_Control_SetCaption x (apply 'strcat (mapcar '(lambda (xx) (strcat (itoa xx) ", ")) (dcl_Control_Getpos x)))))
;;extra (swap object postion and size properties)
;;swap object positions Left,Top,Width & Height
(defun odcl:swapobjects (obj1 obj2 smoothspeed) (odcl:slideobjects (list (cons obj1 (dcl_Control_GetPos obj2)) (cons obj2 (dcl_Control_GetPos obj1))) smoothspeed T nil));d