From a520e2eff70261e3d28ffd7aa7f5d23252f60c32 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Tue, 19 Sep 2017 05:43:18 +0000 Subject: [PATCH] RxFPC: new component - TRxRangeSelector git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6019 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../trunk/demos/RxDBVerticalGrid/project1.lps | 17 +- .../rx/trunk/images/TRxRangeSelector.png | Bin 0 -> 328 bytes .../images/componet_img/all_component_res.sh | 4 +- .../rx/trunk/images/componet_img/rx_lcl.res | Bin 572 -> 3180 bytes .../images/componet_img/rx_range_h_back.png | Bin 0 -> 300 bytes .../images/componet_img/rx_range_h_sel.png | Bin 0 -> 370 bytes .../images/componet_img/rx_slader_bottom.png | Bin 0 -> 848 bytes .../images/componet_img/rx_slader_top.png | Bin 0 -> 848 bytes components/rx/trunk/images/mk_res.sh | 2 +- components/rx/trunk/images/rx.res | Bin 37331 -> 37724 bytes components/rx/trunk/registerrx.pas | 8 +- components/rx/trunk/rx.inc | 2 + components/rx/trunk/rx.res | Bin 37331 -> 37724 bytes components/rx/trunk/rxcontrols/rx_lcl.res | Bin 572 -> 3180 bytes components/rx/trunk/rxcontrols/rxrangesel.pas | 608 ++++++++++++++++++ components/rx/trunk/rxcontrols/rxspin.pas | 2 - components/rx/trunk/rxdb/rxdbgrid.pas | 157 ++++- components/rx/trunk/rxnew.lpk | 6 +- components/rx/trunk/rxnew.pas | 2 +- 19 files changed, 773 insertions(+), 35 deletions(-) create mode 100644 components/rx/trunk/images/TRxRangeSelector.png create mode 100644 components/rx/trunk/images/componet_img/rx_range_h_back.png create mode 100644 components/rx/trunk/images/componet_img/rx_range_h_sel.png create mode 100644 components/rx/trunk/images/componet_img/rx_slader_bottom.png create mode 100644 components/rx/trunk/images/componet_img/rx_slader_top.png create mode 100644 components/rx/trunk/rxcontrols/rxrangesel.pas diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps index a089f2043..3b71c0128 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps +++ b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps @@ -3,7 +3,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -542,6 +542,17 @@ + + + + + + + + + + + diff --git a/components/rx/trunk/images/TRxRangeSelector.png b/components/rx/trunk/images/TRxRangeSelector.png new file mode 100644 index 0000000000000000000000000000000000000000..76097789b7efcbeb9ed71ea6934c6a329988901c GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5M?jcysy3fAP*AeO zHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IXprWguE{-7{oyjQt8D>kkI;{Ti?f-usp8x-i4gOr$+S6+qAHcHC z=GVvh*3WL$znhW$f4$8w$BnE&BY1dbo9DY3zToZWWd?%g6VsJNB;UP$efk8`V-GK{ zL#is0@0=v|Op=(@!FqnaeR@KIMA^wHG6g?38y$Xn{*=YjhlLE>#z75>_GvqxYpDhq z$fJI{MB-ii9p5(Lj|{V(&1_le|Df$~!J#Ya64NHc1`9_2=KU99lErwGf#FD-w@jiI S`)Z&E89ZJ6T-G@yGywoL=X@;y literal 0 HcmV?d00001 diff --git a/components/rx/trunk/images/componet_img/all_component_res.sh b/components/rx/trunk/images/componet_img/all_component_res.sh index 46be41aed..355c58ef6 100644 --- a/components/rx/trunk/images/componet_img/all_component_res.sh +++ b/components/rx/trunk/images/componet_img/all_component_res.sh @@ -5,7 +5,9 @@ rm rxdbgrid.res rm pickdate.rex /usr/local/share/lazarus/tools/lazres rxdbgrid.res rx_markerdown.png rx_markerup.png rx_DropDown.png rx_Ellipsis.png rx_Glyph.png rx_minus.png rx_plus.png rx_UpDown.png rx_menu_grid.png -/usr/local/share/lazarus/tools/lazres rx_lcl.res picDateEdit.png rxbtn_downarrow.png + +/usr/local/share/lazarus/tools/lazres rx_lcl.res picDateEdit.png rxbtn_downarrow.png rx_range_h_back.png rx_range_h_sel.png rx_slader_bottom.png rx_slader_top.png + /usr/local/share/lazarus/tools/lazres pickdate.res rx_next1.png rx_next2.png rx_prev1.png rx_prev2.png #../../../../tools\lazres.exe tooledit.lrs picDateEdit.bmp diff --git a/components/rx/trunk/images/componet_img/rx_lcl.res b/components/rx/trunk/images/componet_img/rx_lcl.res index 7034a20a6a68bd37c21481c845750cd2270bb45d..80abad26d65b15c544c6306a0028df211fdd6881 100644 GIT binary patch literal 3180 zcmchZ2~<;88pm${H3V6T9TowBQIy>*pc0@38b~5rfQ(CZnjqi;0x>KBVFZCHw15sR zwMEgYwMP$XEgY?2S%RR60!kdb28r}7>cJO?ddslll$&+zW=-Tec$)H z?;(Vc1yqGXS)se25OD}O!HhydKrF;W?;#rUL~P^@KN^hLbJlu#^RgUP09~7~k^nQ> zOa?6&T2rXYHPqpnIacEajXukd?X5ttD$35zRwxvA?%aXyW}~uNn8NMyrPI{kTJ9%> zK_rvr$;Nm3=htf2Sm3?W1~uwOW4Jhn7?$Bhrkr!Z;>00cY29kX(^&IQLaxg|Wz$~? z!)Za8>#oH+<`;fN9lw7*#pc5B-_JyEE-2mJL?|(7WMnni$4=@O^nceh<06%v{$6U^ zXdhgvd&A7&;8br_KCEgL@4YQPJTyLn8pe-+29b#*iUZNbfxL-La-llIpJGRJq7sQa zdXMc|Ac&3)-?uw?PO!m&P!K)dS2%}9kl<`c}v!Dt)u z0C|HtS7@hW0+Xv|z5GQOw?^IQ>}cA4elEi_d`a%0?SU`S%@BH`udeosVeAsHRPEay za^u(g=D;pJVZU_94Gv;J^@8zx$QKhqS!CZ>c4*--!!vq&b)eDMJ&2RTIxg_ z9tGy8cLu&+y#`EwD?c`3`9XsGfLN2LWXKN+)q4;W^cc;=uGh>j=l>Hd-=de_mkCBs8vu~_orm-bJRWfHMSBx+9DDwBvL63IYA`RM4VsQV|G zOeU2|TX??X;*sXP9upH2t+9-WvC*-yvGxSkgiJC%KK>wO>x5)PE|-rFJei!F6t~t+ zPfz!L93|^$nH(9K8kNpWP4yh!2^m>(qBj~mLW~a%2tjH#zP1EL`OJ5EL1K|ks9es$ zdC6pERgO~kX`PK0cZ1gW&zTb55h4%F=6z+{%?$^7>T;0YM32xUOm+tXz z-#1{t>>WXQWW@`s#?_pg-R5nbFD7sH5|Z&h1eXW@qq?M!f5{qoUFmsT(b#}rb2gq#{-nJIcj|}8GS~MVj&|?9 z&f``5yEx{XUQvQ;^obQQp~O!w^?C3z<+7SLC%dXhwrSR3}%{ry$k=M>GJXOVX= zfA+z|hL2jTP0VMyiW`P+9MZ^05qj*K=AyIWpbnccBOOb9_u>TU`7?p-_+66vXPaX- z@+;T$lPn5be>Tr@6Fu5Vcz4oEGIl6!^M`I1OSfIx61B_NuhNovcPfp;LiRQ(9z(|P sP>XX&-k{_#?09MM0>M0o&JHA^1DT9{^O8tZB1tJ2_lk%D!5`!Bzt_-(iU0rr delta 7 OcmaDOv4>@Y4HEzjQ3A67 diff --git a/components/rx/trunk/images/componet_img/rx_range_h_back.png b/components/rx/trunk/images/componet_img/rx_range_h_back.png new file mode 100644 index 0000000000000000000000000000000000000000..37e8bbf48a154d177d6c575b04492c7ddc4e55d6 GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y|0VEja3uN#CDVB6cUq=Rpjs4tz5?O(Kg=CK) zUj~LMH3o);76yi2K%s^g3=E|P3=FRl7#OT(FffQ0%-I!a1C(G&@^*J&_}|`tWO>_47BMw2s1iq%&q_mvX^-Jy0Smy6yh{w(05pTA1Ea6>Eal|aXop>pYtac9XxX2 z(5V9l4)rh_8yRk>`Ej0u!M~IFx_{Ju6`)ep64!{5l*E!$tK_0oAjM#0U}&yuV5w_p z5n^a+Wo&3=WUOsqY-M1uNY54IO@xNr{FKbJN@NWNmR2T~K&223bDzIm1JuCa>FVdQ I&MBb@04L8<00000 literal 0 HcmV?d00001 diff --git a/components/rx/trunk/images/componet_img/rx_range_h_sel.png b/components/rx/trunk/images/componet_img/rx_range_h_sel.png new file mode 100644 index 0000000000000000000000000000000000000000..d89060d052ef3e18f54d555405c810155ec6a8e6 GIT binary patch literal 370 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y|0wO&^wH^W~mUKs7M+SzC{oH>NS%G|oWRD45bDP46hOx7_4S6Fo+k-*%fF5lrRYJ32~ig#XsMQf1$O& zm0;P+!LrvPRd2-W+)OdKon>>kz~z3K_k)_?M@`YED#A}!M*RQ(|Kwps37}raByV>Y zeu-TSH-Q|^0*}aIpd+t?Fr$;k>aPTI0cqeG+C%ni=m|@wNc$KN`uC&BCnS>qR85r80aEte9EGq))QY~?fC`m~y zNwrEYN(E93Mh1rFx(1fIh87`)rdGy=Rz}9!2F6wf28;AuL4k$Pkei>9nO2FS!NAJc Z$jaCpqCvLrqBc+igQu&X%Q~loCIGkpY6t)T literal 0 HcmV?d00001 diff --git a/components/rx/trunk/images/componet_img/rx_slader_bottom.png b/components/rx/trunk/images/componet_img/rx_slader_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..587ca63b4281030d9096d3ae9dcc25edb10048ea GIT binary patch literal 848 zcmeAS@N?(olHy`uVBq!ia0vp^d_XM3!3-p0n&d$gOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>xZ!hdPR2p_~LFfAdhxgS!=Xwgy_ZGd)^?cP9f4VvKbW7@+w&?#1 z3?C}oF7y^&>@9p-?e=h4-@7W0t5YlAmAYSONqtxD{;ACEQ@PvwGWR>(*>B6;pRJtm zso3}J#<~ChGkmP@_^@`;^F{5CClx>JN`G7C2{a0*_+z=pfgI1LXAkYq@i^6-^6|~9 z4<9~!eEss`CszP!JC?epi)pFVv$Rp9;Y!@H9i z4nKbUIG6A7WFL*4}$C%XeMidd?pVPaf;(?s~EN3eZ!kC9V-A zDTyViR>?)FK#IZ0z|dURz*5)HBE-9gP2NC6cw Nc)I$ztaD0e0ss}bj8Omp literal 0 HcmV?d00001 diff --git a/components/rx/trunk/images/componet_img/rx_slader_top.png b/components/rx/trunk/images/componet_img/rx_slader_top.png new file mode 100644 index 0000000000000000000000000000000000000000..bfd1857652a9eae6b6182b68b68aa83e81b1adbe GIT binary patch literal 848 zcmeAS@N?(olHy`uVBq!ia0vp^d_XM3!3-p0n&d$gOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>*peJXc*U*`U?+~Z?~$A`6(o-b;DJgN9$SNf-7-?tm*zAbluwsOLq?(B~hKsD|_ z#h=RD-j%z*D|NrnlKQU7zPA^494ZaFx1jTXL&N7Xm$#Lk_ZnmFcV~aTdg|x9SHHe| z`t$48hjRyi|Ni~+=g)7?AN~08<4Se-kB{%ZfB$~5G~mbQkKew1JD2bA(}h?Qa4Ns>N$6+O@Xs*ev~(9x`RcqIw+lxm4M!Svs?A=W@P_gZ}ZD>BP-Ado_e0y=J{@hFL?WTnSr4B#B^m5 z$#<_`pFY9#*u%@~kgAI0J12=flO$$!u%4f9pPrB)QFd~QOu^61Mu(rCKV|XsVIc#z zaZtmeecI0FTB?C2^6;qNE|GW_f5*2?_#?xtXER$?`aftpTyW@$y2P{zvB84Tzj^M!Svs?A=W@P_gZ}ZD>BP-Ado_e0y=J{@hFL?WTnSr4B#B^m5 z$#<_`pFY9#*u%@~kgAI0J12=flO$$!u%4f9pPrB)QFd~QOu^61Mu(rCKV|XsVIc#z zaZtmeecI0FTB?C2^6;qNE|GW_f5*2?_#?xtXER$?`aftpTyW@$y2P{zvB84Tzj^*pc0@38b~5rfQ(CZnjqi;0x>KBVFZCHw15sR zwMEgYwMP$XEgY?2S%RR60!kdb28r}7>cJO?ddslll$&+zW=-Tec$)H z?;(Vc1yqGXS)se25OD}O!HhydKrF;W?;#rUL~P^@KN^hLbJlu#^RgUP09~7~k^nQ> zOa?6&T2rXYHPqpnIacEajXukd?X5ttD$35zRwxvA?%aXyW}~uNn8NMyrPI{kTJ9%> zK_rvr$;Nm3=htf2Sm3?W1~uwOW4Jhn7?$Bhrkr!Z;>00cY29kX(^&IQLaxg|Wz$~? z!)Za8>#oH+<`;fN9lw7*#pc5B-_JyEE-2mJL?|(7WMnni$4=@O^nceh<06%v{$6U^ zXdhgvd&A7&;8br_KCEgL@4YQPJTyLn8pe-+29b#*iUZNbfxL-La-llIpJGRJq7sQa zdXMc|Ac&3)-?uw?PO!m&P!K)dS2%}9kl<`c}v!Dt)u z0C|HtS7@hW0+Xv|z5GQOw?^IQ>}cA4elEi_d`a%0?SU`S%@BH`udeosVeAsHRPEay za^u(g=D;pJVZU_94Gv;J^@8zx$QKhqS!CZ>c4*--!!vq&b)eDMJ&2RTIxg_ z9tGy8cLu&+y#`EwD?c`3`9XsGfLN2LWXKN+)q4;W^cc;=uGh>j=l>Hd-=de_mkCBs8vu~_orm-bJRWfHMSBx+9DDwBvL63IYA`RM4VsQV|G zOeU2|TX??X;*sXP9upH2t+9-WvC*-yvGxSkgiJC%KK>wO>x5)PE|-rFJei!F6t~t+ zPfz!L93|^$nH(9K8kNpWP4yh!2^m>(qBj~mLW~a%2tjH#zP1EL`OJ5EL1K|ks9es$ zdC6pERgO~kX`PK0cZ1gW&zTb55h4%F=6z+{%?$^7>T;0YM32xUOm+tXz z-#1{t>>WXQWW@`s#?_pg-R5nbFD7sH5|Z&h1eXW@qq?M!f5{qoUFmsT(b#}rb2gq#{-nJIcj|}8GS~MVj&|?9 z&f``5yEx{XUQvQ;^obQQp~O!w^?C3z<+7SLC%dXhwrSR3}%{ry$k=M>GJXOVX= zfA+z|hL2jTP0VMyiW`P+9MZ^05qj*K=AyIWpbnccBOOb9_u>TU`7?p-_+66vXPaX- z@+;T$lPn5be>Tr@6Fu5Vcz4oEGIl6!^M`I1OSfIx61B_NuhNovcPfp;LiRQ(9z(|P sP>XX&-k{_#?09MM0>M0o&JHA^1DT9{^O8tZB1tJ2_lk%D!5`!Bzt_-(iU0rr delta 7 OcmaDOv4>@Y4HEzjQ3A67 diff --git a/components/rx/trunk/rxcontrols/rxrangesel.pas b/components/rx/trunk/rxcontrols/rxrangesel.pas new file mode 100644 index 000000000..961f944ab --- /dev/null +++ b/components/rx/trunk/rxcontrols/rxrangesel.pas @@ -0,0 +1,608 @@ +{ rxapputils unit + + Copyright (C) 2005-2017 Lagunov Aleksey alexs75@yandex.ru and Lazarus team + original conception from rx library for Delphi (c) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} + +unit RxRangeSel; + +{$I rx.inc} + +interface + +uses + Classes, SysUtils, Types, Controls, LMessages, Graphics; + +type + TRxRangeSelectorState = + (rssNormal, rssDisabled, + rssThumbTopHover, rssThumbTopDown, + rssThumbBottomHover, rssThumbBottomDown, + rssBlockHover, rssBlockDown); + + TRxRangeSelectorStyle = (rxrsSimple, rxrsLazarus, rxrsNative); + + { TRxCustomRangeSelector } + + TRxCustomRangeSelector = class(TCustomControl) + private + FBackgroudGlyph: TBitmap; + FMax: Double; + FMin: Double; + FOnChange: TNotifyEvent; + FSelectedEnd: Double; + FSelectedGlyph: TBitmap; + FSelectedStart: Double; + FState: TRxRangeSelectorState; + FStyle: TRxRangeSelectorStyle; + FThumbTopGlyph:TBitmap; + FThumbBottomGlyph:TBitmap; + // + FThumbPosTop : TRect; + FThumbPosBottom : TRect; + FTracerPos : TRect; + FSelectedPos : TRect; + FThumbSize : TSize; + + FDblClicked : Boolean; + FDown : boolean; + FPrevX : integer; + FPrevY : integer; + procedure DoChange; + function GetSelectedLength: Double; + function GetThumbBottomGlyph: TBitmap; + function GetThumbTopGlyph: TBitmap; + function IsThumbBottomGlyphStored: Boolean; + function IsThumbTopGlyphStored: Boolean; + procedure SetBackgroudGlyph(AValue: TBitmap); + procedure SetMax(AValue: Double); + procedure SetMin(AValue: Double); + procedure SetSelectedEnd(AValue: Double); + procedure SetSelectedGlyph(AValue: TBitmap); + procedure SetSelectedStart(AValue: Double); + procedure SetStyle(AValue: TRxRangeSelectorStyle); + procedure SetThumbBottomGlyph(AValue: TBitmap); + procedure SetThumbTopGlyph(AValue: TBitmap); + procedure InitSizes; + procedure UpdateData; + function LogicalToScreen(const LogicalPos: double): double; + function BarWidth: integer; + procedure SetState(AValue: TRxRangeSelectorState); + function DeduceState(const AX, AY: integer; const ADown: boolean): TRxRangeSelectorState; + protected + procedure Paint; override; + class function GetControlClassDefaultSize: TSize; override; + procedure Loaded; override; + + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; + procedure MouseLeave; override ; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + property SelectedGlyph: TBitmap read FSelectedGlyph write SetSelectedGlyph; + property BackgroudGlyph: TBitmap read FBackgroudGlyph write SetBackgroudGlyph; + + procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override; + property Min:Double read FMin write SetMin; + property Max:Double read FMax write SetMax; + property SelectedStart : Double read FSelectedStart write SetSelectedStart; + property SelectedEnd : Double read FSelectedEnd write SetSelectedEnd; + property SelectedLength : Double read GetSelectedLength; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + property Style:TRxRangeSelectorStyle read FStyle write SetStyle; + property ThumbTopGlyph: TBitmap read GetThumbTopGlyph write SetThumbTopGlyph {stored IsThumbTopGlyphStored}; + property ThumbBottomGlyph: TBitmap read GetThumbBottomGlyph write SetThumbBottomGlyph {stored IsThumbBottomGlyphStored}; + property State:TRxRangeSelectorState read FState; + end; + + { TRxRangeSelector } + + TRxRangeSelector = class(TRxCustomRangeSelector) + published + property Anchors; + property Enabled; + property Visible; + property Color ; + + property Min; + property Max; + property SelectedStart; + property SelectedEnd; + property Style; + property OnChange; + property ThumbTopGlyph; + property ThumbBottomGlyph; + property SelectedGlyph; + end; + +implementation +uses rxlclutils, LCLType, LCLIntf, Themes; + +function IsIntInInterval(x, xmin, xmax: integer): boolean; inline; +begin + IsIntInInterval := (xmin <= x) and (x <= xmax); +end; + +function PointInRect(const X, Y: integer; const Rect: TRect): boolean; inline; +begin + PointInRect := IsIntInInterval(X, Rect.Left, Rect.Right) and + IsIntInInterval(Y, Rect.Top, Rect.Bottom); +end; + +function IsRealInInterval(x, xmin, xmax: extended): boolean; inline; +begin + IsRealInInterval := (xmin <= x) and (x <= xmax); +end; + +{ TRxCustomRangeSelector } + +procedure TRxCustomRangeSelector.SetMax(AValue: Double); +begin + if FMax=AValue then Exit; + FMax:=AValue; + + if FSelectedEnd > FMax then + FSelectedEnd:=FMax; + + UpdateData; + Invalidate; + DoChange; +end; + +procedure TRxCustomRangeSelector.DoChange; +begin + if Assigned(FOnChange) then + FOnChange(Self); +end; + +function TRxCustomRangeSelector.GetSelectedLength: Double; +begin + Result:=FSelectedEnd - FSelectedStart; +end; + +function TRxCustomRangeSelector.GetThumbBottomGlyph: TBitmap; +begin + Result:=FThumbBottomGlyph; +end; + +function TRxCustomRangeSelector.GetThumbTopGlyph: TBitmap; +begin + Result:=FThumbTopGlyph; +end; + +function TRxCustomRangeSelector.IsThumbBottomGlyphStored: Boolean; +begin + +end; + +function TRxCustomRangeSelector.IsThumbTopGlyphStored: Boolean; +begin + +end; + +procedure TRxCustomRangeSelector.SetBackgroudGlyph(AValue: TBitmap); +begin + InitSizes; + FBackgroudGlyph.Assign(AValue); +end; + +procedure TRxCustomRangeSelector.SetMin(AValue: Double); +begin + if FMin=AValue then Exit; + FMin:=AValue; + + if FSelectedStart < FMin then + FSelectedStart:=FMin; + + UpdateData; + Invalidate; + DoChange; +end; + +procedure TRxCustomRangeSelector.SetSelectedEnd(AValue: Double); +begin + if FSelectedEnd=AValue then Exit; + FSelectedEnd:=AValue; + + if FSelectedEnd > FMax then + FSelectedEnd:=FMax + else + if FSelectedEnd < FSelectedStart then + FSelectedEnd:=FSelectedStart; + + UpdateData; + Invalidate; + DoChange; +end; + +procedure TRxCustomRangeSelector.SetSelectedGlyph(AValue: TBitmap); +begin + InitSizes; + FSelectedGlyph.Assign(AValue); +end; + +procedure TRxCustomRangeSelector.SetSelectedStart(AValue: Double); +begin + if FSelectedStart=AValue then Exit; + FSelectedStart:=AValue; + + if FSelectedStart < FMin then + FSelectedStart:=FMin + else + if FSelectedStart > FSelectedEnd then + FSelectedStart:=FSelectedEnd; + + UpdateData; + Invalidate; + DoChange; +end; + +procedure TRxCustomRangeSelector.SetStyle(AValue: TRxRangeSelectorStyle); +begin + if FStyle=AValue then Exit; + FStyle:=AValue; + InitSizes; + UpdateData; + Invalidate; +end; + +procedure TRxCustomRangeSelector.SetThumbBottomGlyph(AValue: TBitmap); +begin + FThumbBottomGlyph.Assign(AValue); + InitSizes; + UpdateData; + Invalidate; +end; + +procedure TRxCustomRangeSelector.SetThumbTopGlyph(AValue: TBitmap); +begin + FThumbTopGlyph.Assign(AValue); + InitSizes; + UpdateData; + Invalidate; +end; + +procedure TRxCustomRangeSelector.InitSizes; +var + TD: TThemedElementDetails; +begin + {$IFDEF WINDOWS} + if (FStyle = rxrsNative) and ThemeServices.ThemesEnabled then + begin + TD:=ThemeServices.GetElementDetails(ttbThumbBottomPressed); + FThumbSize:=ThemeServices.GetDetailSize(TD); + end + else + {$ENDIF WINDOWS} + if Assigned(FThumbTopGlyph) and (FThumbTopGlyph.Width > 0) then + begin + FThumbSize.CX:=FThumbTopGlyph.Width; + FThumbSize.CY:=FThumbTopGlyph.Height; + end + else + if Assigned(FThumbBottomGlyph) and (FThumbBottomGlyph.Width > 0) then + begin + FThumbSize.CX:=FThumbBottomGlyph.Width; + FThumbSize.CY:=FThumbBottomGlyph.Height; + end + else + begin + FThumbSize.CX:=6; + FThumbSize.CY:=10; + end; +end; + +procedure TRxCustomRangeSelector.UpdateData; +begin + FTracerPos.Left := FThumbSize.CX div 2; + FTracerPos.Right :=Width - FThumbSize.CX div 2; + FTracerPos.Top:=FThumbTopGlyph.Height + 1; + FTracerPos.Bottom:=FThumbPosBottom.Top - 1; + + FSelectedPos.Left := round(LogicalToScreen(FSelectedStart)) - FThumbSize.CX div 2; + FSelectedPos.Top := FTracerPos.Top; + FSelectedPos.Right := round(LogicalToScreen(FSelectedEnd)) + FThumbSize.CX div 2; + FSelectedPos.Bottom := FTracerPos.Bottom; + + + FThumbPosTop.Top:=0; + FThumbPosTop.Left:=FSelectedPos.Left - FThumbSize.CX div 2; + FThumbPosTop.Bottom:=FThumbTopGlyph.Height; + FThumbPosTop.Right:=FThumbPosTop.Left + FThumbSize.CX; + + FThumbPosBottom.Bottom:=Height; + FThumbPosBottom.Right:=FSelectedPos.Right + FThumbSize.CX div 2; + FThumbPosBottom.Top:=Height - FThumbBottomGlyph.Height; + FThumbPosBottom.Left:=FThumbPosBottom.Right - FThumbSize.CX; +end; + +function TRxCustomRangeSelector.LogicalToScreen(const LogicalPos: double + ): double; +begin + result := FThumbSize.CX + BarWidth * (LogicalPos - FMin) / (FMax - FMin) +end; + +function TRxCustomRangeSelector.BarWidth: integer; +begin + result := Width - 2 * FThumbSize.CX; +end; + +procedure TRxCustomRangeSelector.SetState(AValue: TRxRangeSelectorState); +begin + if AValue <> FState then + begin + FState := AValue; + Invalidate; + end; +end; + +function TRxCustomRangeSelector.DeduceState(const AX, AY: integer; + const ADown: boolean): TRxRangeSelectorState; +begin + Result := rssNormal; + + if not Enabled then + Result := rssDisabled + else + begin + if PointInRect(AX, AY, FThumbPosTop) then + begin + if ADown then + Result := rssThumbTopDown + else + Result := rssThumbTopHover; + end + else + if PointInRect(AX, AY, FThumbPosBottom) then + begin + if ADown then + Result := rssThumbBottomDown + else + Result := rssThumbBottomHover; + end + else + if PointInRect(AX, AY, FSelectedPos) then + begin + if ADown then + Result := rssBlockDown + else + Result := rssBlockHover; + end; + end; +end; + +procedure TRxCustomRangeSelector.Paint; +var + DE: TThemedElementDetails; +begin + inherited Paint; + Canvas.Brush.Color := Color; + Canvas.FillRect(ClientRect); + + {$IFDEF WINDOWS} + if (FStyle = rxrsNative) and ThemeServices.ThemesEnabled then + begin + DE:=ThemeServices.GetElementDetails(ttbThumbBottomPressed); + ThemeServices.DrawElement( Canvas.Handle, DE, FThumbPosTop); + + DE:=ThemeServices.GetElementDetails(ttbThumbTopPressed); + ThemeServices.DrawElement( Canvas.Handle, DE, FThumbPosBottom); + + DE:=ThemeServices.GetElementDetails(ttbTrack); + ThemeServices.DrawElement( Canvas.Handle, DE, FTracerPos); + + DE:=ThemeServices.GetElementDetails(ttbThumbNormal); + ThemeServices.DrawElement( Canvas.Handle, DE, FSelectedPos); + end + else + {$ENDIF WINDOWS} + if FStyle = rxrsSimple then + begin + Canvas.Brush.Color := Color; + Canvas.FillRect(ClientRect); + + DrawEdge(Canvas.Handle, FTracerPos, EDGE_SUNKEN, BF_RECT); + + Canvas.Brush.Color := clHighlight; + Canvas.FillRect(FSelectedPos); + + case FState of + rssDisabled: + DrawEdge(Canvas.Handle, FSelectedPos, EDGE_BUMP, BF_RECT or BF_MONO); + rssBlockHover: + DrawEdge(Canvas.Handle, FSelectedPos, EDGE_RAISED, BF_RECT); + rssBlockDown: + DrawEdge(Canvas.Handle, FSelectedPos, EDGE_SUNKEN, BF_RECT); + else + DrawEdge(Canvas.Handle, FSelectedPos, EDGE_ETCHED, BF_RECT); + end; + + case FState of + rssDisabled: + DrawEdge(Canvas.Handle, FThumbPosTop, EDGE_BUMP, BF_RECT or BF_MONO); + rssThumbTopHover: + DrawEdge(Canvas.Handle, FThumbPosTop, EDGE_RAISED, BF_RECT); + rssThumbTopDown: + DrawEdge(Canvas.Handle, FThumbPosTop, EDGE_SUNKEN, BF_RECT); + else + DrawEdge(Canvas.Handle, FThumbPosTop, EDGE_ETCHED, BF_RECT); + end; + + case FState of + rssDisabled: + DrawEdge(Canvas.Handle, FThumbPosBottom, EDGE_BUMP, BF_RECT or BF_MONO); + rssThumbBottomHover: + DrawEdge(Canvas.Handle, FThumbPosBottom, EDGE_RAISED, BF_RECT); + rssThumbBottomDown: + DrawEdge(Canvas.Handle, FThumbPosBottom, EDGE_SUNKEN, BF_RECT); + else + DrawEdge(Canvas.Handle, FThumbPosBottom, EDGE_ETCHED, BF_RECT); + end; + end + else + begin + Canvas.Draw(FThumbPosTop.Left, FThumbPosTop.Top, FThumbTopGlyph); + Canvas.Draw(FThumbPosBottom.Left, FThumbPosBottom.Top, FThumbBottomGlyph); + + if (FBackgroudGlyph.Width > 0) and (FBackgroudGlyph.Height>0) then + begin + Canvas.StretchDraw(FTracerPos, FBackgroudGlyph) + end; + + if (FSelectedGlyph.Width > 0) and (FSelectedGlyph.Height > 0) then + Canvas.StretchDraw(FSelectedPos, FSelectedGlyph) + else + begin + Canvas.Brush.Color := clBlue; + Canvas.FillRect(FSelectedPos); + end; + end +end; + +class function TRxCustomRangeSelector.GetControlClassDefaultSize: TSize; +begin + Result.CX := 100; + Result.CY := 60; +end; + +procedure TRxCustomRangeSelector.Loaded; +begin + inherited Loaded; + UpdateData; +end; + +procedure TRxCustomRangeSelector.MouseDown(Button: TMouseButton; + Shift: TShiftState; X: Integer; Y: Integer); +begin + inherited MouseDown(Button, Shift, X, Y); + + if FDblClicked then + begin + FDblClicked := false; + Exit; + end; + + FDown := Button = mbLeft; + SetState(DeduceState(X, Y, FDown)); +end; + +procedure TRxCustomRangeSelector.MouseMove(Shift: TShiftState; X: Integer; + Y: Integer); +begin + inherited MouseMove(Shift, X, Y); + + if FState = rssThumbTopDown then + SetSelectedStart(FSelectedStart + (X - FPrevX) * (FMax - FMin) / BarWidth) + else + if FState = rssThumbBottomDown then + SetSelectedEnd(FSelectedEnd + (X - FPrevX) * (FMax - FMin) / BarWidth) + else + if FState = rssBlockDown then + begin + if IsRealInInterval(FSelectedStart + (X - FPrevX) * (FMax - FMin) / BarWidth, FMin, FMax) and + IsRealInInterval(FSelectedEnd + (X - FPrevX) * (FMax - FMin) / BarWidth, FMin, FMax) then + begin + SetSelectedStart(FSelectedStart + (X - FPrevX) * (FMax - FMin) / BarWidth); + SetSelectedEnd(FSelectedEnd + (X - FPrevX) * (FMax - FMin) / BarWidth); + end; + end + else + SetState(DeduceState(X, Y, FDown)); + + FPrevX := X; + FPrevY := Y; +end; + +procedure TRxCustomRangeSelector.MouseUp(Button: TMouseButton; + Shift: TShiftState; X: Integer; Y: Integer); +begin + inherited MouseUp(Button, Shift, X, Y); + FDown := false; + SetState(DeduceState(X, Y, FDown)); +end; + +procedure TRxCustomRangeSelector.MouseLeave; +begin + inherited MouseLeave; + if Enabled then + SetState(rssNormal) + else + SetState(rssDisabled); +end; + +procedure TRxCustomRangeSelector.SetBounds(aLeft, aTop, aWidth, aHeight: integer + ); +begin + inherited SetBounds(aLeft, aTop, aWidth, aHeight); + InitSizes; + UpdateData; + Invalidate; +end; + +const + sRxRange_h_back = 'RX_RANGE_H_BACK'; + sRxRange_h_sel = 'RX_RANGE_H_SEL'; + sRX_SLADER_BOTTOM = 'RX_SLADER_BOTTOM'; + sRX_SLADER_TOP = 'RX_SLADER_TOP'; + +constructor TRxCustomRangeSelector.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + +// FThumbTopGlyph:=TBitmap.Create; +// FThumbBottomGlyph:=TBitmap.Create; + +// FSelectedGlyph:=TBitmap.Create; +// FBackgroudGlyph:=TBitmap.Create; + FSelectedGlyph := CreateResBitmap(sRxRange_h_sel); + FBackgroudGlyph := CreateResBitmap(sRxRange_h_back); + + FThumbTopGlyph:=CreateResBitmap(sRX_SLADER_TOP); + FThumbBottomGlyph:=CreateResBitmap(sRX_SLADER_BOTTOM); + + with GetControlClassDefaultSize do + SetInitialBounds(0, 0, CX, CY); + + FSelectedEnd:=50; + FMax:=100; +end; + +destructor TRxCustomRangeSelector.Destroy; +begin + FreeAndNil(FThumbTopGlyph); + FreeAndNil(FThumbBottomGlyph); + FreeAndNil(FSelectedGlyph); + FreeAndNil(FBackgroudGlyph); + inherited Destroy; +end; + +end. + diff --git a/components/rx/trunk/rxcontrols/rxspin.pas b/components/rx/trunk/rxcontrols/rxspin.pas index 22fd5744b..a61e91b54 100644 --- a/components/rx/trunk/rxcontrols/rxspin.pas +++ b/components/rx/trunk/rxcontrols/rxspin.pas @@ -758,8 +758,6 @@ begin end; procedure TRxSpinEdit.LMSize(var Message: TLMSize); -var - MinHeight: Integer; begin inherited; ResizeButton; diff --git a/components/rx/trunk/rxdb/rxdbgrid.pas b/components/rx/trunk/rxdb/rxdbgrid.pas index ef27d73b0..6a8d532fd 100644 --- a/components/rx/trunk/rxdb/rxdbgrid.pas +++ b/components/rx/trunk/rxdb/rxdbgrid.pas @@ -922,7 +922,9 @@ type function GetDefaultEditor(Column: Integer): TWinControl; override; procedure PrepareCanvas(aCol, aRow: Integer; AState: TGridDrawState); override; - +{$IFDEF DEVELOPER_RX} + procedure InternalAdjustRowCount(var RecCount:integer); override; +{$ENDIF} property Editor; public constructor Create(AOwner: TComponent); override; @@ -5060,33 +5062,31 @@ begin end; procedure TRxDBGrid.KeyDown(var Key: word; Shift: TShiftState); -//var -// FTmpReadOnly: boolean; - procedure DoShowFindDlg; - begin - if not (rdgAllowDialogFind in OptionsRx) then - exit; - if Length(QuickUTF8Search) > 0 then - QuickUTF8Search := ''; - ShowFindDialog; - end; +procedure DoShowFindDlg; +begin + if not (rdgAllowDialogFind in OptionsRx) then + exit; + if Length(QuickUTF8Search) > 0 then + QuickUTF8Search := ''; + ShowFindDialog; +end; - procedure DoShowColumnsDlg; - begin - if not (rdgAllowColumnsForm in OptionsRx) then - exit; - if Length(QuickUTF8Search) > 0 then - QuickUTF8Search := ''; - ShowColumnsDialog; - end; +procedure DoShowColumnsDlg; +begin + if not (rdgAllowColumnsForm in OptionsRx) then + exit; + if Length(QuickUTF8Search) > 0 then + QuickUTF8Search := ''; + ShowColumnsDialog; +end; - procedure DoShowQuickFilter; - begin - if not (rdgAllowQuickFilter in FOptionsRx) then - exit; - OnFilter(Self); - end; +procedure DoShowQuickFilter; +begin + if not (rdgAllowQuickFilter in FOptionsRx) then + exit; + OnFilter(Self); +end; begin if (Key in CCancelQuickSearchKeys) then @@ -5230,6 +5230,10 @@ begin H:=H - GetDefaultRowHeight * FFooterOptions.RowCount; Result := H div GetDefaultRowHeight; + + if rdgFilter in OptionsRx then + Dec(Result, 1); + if dgTitles in Options then Dec(Result, 1); end @@ -6343,6 +6347,109 @@ begin inherited PrepareCanvas(aCol, aRow, AState); end; +{$IFDEF DEVELOPER_RX} +type + THackDataLink = class(TDataLink) + + end; + +procedure TRxDBGrid.InternalAdjustRowCount(var RecCount: integer); +var + CurActiveRecord, j, H1, FRec, H, H2: Integer; + i: LongInt; + R: TRxColumn; + F: TField; + S: String; +begin + inherited InternalAdjustRowCount(RecCount); + + if (not (Assigned(DataLink) and DataLink.Active)) or ((GCache.VisibleGrid.Top=0) and (GCache.VisibleGrid.Bottom=0)) then + exit; + + CurActiveRecord:=DataLink.ActiveRecord; + + if dgTitles in Options then + begin + FRec:=1; + H2:=1; + end + else + begin + FRec:=0; + H2:=0; + end; + + for i:=GCache.VisibleGrid.Top to GCache.VisibleGrid.Bottom do + begin + DataLink.ActiveRecord:=i - FixedRows; +// P:=PtrInt(DataSource.DataSet.ActiveBuffer); + H:=1; + for j:=0 to Columns.Count-1 do + begin + R:=Columns[j] as TRxColumn; + if R.WordWrap then + begin + F:=R.Field; + if Assigned(F) then + S:=F.DisplayText + else + S:=''; + + H1 := Max((Canvas.TextWidth(S) + 2) div R.Width + 1, H); + if H1 > WordCount(S, [' ']) then + H1 := WordCount(S, [' ']); + end + else + H1:=1; + H:=Max(H, H1); + end; + + +{ + + if FGroupItems.Active and DatalinkActive then + if Assigned(FGroupItems.FindGroupItem(DataSource.DataSet.Bookmark)) then + Inc(H); + + + if i RecCount then + begin +// RecCount:=FRec; + if (FRec < FixedRows + CurActiveRecord) {and (CurActiveRecord = DataLink.ActiveRecord)} then + begin + TopRow:=1; +// THackDataLink(DataLink).FirstRecord:=THackDataLink(DataLink).FirstRecord + 1; +{ H:=CurActiveRecord - DataLink.ActiveRecord; + THackDataLink(DataLink).FirstRecord:=THackDataLink(DataLink).FirstRecord + 1; + THackDataSet(DataLink.DataSet).RecalcBufListSize;} +// THackDataLink(DataLink).BufferCount:=FRec; + H:=0; + end; +// DataLink.BufferCount:=FRec; +// break; + end + else + begin + FRec:=FRec + 1; + H2:=H2 + H; + end; + end; + + DataLink.ActiveRecord:=CurActiveRecord; + +end; +{$ENDIF} + procedure TRxDBGrid.GetOnCreateLookup; begin if Assigned(F_CreateLookup) then diff --git a/components/rx/trunk/rxnew.lpk b/components/rx/trunk/rxnew.lpk index c59658090..9bc53f8c7 100644 --- a/components/rx/trunk/rxnew.lpk +++ b/components/rx/trunk/rxnew.lpk @@ -26,7 +26,7 @@ Copyright (c) 1998 Master-Bank translate to Lazarus by alexs in 2005 - 2017"/> - + @@ -314,6 +314,10 @@ translate to Lazarus by alexs in 2005 - 2017"/> + + + + diff --git a/components/rx/trunk/rxnew.pas b/components/rx/trunk/rxnew.pas index f084b2993..326fcdf54 100644 --- a/components/rx/trunk/rxnew.pas +++ b/components/rx/trunk/rxnew.pas @@ -21,7 +21,7 @@ uses RxIniPropStorage, rxlclconst, rxlogin, RxMDI, rxpagemngr, rxpickdate, rxShortCutUnit, rxspin, rxswitch, RxSystemServices, rxtbrsetup, RxTimeEdit, rxtoolbar, rxtooledit, RxDBGrid_PopUpFilterUnit, rxdbverticalgrid, - rxlclutils, LazarusPackageIntf; + rxlclutils, RxRangeSel, LazarusPackageIntf; implementation