RealICQContacterListView.pas 155 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483
  1. {
  2. 文件名:RealICQContacterListView.pas
  3. 功 能:用于显示即时消息软件(RealICQ)中用户列表的自定义组件,支持多种显示方式。
  4. 建 立:尹进
  5. 历 史:
  6. 2005.12.23:补文件说明信息(尹进)
  7. }
  8. unit RealICQContacterListView;
  9. interface
  10. uses
  11. RealICQHoverImage, SingleBorderHintWindow, RealICQUtils, RealICQModel,
  12. RealICQUIColor, RealICQColors, RealICQClient, Messages, SysUtils, Forms,
  13. Windows, Classes, Controls, ExtCtrls, StdCtrls, Buttons, Graphics;
  14. {$INCLUDE ..\..\Client\LXTalk.inc}
  15. const
  16. cntHeightOfBigHeadImage = 35;
  17. cntHeightOfMiddleHeadImage = 35;
  18. cntHeightOfSmallHeadImage = 27;
  19. cntHeightOfNoHeadImage = 27;
  20. FlashColorCount = 6;
  21. FlashColors: array[1..FlashColorCount] of TColor = (clYellow, clLime, clFuchsia, clAqua, clBlue, clRed);
  22. CityLevels: WideString = '省市区县';
  23. type
  24. TRealICQContacterListView = class;
  25. TRealICQContacterListItemStyle = (lsBigHeadImage, lsMiddleHeadImage, lsSmallHeadImage, lsNoHeadImage);
  26. TRealICQContacterListItemCaptionStyle = (csDisplayName, csLoginName, csDisplayNameAndLoginName);
  27. TRealICQFlashStyle = (fsJump, fsDisappear);
  28. TNoScrollListBox = class(TCustomListBox)
  29. private
  30. FBufferedBitmap: TBitMap;
  31. FListView: TRealICQContacterListView;
  32. FMouseInDown: Boolean;
  33. procedure DrawContacterItem(ACanvas: TCanvas; Index: Integer; Rect: TRect; State: TOwnerDrawState);
  34. protected
  35. procedure WMEraseBKGND(var Message: TWMEraseBKGND); message WM_ERASEBKGND;
  36. procedure WMSIZE(var Message: TWMSIZE); message WM_SIZE;
  37. procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
  38. procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
  39. procedure WMMouseDown(var Message: TWMLBUTTONDOWN); message WM_LBUTTONDOWN;
  40. procedure CreateParams(var Params: TCreateParams); override;
  41. public
  42. constructor Create(AOwner: TComponent); override;
  43. destructor Destroy; override;
  44. end;
  45. TListBoxScrollBar = class(TCustomPanel)
  46. private
  47. FListView: TRealICQContacterListView;
  48. //ListBox的可滚动的高度
  49. FClientRange: Integer;
  50. //滚动条可移动的高度
  51. FScrollRange: Integer;
  52. FTrackingBarTopRange: Integer;
  53. FAssignedPicture: Boolean;
  54. FButtonDown: Boolean;
  55. FTrackingBarDown: Boolean;
  56. FTrackingBarDonwY: Integer;
  57. FMovedYValue: Integer;
  58. FTopButtonImage: TRealICQHoverImage;
  59. FBottomButtonImage: TRealICQHoverImage;
  60. FBarButtonTopImage: TRealICQHoverImage;
  61. FBarButtonMiddleImage: TRealICQHoverImage;
  62. FBarButtonBottomImage: TRealICQHoverImage;
  63. FBackgroundImage: TRealICQHoverImage;
  64. FDrawing: Boolean;
  65. procedure DrawScrollBar;
  66. procedure ListBoxResize(Sender: TObject);
  67. procedure ListBoxConstrainedResize(Sender: TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer);
  68. procedure ListBoxMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
  69. procedure ListBoxMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
  70. procedure TopButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  71. procedure TopButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  72. procedure TopButtonImageMouseEnter(Sender: TObject);
  73. procedure TopButtonImageMouseLeave(Sender: TObject);
  74. procedure BottomButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  75. procedure BottomButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  76. procedure BottomButtonImageMouseEnter(Sender: TObject);
  77. procedure BottomButtonImageMouseLeave(Sender: TObject);
  78. procedure BarButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  79. procedure BarButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  80. procedure BarButtonImageMouseEnter(Sender: TObject);
  81. procedure BarButtonImageMouseLeave(Sender: TObject);
  82. procedure BarButtonImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  83. procedure BackgroundImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  84. procedure BackgroundImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  85. procedure BackgroundImageMouseEnter(Sender: TObject);
  86. procedure BackgroundImageMouseLeave(Sender: TObject);
  87. protected
  88. public
  89. constructor Create(AOwner: TComponent); override;
  90. destructor Destroy; override;
  91. published
  92. end;
  93. TRealICQContacterListItem = class
  94. private
  95. FListView: TRealICQContacterListView;
  96. FAdjustPositioned: Boolean;
  97. FCaptionColor: TColor;
  98. FHeadImagePosition: Integer;
  99. FFlashStyle: TRealICQFlashStyle;
  100. FFlashCaptionThread: TThread;
  101. FFlashImageThread: TThread;
  102. FMouseInRect: Boolean;
  103. FHint: string;
  104. FLoginName: string;
  105. FDisplayName: string;
  106. FWatchword: string;
  107. FLoginState: TRealICQLoginState;
  108. FLeaveMessage: string;
  109. FHeadImagePicture: TPicture;
  110. FHasCamera: Boolean;
  111. FHasTelephone: Boolean;
  112. FHasMobilePhone: Boolean;
  113. FHasEmail: Boolean;
  114. FHasSMS: Boolean;
  115. FHasAddFriend: Boolean;
  116. FStateIndex: Integer;
  117. FHeadImageRect: TRect;
  118. FCameraRect: TRect;
  119. FTelephoneRect: TRect;
  120. FMobilePhoneRect: TRect;
  121. FEmailRect: TRect;
  122. FSMSRect: TRect;
  123. FTextRect: TRect;
  124. FAddFriendRect: TRect;
  125. FMouseOver: Boolean;
  126. FMouseInTextRect: Boolean;
  127. FMouseInHeadImageRect: Boolean;
  128. FMouseInCameraRect: Boolean;
  129. FMouseInTelephoneRect: Boolean;
  130. FMouseInMobilePhoneRect: Boolean;
  131. FMouseInEmailRect: Boolean;
  132. FMouseInSMSRect: Boolean;
  133. FMouseInAddFriendRect: Boolean;
  134. FTel, FMobile: string;
  135. FCompany, FBranch: string;
  136. FHeadImageHint, FCameraHint, FTelephoneHint, FMobilePhoneHint, FEmailHint, FSMSHint: string;
  137. FAddFriendHint: string;
  138. FServerName: string;
  139. procedure SetDisplayName(Value: string);
  140. procedure SetWatchword(Value: string);
  141. procedure SetHeadImagePicture(Value: TPicture);
  142. function GetItemIndex: Integer;
  143. function GetSelected: Boolean;
  144. procedure SetSelected(Value: Boolean);
  145. procedure SetLoginState(Value: TRealICQLoginState);
  146. procedure HeadImagePictureChange(Sender: TObject);
  147. procedure AdjustPosition;
  148. function GetStatePosition(ALoginState: TRealICQLoginState): Integer;
  149. procedure SetBranch(const Value: string);
  150. protected
  151. public
  152. Data: Pointer;
  153. constructor Create(ALoginName: string; AListView: TRealICQContacterListView);
  154. destructor Destroy; override;
  155. procedure Flash(AStyle: TRealICQFlashStyle);
  156. procedure StopFlash;
  157. procedure ReDrawItem;
  158. procedure MoveToTop;
  159. property Branch: string read FBranch write SetBranch;
  160. published
  161. property LoginName: string read FLoginName;
  162. property DisplayName: string read FDisplayName write SetDisplayName;
  163. property Watchword: string read FWatchword write SetWatchword;
  164. property Selected: Boolean read GetSelected write SetSelected;
  165. property LoginState: TRealICQLoginState read FLoginState write SetLoginState;
  166. property LeaveMessage: string read FLeaveMessage write FLeaveMessage;
  167. property HeadImagePicture: TPicture read FHeadImagePicture write SetHeadImagePicture;
  168. property ItemIndex: Integer read GetItemIndex;
  169. property ListView: TRealICQContacterListView read FListView;
  170. property Mobile: string read FMobile write FMobile;
  171. property Tel: string read FTel write FTel;
  172. property StateIndex: Integer read FStateIndex write FStateIndex;
  173. property HasCamera: Boolean read FHasCamera write FHasCamera;
  174. property HasTelephone: Boolean read FHasTelephone write FHasTelephone;
  175. property HasMobilePhone: Boolean read FHasMobilePhone write FHasMobilePhone;
  176. property HasEmail: Boolean read FHasEmail write FHasEmail;
  177. property HasSMS: Boolean read FHasSMS write FHasSMS;
  178. property HasAddFriend: Boolean read FHasAddFriend write FHasAddFriend;
  179. property HeadImageHint: string read FHeadImageHint write FHeadImageHint;
  180. property CameraHint: string read FCameraHint write FCameraHint;
  181. property TelephoneHint: string read FTelephoneHint write FTelephoneHint;
  182. property MobilePhoneHint: string read FMobilePhoneHint write FMobilePhoneHint;
  183. property EmailHint: string read FEmailHint write FEmailHint;
  184. property SMSHint: string read FSMSHint write FSMSHint;
  185. property AddFriendHint: string read FAddFriendHint write FAddFriendHint;
  186. property Company: string read FCompany write FCompany;
  187. property ServerName: string read FServerName write FServerName;
  188. end;
  189. TRealICQContacterListItems = class(TStrings)
  190. private
  191. FRealICQContacterListView: TRealICQContacterListView;
  192. protected
  193. function GetObject(Index: Integer): TObject; override;
  194. procedure Put(Index: Integer; const S: string); override;
  195. function Get(Index: Integer): string; override;
  196. function GetCount: Integer; override;
  197. public
  198. constructor Create(ARealICQContacterListView: TRealICQContacterListView);
  199. destructor Destroy; override;
  200. function Add(const S: string): Integer; override;
  201. procedure Insert(Index: Integer; const S: string); override;
  202. procedure Clear; override;
  203. procedure Delete(Index: Integer); override;
  204. function IndexOf(const S: string): Integer; override;
  205. procedure Move(CurIndex, NewIndex: Integer); override;
  206. end;
  207. TRealICQContacterListItemNotifyEvent = procedure(Item: TRealICQContacterListItem) of object;
  208. TRealICQContacterListItemIconButtonType = (ltCamera, ltTel, ltMobile, ltEmail, ltSMS, ltHeadImage, ltAddFriend);
  209. TRealICQContacterListItemIconButtonEvent = procedure(Sender: TObject; Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType) of object;
  210. TRealICQContacterListItemShowHintEvent = procedure(Sender: TObject; Item: TRealICQContacterListItem; var HintStr: string) of object;
  211. TRealICQContacterListViewDropFilesEvent = procedure(Sender: TObject; var Message: TMessage) of object;
  212. TRealICQContacterListView = class(TPanel, IRealICQUIColor)
  213. private
  214. FNoScrollListBox: TNoScrollListBox;
  215. FListBoxScrollBar: TListBoxScrollBar;
  216. FAdjustPosition: Boolean;
  217. FFlashCaptionOnOnline: Boolean;
  218. FOnlineNumeric: Cardinal;
  219. FStyle: TRealICQContacterListItemStyle;
  220. FCaptionStyle: TRealICQContacterListItemCaptionStyle;
  221. FSelectedItemBorderColor: TColor;
  222. FSelectedItemBorderInnerColor: TColor;
  223. FSelectedItemBackColor: TColor;
  224. FHeadImageBorderColor: TColor;
  225. FHeadImageBackColor: TColor;
  226. FSelectedItemBackgroud: TPicture;
  227. FDefaultPictureBig: TPicture;
  228. FDefaultPictureMiddle: TPicture;
  229. FDefaultPictureSmall: TPicture;
  230. FDefaultPictureBigOffline: TPicture;
  231. FDefaultPictureMiddleOffline: TPicture;
  232. FDefaultPictureSmallOffline: TPicture;
  233. FLeavePicture: TIcon;
  234. FBusyPicture: TIcon;
  235. FMutePicture: TIcon;
  236. FLeavePictureBig: TIcon;
  237. FBusyPictureBig: TIcon;
  238. FMutePictureBig: TIcon;
  239. FCameraIcon: TIcon;
  240. FTelephoneIcon: TIcon;
  241. FMobilePhoneIcon: TIcon;
  242. FEmailIcon: TIcon;
  243. FSMSIcon: TIcon;
  244. FAddFriendIcon: TIcon;
  245. FShowHeadImageButton: Boolean;
  246. FShowTelButton: Boolean;
  247. FShowMobileButton: Boolean;
  248. FShowCameraButton: Boolean;
  249. FShowEmailButton: Boolean;
  250. FShowSMSButton: Boolean;
  251. FShowAddFriendButton: Boolean;
  252. FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor: TColor;
  253. FItems: TStrings;
  254. FTimer: TTimer;
  255. FHintWindow: TSingleBorderHintWindow;
  256. FTimerItemIndex: Integer;
  257. FOnSelectItemChanged: TRealICQContacterListItemNotifyEvent;
  258. FOnItemClick: TRealICQContacterListItemNotifyEvent;
  259. FOnItemDoubleClick: TRealICQContacterListItemNotifyEvent;
  260. FOnItemMouseEnter: TRealICQContacterListItemNotifyEvent;
  261. FOnItemMouseLeave: TRealICQContacterListItemNotifyEvent;
  262. FOnItemFlashCaption: TRealICQContacterListItemNotifyEvent;
  263. FOnItemOnline: TRealICQContacterListItemNotifyEvent;
  264. FOnItemOffline: TRealICQContacterListItemNotifyEvent;
  265. FOnItemIconButtonClick: TRealICQContacterListItemIconButtonEvent;
  266. FOnItemIconButtonDblClick: TRealICQContacterListItemIconButtonEvent;
  267. FOnItemShowHint: TRealICQContacterListItemShowHintEvent;
  268. FOnDropFiles: TRealICQContacterListViewDropFilesEvent;
  269. FOnItemMouseDown: TMouseEvent;
  270. FOnItemMouseUp: TMouseEvent;
  271. FOnHeadImageMouseEnter: TRealICQContacterListItemNotifyEvent;
  272. FOnHeadImageMouseLeave: TRealICQContacterListItemNotifyEvent;
  273. FScrollTopButtonPictureNormal: TPicture;
  274. FScrollTopButtonPictureHover: TPicture;
  275. FScrollTopButtonPictureDown: TPicture;
  276. FScrollBottomButtonPictureNormal: TPicture;
  277. FScrollBottomButtonPictureHover: TPicture;
  278. FScrollBottomButtonPictureDown: TPicture;
  279. FScrollBarButtonTopPictureNormal: TPicture;
  280. FScrollBarButtonTopPictureHover: TPicture;
  281. FScrollBarButtonTopPictureDown: TPicture;
  282. FScrollBarButtonMiddlePictureNormal: TPicture;
  283. FScrollBarButtonMiddlePictureHover: TPicture;
  284. FScrollBarButtonMiddlePictureDown: TPicture;
  285. FScrollBarButtonBottomPictureNormal: TPicture;
  286. FScrollBarButtonBottomPictureHover: TPicture;
  287. FScrollBarButtonBottomPictureDown: TPicture;
  288. FScrollBackgroundPictureNormal: TPicture;
  289. FScrollBackgroundPictureHover: TPicture;
  290. FScrollBackgroundPictureDown: TPicture;
  291. procedure SetScrollTopButtonPictureNormal(Value: TPicture);
  292. procedure SetScrollTopButtonPictureHover(Value: TPicture);
  293. procedure SetScrollTopButtonPictureDown(Value: TPicture);
  294. procedure SetScrollBottomButtonPictureNormal(Value: TPicture);
  295. procedure SetScrollBottomButtonPictureHover(Value: TPicture);
  296. procedure SetScrollBottomButtonPictureDown(Value: TPicture);
  297. procedure SetScrollBarButtonTopPictureNormal(Value: TPicture);
  298. procedure SetScrollBarButtonTopPictureHover(Value: TPicture);
  299. procedure SetScrollBarButtonTopPictureDown(Value: TPicture);
  300. procedure SetScrollBarButtonMiddlePictureNormal(Value: TPicture);
  301. procedure SetScrollBarButtonMiddlePictureHover(Value: TPicture);
  302. procedure SetScrollBarButtonMiddlePictureDown(Value: TPicture);
  303. procedure SetScrollBarButtonBottomPictureNormal(Value: TPicture);
  304. procedure SetScrollBarButtonBottomPictureHover(Value: TPicture);
  305. procedure SetScrollBarButtonBottomPictureDown(Value: TPicture);
  306. procedure SetScrollBackgroundPictureNormal(Value: TPicture);
  307. procedure SetScrollBackgroundPictureHover(Value: TPicture);
  308. procedure SetScrollBackgroundPictureDown(Value: TPicture);
  309. procedure SetStyle(Value: TRealICQContacterListItemStyle);
  310. procedure SetCaptionStyle(Value: TRealICQContacterListItemCaptionStyle);
  311. procedure SetSelectedItemBorderColor(Value: TColor);
  312. procedure SetSelectedItemBorderInnerColor(Value: TColor);
  313. procedure SetSelectedItemBackColor(Value: TColor);
  314. procedure SetHeadImageBorderColor(Value: TColor);
  315. procedure SetHeadImageBackColor(Value: TColor);
  316. procedure SetSelectedItemBackgroud(Value: TPicture);
  317. procedure SetDefaultPictureBig(Value: TPicture);
  318. procedure SetDefaultPictureMiddle(Value: TPicture);
  319. procedure SetDefaultPictureSmall(Value: TPicture);
  320. procedure SetDefaultPictureBigOffline(Value: TPicture);
  321. procedure SetDefaultPictureMiddleOffline(Value: TPicture);
  322. procedure SetDefaultPictureSmallOffline(Value: TPicture);
  323. procedure SetLeavePicture(Value: TIcon);
  324. procedure SetBusyPicture(Value: TIcon);
  325. procedure SetMutePicture(Value: TIcon);
  326. procedure SetLeavePictureBig(Value: TIcon);
  327. procedure SetBusyPictureBig(Value: TIcon);
  328. procedure SetMutePictureBig(Value: TIcon);
  329. procedure SetCameraIcon(Value: TIcon);
  330. procedure SetTelephoneIcon(Value: TIcon);
  331. procedure SetMobilePhoneIcon(Value: TIcon);
  332. procedure SetEmailIcon(Value: TIcon);
  333. procedure SetSMSIcon(Value: TIcon);
  334. procedure SetAddFriendIcon(Value: TIcon);
  335. function GetSelCount: Integer;
  336. procedure SetTopIndex(Value: Integer);
  337. function GetTopIndex: Integer;
  338. procedure WhenClick(Sender: TObject);
  339. procedure WhenDoubleClick(Sender: TObject);
  340. procedure WhenMouseLeave(Sender: TObject);
  341. procedure WhenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  342. procedure WhenMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  343. procedure WhenMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  344. procedure TimerOnTimer(Sender: TObject);
  345. procedure ShowCustomHint(Item: TRealICQContacterListItem);
  346. function GetCopyRight: string;
  347. protected
  348. procedure DoHeadImageMouseEnter(Item: TRealICQContacterListItem);
  349. procedure DoHeadImageMouseLeave(Item: TRealICQContacterListItem);
  350. procedure DoSelectItemChanged(Item: TRealICQContacterListItem);
  351. procedure DoItemClick(Item: TRealICQContacterListItem);
  352. procedure DoItemDoubleClick(Item: TRealICQContacterListItem);
  353. procedure DoItemMouseEnter(Item: TRealICQContacterListItem);
  354. procedure DoItemMouseLeave(Item: TRealICQContacterListItem);
  355. procedure DoItemFlashCaption(Item: TRealICQContacterListItem);
  356. procedure DoItemOnline(Item: TRealICQContacterListItem);
  357. procedure DoItemOffline(Item: TRealICQContacterListItem);
  358. procedure DoItemIconButtonClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
  359. procedure DoItemIconButtonDblClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
  360. procedure DoItemShowHint(Item: TRealICQContacterListItem; var HintStr: string);
  361. procedure DoDropFiles(var Message: TMessage);
  362. procedure DropFiles(var Message: TMessage); message WM_DropFiles;
  363. public
  364. constructor Create(AOwner: TComponent); override;
  365. destructor Destroy; override;
  366. procedure ChangeUIColor(AColor: TColor);
  367. function ItemAtPos(Pos: TPoint; Existing: Boolean): Integer;
  368. procedure ReDrawAll;
  369. property FlashCaptionOnOnline: Boolean read FFlashCaptionOnOnline write FFlashCaptionOnOnline;
  370. property OnlineNumeric: Cardinal read FOnlineNumeric;
  371. property Items: TStrings read FItems;
  372. property SelCount: Integer read GetSelCount;
  373. property TopIndex: Integer read GetTopIndex write SetTopIndex;
  374. published
  375. property CopyRight: string read GetCopyRight;
  376. property Caption;
  377. property Color;
  378. property Align;
  379. property Anchors;
  380. property Style: TRealICQContacterListItemStyle read FStyle write SetStyle;
  381. property CaptionStyle: TRealICQContacterListItemCaptionStyle read FCaptionStyle write SetCaptionStyle;
  382. property SelectedItemBorderInnerColor: TColor read FSelectedItemBorderInnerColor write SetSelectedItemBorderInnerColor;
  383. property SelectedItemBorderColor: TColor read FSelectedItemBorderColor write SetSelectedItemBorderColor;
  384. property SelectedItemBackColor: TColor read FSelectedItemBackColor write SetSelectedItemBackColor;
  385. property HeadImageBorderColor: TColor read FHeadImageBorderColor write SetHeadImageBorderColor;
  386. property HeadImageBackColor: TColor read FHeadImageBackColor write SetHeadImageBackColor;
  387. property SelectedItemBackgroud: TPicture read FSelectedItemBackgroud write SetSelectedItemBackgroud;
  388. property DefaultPictureBig: TPicture read FDefaultPictureBig write SetDefaultPictureBig;
  389. property DefaultPictureMiddle: TPicture read FDefaultPictureMiddle write SetDefaultPictureMiddle;
  390. property DefaultPictureSmall: TPicture read FDefaultPictureSmall write SetDefaultPictureSmall;
  391. property DefaultPictureBigOffline: TPicture read FDefaultPictureBigOffline write SetDefaultPictureBigOffline;
  392. property DefaultPictureMiddleOffline: TPicture read FDefaultPictureMiddleOffline write SetDefaultPictureMiddleOffline;
  393. property DefaultPictureSmallOffline: TPicture read FDefaultPictureSmallOffline write SetDefaultPictureSmallOffline;
  394. property AdjustPosition: Boolean read FAdjustPosition write FAdjustPosition;
  395. property LeavePicture: TIcon read FLeavePicture write SetLeavePicture;
  396. property BusyPicture: TIcon read FBusyPicture write SetBusyPicture;
  397. property MutePicture: TIcon read FMutePicture write SetMutePicture;
  398. property LeavePictureBig: TIcon read FLeavePictureBig write SetLeavePictureBig;
  399. property BusyPictureBig: TIcon read FBusyPictureBig write SetBusyPictureBig;
  400. property MutePictureBig: TIcon read FMutePictureBig write SetMutePictureBig;
  401. property CameraIcon: TIcon read FCameraIcon write SetCameraIcon;
  402. property TelephoneIcon: TIcon read FTelephoneIcon write SetTelephoneIcon;
  403. property MobilePhoneIcon: TIcon read FMobilePhoneIcon write SetMobilePhoneIcon;
  404. property EmailIcon: TIcon read FEmailIcon write SetEmailIcon;
  405. property SMSIcon: TIcon read FSMSIcon write SetSMSIcon;
  406. property AddFriendIcon: TIcon read FAddFriendIcon write SetAddFriendIcon;
  407. property ShowHeadImageButton: Boolean read FShowHeadImageButton write FShowHeadImageButton;
  408. property ShowTelButton: Boolean read FShowTelButton write FShowTelButton;
  409. property ShowMobileButton: Boolean read FShowMobileButton write FShowMobileButton;
  410. property ShowCameraButton: Boolean read FShowCameraButton write FShowCameraButton;
  411. property ShowEmailButton: Boolean read FShowEmailButton write FShowEmailButton;
  412. property ShowSMSButton: Boolean read FShowSMSButton write FShowSMSButton;
  413. property ShowAddFriendButton: Boolean read FShowAddFriendButton write FShowAddFriendButton;
  414. property ScrollTopButtonPictureNormal: TPicture read FScrollTopButtonPictureNormal write SetScrollTopButtonPictureNormal;
  415. property ScrollTopButtonPictureHover: TPicture read FScrollTopButtonPictureHover write SetScrollTopButtonPictureHover;
  416. property ScrollTopButtonPictureDown: TPicture read FScrollTopButtonPictureDown write SetScrollTopButtonPictureDown;
  417. property ScrollBottomButtonPictureNormal: TPicture read FScrollBottomButtonPictureNormal write SetScrollBottomButtonPictureNormal;
  418. property ScrollBottomButtonPictureHover: TPicture read FScrollBottomButtonPictureHover write SetScrollBottomButtonPictureHover;
  419. property ScrollBottomButtonPictureDown: TPicture read FScrollBottomButtonPictureDown write SetScrollBottomButtonPictureDown;
  420. property ScrollBarButtonTopPictureNormal: TPicture read FScrollBarButtonTopPictureNormal write SetScrollBarButtonTopPictureNormal;
  421. property ScrollBarButtonTopPictureHover: TPicture read FScrollBarButtonTopPictureHover write SetScrollBarButtonTopPictureHover;
  422. property ScrollBarButtonTopPictureDown: TPicture read FScrollBarButtonTopPictureDown write SetScrollBarButtonTopPictureDown;
  423. property ScrollBarButtonMiddlePictureNormal: TPicture read FScrollBarButtonMiddlePictureNormal write SetScrollBarButtonMiddlePictureNormal;
  424. property ScrollBarButtonMiddlePictureHover: TPicture read FScrollBarButtonMiddlePictureHover write SetScrollBarButtonMiddlePictureHover;
  425. property ScrollBarButtonMiddlePictureDown: TPicture read FScrollBarButtonMiddlePictureDown write SetScrollBarButtonMiddlePictureDown;
  426. property ScrollBarButtonBottomPictureNormal: TPicture read FScrollBarButtonBottomPictureNormal write SetScrollBarButtonBottomPictureNormal;
  427. property ScrollBarButtonBottomPictureHover: TPicture read FScrollBarButtonBottomPictureHover write SetScrollBarButtonBottomPictureHover;
  428. property ScrollBarButtonBottomPictureDown: TPicture read FScrollBarButtonBottomPictureDown write SetScrollBarButtonBottomPictureDown;
  429. property ScrollBackgroundPictureNormal: TPicture read FScrollBackgroundPictureNormal write SetScrollBackgroundPictureNormal;
  430. property ScrollBackgroundPictureHover: TPicture read FScrollBackgroundPictureHover write SetScrollBackgroundPictureHover;
  431. property ScrollBackgroundPictureDown: TPicture read FScrollBackgroundPictureDown write SetScrollBackgroundPictureDown;
  432. property OnSelectItemChanged: TRealICQContacterListItemNotifyEvent read FOnSelectItemChanged write FOnSelectItemChanged;
  433. property OnItemClick: TRealICQContacterListItemNotifyEvent read FOnItemClick write FOnItemClick;
  434. property OnItemDoubleClick: TRealICQContacterListItemNotifyEvent read FOnItemDoubleClick write FOnItemDoubleClick;
  435. property OnItemMouseEnter: TRealICQContacterListItemNotifyEvent read FOnItemMouseEnter write FOnItemMouseEnter;
  436. property OnItemMouseLeave: TRealICQContacterListItemNotifyEvent read FOnItemMouseLeave write FOnItemMouseLeave;
  437. property OnItemFlashCaption: TRealICQContacterListItemNotifyEvent read FOnItemFlashCaption write FOnItemFlashCaption;
  438. property OnItemOnline: TRealICQContacterListItemNotifyEvent read FOnItemOnline write FOnItemOnline;
  439. property OnItemOffline: TRealICQContacterListItemNotifyEvent read FOnItemOffline write FOnItemOffline;
  440. property OnItemIconButtonClick: TRealICQContacterListItemIconButtonEvent read FOnItemIconButtonClick write FOnItemIconButtonClick;
  441. property OnItemIconButtonDblClick: TRealICQContacterListItemIconButtonEvent read FOnItemIconButtonDblClick write FOnItemIconButtonDblClick;
  442. property OnItemShowHint: TRealICQContacterListItemShowHintEvent read FOnItemShowHint write FOnItemShowHint;
  443. property OnDropFiles: TRealICQContacterListViewDropFilesEvent read FOnDropFiles write FOnDropFiles;
  444. property OnItemMouseDown: TMouseEvent read FOnItemMouseDown write FOnItemMouseDown;
  445. property OnItemMouseUp: TMouseEvent read FOnItemMouseUp write FOnItemMouseUp;
  446. property OnHeadImageMouseEnter: TRealICQContacterListItemNotifyEvent read FOnHeadImageMouseEnter write FOnHeadImageMouseEnter;
  447. property OnHeadImageMouseLeave: TRealICQContacterListItemNotifyEvent read FOnHeadImageMouseLeave write FOnHeadImageMouseLeave;
  448. property ListBox: TNoScrollListBox read FNoScrollListBox;
  449. end;
  450. TRealICQFlashCaption = class(TThread)
  451. private
  452. FRealICQContacterListItem: TRealICQContacterListItem;
  453. FColorIndex: Integer;
  454. procedure FlashCaptionColor;
  455. protected
  456. procedure Execute; override;
  457. public
  458. constructor Create(ARealICQContacterListItem: TRealICQContacterListItem);
  459. destructor Destroy; override;
  460. end;
  461. TRealICQFlashImage = class(TThread)
  462. private
  463. FRealICQContacterListItem: TRealICQContacterListItem;
  464. FPosition: Integer;
  465. procedure FlashImagePosition;
  466. protected
  467. procedure Execute; override;
  468. public
  469. constructor Create(ARealICQContacterListItem: TRealICQContacterListItem);
  470. destructor Destroy; override;
  471. end;
  472. procedure Register;
  473. implementation
  474. uses
  475. StrUtils;
  476. function TRealICQContacterListView.GetCopyRight: string;
  477. begin
  478. Result := '版权所有(C) 2002-2016 浙江万赛软件科技有限公司 保留所有权利。';
  479. end;
  480. {TNoScrollListBox}
  481. constructor TNoScrollListBox.Create(AOwner: TComponent);
  482. begin
  483. inherited Create(AOwner);
  484. Color := clWhite;
  485. FBufferedBitmap := TBitMap.Create;
  486. end;
  487. destructor TNoScrollListBox.Destroy;
  488. begin
  489. try
  490. FreeAndNil(FBufferedBitmap);
  491. except
  492. end;
  493. inherited Destroy;
  494. end;
  495. procedure TNoScrollListBox.CreateParams(var Params: TCreateParams);
  496. begin
  497. inherited CreateParams(Params);
  498. with Params do
  499. begin
  500. Style := Style - WS_VSCROLL;
  501. end;
  502. end;
  503. procedure TNoScrollListBox.WMPaint(var Message: TWMPaint);
  504. begin
  505. inherited;
  506. end;
  507. procedure TNoScrollListBox.WMMouseDown(var Message: TWMLBUTTONDOWN);
  508. begin
  509. try
  510. if Assigned(FListView.FOnItemMouseDown) then
  511. FListView.FOnItemMouseDown(FListView, mbLeft, [], Message.XPos, Message.YPos);
  512. finally
  513. inherited;
  514. end;
  515. end;
  516. procedure TNoScrollListBox.WMEraseBKGND(var Message: TWMEraseBKGND);
  517. var
  518. ACanvas: TCanvas;
  519. begin
  520. ACanvas := TCanvas.Create;
  521. try
  522. ACanvas.Handle := Message.DC;
  523. ACanvas.Pen.Color := clWhite;
  524. ACanvas.Brush.Color := clWhite;
  525. ACanvas.FillRect(Rect(0, ItemHeight * Items.Count, ClientWidth, ClientHeight));
  526. finally
  527. ACanvas.Free;
  528. end;
  529. Message.Result := 1; // 已处理
  530. end;
  531. procedure TNoScrollListBox.WMSIZE(var Message: TWMSIZE);
  532. begin
  533. inherited;
  534. Invalidate;
  535. end;
  536. procedure TNoScrollListBox.DrawContacterItem(ACanvas: TCanvas; Index: Integer; Rect: TRect; State: TOwnerDrawState);
  537. var
  538. ListItem: TRealICQContacterListItem;
  539. R: TRect;
  540. ACaption: string;
  541. ACaptionWidth: Integer;
  542. AHeadPicture: TPicture;
  543. AddLeft, AddTop: Integer;
  544. DrawHeadImage: Boolean;
  545. NeedDrawImageBorder: Boolean;
  546. Icon: TIcon;
  547. P: TPoint;
  548. AStateIcon: TIcon;
  549. b, n: string;
  550. function GetCaption(AServerName, ABranchName, ADisplayName: WideString): string;
  551. begin
  552. {$IFDEF LSSBGZS}
  553. if AServerName <> '' then
  554. begin
  555. if ABranchName <> '' then
  556. begin
  557. if Pos(LeftStr(ABranchName, 1), CityLevels) > 0 then
  558. begin
  559. Delete(ABranchName, 1, 1);
  560. Result := ADisplayName + '(' + AServerName + ABranchName + ')';
  561. end
  562. else if Pos(AServerName, ABranchName) > 0 then
  563. begin
  564. Result := ADisplayName + '(' + ABranchName + ')';
  565. end
  566. else if (Pos(RightStr(AServerName, 1), CityLevels) > 1) and (Pos(LeftStr(AServerName, Length(AServerName) - 1), ABranchName) > 0) then
  567. Result := ADisplayName + '(' + ABranchName + ')'
  568. else
  569. begin
  570. Result := ADisplayName + '(' + AServerName + ABranchName + ')';
  571. end;
  572. end
  573. else
  574. Result := ADisplayName + '(' + AServerName + ')';
  575. end
  576. else
  577. {$ENDIF}
  578. begin
  579. if ABranchName <> '' then
  580. begin
  581. Result := ADisplayName + '(' + ABranchName + ')'
  582. end
  583. else
  584. Result := ADisplayName;
  585. end;
  586. end;
  587. begin
  588. ListItem := Items.Objects[Index] as TRealICQContacterListItem;
  589. if ListItem = nil then
  590. exit;
  591. P.X := Mouse.CursorPos.X;
  592. P.Y := Mouse.CursorPos.Y;
  593. P := ScreenToClient(P);
  594. with ListItem do
  595. begin
  596. FHeadImageRect.Left := 0;
  597. FHeadImageRect.Top := 0;
  598. FHeadImageRect.Right := 0;
  599. FHeadImageRect.Bottom := 0;
  600. FCameraRect.Left := 0;
  601. FCameraRect.Top := 0;
  602. FCameraRect.Right := 0;
  603. FCameraRect.Bottom := 0;
  604. FTelephoneRect.Left := 0;
  605. FTelephoneRect.Top := 0;
  606. FTelephoneRect.Right := 0;
  607. FTelephoneRect.Bottom := 0;
  608. FMobilePhoneRect.Left := 0;
  609. FMobilePhoneRect.Top := 0;
  610. FMobilePhoneRect.Right := 0;
  611. FMobilePhoneRect.Bottom := 0;
  612. FSMSRect.Left := 0;
  613. FSMSRect.Top := 0;
  614. FSMSRect.Right := 0;
  615. FSMSRect.Bottom := 0;
  616. FTextRect.Left := 0;
  617. FTextRect.Top := 0;
  618. FTextRect.Right := 0;
  619. FTextRect.Bottom := 0;
  620. FAddFriendRect.Left := 0;
  621. FAddFriendRect.Top := 0;
  622. FAddFriendRect.Right := 0;
  623. FAddFriendRect.Bottom := 0;
  624. end;
  625. NeedDrawImageBorder := False;
  626. ACanvas.FillRect(Rect);
  627. {$region '绘制选中状态的背景'}
  628. if (odSelected in State) or ListItem.FMouseOver then
  629. begin
  630. NeedDrawImageBorder := True;
  631. if (odSelected in State) then
  632. begin
  633. ACanvas.Pen.Color := FListView.FSelectedItemBorderColor;
  634. ACanvas.Brush.Color := FListView.FSelectedItemBackColor;
  635. end
  636. else
  637. begin
  638. ACanvas.Pen.Color := RealICQColors.ConvertColorToLighter(FListView.FSelectedItemBorderColor, 12);
  639. ACanvas.Brush.Color := RealICQColors.ConvertColorToLighter(FListView.FSelectedItemBackColor, 6);
  640. end;
  641. R.Left := Rect.Left;
  642. R.Top := Rect.Top + 1;
  643. R.Right := Rect.Right - 1;
  644. R.Bottom := Rect.Bottom;
  645. ACanvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 5, 5);
  646. R.Left := Rect.Left + 2;
  647. R.Top := Rect.Top + 3;
  648. R.Right := Rect.Right - 3;
  649. R.Bottom := Rect.Bottom - 2;
  650. // ACanvas.StretchDraw(R, FListView.FSelectedItemBackgroud.Graphic);
  651. ACanvas.Pen.Color := FListView.SelectedItemBorderInnerColor;
  652. ACanvas.Brush.Style := bsClear;
  653. ACanvas.RoundRect(R.Left - 1, R.Top - 1, R.Right + 1, R.Bottom + 1, 3, 3);
  654. end;
  655. {$endregion'}
  656. {$region '计算头像的位置,头像跳动时用到'}
  657. DrawHeadImage := True;
  658. AddLeft := 0;
  659. AddTop := 0;
  660. if ListItem.FFlashStyle = fsJump then
  661. begin
  662. case ListItem.FHeadImagePosition of
  663. 1:
  664. begin
  665. AddLeft := -1;
  666. AddTop := +1;
  667. end;
  668. 2:
  669. begin
  670. AddLeft := 0;
  671. AddTop := -1;
  672. end;
  673. 3:
  674. begin
  675. AddLeft := +1;
  676. AddTop := +1;
  677. end;
  678. end;
  679. end
  680. else
  681. begin
  682. if ListItem.FHeadImagePosition mod 2 = 0 then
  683. DrawHeadImage := True
  684. else
  685. DrawHeadImage := False;
  686. end;
  687. {$endregion'}
  688. AHeadPicture := TPicture.Create;
  689. try
  690. case FListView.Style of
  691. lsBigHeadImage:
  692. begin
  693. {$region '绘制 48*48 高度的Item'}
  694. if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
  695. begin
  696. NeedDrawImageBorder := True;
  697. AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
  698. end
  699. else
  700. begin
  701. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddle.Graphic);
  702. end;
  703. if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  704. begin
  705. if (FListView.FDefaultPictureMiddleOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
  706. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddleOffline.Graphic)
  707. else
  708. RealICQColors.Grayscale(AHeadPicture.Bitmap);
  709. end;
  710. if NeedDrawImageBorder or ListItem.FMouseOver then
  711. begin
  712. //画头像边框
  713. ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
  714. ACanvas.Brush.Color := FListView.FHeadImageBackColor;
  715. R.Left := Rect.Left + 3 + AddLeft;
  716. R.Top := Rect.Top + 4 + AddTop;
  717. R.Right := R.Left + 28;
  718. R.Bottom := R.Top + 28;
  719. ACanvas.Rectangle(R);
  720. end;
  721. R.Left := Rect.Left + 5 + AddLeft;
  722. R.Top := Rect.Top + 6 + AddTop;
  723. R.Right := R.Left + 24;
  724. R.Bottom := R.Top + 24;
  725. if DrawHeadImage then
  726. ACanvas.StretchDraw(R, AHeadPicture.Graphic);
  727. ListItem.FHeadImageRect := R;
  728. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  729. ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
  730. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
  731. ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 28;
  732. ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 28;
  733. if PtInRect(ListItem.FHeadImageRect, P) then
  734. begin
  735. if not ListItem.FMouseInHeadImageRect then
  736. begin
  737. if FMouseInDown then
  738. begin
  739. ListItem.FMouseInHeadImageRect := True;
  740. if FListView.FShowHeadImageButton then
  741. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
  742. end;
  743. end;
  744. end;
  745. if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
  746. begin
  747. AStateIcon := nil;
  748. if ListItem.FLoginState = stLeave then
  749. AStateIcon := FListView.FLeavePictureBig;
  750. if ListItem.FLoginState = stBusy then
  751. AStateIcon := FListView.FBusyPictureBig;
  752. if ListItem.FLoginState = stMute then
  753. AStateIcon := FListView.FMutePictureBig;
  754. if ListItem.FLoginState = stMobileOnline then
  755. AStateIcon := FListView.FMobilePhoneIcon;
  756. if AStateIcon <> nil then
  757. begin
  758. R.Left := R.Right - 11;
  759. R.Top := R.Bottom - 11;
  760. DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 11, 11, 0, 0, DI_NORMAL);
  761. end;
  762. end;
  763. //TextRect
  764. R.Left := Rect.Left;
  765. R.Top := Rect.Top;
  766. R.Right := Rect.Right - 3;
  767. R.Bottom := Rect.Bottom;
  768. if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
  769. ACaption := ListItem.FLoginName
  770. else if FListView.FCaptionStyle = csDisplayName then
  771. ACaption := ListItem.FDisplayName
  772. else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
  773. ACaption := ListItem.FDisplayName;
  774. //else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
  775. // ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
  776. ACanvas.Brush.Style := bsClear;
  777. ACanvas.Font := FListView.Font;
  778. if ListItem.FCaptionColor <> $00FFFFFF then
  779. ACanvas.Font.Color := ListItem.FCaptionColor
  780. else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  781. ACanvas.Font.Color := clGray
  782. else
  783. ACanvas.Font.Color := clBlack;
  784. ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 5, ACaption);
  785. ACaptionWidth := ACanvas.TextWidth(ACaption);
  786. ListItem.FHint := ACaption;
  787. if FListView.FCaptionStyle = csDisplayNameAndLoginName then
  788. begin
  789. ACaption := '<' + ListItem.FLoginName + '>';
  790. ACanvas.Font.Color := clRed;
  791. ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 5, ACaption);
  792. ACaptionWidth := ACaptionWidth + ACanvas.TextWidth(ACaption);
  793. end;
  794. if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
  795. ACaption := '(' + ListItem.FLeaveMessage + ')'
  796. else if (ListItem.FLoginState = stMute) then
  797. ACaption := '(' + StateValues[4] + ')'
  798. else
  799. ACaption := '';
  800. ACanvas.Font.Color := clGray;
  801. ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 5, ACaption);
  802. ListItem.FHint := ListItem.FHint + ACaption;
  803. if (Length(ListItem.FWatchword) = 0) then
  804. ACaption := ''
  805. else
  806. ACaption := ListItem.FWatchword;
  807. //ACaption:= '(' + ListItem.FWatchword + ')';
  808. ACanvas.Font.Color := clGray;
  809. ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 22, ACaption);
  810. ListItem.FHint := ListItem.FHint + ACaption;
  811. {$region '文字区域'}
  812. ListItem.FTextRect := R;
  813. ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  814. ListItem.FTextRect.Left := ListItem.FTextRect.Left + 35;
  815. ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + 35;
  816. {$endregion}
  817. R.Left := Rect.Left + 35 - 20;
  818. R.Top := Rect.Top + 39;
  819. {$region '绘制短信图标'}
  820. if ListItem.HasSMS and FListView.ShowSMSButton then
  821. begin
  822. R.Left := R.Left + 24;
  823. R.Right := R.Left + 16;
  824. R.Bottom := R.Top + 16;
  825. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  826. ListItem.FSMSRect := R;
  827. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  828. ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
  829. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
  830. ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
  831. ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
  832. if PtInRect(ListItem.FSMSRect, P) then
  833. begin
  834. if not ListItem.FMouseInSMSRect then
  835. begin
  836. if FMouseInDown then
  837. begin
  838. ListItem.FMouseInSMSRect := True;
  839. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
  840. end;
  841. end;
  842. end;
  843. end;
  844. {$endregion'}
  845. {$region '绘制信箱图标'}
  846. if ListItem.HasEmail and FListView.ShowEmailButton then
  847. begin
  848. R.Left := R.Left + 24;
  849. R.Right := R.Left + 16;
  850. R.Bottom := R.Top + 16;
  851. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  852. ListItem.FEmailRect := R;
  853. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  854. ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
  855. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
  856. ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
  857. ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
  858. if PtInRect(ListItem.FEmailRect, P) then
  859. begin
  860. if not ListItem.FMouseInEmailRect then
  861. begin
  862. if FMouseInDown then
  863. begin
  864. ListItem.FMouseInEmailRect := True;
  865. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
  866. end;
  867. end;
  868. end;
  869. end;
  870. {$endregion'}
  871. {$region '绘制手机图标'}
  872. if ListItem.FHasMobilePhone and FListView.ShowMobileButton then
  873. begin
  874. R.Left := R.Left + 24;
  875. R.Right := R.Left + 16;
  876. R.Bottom := R.Top + 16;
  877. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  878. ListItem.FMobilePhoneRect := R;
  879. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  880. ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
  881. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
  882. ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
  883. ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
  884. if PtInRect(ListItem.FMobilePhoneRect, P) then
  885. begin
  886. if not ListItem.FMouseInMobilePhoneRect then
  887. begin
  888. if FMouseInDown then
  889. begin
  890. ListItem.FMouseInMobilePhoneRect := True;
  891. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
  892. end;
  893. end;
  894. end;
  895. end;
  896. {$endregion'}
  897. {$region '绘制坐机图标'}
  898. if ListItem.FHasTelephone and FListView.ShowTelButton then
  899. begin
  900. R.Left := R.Left + 24;
  901. R.Right := R.Left + 16;
  902. R.Bottom := R.Top + 16;
  903. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.TelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  904. ListItem.FTelephoneRect := R;
  905. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  906. ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
  907. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
  908. ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
  909. ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
  910. if PtInRect(ListItem.FTelephoneRect, P) then
  911. begin
  912. if not ListItem.FMouseInTelephoneRect then
  913. begin
  914. if FMouseInDown then
  915. begin
  916. ListItem.FMouseInTelephoneRect := True;
  917. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
  918. end;
  919. end;
  920. end;
  921. end;
  922. {$endregion'}
  923. {$region '绘制摄像头图标'}
  924. if ListItem.FHasCamera and FListView.ShowCameraButton then
  925. begin
  926. if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
  927. begin
  928. R.Left := R.Left + 24;
  929. R.Right := R.Left + 16;
  930. R.Bottom := R.Top + 16;
  931. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  932. ListItem.FCameraRect := R;
  933. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  934. ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
  935. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
  936. ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
  937. ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
  938. if PtInRect(ListItem.FCameraRect, P) then
  939. begin
  940. if not ListItem.FMouseInCameraRect then
  941. begin
  942. if FMouseInDown then
  943. begin
  944. ListItem.FMouseInCameraRect := True;
  945. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
  946. end;
  947. end;
  948. end;
  949. end;
  950. end;
  951. {$endregion'}
  952. {$region '绘制增加好友图标'}
  953. if ListItem.FHasAddFriend and FListView.ShowAddFriendButton then
  954. begin
  955. R.Left := R.Left + 24;
  956. R.Right := R.Left + 16;
  957. R.Bottom := R.Top + 16;
  958. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  959. ListItem.FAddFriendRect := R;
  960. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  961. ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
  962. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
  963. ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
  964. ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
  965. if PtInRect(ListItem.FAddFriendRect, P) then
  966. begin
  967. if not ListItem.FMouseInAddFriendRect then
  968. begin
  969. if FMouseInDown then
  970. begin
  971. ListItem.FMouseInAddFriendRect := True;
  972. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
  973. end;
  974. end;
  975. end;
  976. end;
  977. {$endregion'}
  978. end;
  979. lsMiddleHeadImage:
  980. begin
  981. {$region '绘制 24*24 高度的Item'}
  982. if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
  983. begin
  984. NeedDrawImageBorder := True;
  985. AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
  986. end
  987. else
  988. begin
  989. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddle.Graphic);
  990. end;
  991. if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  992. begin
  993. if (FListView.FDefaultPictureMiddleOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
  994. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddleOffline.Graphic)
  995. else
  996. RealICQColors.Grayscale(AHeadPicture.Bitmap);
  997. end;
  998. if NeedDrawImageBorder or ListItem.FMouseOver then
  999. begin
  1000. //画头像边框
  1001. ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
  1002. ACanvas.Brush.Color := FListView.FHeadImageBackColor;
  1003. R.Left := Rect.Left + 3 + AddLeft;
  1004. R.Top := Rect.Top + 4 + AddTop;
  1005. R.Right := R.Left + 28;
  1006. R.Bottom := R.Top + 28;
  1007. ACanvas.Rectangle(R);
  1008. end;
  1009. R.Left := Rect.Left + 5 + AddLeft;
  1010. R.Top := Rect.Top + 6 + AddTop;
  1011. R.Right := R.Left + 24;
  1012. R.Bottom := R.Top + 24;
  1013. if DrawHeadImage then
  1014. ACanvas.StretchDraw(R, AHeadPicture.Graphic);
  1015. ListItem.FHeadImageRect := R;
  1016. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1017. ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
  1018. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
  1019. ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 28;
  1020. ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 28;
  1021. if PtInRect(ListItem.FHeadImageRect, P) then
  1022. begin
  1023. if not ListItem.FMouseInHeadImageRect then
  1024. begin
  1025. if FMouseInDown then
  1026. begin
  1027. ListItem.FMouseInHeadImageRect := True;
  1028. if FListView.FShowHeadImageButton then
  1029. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
  1030. end;
  1031. end;
  1032. end;
  1033. if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
  1034. begin
  1035. AStateIcon := nil;
  1036. if ListItem.FLoginState = stLeave then
  1037. AStateIcon := FListView.FLeavePictureBig;
  1038. if ListItem.FLoginState = stBusy then
  1039. AStateIcon := FListView.FBusyPictureBig;
  1040. if ListItem.FLoginState = stMute then
  1041. AStateIcon := FListView.FMutePictureBig;
  1042. if ListItem.FLoginState = stMobileOnline then
  1043. AStateIcon := FListView.FMobilePhoneIcon;
  1044. if AStateIcon <> nil then
  1045. begin
  1046. R.Left := R.Right - 11;
  1047. R.Top := R.Bottom - 11;
  1048. DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 11, 11, 0, 0, DI_NORMAL);
  1049. end;
  1050. end;
  1051. //TextRect
  1052. R.Left := Rect.Left;
  1053. R.Top := Rect.Top;
  1054. R.Right := Rect.Right - 3;
  1055. R.Bottom := Rect.Bottom;
  1056. if ListItem.FHasCamera then
  1057. if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
  1058. R.Right := R.Right - 24;
  1059. if ListItem.FHasTelephone then
  1060. R.Right := R.Right - 24;
  1061. if ListItem.FHasMobilePhone then
  1062. R.Right := R.Right - 24;
  1063. if ListItem.FHasEmail then
  1064. R.Right := R.Right - 24;
  1065. if ListItem.FHasSMS then
  1066. R.Right := R.Right - 24;
  1067. R.Right := R.Right - 4;
  1068. if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
  1069. ACaption := ListItem.FLoginName
  1070. else if FListView.FCaptionStyle = csDisplayName then
  1071. ACaption := ListItem.FDisplayName
  1072. else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
  1073. ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
  1074. ACanvas.Brush.Style := bsClear;
  1075. ACanvas.Font := FListView.Font;
  1076. if ListItem.FCaptionColor <> $00FFFFFF then
  1077. ACanvas.Font.Color := ListItem.FCaptionColor
  1078. else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  1079. ACanvas.Font.Color := clGray
  1080. else
  1081. ACanvas.Font.Color := clBlack;
  1082. ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 12, ACaption);
  1083. ACaptionWidth := ACanvas.TextWidth(ACaption);
  1084. ListItem.FHint := ACaption;
  1085. if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
  1086. ACaption := '(' + ListItem.FLeaveMessage + ')'
  1087. else if (ListItem.FLoginState = stMute) then
  1088. ACaption := '(' + StateValues[4] + ')'
  1089. else
  1090. ACaption := '';
  1091. ACanvas.Font.Color := clGray;
  1092. ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 12, ACaption);
  1093. Inc(ACaptionWidth, ACanvas.TextWidth(ACaption));
  1094. ListItem.FHint := ListItem.FHint + ACaption;
  1095. if (Length(ListItem.FWatchword) = 0) then
  1096. ACaption := ''
  1097. else
  1098. ACaption := ' - ' + ListItem.FWatchword;
  1099. ACanvas.Font.Color := clGray;
  1100. ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 12, ACaption);
  1101. ListItem.FHint := ListItem.FHint + ACaption;
  1102. {$region '文字区域'}
  1103. ListItem.FTextRect := R;
  1104. ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1105. ListItem.FTextRect.Left := ListItem.FTextRect.Left + 35;
  1106. ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + ItemHeight;
  1107. {$endregion}
  1108. R.Left := Rect.Right;
  1109. R.Top := Rect.Top + 9;
  1110. {$region '绘制摄像头图标'}
  1111. if ListItem.FHasCamera then
  1112. begin
  1113. if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
  1114. begin
  1115. R.Left := R.Left - 24;
  1116. R.Right := R.Left + 16;
  1117. R.Bottom := R.Top + 16;
  1118. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1119. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1120. ListItem.FCameraRect := R;
  1121. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1122. ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
  1123. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
  1124. ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
  1125. ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
  1126. if PtInRect(ListItem.FCameraRect, P) then
  1127. begin
  1128. if not ListItem.FMouseInCameraRect then
  1129. begin
  1130. if FMouseInDown then
  1131. begin
  1132. ListItem.FMouseInCameraRect := True;
  1133. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
  1134. end;
  1135. end;
  1136. end;
  1137. end;
  1138. end;
  1139. {$endregion}
  1140. {$region '绘制坐机图标'}
  1141. if ListItem.HasTelephone then
  1142. begin
  1143. R.Left := R.Left - 24;
  1144. R.Right := R.Left + 16;
  1145. R.Bottom := R.Top + 16;
  1146. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FTelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1147. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1148. ListItem.FTelephoneRect := R;
  1149. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1150. ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
  1151. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
  1152. ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
  1153. ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
  1154. if PtInRect(ListItem.FTelephoneRect, P) then
  1155. begin
  1156. if not ListItem.FMouseInTelephoneRect then
  1157. begin
  1158. if FMouseInDown then
  1159. begin
  1160. ListItem.FMouseInTelephoneRect := True;
  1161. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
  1162. end;
  1163. end;
  1164. end;
  1165. end;
  1166. {$endregion}
  1167. {$region '绘制手机图标'}
  1168. if ListItem.HasMobilePhone then
  1169. begin
  1170. R.Left := R.Left - 24;
  1171. R.Right := R.Left + 16;
  1172. R.Bottom := R.Top + 16;
  1173. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1174. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1175. ListItem.FMobilePhoneRect := R;
  1176. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1177. ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
  1178. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
  1179. ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
  1180. ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
  1181. if PtInRect(ListItem.FMobilePhoneRect, P) then
  1182. begin
  1183. if not ListItem.FMouseInMobilePhoneRect then
  1184. begin
  1185. if FMouseInDown then
  1186. begin
  1187. ListItem.FMouseInMobilePhoneRect := True;
  1188. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
  1189. end;
  1190. end;
  1191. end;
  1192. end;
  1193. {$endregion}
  1194. {$region '绘制信箱图标'}
  1195. if ListItem.HasEmail then
  1196. begin
  1197. R.Left := R.Left - 24;
  1198. R.Right := R.Left + 16;
  1199. R.Bottom := R.Top + 16;
  1200. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1201. ListItem.FEmailRect := R;
  1202. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1203. ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
  1204. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
  1205. ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
  1206. ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
  1207. if PtInRect(ListItem.FEmailRect, P) then
  1208. begin
  1209. if not ListItem.FMouseInEmailRect then
  1210. begin
  1211. if FMouseInDown then
  1212. begin
  1213. ListItem.FMouseInEmailRect := True;
  1214. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
  1215. end;
  1216. end;
  1217. end;
  1218. end;
  1219. {$endregion'}
  1220. {$region '绘制短信图标'}
  1221. if ListItem.HasSMS then
  1222. begin
  1223. R.Left := R.Left - 24;
  1224. R.Right := R.Left + 16;
  1225. R.Bottom := R.Top + 16;
  1226. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1227. ListItem.FSMSRect := R;
  1228. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1229. ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
  1230. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
  1231. ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
  1232. ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
  1233. if PtInRect(ListItem.FSMSRect, P) then
  1234. begin
  1235. if not ListItem.FMouseInSMSRect then
  1236. begin
  1237. if FMouseInDown then
  1238. begin
  1239. ListItem.FMouseInSMSRect := True;
  1240. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
  1241. end;
  1242. end;
  1243. end;
  1244. end;
  1245. {$endregion'}
  1246. {$endregion}
  1247. {$region '绘制增加好友图标'}
  1248. if ListItem.FHasAddFriend then
  1249. begin
  1250. R.Left := R.Left - 28;
  1251. R.Right := R.Left + 16;
  1252. R.Bottom := R.Top + 16;
  1253. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1254. ListItem.FAddFriendRect := R;
  1255. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1256. ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
  1257. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
  1258. ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
  1259. ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
  1260. if PtInRect(ListItem.FAddFriendRect, P) then
  1261. begin
  1262. if not ListItem.FMouseInAddFriendRect then
  1263. begin
  1264. if FMouseInDown then
  1265. begin
  1266. ListItem.FMouseInAddFriendRect := True;
  1267. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
  1268. end;
  1269. end;
  1270. end;
  1271. end;
  1272. {$endregion'}
  1273. end;
  1274. lsSmallHeadImage:
  1275. begin
  1276. {$region '绘制 16*16 高度的Item'}
  1277. if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
  1278. begin
  1279. NeedDrawImageBorder := ListItem.StateIndex = 1;
  1280. AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
  1281. end
  1282. else
  1283. begin
  1284. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmall.Graphic);
  1285. end;
  1286. if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  1287. begin
  1288. if (FListView.FDefaultPictureSmallOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
  1289. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmallOffline.Graphic)
  1290. else
  1291. RealICQColors.Grayscale(AHeadPicture.Bitmap);
  1292. end;
  1293. if NeedDrawImageBorder or ListItem.FMouseOver then
  1294. begin
  1295. //画头像边框
  1296. ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
  1297. ACanvas.Brush.Color := FListView.FHeadImageBackColor;
  1298. R.Left := Rect.Left + 3 + AddLeft;
  1299. R.Top := Rect.Top + 4 + AddTop;
  1300. R.Right := R.Left + 20;
  1301. R.Bottom := R.Top + 20;
  1302. ACanvas.Rectangle(R);
  1303. end;
  1304. R.Left := Rect.Left + 5 + AddLeft;
  1305. R.Top := Rect.Top + 6 + AddTop;
  1306. R.Right := R.Left + 16;
  1307. R.Bottom := R.Top + 16;
  1308. if DrawHeadImage then
  1309. ACanvas.StretchDraw(R, AHeadPicture.Graphic);
  1310. ListItem.FHeadImageRect := R;
  1311. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1312. ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
  1313. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
  1314. ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 20;
  1315. ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 20;
  1316. if PtInRect(ListItem.FHeadImageRect, P) then
  1317. begin
  1318. if not ListItem.FMouseInHeadImageRect then
  1319. begin
  1320. if FMouseInDown then
  1321. begin
  1322. ListItem.FMouseInHeadImageRect := True;
  1323. if FListView.FShowHeadImageButton then
  1324. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
  1325. end;
  1326. end;
  1327. end;
  1328. if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
  1329. begin
  1330. AStateIcon := nil;
  1331. if ListItem.FLoginState = stLeave then
  1332. AStateIcon := FListView.FLeavePicture;
  1333. if ListItem.FLoginState = stBusy then
  1334. AStateIcon := FListView.FBusyPicture;
  1335. if ListItem.FLoginState = stMute then
  1336. AStateIcon := FListView.FMutePicture;
  1337. if ListItem.FLoginState = stMobileOnline then
  1338. AStateIcon := FListView.FMobilePhoneIcon;
  1339. if AStateIcon <> nil then
  1340. begin
  1341. R.Left := R.Right - 9;
  1342. R.Top := R.Bottom - 9;
  1343. DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 9, 9, 0, 0, DI_NORMAL);
  1344. end;
  1345. end;
  1346. //TextRect
  1347. R.Left := Rect.Left;
  1348. R.Top := Rect.Top;
  1349. R.Right := Rect.Right - 3;
  1350. R.Bottom := Rect.Bottom;
  1351. if ListItem.FHasCamera then
  1352. if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
  1353. R.Right := R.Right - 24;
  1354. if ListItem.FHasTelephone then
  1355. R.Right := R.Right - 24;
  1356. if ListItem.FHasMobilePhone then
  1357. R.Right := R.Right - 24;
  1358. if ListItem.FHasEmail then
  1359. R.Right := R.Right - 24;
  1360. if ListItem.FHasSMS then
  1361. R.Right := R.Right - 24;
  1362. R.Right := R.Right - 4;
  1363. if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
  1364. ACaption := ListItem.FLoginName
  1365. else if FListView.FCaptionStyle = csDisplayName then
  1366. ACaption := ListItem.FDisplayName
  1367. else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
  1368. ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
  1369. ACanvas.Brush.Style := bsClear;
  1370. ACanvas.Font := FListView.Font;
  1371. if ListItem.FCaptionColor <> $00FFFFFF then
  1372. ACanvas.Font.Color := ListItem.FCaptionColor
  1373. else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  1374. ACanvas.Font.Color := clGray
  1375. else
  1376. ACanvas.Font.Color := clBlack;
  1377. ACanvas.TextRect(R, Rect.Left + 27, Rect.Top + 8, ACaption);
  1378. ACaptionWidth := ACanvas.TextWidth(ACaption);
  1379. ListItem.FHint := ACaption;
  1380. if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
  1381. ACaption := '(' + ListItem.FLeaveMessage + ')'
  1382. else if (ListItem.FLoginState = stMute) then
  1383. ACaption := '(' + StateValues[4] + ')'
  1384. else
  1385. ACaption := '';
  1386. ACanvas.Font.Color := clGray;
  1387. ACanvas.TextRect(R, Rect.Left + 27 + ACaptionWidth, Rect.Top + 8, ACaption);
  1388. Inc(ACaptionWidth, ACanvas.TextWidth(ACaption));
  1389. ListItem.FHint := ListItem.FHint + ACaption;
  1390. if (Length(ListItem.FWatchword) = 0) then
  1391. ACaption := ''
  1392. else
  1393. ACaption := ' - ' + ListItem.FWatchword;
  1394. ACanvas.Font.Color := clGray;
  1395. ACanvas.TextRect(R, Rect.Left + 27 + ACaptionWidth, Rect.Top + 8, ACaption);
  1396. ListItem.FHint := ListItem.FHint + ACaption;
  1397. {$region '文字区域'}
  1398. ListItem.FTextRect := R;
  1399. ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1400. ListItem.FTextRect.Left := ListItem.FTextRect.Left + 27;
  1401. ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + ItemHeight;
  1402. {$endregion}
  1403. R.Left := Rect.Right;
  1404. R.Top := Rect.Top + 6;
  1405. {$region '绘制摄像头图标'}
  1406. if ListItem.FHasCamera then
  1407. begin
  1408. if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
  1409. begin
  1410. R.Left := R.Left - 24;
  1411. R.Right := R.Left + 16;
  1412. R.Bottom := R.Top + 16;
  1413. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1414. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1415. ListItem.FCameraRect := R;
  1416. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1417. ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
  1418. ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
  1419. ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
  1420. ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
  1421. if PtInRect(ListItem.FCameraRect, P) then
  1422. begin
  1423. if not ListItem.FMouseInCameraRect then
  1424. begin
  1425. if FMouseInDown then
  1426. begin
  1427. ListItem.FMouseInCameraRect := True;
  1428. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
  1429. end;
  1430. end;
  1431. end;
  1432. end;
  1433. end;
  1434. {$endregion}
  1435. {$region '绘制坐机图标'}
  1436. if ListItem.HasTelephone then
  1437. begin
  1438. R.Left := R.Left - 24;
  1439. R.Right := R.Left + 16;
  1440. R.Bottom := R.Top + 16;
  1441. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FTelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1442. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1443. ListItem.FTelephoneRect := R;
  1444. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1445. ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
  1446. ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
  1447. ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
  1448. ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
  1449. if PtInRect(ListItem.FTelephoneRect, P) then
  1450. begin
  1451. if not ListItem.FMouseInTelephoneRect then
  1452. begin
  1453. if FMouseInDown then
  1454. begin
  1455. ListItem.FMouseInTelephoneRect := True;
  1456. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
  1457. end;
  1458. end;
  1459. end;
  1460. end;
  1461. {$endregion}
  1462. {$region '绘制手机图标'}
  1463. if ListItem.HasMobilePhone then
  1464. begin
  1465. R.Left := R.Left - 24;
  1466. R.Right := R.Left + 16;
  1467. R.Bottom := R.Top + 16;
  1468. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1469. //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
  1470. ListItem.FMobilePhoneRect := R;
  1471. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1472. ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
  1473. ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
  1474. ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
  1475. ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
  1476. if PtInRect(ListItem.FMobilePhoneRect, P) then
  1477. begin
  1478. if not ListItem.FMouseInMobilePhoneRect then
  1479. begin
  1480. if FMouseInDown then
  1481. begin
  1482. ListItem.FMouseInMobilePhoneRect := True;
  1483. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
  1484. end;
  1485. end;
  1486. end;
  1487. end;
  1488. {$endregion}
  1489. {$region '绘制信箱图标'}
  1490. if ListItem.HasEmail then
  1491. begin
  1492. R.Left := R.Left - 24;
  1493. R.Right := R.Left + 16;
  1494. R.Bottom := R.Top + 16;
  1495. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1496. ListItem.FEmailRect := R;
  1497. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1498. ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
  1499. ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
  1500. ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
  1501. ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
  1502. if PtInRect(ListItem.FEmailRect, P) then
  1503. begin
  1504. if not ListItem.FMouseInEmailRect then
  1505. begin
  1506. if FMouseInDown then
  1507. begin
  1508. ListItem.FMouseInEmailRect := True;
  1509. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
  1510. end;
  1511. end;
  1512. end;
  1513. end;
  1514. {$endregion'}
  1515. {$region '绘制短信图标'}
  1516. if ListItem.HasSMS then
  1517. begin
  1518. R.Left := R.Left - 23;
  1519. R.Right := R.Left + 16;
  1520. R.Bottom := R.Top + 16;
  1521. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1522. ListItem.FSMSRect := R;
  1523. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1524. ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
  1525. ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
  1526. ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
  1527. ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
  1528. if PtInRect(ListItem.FSMSRect, P) then
  1529. begin
  1530. if not ListItem.FMouseInSMSRect then
  1531. begin
  1532. if FMouseInDown then
  1533. begin
  1534. ListItem.FMouseInSMSRect := True;
  1535. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
  1536. end;
  1537. end;
  1538. end;
  1539. end;
  1540. {$endregion'}
  1541. {$endregion}
  1542. {$region '绘制增加好友图标'}
  1543. if ListItem.FHasAddFriend then
  1544. begin
  1545. R.Left := R.Left - 23;
  1546. R.Right := R.Left + 16;
  1547. R.Bottom := R.Top + 16;
  1548. DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
  1549. ListItem.FAddFriendRect := R;
  1550. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1551. ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
  1552. ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
  1553. ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
  1554. ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
  1555. if PtInRect(ListItem.FAddFriendRect, P) then
  1556. begin
  1557. if not ListItem.FMouseInAddFriendRect then
  1558. begin
  1559. if FMouseInDown then
  1560. begin
  1561. ListItem.FMouseInAddFriendRect := True;
  1562. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
  1563. end;
  1564. end;
  1565. end;
  1566. end;
  1567. {$endregion'}
  1568. end;
  1569. lsNoHeadImage:
  1570. begin
  1571. {$region '绘制 16*16 高度的Item'}
  1572. if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
  1573. begin
  1574. NeedDrawImageBorder := ListItem.StateIndex = 1;
  1575. AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
  1576. end
  1577. else
  1578. begin
  1579. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmall.Graphic);
  1580. end;
  1581. if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  1582. begin
  1583. if (FListView.FDefaultPictureSmallOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
  1584. AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmallOffline.Graphic)
  1585. else
  1586. RealICQColors.Grayscale(AHeadPicture.Bitmap);
  1587. end;
  1588. if NeedDrawImageBorder or ListItem.FMouseOver then
  1589. begin
  1590. //画头像边框
  1591. ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
  1592. ACanvas.Brush.Color := FListView.FHeadImageBackColor;
  1593. R.Left := Rect.Left + 3 + AddLeft;
  1594. R.Top := Rect.Top + 4 + AddTop;
  1595. R.Right := R.Left + 20;
  1596. R.Bottom := R.Top + 20;
  1597. ACanvas.Rectangle(R);
  1598. end;
  1599. R.Left := Rect.Left + 5 + AddLeft;
  1600. R.Top := Rect.Top + 6 + AddTop;
  1601. R.Right := R.Left + 16;
  1602. R.Bottom := R.Top + 16;
  1603. if DrawHeadImage then
  1604. ACanvas.StretchDraw(R, AHeadPicture.Graphic);
  1605. ListItem.FHeadImageRect := R;
  1606. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
  1607. ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
  1608. ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
  1609. ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 20;
  1610. ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 20;
  1611. if PtInRect(ListItem.FHeadImageRect, P) then
  1612. begin
  1613. if not ListItem.FMouseInHeadImageRect then
  1614. begin
  1615. if FMouseInDown then
  1616. begin
  1617. ListItem.FMouseInHeadImageRect := True;
  1618. if FListView.FShowHeadImageButton then
  1619. DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
  1620. end;
  1621. end;
  1622. end;
  1623. if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
  1624. begin
  1625. AStateIcon := nil;
  1626. if ListItem.FLoginState = stLeave then
  1627. AStateIcon := FListView.FLeavePicture;
  1628. if ListItem.FLoginState = stBusy then
  1629. AStateIcon := FListView.FBusyPicture;
  1630. if ListItem.FLoginState = stMute then
  1631. AStateIcon := FListView.FMutePicture;
  1632. if ListItem.FLoginState = stMobileOnline then
  1633. AStateIcon := FListView.FMobilePhoneIcon;
  1634. if AStateIcon <> nil then
  1635. begin
  1636. R.Left := R.Right - 9;
  1637. R.Top := R.Bottom - 9;
  1638. DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 9, 9, 0, 0, DI_NORMAL);
  1639. end;
  1640. end;
  1641. //TextRect
  1642. R.Left := Rect.Left;
  1643. R.Top := Rect.Top;
  1644. R.Right := Rect.Right - 3;
  1645. R.Bottom := Rect.Bottom;
  1646. if ListItem.Company <> '' then
  1647. b := ListItem.Company
  1648. else if ListItem.Branch <> '' then
  1649. b := ListItem.Branch;
  1650. if ListItem.DisplayName <> '' then
  1651. n := ListItem.DisplayName
  1652. else
  1653. n := ListItem.LoginName;
  1654. ACaption := GetCaption(ListItem.ServerName, b, n);
  1655. ACanvas.Brush.Style := bsClear;
  1656. ACanvas.Font := FListView.Font;
  1657. if ListItem.FCaptionColor <> $00FFFFFF then
  1658. ACanvas.Font.Color := ListItem.FCaptionColor
  1659. else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
  1660. ACanvas.Font.Color := clGray
  1661. else
  1662. ACanvas.Font.Color := clBlack;
  1663. ACanvas.TextRect(R, Rect.Left + 27, Rect.Top + 8, ACaption);
  1664. ACaptionWidth := ACanvas.TextWidth(ACaption);
  1665. end;
  1666. end;
  1667. finally
  1668. AHeadPicture.Free;
  1669. end;
  1670. with ListItem do
  1671. begin
  1672. {if not FListView.FShowHeadImageButton then
  1673. begin
  1674. FHeadImageRect.Left := 0;
  1675. FHeadImageRect.Top := 0;
  1676. FHeadImageRect.Right := 0;
  1677. FHeadImageRect.Bottom := 0;
  1678. end;}
  1679. if not FListView.FShowCameraButton then
  1680. begin
  1681. FCameraRect.Left := 0;
  1682. FCameraRect.Top := 0;
  1683. FCameraRect.Right := 0;
  1684. FCameraRect.Bottom := 0;
  1685. end;
  1686. if not FListView.FShowTelButton then
  1687. begin
  1688. FTelephoneRect.Left := 0;
  1689. FTelephoneRect.Top := 0;
  1690. FTelephoneRect.Right := 0;
  1691. FTelephoneRect.Bottom := 0;
  1692. end;
  1693. if not FListView.FShowMobileButton then
  1694. begin
  1695. FMobilePhoneRect.Left := 0;
  1696. FMobilePhoneRect.Top := 0;
  1697. FMobilePhoneRect.Right := 0;
  1698. FMobilePhoneRect.Bottom := 0;
  1699. end;
  1700. if not FListView.FShowEmailButton then
  1701. begin
  1702. FEmailRect.Left := 0;
  1703. FEmailRect.Top := 0;
  1704. FEmailRect.Right := 0;
  1705. FEmailRect.Bottom := 0;
  1706. end;
  1707. if not FListView.FShowSMSButton then
  1708. begin
  1709. FSMSRect.Left := 0;
  1710. FSMSRect.Top := 0;
  1711. FSMSRect.Right := 0;
  1712. FSMSRect.Bottom := 0;
  1713. end;
  1714. if not FListView.FShowAddFriendButton then
  1715. begin
  1716. FAddFriendRect.Left := 0;
  1717. FAddFriendRect.Top := 0;
  1718. FAddFriendRect.Right := 0;
  1719. FAddFriendRect.Bottom := 0;
  1720. end;
  1721. end;
  1722. end;
  1723. procedure TNoScrollListBox.CNDrawItem(var Message: TWMDrawItem);
  1724. var
  1725. State: TOwnerDrawState;
  1726. R: TRect;
  1727. begin
  1728. with Message.DrawItemStruct^ do
  1729. begin
  1730. State := TOwnerDrawState(LongRec(itemState).Lo);
  1731. Canvas.Handle := hDC;
  1732. try
  1733. //FBufferedBitmap.Canvas.Lock;
  1734. //Canvas.Lock;
  1735. Canvas.Font := Font;
  1736. Canvas.Brush := Brush;
  1737. if itemID >= Cardinal(Items.Count - 1) then
  1738. begin
  1739. R.Left := rcItem.Left;
  1740. R.Top := rcItem.Bottom;
  1741. R.Right := ClientWidth;
  1742. R.Bottom := ClientHeight;
  1743. Canvas.Brush.Color := clWhite;
  1744. Canvas.FillRect(R);
  1745. end;
  1746. //启用缓冲,先在 FBufferedBitmap 绘好图形
  1747. FBufferedBitmap.Width := rcItem.Right - rcItem.Left;
  1748. FBufferedBitmap.Height := rcItem.Bottom - rcItem.Top;
  1749. FBufferedBitmap.Canvas.Brush.Color := clWhite;
  1750. FBufferedBitmap.Canvas.Pen.Color := clBlack;
  1751. R.Left := 0;
  1752. R.Top := 0;
  1753. R.Right := FBufferedBitmap.Width;
  1754. R.Bottom := FBufferedBitmap.Height;
  1755. if Integer(itemID) >= 0 then
  1756. DrawContacterItem(FBufferedBitmap.Canvas, itemID, R, State)
  1757. else
  1758. FBufferedBitmap.Canvas.FillRect(R);
  1759. //将绘好的图形复制到Canvas上去
  1760. Canvas.CopyRect(rcItem, FBufferedBitmap.Canvas, R);
  1761. finally
  1762. //Canvas.Unlock;
  1763. //FBufferedBitmap.Canvas.Unlock;
  1764. Canvas.Handle := 0;
  1765. end;
  1766. end;
  1767. FListView.FListBoxScrollBar.DrawScrollBar;
  1768. end;
  1769. {TRealICQScrollBar}
  1770. procedure TListBoxScrollBar.TopButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1771. var
  1772. WaitTimes: Integer;
  1773. begin
  1774. FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureDown);
  1775. FButtonDown := True;
  1776. WaitTimes := 0;
  1777. while FButtonDown do
  1778. begin
  1779. if (WaitTimes = 0) or (WaitTimes > 10) then
  1780. begin
  1781. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEUP, 0);
  1782. DrawScrollBar;
  1783. end;
  1784. Application.ProcessMessages;
  1785. Sleep(50);
  1786. Inc(WaitTimes);
  1787. end;
  1788. end;
  1789. procedure TListBoxScrollBar.TopButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1790. begin
  1791. FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureHover);
  1792. FButtonDown := False;
  1793. end;
  1794. procedure TListBoxScrollBar.TopButtonImageMouseEnter(Sender: TObject);
  1795. begin
  1796. FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureHover);
  1797. end;
  1798. procedure TListBoxScrollBar.TopButtonImageMouseLeave(Sender: TObject);
  1799. begin
  1800. FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureNormal);
  1801. end;
  1802. procedure TListBoxScrollBar.BottomButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1803. var
  1804. WaitTimes: Integer;
  1805. begin
  1806. FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureDown);
  1807. FButtonDown := True;
  1808. WaitTimes := 0;
  1809. while FButtonDown do
  1810. begin
  1811. if (WaitTimes = 0) or (WaitTimes > 10) then
  1812. begin
  1813. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
  1814. DrawScrollBar;
  1815. end;
  1816. Application.ProcessMessages;
  1817. Sleep(50);
  1818. Inc(WaitTimes);
  1819. end;
  1820. end;
  1821. procedure TListBoxScrollBar.BottomButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1822. begin
  1823. FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureHover);
  1824. FButtonDown := False;
  1825. end;
  1826. procedure TListBoxScrollBar.BottomButtonImageMouseEnter(Sender: TObject);
  1827. begin
  1828. FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureHover);
  1829. end;
  1830. procedure TListBoxScrollBar.BottomButtonImageMouseLeave(Sender: TObject);
  1831. begin
  1832. FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureNormal);
  1833. end;
  1834. procedure TListBoxScrollBar.BarButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1835. begin
  1836. FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureDown);
  1837. FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureDown);
  1838. FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureDown);
  1839. FTrackingBarDown := True;
  1840. FTrackingBarDonwY := Y;
  1841. end;
  1842. procedure TListBoxScrollBar.BarButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1843. begin
  1844. FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureHover);
  1845. FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureHover);
  1846. FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureHover);
  1847. FTrackingBarDown := False;
  1848. end;
  1849. procedure TListBoxScrollBar.BarButtonImageMouseEnter(Sender: TObject);
  1850. begin
  1851. FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureHover);
  1852. FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureHover);
  1853. FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureHover);
  1854. end;
  1855. procedure TListBoxScrollBar.BarButtonImageMouseLeave(Sender: TObject);
  1856. begin
  1857. FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureNormal);
  1858. FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureNormal);
  1859. FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureNormal);
  1860. end;
  1861. procedure TListBoxScrollBar.BarButtonImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  1862. var
  1863. MovedYValue, Increment, ModeValue, DivValue: Integer;
  1864. begin
  1865. if FTrackingBarDown then
  1866. begin
  1867. MovedYValue := (Y - FTrackingBarDonwY);
  1868. FMovedYValue := FMovedYValue + MovedYValue;
  1869. if FBarButtonTopImage.Top + MovedYValue < (FTopButtonImage.Height + 1) then
  1870. FBarButtonTopImage.Top := (FTopButtonImage.Height + 1)
  1871. else if FBarButtonTopImage.Top + MovedYValue > (FTopButtonImage.Height + 1) + FTrackingBarTopRange then
  1872. FBarButtonTopImage.Top := (FTopButtonImage.Height + 1) + FTrackingBarTopRange
  1873. else
  1874. FBarButtonTopImage.Top := FBarButtonTopImage.Top + MovedYValue;
  1875. FBarButtonMiddleImage.Top := FBarButtonTopImage.Top + FBarButtonTopImage.Height;
  1876. FBarButtonBottomImage.Top := FBarButtonMiddleImage.Top + FBarButtonMiddleImage.Height;
  1877. Increment := Round((FClientRange - FListView.Height) * (FMovedYValue / FTrackingBarTopRange));
  1878. if ABS(Increment) < FListView.FNoScrollListBox.ItemHeight then
  1879. Exit;
  1880. ModeValue := Increment mod FListView.FNoScrollListBox.ItemHeight;
  1881. if ModeValue <> 0 then
  1882. begin
  1883. if ModeValue > FListView.FNoScrollListBox.ItemHeight / 2 then
  1884. begin
  1885. Increment := Increment + (FListView.FNoScrollListBox.ItemHeight - ModeValue);
  1886. end
  1887. else
  1888. begin
  1889. Increment := Increment - ModeValue;
  1890. end;
  1891. end;
  1892. Repaint;
  1893. DivValue := Increment div FListView.FNoScrollListBox.ItemHeight;
  1894. if FListView.FNoScrollListBox.TopIndex + DivValue < 0 then
  1895. FListView.FNoScrollListBox.TopIndex := 0
  1896. else if FListView.FNoScrollListBox.TopIndex + DivValue >= FListView.FNoScrollListBox.Items.Count then
  1897. FListView.FNoScrollListBox.TopIndex := FListView.FNoScrollListBox.Items.Count - 1
  1898. else
  1899. FListView.FNoScrollListBox.TopIndex := FListView.FNoScrollListBox.TopIndex + DivValue;
  1900. FTrackingBarDown := False;
  1901. DrawScrollBar;
  1902. FTrackingBarDown := True;
  1903. Repaint;
  1904. FMovedYValue := 0;
  1905. end;
  1906. end;
  1907. procedure TListBoxScrollBar.BackgroundImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1908. var
  1909. WaitTimes: Integer;
  1910. begin
  1911. FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureDown);
  1912. if (Y > FBarButtonTopImage.Top - 10) and (Y < (FBarButtonBottomImage.Top + FBarButtonBottomImage.Height) + 10) then
  1913. exit;
  1914. FButtonDown := True;
  1915. WaitTimes := 0;
  1916. while FButtonDown do
  1917. begin
  1918. if (WaitTimes = 0) or (WaitTimes > 10) then
  1919. begin
  1920. if Y < FBarButtonTopImage.Top then
  1921. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_PAGEUP, 0)
  1922. else if Y > (FBarButtonBottomImage.Top + FBarButtonBottomImage.Height) then
  1923. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_PAGEDOWN, 0);
  1924. DrawScrollBar;
  1925. end;
  1926. Application.ProcessMessages;
  1927. Sleep(50);
  1928. Inc(WaitTimes);
  1929. end;
  1930. end;
  1931. procedure TListBoxScrollBar.BackgroundImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1932. begin
  1933. FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureHover);
  1934. FButtonDown := False;
  1935. end;
  1936. procedure TListBoxScrollBar.BackgroundImageMouseEnter(Sender: TObject);
  1937. begin
  1938. FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureHover);
  1939. end;
  1940. procedure TListBoxScrollBar.BackgroundImageMouseLeave(Sender: TObject);
  1941. begin
  1942. FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureNormal);
  1943. end;
  1944. procedure TListBoxScrollBar.ListBoxResize(Sender: TObject);
  1945. begin
  1946. DrawScrollBar;
  1947. end;
  1948. procedure TListBoxScrollBar.ListBoxConstrainedResize(Sender: TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer);
  1949. begin
  1950. //DrawScrollBar;
  1951. end;
  1952. procedure TListBoxScrollBar.ListBoxMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
  1953. begin
  1954. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEUP, 0);
  1955. DrawScrollBar;
  1956. Handled := True;
  1957. end;
  1958. procedure TListBoxScrollBar.ListBoxMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
  1959. begin
  1960. PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
  1961. DrawScrollBar;
  1962. Handled := True;
  1963. end;
  1964. procedure TListBoxScrollBar.DrawScrollBar;
  1965. var
  1966. FixedBarButtonHeight: Integer;
  1967. begin
  1968. if FTrackingBarDown then
  1969. Exit;
  1970. if FDrawing then
  1971. Exit;
  1972. FDrawing := True;
  1973. FClientRange := FListView.Items.Count * FListView.FNoScrollListBox.ItemHeight;
  1974. FListView.FNoScrollListBox.OnResize := nil;
  1975. FListView.FNoScrollListBox.OnConstrainedResize := nil;
  1976. DisableAlign;
  1977. try
  1978. if (FClientRange <= FListView.Height) or (FClientRange <= 0) then
  1979. begin
  1980. FListView.FNoScrollListBox.Width := FListView.Width;
  1981. Width := 0;
  1982. Exit;
  1983. end;
  1984. FixedBarButtonHeight := FTopButtonImage.Height + FBottomButtonImage.Height;
  1985. if (FixedBarButtonHeight >= FListView.Height) then
  1986. begin
  1987. FListView.FNoScrollListBox.Width := FListView.Width;
  1988. Width := 0;
  1989. Exit;
  1990. end;
  1991. FixedBarButtonHeight := FixedBarButtonHeight + FListView.FScrollBarButtonTopPictureNormal.Height + FListView.FScrollBarButtonBottomPictureNormal.Height + 2;
  1992. if (FixedBarButtonHeight >= FListView.Height) then
  1993. begin
  1994. FBarButtonTopImage.Visible := False;
  1995. FBarButtonMiddleImage.Visible := False;
  1996. FBarButtonBottomImage.Visible := False;
  1997. end
  1998. else
  1999. begin
  2000. FBarButtonTopImage.Visible := True;
  2001. FBarButtonMiddleImage.Visible := True;
  2002. FBarButtonBottomImage.Visible := True;
  2003. end;
  2004. FClientRange := FClientRange + FListView.Height mod FListView.FNoScrollListBox.ItemHeight;
  2005. FScrollRange := FListView.Height - FixedBarButtonHeight;
  2006. Visible := True;
  2007. Width := FListView.FScrollTopButtonPictureNormal.Width;
  2008. Height := FListView.Height;
  2009. FListView.FNoScrollListBox.Width := FListView.Width - Width;
  2010. if not FAssignedPicture then
  2011. FTopButtonImage.Picture.Assign(FListView.FScrollTopButtonPictureNormal);
  2012. FTopButtonImage.Left := 0;
  2013. FTopButtonImage.Top := 0;
  2014. if not FAssignedPicture then
  2015. FBottomButtonImage.Picture.Assign(FListView.FScrollBottomButtonPictureNormal);
  2016. FBottomButtonImage.Left := 0;
  2017. FBottomButtonImage.Top := FListView.Height - FTopButtonImage.Height;
  2018. if not FAssignedPicture then
  2019. FBarButtonTopImage.Picture.Assign(FListView.FScrollBarButtonTopPictureNormal);
  2020. FBarButtonTopImage.Left := 0;
  2021. if not FAssignedPicture then
  2022. FBarButtonMiddleImage.Picture.Assign(FListView.FScrollBarButtonMiddlePictureNormal);
  2023. FBarButtonMiddleImage.Left := 0;
  2024. FBarButtonMiddleImage.Height := Round(FScrollRange * (FListView.Height / FClientRange));
  2025. FBarButtonMiddleImage.Width := FListView.FScrollBarButtonMiddlePictureNormal.Width;
  2026. if not FAssignedPicture then
  2027. FBarButtonBottomImage.Picture.Assign(FListView.FScrollBarButtonBottomPictureNormal);
  2028. FBarButtonBottomImage.Left := 0;
  2029. FTrackingBarTopRange := FScrollRange - FBarButtonMiddleImage.Height - 1;
  2030. FBarButtonTopImage.Top := (FTopButtonImage.Height + 1) + Round(FTrackingBarTopRange * ((FListView.FNoScrollListBox.TopIndex * FListView.FNoScrollListBox.ItemHeight) / (FClientRange - FListView.Height)));
  2031. FBarButtonMiddleImage.Top := FBarButtonTopImage.Top + FBarButtonTopImage.Height;
  2032. FBarButtonBottomImage.Top := FBarButtonMiddleImage.Top + FBarButtonMiddleImage.Height;
  2033. if not FAssignedPicture then
  2034. FBackgroundImage.Picture.Assign(FListView.FScrollBackgroundPictureNormal);
  2035. FBackgroundImage.SendToBack;
  2036. FAssignedPicture := True;
  2037. finally
  2038. EnableAlign;
  2039. FDrawing := False;
  2040. FListView.FNoScrollListBox.OnResize := ListBoxResize;
  2041. FListView.FNoScrollListBox.OnConstrainedResize := ListBoxConstrainedResize;
  2042. end;
  2043. end;
  2044. constructor TListBoxScrollBar.Create(AOwner: TComponent);
  2045. begin
  2046. inherited Create(AOwner);
  2047. Width := 20;
  2048. Height := 180;
  2049. Caption := '';
  2050. DoubleBuffered := True;
  2051. ParentColor := True;
  2052. BevelInner := bvNone;
  2053. BevelOuter := bvNone;
  2054. FDrawing := False;
  2055. FTopButtonImage := TRealICQHoverImage.Create(Self);
  2056. FTopButtonImage.Parent := Self;
  2057. FTopButtonImage.AutoSize := True;
  2058. FTopButtonImage.Transparent := True;
  2059. FTopButtonImage.Anchors := [akLeft, akTop];
  2060. FTopButtonImage.OnMouseEnter := TopButtonImageMouseEnter;
  2061. FTopButtonImage.OnMouseLeave := TopButtonImageMouseLeave;
  2062. FTopButtonImage.OnMouseDown := TopButtonImageMouseDown;
  2063. FTopButtonImage.OnMouseUp := TopButtonImageMouseUp;
  2064. FBottomButtonImage := TRealICQHoverImage.Create(Self);
  2065. FBottomButtonImage.Parent := Self;
  2066. FBottomButtonImage.AutoSize := True;
  2067. FBottomButtonImage.Transparent := True;
  2068. FBottomButtonImage.Anchors := [akLeft, akBottom];
  2069. FBottomButtonImage.OnMouseEnter := BottomButtonImageMouseEnter;
  2070. FBottomButtonImage.OnMouseLeave := BottomButtonImageMouseLeave;
  2071. FBottomButtonImage.OnMouseDown := BottomButtonImageMouseDown;
  2072. FBottomButtonImage.OnMouseUp := BottomButtonImageMouseUp;
  2073. FBarButtonTopImage := TRealICQHoverImage.Create(Self);
  2074. FBarButtonTopImage.Parent := Self;
  2075. FBarButtonTopImage.AutoSize := True;
  2076. FBarButtonTopImage.Transparent := False;
  2077. FBarButtonTopImage.OnMouseEnter := BarButtonImageMouseEnter;
  2078. FBarButtonTopImage.OnMouseLeave := BarButtonImageMouseLeave;
  2079. FBarButtonTopImage.OnMouseDown := BarButtonImageMouseDown;
  2080. FBarButtonTopImage.OnMouseUp := BarButtonImageMouseUp;
  2081. FBarButtonTopImage.OnMouseMove := BarButtonImageMouseMove;
  2082. FBarButtonMiddleImage := TRealICQHoverImage.Create(Self);
  2083. FBarButtonMiddleImage.Parent := Self;
  2084. FBarButtonMiddleImage.AutoSize := False;
  2085. FBarButtonMiddleImage.Transparent := False;
  2086. FBarButtonMiddleImage.Stretch := True;
  2087. FBarButtonMiddleImage.OnMouseEnter := BarButtonImageMouseEnter;
  2088. FBarButtonMiddleImage.OnMouseLeave := BarButtonImageMouseLeave;
  2089. FBarButtonMiddleImage.OnMouseDown := BarButtonImageMouseDown;
  2090. FBarButtonMiddleImage.OnMouseUp := BarButtonImageMouseUp;
  2091. FBarButtonMiddleImage.OnMouseMove := BarButtonImageMouseMove;
  2092. FBarButtonBottomImage := TRealICQHoverImage.Create(Self);
  2093. FBarButtonBottomImage.Parent := Self;
  2094. FBarButtonBottomImage.AutoSize := True;
  2095. FBarButtonBottomImage.Transparent := False;
  2096. FBarButtonBottomImage.OnMouseEnter := BarButtonImageMouseEnter;
  2097. FBarButtonBottomImage.OnMouseLeave := BarButtonImageMouseLeave;
  2098. FBarButtonBottomImage.OnMouseDown := BarButtonImageMouseDown;
  2099. FBarButtonBottomImage.OnMouseUp := BarButtonImageMouseUp;
  2100. FBarButtonBottomImage.OnMouseMove := BarButtonImageMouseMove;
  2101. FBackgroundImage := TRealICQHoverImage.Create(Self);
  2102. FBackgroundImage.Parent := Self;
  2103. FBackgroundImage.AutoSize := False;
  2104. FBackgroundImage.Stretch := True;
  2105. FBackgroundImage.Transparent := False;
  2106. FBackgroundImage.Align := alClient;
  2107. FBackgroundImage.OnMouseEnter := BackgroundImageMouseEnter;
  2108. FBackgroundImage.OnMouseLeave := BackgroundImageMouseLeave;
  2109. FBackgroundImage.OnMouseDown := BackgroundImageMouseDown;
  2110. FBackgroundImage.OnMouseUp := BackgroundImageMouseUp;
  2111. FMovedYValue := 0;
  2112. end;
  2113. destructor TListBoxScrollBar.Destroy;
  2114. begin
  2115. try
  2116. FreeAndNil(FBackgroundImage);
  2117. FreeAndNil(FBarButtonBottomImage);
  2118. FreeAndNil(FBarButtonMiddleImage);
  2119. FreeAndNil(FBarButtonTopImage);
  2120. FreeAndNil(FBottomButtonImage);
  2121. FreeAndNil(FTopButtonImage);
  2122. except
  2123. end;
  2124. inherited Destroy;
  2125. end;
  2126. {TRealICQContacterListItems}
  2127. constructor TRealICQContacterListItems.Create(ARealICQContacterListView: TRealICQContacterListView);
  2128. begin
  2129. inherited Create;
  2130. FRealICQContacterListView := ARealICQContacterListView;
  2131. end;
  2132. destructor TRealICQContacterListItems.Destroy;
  2133. begin
  2134. try
  2135. Clear;
  2136. except
  2137. end;
  2138. inherited Destroy;
  2139. end;
  2140. function TRealICQContacterListItems.GetObject(Index: Integer): TObject;
  2141. begin
  2142. if Index = -1 then
  2143. Exit;
  2144. Result := FRealICQContacterListView.FNoScrollListBox.Items.Objects[Index];
  2145. end;
  2146. procedure TRealICQContacterListItems.Put(Index: Integer; const S: string);
  2147. begin
  2148. end;
  2149. function TRealICQContacterListItems.Get(Index: Integer): string;
  2150. begin
  2151. Result := FRealICQContacterListView.FNoScrollListBox.Items[Index];
  2152. end;
  2153. function TRealICQContacterListItems.GetCount: Integer;
  2154. begin
  2155. Result := FRealICQContacterListView.FNoScrollListBox.Items.Count;
  2156. end;
  2157. function TRealICQContacterListItems.Add(const S: string): Integer;
  2158. var
  2159. RealICQContacterListItem: TRealICQContacterListItem;
  2160. begin
  2161. RealICQContacterListItem := TRealICQContacterListItem.Create(S, FRealICQContacterListView);
  2162. Result := FRealICQContacterListView.FNoScrollListBox.Items.AddObject(S, RealICQContacterListItem);
  2163. end;
  2164. procedure TRealICQContacterListItems.Insert(Index: Integer; const S: string);
  2165. begin
  2166. //位置按登录状态以及呢称进行排序,所以Insert方法功能同Add方法。
  2167. Add(S);
  2168. end;
  2169. procedure TRealICQContacterListItems.Move(CurIndex, NewIndex: Integer);
  2170. begin
  2171. FRealICQContacterListView.FNoScrollListBox.Items.Move(CurIndex, NewIndex);
  2172. end;
  2173. procedure TRealICQContacterListItems.Clear;
  2174. begin
  2175. if FRealICQContacterListView.FNoScrollListBox = nil then
  2176. Exit;
  2177. while Count > 0 do
  2178. begin
  2179. Delete(0);
  2180. end;
  2181. FRealICQContacterListView.FNoScrollListBox.Items.Clear;
  2182. end;
  2183. procedure TRealICQContacterListItems.Delete(Index: Integer);
  2184. var
  2185. RealICQContacterListItem: TRealICQContacterListItem;
  2186. begin
  2187. RealICQContacterListItem := FRealICQContacterListView.FNoScrollListBox.Items.Objects[Index] as TRealICQContacterListItem;
  2188. FreeAndNil(RealICQContacterListItem);
  2189. FRealICQContacterListView.FNoScrollListBox.Items.Delete(Index);
  2190. end;
  2191. function TRealICQContacterListItems.IndexOf(const S: string): Integer;
  2192. begin
  2193. Result := FRealICQContacterListView.FNoScrollListBox.Items.IndexOf(S);
  2194. end;
  2195. {TRealICQContacterListItem}
  2196. function TRealICQContacterListItem.GetStatePosition(ALoginState: TRealICQLoginState): Integer;
  2197. begin
  2198. Result := 0;
  2199. case ALoginState of
  2200. stOnline:
  2201. Result := 5;
  2202. stMute:
  2203. Result := 4;
  2204. stBusy:
  2205. Result := 3;
  2206. stLeave:
  2207. Result := 2;
  2208. stOffline, stHidden:
  2209. Result := 1;
  2210. end;
  2211. end;
  2212. procedure TRealICQContacterListItem.MoveToTop;
  2213. begin
  2214. FListView.Items.Move(ItemIndex, 0);
  2215. ReDrawItem;
  2216. end;
  2217. procedure TRealICQContacterListItem.AdjustPosition;
  2218. var
  2219. RealICQContacterListItem: TRealICQContacterListItem;
  2220. iLoop, CurrentItemStatePosition, LoopItemStatePosition: Integer;
  2221. CurrentItemString, LoopItemString: string;
  2222. begin
  2223. if not FListView.FAdjustPosition then
  2224. Exit;
  2225. FAdjustPositioned := True;
  2226. CurrentItemStatePosition := GetStatePosition(FLoginState);
  2227. if Length(Trim(FDisplayName)) = 0 then
  2228. CurrentItemString := Chr(255) + FLoginName //如果没有呢称,则排到最后面
  2229. else
  2230. CurrentItemString := FDisplayName;
  2231. //调整位置
  2232. for iLoop := 0 to FListView.Items.Count - 1 do
  2233. begin
  2234. RealICQContacterListItem := FListView.Items.Objects[iLoop] as TRealICQContacterListItem;
  2235. if iLoop = ItemIndex then
  2236. continue;
  2237. if Length(Trim(RealICQContacterListItem.FDisplayName)) = 0 then
  2238. LoopItemString := Chr(255) + RealICQContacterListItem.FLoginName //如果没有呢称,则排到最后面
  2239. else
  2240. LoopItemString := RealICQContacterListItem.FDisplayName;
  2241. LoopItemStatePosition := GetStatePosition(RealICQContacterListItem.FLoginState);
  2242. if CurrentItemStatePosition < LoopItemStatePosition then
  2243. begin
  2244. if iLoop = FListView.Items.Count - 1 then
  2245. begin
  2246. FListView.Items.Move(ItemIndex, iLoop);
  2247. break;
  2248. end
  2249. else
  2250. begin
  2251. continue;
  2252. end;
  2253. end
  2254. else if LoopItemStatePosition = CurrentItemStatePosition then
  2255. begin
  2256. if AnsiCompareStr(CurrentItemString, LoopItemString) < 0 then
  2257. begin
  2258. if ItemIndex < iLoop then
  2259. FListView.Items.Move(ItemIndex, iLoop - 1)
  2260. else
  2261. FListView.Items.Move(ItemIndex, iLoop);
  2262. break;
  2263. end;
  2264. if iLoop = FListView.Items.Count - 1 then
  2265. begin
  2266. FListView.Items.Move(ItemIndex, iLoop);
  2267. break;
  2268. end;
  2269. end
  2270. else if CurrentItemStatePosition > LoopItemStatePosition then
  2271. begin
  2272. if ItemIndex < iLoop then
  2273. FListView.Items.Move(ItemIndex, iLoop - 1)
  2274. else
  2275. FListView.Items.Move(ItemIndex, iLoop);
  2276. break;
  2277. end;
  2278. end;
  2279. end;
  2280. procedure TRealICQContacterListItem.SetLoginState(Value: TRealICQLoginState);
  2281. var
  2282. OldLoginState: TRealICQLoginState;
  2283. iWaitTimes: Integer;
  2284. begin
  2285. if (FLoginState = Value) and FAdjustPositioned then
  2286. Exit;
  2287. OldLoginState := FLoginState;
  2288. FLoginState := Value;
  2289. //调整在线人数的值
  2290. if ((Value <> stOffline) and (Value <> stHidden)) and ((OldLoginState = stOffline) or (OldLoginState = stHidden)) then
  2291. begin
  2292. Inc(FListView.FOnlineNumeric);
  2293. FListView.Items.Move(ItemIndex, 0);
  2294. FListView.DoItemOnline(Self);
  2295. end;
  2296. //调整在线人数的值
  2297. if ((Value = stOffline) or (Value = stHidden)) and ((OldLoginState <> stOffline) and (OldLoginState <> stHidden)) then
  2298. begin
  2299. Dec(FListView.FOnlineNumeric);
  2300. FListView.Items.Move(ItemIndex, FListView.Items.Count - 1);
  2301. FListView.DoItemOffline(Self);
  2302. end;
  2303. //
  2304. // if (FLoginState <> stOnline) and (FFlashCaptionThread <> nil) then
  2305. // begin
  2306. // FFlashCaptionThread.Terminate;
  2307. // iWaitTimes := 0;
  2308. // while FFlashCaptionThread <> nil do
  2309. // begin
  2310. // Sleep(100);
  2311. // Application.ProcessMessages;
  2312. // Inc(iWaitTimes);
  2313. // if iWaitTimes > 100 then break; //最多等待连接线程结束10s时间
  2314. // end;
  2315. // end;
  2316. //
  2317. // AdjustPosition;
  2318. //
  2319. // if (FLoginState = stOnline) and (FListView.FlashCaptionOnOnline) then
  2320. // begin
  2321. // if FFlashCaptionThread = nil then FFlashCaptionThread := TRealICQFlashCaption.Create(Self);
  2322. // FListView.DoItemFlashCaption(Self);
  2323. // end;
  2324. end;
  2325. function TRealICQContacterListItem.GetItemIndex: Integer;
  2326. begin
  2327. Result := FListView.FNoScrollListBox.Items.IndexOf(FLoginName);
  2328. end;
  2329. function TRealICQContacterListItem.GetSelected: Boolean;
  2330. begin
  2331. Result := FListView.FNoScrollListBox.Selected[ItemIndex];
  2332. end;
  2333. procedure TRealICQContacterListItem.SetSelected(Value: Boolean);
  2334. begin
  2335. if Selected = Value then
  2336. Exit;
  2337. FListView.FNoScrollListBox.Selected[ItemIndex] := Value;
  2338. FListView.DoSelectItemChanged(Self);
  2339. end;
  2340. procedure TRealICQContacterListItem.HeadImagePictureChange(Sender: TObject);
  2341. begin
  2342. //FListView.FNoScrollListBox.Invalidate;
  2343. end;
  2344. procedure TRealICQContacterListItem.SetBranch(const Value: string);
  2345. begin
  2346. FBranch := Value;
  2347. end;
  2348. procedure TRealICQContacterListItem.SetDisplayName(Value: string);
  2349. begin
  2350. if AnsiSameStr(FDisplayName, Trim(Value)) and FAdjustPositioned then
  2351. Exit;
  2352. FDisplayName := Trim(Value);
  2353. // AdjustPosition;
  2354. end;
  2355. procedure TRealICQContacterListItem.SetWatchword(Value: string);
  2356. begin
  2357. FWatchword := Trim(Value);
  2358. end;
  2359. procedure TRealICQContacterListItem.SetHeadImagePicture(Value: TPicture);
  2360. begin
  2361. FHeadImagePicture.Assign(Value);
  2362. end;
  2363. procedure TRealICQContacterListItem.ReDrawItem;
  2364. var
  2365. ListItem: TRealICQContacterListItem;
  2366. FListView: TRealICQContacterListView;
  2367. Rect: TRect;
  2368. begin
  2369. ListItem := Self;
  2370. if ListItem = nil then
  2371. exit;
  2372. FListView := ListItem.FListView;
  2373. if not FListView.Visible then
  2374. exit;
  2375. if FListView.Height = 0 then
  2376. exit;
  2377. Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
  2378. if Rect.Bottom < 0 then
  2379. Exit;
  2380. if Rect.Top > FListView.Height then
  2381. Exit;
  2382. InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
  2383. end;
  2384. procedure TRealICQContacterListItem.Flash(AStyle: TRealICQFlashStyle);
  2385. begin
  2386. FFlashStyle := AStyle;
  2387. if FFlashImageThread = nil then
  2388. begin
  2389. FFlashImageThread := TRealICQFlashImage.Create(Self);
  2390. end;
  2391. end;
  2392. procedure TRealICQContacterListItem.StopFlash;
  2393. var
  2394. iWaitTimes: Integer;
  2395. begin
  2396. if FFlashImageThread <> nil then
  2397. begin
  2398. FFlashImageThread.Terminate;
  2399. iWaitTimes := 0;
  2400. while FFlashImageThread <> nil do
  2401. begin
  2402. Inc(iWaitTimes);
  2403. if iWaitTimes > 5000 then
  2404. Exit;
  2405. Sleep(10);
  2406. Application.ProcessMessages;
  2407. end;
  2408. end;
  2409. end;
  2410. constructor TRealICQContacterListItem.Create(ALoginName: string; AListView: TRealICQContacterListView);
  2411. begin
  2412. FLoginName := ALoginName;
  2413. FListView := AListView;
  2414. FAdjustPositioned := False;
  2415. FCaptionColor := $00FFFFFF;
  2416. FHeadImagePosition := 0;
  2417. FDisplayName := '';
  2418. FWatchword := '';
  2419. FHasCamera := False;
  2420. FLoginState := stOffline;
  2421. Data := nil;
  2422. FMouseInRect := False;
  2423. FStateIndex := 1;
  2424. FHeadImagePicture := TPicture.Create;
  2425. FHeadImagePicture.OnChange := HeadImagePictureChange;
  2426. FMouseOver := False;
  2427. FMouseInHeadImageRect := False;
  2428. FMouseInCameraRect := False;
  2429. FMouseInTelephoneRect := False;
  2430. FMouseInMobilePhoneRect := False;
  2431. FMouseInEmailRect := False;
  2432. FMouseInSMSRect := False;
  2433. FMouseInAddFriendRect := False;
  2434. FHeadImageHint := '';
  2435. FCameraHint := '';
  2436. FTelephoneHint := '';
  2437. FMobilePhoneHint := '';
  2438. FEmailHint := '';
  2439. FSMSHint := '';
  2440. FCompany := '';
  2441. FBranch := '';
  2442. FHeadImageRect.Left := 0;
  2443. FHeadImageRect.Top := 0;
  2444. FHeadImageRect.Right := 0;
  2445. FHeadImageRect.Bottom := 0;
  2446. FCameraRect.Left := 0;
  2447. FCameraRect.Top := 0;
  2448. FCameraRect.Right := 0;
  2449. FCameraRect.Bottom := 0;
  2450. FTelephoneRect.Left := 0;
  2451. FTelephoneRect.Top := 0;
  2452. FTelephoneRect.Right := 0;
  2453. FTelephoneRect.Bottom := 0;
  2454. FMobilePhoneRect.Left := 0;
  2455. FMobilePhoneRect.Top := 0;
  2456. FMobilePhoneRect.Right := 0;
  2457. FMobilePhoneRect.Bottom := 0;
  2458. FEmailRect.Left := 0;
  2459. FEmailRect.Top := 0;
  2460. FEmailRect.Right := 0;
  2461. FEmailRect.Bottom := 0;
  2462. FSMSRect.Left := 0;
  2463. FSMSRect.Top := 0;
  2464. FSMSRect.Right := 0;
  2465. FSMSRect.Bottom := 0;
  2466. end;
  2467. destructor TRealICQContacterListItem.Destroy;
  2468. var
  2469. iWaitTimes: Integer;
  2470. begin
  2471. try
  2472. //调整在线人数的值
  2473. if (FLoginState <> stOffline) and (FLoginState <> stHidden) then
  2474. Dec(FListView.FOnlineNumeric);
  2475. if FFlashCaptionThread <> nil then
  2476. begin
  2477. FFlashCaptionThread.Terminate;
  2478. iWaitTimes := 0;
  2479. while FFlashCaptionThread <> nil do
  2480. begin
  2481. Sleep(10);
  2482. Application.ProcessMessages;
  2483. Inc(iWaitTimes);
  2484. if iWaitTimes > 100 then
  2485. break; //最多等待连接线程结束10s时间
  2486. end;
  2487. end;
  2488. if FFlashImageThread <> nil then
  2489. begin
  2490. FFlashImageThread.Terminate;
  2491. while FFlashImageThread <> nil do
  2492. begin
  2493. Sleep(10);
  2494. Application.ProcessMessages;
  2495. end;
  2496. end;
  2497. FHeadImagePicture.OnChange := nil;
  2498. FreeAndNil(FHeadImagePicture);
  2499. except
  2500. end;
  2501. inherited Destroy;
  2502. end;
  2503. {TRealICQContacterListView}
  2504. procedure TRealICQContacterListView.SetScrollTopButtonPictureNormal(Value: TPicture);
  2505. begin
  2506. FScrollTopButtonPictureNormal.Assign(Value);
  2507. end;
  2508. procedure TRealICQContacterListView.SetScrollTopButtonPictureHover(Value: TPicture);
  2509. begin
  2510. FScrollTopButtonPictureHover.Assign(Value);
  2511. end;
  2512. procedure TRealICQContacterListView.SetScrollTopButtonPictureDown(Value: TPicture);
  2513. begin
  2514. FScrollTopButtonPictureDown.Assign(Value);
  2515. end;
  2516. procedure TRealICQContacterListView.SetScrollBottomButtonPictureNormal(Value: TPicture);
  2517. begin
  2518. FScrollBottomButtonPictureNormal.Assign(Value);
  2519. end;
  2520. procedure TRealICQContacterListView.SetScrollBottomButtonPictureHover(Value: TPicture);
  2521. begin
  2522. FScrollBottomButtonPictureHover.Assign(Value);
  2523. end;
  2524. procedure TRealICQContacterListView.SetScrollBottomButtonPictureDown(Value: TPicture);
  2525. begin
  2526. FScrollBottomButtonPictureDown.Assign(Value);
  2527. end;
  2528. procedure TRealICQContacterListView.SetScrollBarButtonTopPictureNormal(Value: TPicture);
  2529. begin
  2530. FScrollBarButtonTopPictureNormal.Assign(Value);
  2531. end;
  2532. procedure TRealICQContacterListView.SetScrollBarButtonTopPictureHover(Value: TPicture);
  2533. begin
  2534. FScrollBarButtonTopPictureHover.Assign(Value);
  2535. end;
  2536. procedure TRealICQContacterListView.SetScrollBarButtonTopPictureDown(Value: TPicture);
  2537. begin
  2538. FScrollBarButtonTopPictureDown.Assign(Value);
  2539. end;
  2540. procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureNormal(Value: TPicture);
  2541. begin
  2542. FScrollBarButtonMiddlePictureNormal.Assign(Value);
  2543. end;
  2544. procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureHover(Value: TPicture);
  2545. begin
  2546. FScrollBarButtonMiddlePictureHover.Assign(Value);
  2547. end;
  2548. procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureDown(Value: TPicture);
  2549. begin
  2550. FScrollBarButtonMiddlePictureDown.Assign(Value);
  2551. end;
  2552. procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureNormal(Value: TPicture);
  2553. begin
  2554. FScrollBarButtonBottomPictureNormal.Assign(Value);
  2555. end;
  2556. procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureHover(Value: TPicture);
  2557. begin
  2558. FScrollBarButtonBottomPictureHover.Assign(Value);
  2559. end;
  2560. procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureDown(Value: TPicture);
  2561. begin
  2562. FScrollBarButtonBottomPictureDown.Assign(Value);
  2563. end;
  2564. procedure TRealICQContacterListView.SetScrollBackgroundPictureNormal(Value: TPicture);
  2565. begin
  2566. FScrollBackgroundPictureNormal.Assign(Value);
  2567. end;
  2568. procedure TRealICQContacterListView.SetScrollBackgroundPictureHover(Value: TPicture);
  2569. begin
  2570. FScrollBackgroundPictureHover.Assign(Value);
  2571. end;
  2572. procedure TRealICQContacterListView.SetScrollBackgroundPictureDown(Value: TPicture);
  2573. begin
  2574. FScrollBackgroundPictureDown.Assign(Value);
  2575. end;
  2576. procedure TRealICQContacterListView.SetCaptionStyle(Value: TRealICQContacterListItemCaptionStyle);
  2577. begin
  2578. FCaptionStyle := Value;
  2579. FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
  2580. FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
  2581. FNoScrollListBox.Invalidate;
  2582. end;
  2583. procedure TRealICQContacterListView.SetStyle(Value: TRealICQContacterListItemStyle);
  2584. begin
  2585. FStyle := Value;
  2586. case FStyle of
  2587. lsBigHeadImage:
  2588. FNoScrollListBox.ItemHeight := cntHeightOfBigHeadImage;
  2589. lsMiddleHeadImage:
  2590. FNoScrollListBox.ItemHeight := cntHeightOfMiddleHeadImage;
  2591. lsSmallHeadImage:
  2592. FNoScrollListBox.ItemHeight := cntHeightOfSmallHeadImage;
  2593. lsNoHeadImage:
  2594. FNoScrollListBox.ItemHeight := cntHeightOfNoHeadImage;
  2595. end;
  2596. FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
  2597. FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
  2598. FNoScrollListBox.Invalidate;
  2599. end;
  2600. procedure TRealICQContacterListView.WhenMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  2601. var
  2602. P: TPoint;
  2603. iIndex, iLoop: Integer;
  2604. ListItem: TRealICQContacterListItem;
  2605. begin
  2606. FTimerItemIndex := -1;
  2607. FTimer.Enabled := False;
  2608. FHintWindow.ReleaseHandle;
  2609. FHintWindow.Visible := False;
  2610. if Button = mbLeft then
  2611. FNoScrollListBox.FMouseInDown := True;
  2612. //if Button = mbLeft then Exit;
  2613. P.X := X;
  2614. P.Y := Y;
  2615. iIndex := FNoScrollListBox.ItemAtPos(P, True);
  2616. if iIndex = -1 then
  2617. begin
  2618. DoItemClick(nil);
  2619. if Button <> mbLeft then
  2620. begin
  2621. for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
  2622. if FNoScrollListBox.Selected[iLoop] then
  2623. if Button <> mbLeft then
  2624. FNoScrollListBox.Selected[iLoop] := False;
  2625. end;
  2626. Exit;
  2627. end;
  2628. ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
  2629. DoItemClick(ListItem);
  2630. if (Button = mbLeft) then
  2631. begin
  2632. if ListItem.FMouseInHeadImageRect then
  2633. begin
  2634. if FNoScrollListBox.FListView.FShowHeadImageButton then
  2635. begin
  2636. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
  2637. Exit;
  2638. end;
  2639. end;
  2640. if ListItem.FMouseInCameraRect then
  2641. begin
  2642. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
  2643. Exit;
  2644. end;
  2645. if ListItem.FMouseInTelephoneRect then
  2646. begin
  2647. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
  2648. Exit;
  2649. end;
  2650. if ListItem.FMouseInMobilePhoneRect then
  2651. begin
  2652. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
  2653. Exit;
  2654. end;
  2655. if ListItem.FMouseInEmailRect then
  2656. begin
  2657. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
  2658. Exit;
  2659. end;
  2660. if ListItem.FMouseInSMSRect then
  2661. begin
  2662. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
  2663. Exit;
  2664. end;
  2665. if ListItem.FMouseInAddFriendRect then
  2666. begin
  2667. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
  2668. Exit;
  2669. end;
  2670. end;
  2671. if (not FNoScrollListBox.Selected[iIndex]) and (Button <> mbLeft) then
  2672. begin
  2673. for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
  2674. if FNoScrollListBox.Selected[iLoop] then
  2675. FNoScrollListBox.Selected[iLoop] := False;
  2676. FNoScrollListBox.Selected[iIndex] := True;
  2677. end;
  2678. end;
  2679. procedure TRealICQContacterListView.WhenMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  2680. var
  2681. P: TPoint;
  2682. iIndex: Integer;
  2683. ListItem: TRealICQContacterListItem;
  2684. begin
  2685. if Assigned(FOnItemMouseUp) then
  2686. FOnItemMouseUp(Self, Button, Shift, X, Y);
  2687. FNoScrollListBox.FMouseInDown := False;
  2688. P.X := X;
  2689. P.Y := Y;
  2690. iIndex := FNoScrollListBox.ItemAtPos(P, True);
  2691. if iIndex = -1 then
  2692. begin
  2693. Exit;
  2694. end;
  2695. ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
  2696. if (Button = mbLeft) then
  2697. begin
  2698. if ListItem.FMouseInHeadImageRect then
  2699. begin
  2700. if FNoScrollListBox.FListView.FShowHeadImageButton then
  2701. begin
  2702. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibUp);
  2703. Exit;
  2704. end;
  2705. end;
  2706. if ListItem.FMouseInCameraRect then
  2707. begin
  2708. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibUp);
  2709. Exit;
  2710. end;
  2711. if ListItem.FMouseInTelephoneRect then
  2712. begin
  2713. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibUp);
  2714. Exit;
  2715. end;
  2716. if ListItem.FMouseInMobilePhoneRect then
  2717. begin
  2718. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibUp);
  2719. Exit;
  2720. end;
  2721. if ListItem.FMouseInEmailRect then
  2722. begin
  2723. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibUp);
  2724. Exit;
  2725. end;
  2726. if ListItem.FMouseInSMSRect then
  2727. begin
  2728. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibUp);
  2729. Exit;
  2730. end;
  2731. if ListItem.FMouseInAddFriendRect then
  2732. begin
  2733. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibUp);
  2734. Exit;
  2735. end;
  2736. end;
  2737. end;
  2738. procedure TRealICQContacterListView.WhenClick(Sender: TObject);
  2739. var
  2740. P: TPoint;
  2741. iIndex: Integer;
  2742. ListItem: TRealICQContacterListItem;
  2743. begin
  2744. P.X := Mouse.CursorPos.X;
  2745. P.Y := Mouse.CursorPos.Y;
  2746. P := FNoScrollListBox.ScreenToClient(P);
  2747. iIndex := FNoScrollListBox.ItemAtPos(P, True);
  2748. if iIndex <> -1 then
  2749. begin
  2750. ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
  2751. if ListItem.FMouseInHeadImageRect then
  2752. begin
  2753. if FNoScrollListBox.FListView.FShowHeadImageButton then
  2754. begin
  2755. DoItemIconButtonClick(ListItem, ltHeadImage);
  2756. Exit;
  2757. end;
  2758. end;
  2759. if ListItem.FMouseInCameraRect then
  2760. begin
  2761. DoItemIconButtonClick(ListItem, ltCamera);
  2762. Exit;
  2763. end;
  2764. if ListItem.FMouseInTelephoneRect then
  2765. begin
  2766. DoItemIconButtonClick(ListItem, ltTel);
  2767. Exit;
  2768. end;
  2769. if ListItem.FMouseInMobilePhoneRect then
  2770. begin
  2771. DoItemIconButtonClick(ListItem, ltMobile);
  2772. Exit;
  2773. end;
  2774. if ListItem.FMouseInEmailRect then
  2775. begin
  2776. DoItemIconButtonClick(ListItem, ltEmail);
  2777. Exit;
  2778. end;
  2779. if ListItem.FMouseInSMSRect then
  2780. begin
  2781. DoItemIconButtonClick(ListItem, ltSMS);
  2782. Exit;
  2783. end;
  2784. if ListItem.FMouseInAddFriendRect then
  2785. begin
  2786. DoItemIconButtonClick(ListItem, ltAddFriend);
  2787. Exit;
  2788. end;
  2789. DoItemClick(ListItem);
  2790. end;
  2791. end;
  2792. procedure TRealICQContacterListView.WhenDoubleClick(Sender: TObject);
  2793. var
  2794. P: TPoint;
  2795. iIndex: Integer;
  2796. ListItem: TRealICQContacterListItem;
  2797. begin
  2798. P.X := Mouse.CursorPos.X;
  2799. P.Y := Mouse.CursorPos.Y;
  2800. P := FNoScrollListBox.ScreenToClient(P);
  2801. iIndex := FNoScrollListBox.ItemAtPos(P, True);
  2802. if iIndex <> -1 then
  2803. begin
  2804. ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
  2805. if ListItem.FMouseInHeadImageRect then
  2806. begin
  2807. if FNoScrollListBox.FListView.FShowHeadImageButton then
  2808. begin
  2809. DoItemIconButtonDblClick(ListItem, ltHeadImage);
  2810. Exit;
  2811. end;
  2812. end;
  2813. if ListItem.FMouseInCameraRect then
  2814. begin
  2815. DoItemIconButtonDblClick(ListItem, ltCamera);
  2816. Exit;
  2817. end;
  2818. if ListItem.FMouseInTelephoneRect then
  2819. begin
  2820. DoItemIconButtonDblClick(ListItem, ltTel);
  2821. Exit;
  2822. end;
  2823. if ListItem.FMouseInMobilePhoneRect then
  2824. begin
  2825. DoItemIconButtonDblClick(ListItem, ltMobile);
  2826. Exit;
  2827. end;
  2828. if ListItem.FMouseInEmailRect then
  2829. begin
  2830. DoItemIconButtonDblClick(ListItem, ltEmail);
  2831. Exit;
  2832. end;
  2833. if ListItem.FMouseInSMSRect then
  2834. begin
  2835. DoItemIconButtonDblClick(ListItem, ltSMS);
  2836. Exit;
  2837. end;
  2838. if ListItem.FMouseInAddFriendRect then
  2839. begin
  2840. DoItemIconButtonDblClick(ListItem, ltAddFriend);
  2841. Exit;
  2842. end;
  2843. ListItem.StopFlash;
  2844. DoItemDoubleClick(ListItem);
  2845. end;
  2846. end;
  2847. procedure TRealICQContacterListView.TimerOnTimer(Sender: TObject);
  2848. var
  2849. P: TPoint;
  2850. ItemIndex: Integer;
  2851. begin
  2852. FTimer.Enabled := False;
  2853. P := FNoScrollListBox.ScreenToClient(Mouse.CursorPos);
  2854. ItemIndex := FNoScrollListBox.ItemAtPos(P, True);
  2855. if FTimerItemIndex <> ItemIndex then
  2856. Exit;
  2857. ShowCustomHint(Items.Objects[ItemIndex] as TRealICQContacterListItem);
  2858. end;
  2859. procedure TRealICQContacterListView.ShowCustomHint(Item: TRealICQContacterListItem);
  2860. var
  2861. P: TPoint;
  2862. Rect: TRect;
  2863. HintStr: string;
  2864. TextWidth, TextHeight: Integer;
  2865. HintStrList: TStringList;
  2866. iLoop: Integer;
  2867. begin
  2868. if not ShowHint then
  2869. Exit;
  2870. if Item.StateIndex = 0 then
  2871. Exit;
  2872. if (Item.FMouseInTextRect) or (Item.FMouseInHeadImageRect and self.FShowHeadImageButton) then
  2873. begin
  2874. HintStr := Copy(Item.LoginName, AnsiPos('-', Item.LoginName) + 1, Length(Item.LoginName) - AnsiPos('-', Item.LoginName));
  2875. if Item.FLoginState = stLeave then
  2876. HintStr := HintStr + '(' + Item.FLeaveMessage + ')'
  2877. else
  2878. HintStr := HintStr + '(' + StateValues[Integer(Item.FLoginState) mod 5] + ')';
  2879. if Length(Trim(Item.DisplayName)) > 0 then
  2880. begin
  2881. HintStr := HintStr + #$D#$A + Item.DisplayName;
  2882. end;
  2883. if Length(Trim(Item.Branch)) > 0 then
  2884. HintStr := HintStr + #$D#$A + Item.Branch;
  2885. if Length(Trim(Item.Watchword)) > 0 then
  2886. begin
  2887. HintStr := HintStr + #$D#$A + Item.Watchword;
  2888. end;
  2889. end
  2890. else
  2891. begin
  2892. if Item.FMouseInHeadImageRect then
  2893. HintStr := Item.FHeadImageHint;
  2894. if Item.FMouseInCameraRect then
  2895. HintStr := Item.FCameraHint;
  2896. if Item.FMouseInTelephoneRect then
  2897. HintStr := Item.FTelephoneHint;
  2898. if Item.FMouseInMobilePhoneRect then
  2899. HintStr := Item.FMobilePhoneHint;
  2900. if Item.FMouseInEmailRect then
  2901. HintStr := Item.FEmailHint;
  2902. if Item.FMouseInSMSRect then
  2903. HintStr := Item.FSMSHint;
  2904. if Item.FMouseInAddFriendRect then
  2905. HintStr := Item.FAddFriendHint;
  2906. end;
  2907. DoItemShowHint(Item, HintStr);
  2908. if Length(Trim(HintStr)) = 0 then
  2909. Exit;
  2910. TextWidth := 0;
  2911. TextHeight := 0;
  2912. HintStrList := RealICQUtils.SplitString(HintStr, #$D#$A);
  2913. try
  2914. for iLoop := 0 to HintStrList.Count - 1 do
  2915. begin
  2916. if TextWidth < FHintWindow.Canvas.TextWidth(HintStrList.Strings[iLoop]) then
  2917. TextWidth := FHintWindow.Canvas.TextWidth(HintStrList.Strings[iLoop]);
  2918. Inc(TextHeight, FHintWindow.Canvas.TextHeight(HintStrList.Strings[iLoop]));
  2919. end;
  2920. finally
  2921. HintStrList.Free;
  2922. end;
  2923. P.X := 0;
  2924. P.Y := 0;
  2925. P := FNoScrollListBox.ClientToScreen(P);
  2926. Rect.Left := Mouse.CursorPos.X + 20;
  2927. Rect.Top := FNoScrollListBox.ItemRect(FTimerItemIndex).Top + FNoScrollListBox.ItemHeight + P.Y + 10;
  2928. Rect.Right := Rect.Left + TextWidth + 10;
  2929. Rect.Bottom := Rect.Top + TextHeight + 5;
  2930. FHintWindow.Color := clInfoBk;
  2931. FHintWindow.ActivateHint(Rect, HintStr);
  2932. FHintWindow.Visible := True;
  2933. end;
  2934. procedure TRealICQContacterListView.WhenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  2935. var
  2936. P: TPoint;
  2937. iIndex, iLoop: Integer;
  2938. ListItem: TRealICQContacterListItem;
  2939. procedure OpenHint;
  2940. begin
  2941. FTimerItemIndex := ListItem.ItemIndex;
  2942. if FHintWindow.Visible then
  2943. begin
  2944. ShowCustomHint(ListItem);
  2945. end
  2946. else
  2947. begin
  2948. FTimer.Enabled := False;
  2949. FTimer.Enabled := True;
  2950. end;
  2951. end;
  2952. procedure CloseHint;
  2953. begin
  2954. FTimerItemIndex := -1;
  2955. FTimer.Enabled := False;
  2956. FHintWindow.ReleaseHandle;
  2957. FHintWindow.Visible := False;
  2958. end;
  2959. procedure ResetMouseInRectState;
  2960. begin
  2961. ListItem.FMouseInTextRect := False;
  2962. ListItem.FMouseInHeadImageRect := False;
  2963. ListItem.FMouseInCameraRect := False;
  2964. ListItem.FMouseInTelephoneRect := False;
  2965. ListItem.FMouseInMobilePhoneRect := False;
  2966. ListItem.FMouseInEmailRect := False;
  2967. ListItem.FMouseInSMSRect := False;
  2968. ListItem.FMouseInAddFriendRect := False;
  2969. end;
  2970. begin
  2971. P.X := X;
  2972. P.Y := Y;
  2973. iIndex := FNoScrollListBox.ItemAtPos(P, True);
  2974. for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
  2975. begin
  2976. ListItem := Items.Objects[iLoop] as TRealICQContacterListItem;
  2977. if (iIndex = iLoop) then
  2978. continue;
  2979. if ListItem.FMouseOver then
  2980. begin
  2981. ListItem.FMouseOver := False;
  2982. ListItem.ReDrawItem;
  2983. end;
  2984. if ListItem.FMouseInRect then
  2985. begin
  2986. ListItem.FMouseInRect := False;
  2987. end;
  2988. if ListItem.FMouseInTextRect then
  2989. begin
  2990. ListItem.FMouseInTextRect := False;
  2991. DoItemMouseLeave(ListItem);
  2992. end;
  2993. if ListItem.FMouseInHeadImageRect then
  2994. begin
  2995. DoHeadImageMouseLeave(ListItem);
  2996. ListItem.FMouseInHeadImageRect := False;
  2997. ListItem.ReDrawItem;
  2998. end;
  2999. if ListItem.FMouseInCameraRect then
  3000. begin
  3001. ListItem.FMouseInCameraRect := False;
  3002. ListItem.ReDrawItem;
  3003. end;
  3004. if ListItem.FMouseInTelephoneRect then
  3005. begin
  3006. ListItem.FMouseInTelephoneRect := False;
  3007. ListItem.ReDrawItem;
  3008. end;
  3009. if ListItem.FMouseInMobilePhoneRect then
  3010. begin
  3011. ListItem.FMouseInMobilePhoneRect := False;
  3012. ListItem.ReDrawItem;
  3013. end;
  3014. if ListItem.FMouseInEmailRect then
  3015. begin
  3016. ListItem.FMouseInEmailRect := False;
  3017. ListItem.ReDrawItem;
  3018. end;
  3019. if ListItem.FMouseInSMSRect then
  3020. begin
  3021. ListItem.FMouseInSMSRect := False;
  3022. ListItem.ReDrawItem;
  3023. end;
  3024. if ListItem.FMouseInAddFriendRect then
  3025. begin
  3026. ListItem.FMouseInAddFriendRect := False;
  3027. ListItem.ReDrawItem;
  3028. end;
  3029. end;
  3030. if iIndex >= 0 then
  3031. begin
  3032. ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
  3033. if not ListItem.FMouseOver then
  3034. begin
  3035. ListItem.FMouseOver := True;
  3036. ListItem.ReDrawItem;
  3037. end;
  3038. {$region '是否在头像图标区间'}
  3039. if PtInRect(ListItem.FHeadImageRect, P) then
  3040. begin
  3041. if not ListItem.FMouseInHeadImageRect then
  3042. begin
  3043. ResetMouseInRectState;
  3044. ListItem.FMouseInHeadImageRect := True;
  3045. DoHeadImageMouseEnter(ListItem);
  3046. if FNoScrollListBox.FListView.FShowHeadImageButton then
  3047. begin
  3048. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibUp);
  3049. OpenHint;
  3050. Exit;
  3051. end;
  3052. end;
  3053. end
  3054. else
  3055. begin
  3056. if ListItem.FMouseInHeadImageRect then
  3057. begin
  3058. DoHeadImageMouseLeave(ListItem);
  3059. ListItem.FMouseInHeadImageRect := False;
  3060. ListItem.ReDrawItem;
  3061. CloseHint;
  3062. end;
  3063. end;
  3064. {$endregion}
  3065. {$region '是否在摄像头图标区间'}
  3066. if (ListItem.HasCamera) and (ListItem.LoginState <> stHidden) then
  3067. begin
  3068. if PtInRect(ListItem.FCameraRect, P) then
  3069. begin
  3070. if not ListItem.FMouseInCameraRect then
  3071. begin
  3072. ResetMouseInRectState;
  3073. ListItem.FMouseInCameraRect := True;
  3074. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibUp);
  3075. OpenHint;
  3076. Exit;
  3077. end;
  3078. end
  3079. else
  3080. begin
  3081. if ListItem.FMouseInCameraRect then
  3082. begin
  3083. ListItem.FMouseInCameraRect := False;
  3084. ListItem.ReDrawItem;
  3085. CloseHint;
  3086. end;
  3087. end;
  3088. end;
  3089. {$endregion}
  3090. {$region '是否在坐机图标区间'}
  3091. if (ListItem.HasTelephone) then
  3092. begin
  3093. //MessageBox(0, PChar(IntToStr(P.X) + ',' + IntToStr(P.Y)), PChar(IntToStr(ListItem.FTelephoneRect.Left) + ',' + IntToStr(ListItem.FTelephoneRect.Top) + ',' + IntToStr(ListItem.FTelephoneRect.Right) + ',' + IntToStr(ListItem.FTelephoneRect.Bottom)), MB_OK);
  3094. if PtInRect(ListItem.FTelephoneRect, P) then
  3095. begin
  3096. if not ListItem.FMouseInTelephoneRect then
  3097. begin
  3098. ResetMouseInRectState;
  3099. ListItem.FMouseInTelephoneRect := True;
  3100. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibUp);
  3101. OpenHint;
  3102. Exit;
  3103. end;
  3104. end
  3105. else
  3106. begin
  3107. if ListItem.FMouseInTelephoneRect then
  3108. begin
  3109. ListItem.FMouseInTelephoneRect := False;
  3110. ListItem.ReDrawItem;
  3111. CloseHint;
  3112. end;
  3113. end;
  3114. end;
  3115. {$endregion}
  3116. {$region '是否在手机图标区间'}
  3117. if (ListItem.HasMobilePhone) then
  3118. begin
  3119. if PtInRect(ListItem.FMobilePhoneRect, P) then
  3120. begin
  3121. if not ListItem.FMouseInMobilePhoneRect then
  3122. begin
  3123. ResetMouseInRectState;
  3124. ListItem.FMouseInMobilePhoneRect := True;
  3125. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibUp);
  3126. OpenHint;
  3127. Exit;
  3128. end;
  3129. end
  3130. else
  3131. begin
  3132. if ListItem.FMouseInMobilePhoneRect then
  3133. begin
  3134. ListItem.FMouseInMobilePhoneRect := False;
  3135. ListItem.ReDrawItem;
  3136. CloseHint;
  3137. end;
  3138. end;
  3139. end;
  3140. {$endregion}
  3141. {$region '是否在信箱区间'}
  3142. if (ListItem.FHasEmail) then
  3143. begin
  3144. if PtInRect(ListItem.FEmailRect, P) then
  3145. begin
  3146. if not ListItem.FMouseInEmailRect then
  3147. begin
  3148. ResetMouseInRectState;
  3149. ListItem.FMouseInEmailRect := True;
  3150. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibUp);
  3151. OpenHint;
  3152. Exit;
  3153. end;
  3154. end
  3155. else
  3156. begin
  3157. if ListItem.FMouseInEmailRect then
  3158. begin
  3159. ListItem.FMouseInEmailRect := False;
  3160. ListItem.ReDrawItem;
  3161. CloseHint;
  3162. end;
  3163. end;
  3164. end;
  3165. {$endregion}
  3166. {$region '是否在短信区间'}
  3167. if (ListItem.FHasSMS) then
  3168. begin
  3169. if PtInRect(ListItem.FSMSRect, P) then
  3170. begin
  3171. if not ListItem.FMouseInSMSRect then
  3172. begin
  3173. ResetMouseInRectState;
  3174. ListItem.FMouseInSMSRect := True;
  3175. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibUp);
  3176. OpenHint;
  3177. Exit;
  3178. end;
  3179. end
  3180. else
  3181. begin
  3182. if ListItem.FMouseInSMSRect then
  3183. begin
  3184. ListItem.FMouseInSMSRect := False;
  3185. ListItem.ReDrawItem;
  3186. CloseHint;
  3187. end;
  3188. end;
  3189. end;
  3190. {$endregion}
  3191. {$region '是否在增加好友区间'}
  3192. if (ListItem.FHasAddFriend) then
  3193. begin
  3194. if PtInRect(ListItem.FAddFriendRect, P) then
  3195. begin
  3196. if not ListItem.FMouseInAddFriendRect then
  3197. begin
  3198. ResetMouseInRectState;
  3199. ListItem.FMouseInAddFriendRect := True;
  3200. DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibUp);
  3201. OpenHint;
  3202. Exit;
  3203. end;
  3204. end
  3205. else
  3206. begin
  3207. if ListItem.FMouseInAddFriendRect then
  3208. begin
  3209. ListItem.FMouseInAddFriendRect := False;
  3210. ListItem.ReDrawItem;
  3211. CloseHint;
  3212. end;
  3213. end;
  3214. end;
  3215. {$endregion}
  3216. {$region '是否在文字区间'}
  3217. if PtInRect(ListItem.FTextRect, P) then
  3218. begin
  3219. if not ListItem.FMouseInTextRect then
  3220. begin
  3221. ResetMouseInRectState;
  3222. ListItem.FMouseInTextRect := True;
  3223. DoItemMouseEnter(ListItem);
  3224. OpenHint;
  3225. Exit;
  3226. end;
  3227. end
  3228. else
  3229. begin
  3230. if ListItem.FMouseInTextRect then
  3231. begin
  3232. ListItem.FMouseInTextRect := False;
  3233. CloseHint;
  3234. end;
  3235. end;
  3236. {$endregion}
  3237. end
  3238. else
  3239. begin
  3240. CloseHint;
  3241. end;
  3242. end;
  3243. procedure TRealICQContacterListView.WhenMouseLeave(Sender: TObject);
  3244. var
  3245. iLoop: Integer;
  3246. ListItem: TRealICQContacterListItem;
  3247. begin
  3248. FTimerItemIndex := -1;
  3249. FTimer.Enabled := False;
  3250. FHintWindow.ReleaseHandle;
  3251. FHintWindow.Visible := False;
  3252. for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
  3253. begin
  3254. ListItem := Items.Objects[iLoop] as TRealICQContacterListItem;
  3255. if ListItem.FMouseOver then
  3256. begin
  3257. ListItem.FMouseOver := False;
  3258. ListItem.ReDrawItem;
  3259. end;
  3260. if ListItem.FMouseInRect then
  3261. begin
  3262. ListItem.FMouseInRect := False;
  3263. DoItemMouseLeave(ListItem);
  3264. end;
  3265. if ListItem.FMouseInHeadImageRect then
  3266. begin
  3267. DoHeadImageMouseLeave(ListItem);
  3268. ListItem.FMouseInHeadImageRect := False;
  3269. ListItem.ReDrawItem;
  3270. end;
  3271. if ListItem.FMouseInCameraRect then
  3272. begin
  3273. ListItem.FMouseInCameraRect := False;
  3274. ListItem.ReDrawItem;
  3275. end;
  3276. if ListItem.FMouseInTelephoneRect then
  3277. begin
  3278. ListItem.FMouseInTelephoneRect := False;
  3279. ListItem.ReDrawItem;
  3280. end;
  3281. if ListItem.FMouseInMobilePhoneRect then
  3282. begin
  3283. ListItem.FMouseInMobilePhoneRect := False;
  3284. ListItem.ReDrawItem;
  3285. end;
  3286. if ListItem.FMouseInEmailRect then
  3287. begin
  3288. ListItem.FMouseInEmailRect := False;
  3289. ListItem.ReDrawItem;
  3290. end;
  3291. if ListItem.FMouseInSMSRect then
  3292. begin
  3293. ListItem.FMouseInSMSRect := False;
  3294. ListItem.ReDrawItem;
  3295. end;
  3296. if ListItem.FMouseInAddFriendRect then
  3297. begin
  3298. ListItem.FMouseInAddFriendRect := False;
  3299. ListItem.ReDrawItem;
  3300. end;
  3301. end;
  3302. end;
  3303. procedure TRealICQContacterListView.SetSelectedItemBorderInnerColor(Value: TColor);
  3304. begin
  3305. if FSelectedItemBorderInnerColor = Value then
  3306. Exit;
  3307. FSelectedItemBorderInnerColor := Value;
  3308. end;
  3309. procedure TRealICQContacterListView.SetSelectedItemBorderColor(Value: TColor);
  3310. begin
  3311. if FSelectedItemBorderColor = Value then
  3312. Exit;
  3313. FSelectedItemBorderColor := Value;
  3314. end;
  3315. procedure TRealICQContacterListView.SetSelectedItemBackColor(Value: TColor);
  3316. begin
  3317. if FSelectedItemBackColor = Value then
  3318. Exit;
  3319. FSelectedItemBackColor := Value;
  3320. end;
  3321. procedure TRealICQContacterListView.SetHeadImageBorderColor(Value: TColor);
  3322. begin
  3323. if FHeadImageBorderColor = Value then
  3324. Exit;
  3325. FHeadImageBorderColor := Value;
  3326. end;
  3327. procedure TRealICQContacterListView.SetHeadImageBackColor(Value: TColor);
  3328. begin
  3329. if FHeadImageBackColor = Value then
  3330. Exit;
  3331. FHeadImageBackColor := Value;
  3332. end;
  3333. procedure TRealICQContacterListView.SetSelectedItemBackgroud(Value: TPicture);
  3334. begin
  3335. FSelectedItemBackgroud.Assign(Value);
  3336. end;
  3337. procedure TRealICQContacterListView.SetDefaultPictureBig(Value: TPicture);
  3338. begin
  3339. FDefaultPictureBig.Assign(Value);
  3340. end;
  3341. procedure TRealICQContacterListView.SetDefaultPictureMiddle(Value: TPicture);
  3342. begin
  3343. FDefaultPictureMiddle.Assign(Value);
  3344. end;
  3345. procedure TRealICQContacterListView.SetDefaultPictureSmall(Value: TPicture);
  3346. begin
  3347. FDefaultPictureSmall.Assign(Value);
  3348. end;
  3349. procedure TRealICQContacterListView.SetDefaultPictureBigOffline(Value: TPicture);
  3350. begin
  3351. FDefaultPictureBigOffline.Assign(Value);
  3352. end;
  3353. procedure TRealICQContacterListView.SetDefaultPictureMiddleOffline(Value: TPicture);
  3354. begin
  3355. FDefaultPictureMiddleOffline.Assign(Value);
  3356. end;
  3357. procedure TRealICQContacterListView.SetDefaultPictureSmallOffline(Value: TPicture);
  3358. begin
  3359. FDefaultPictureSmallOffline.Assign(Value);
  3360. end;
  3361. procedure TRealICQContacterListView.SetLeavePictureBig(Value: TIcon);
  3362. begin
  3363. FLeavePictureBig.Assign(Value);
  3364. end;
  3365. procedure TRealICQContacterListView.SetBusyPictureBig(Value: TIcon);
  3366. begin
  3367. FBusyPictureBig.Assign(Value);
  3368. end;
  3369. procedure TRealICQContacterListView.SetMutePictureBig(Value: TIcon);
  3370. begin
  3371. FMutePictureBig.Assign(Value);
  3372. end;
  3373. procedure TRealICQContacterListView.SetLeavePicture(Value: TIcon);
  3374. begin
  3375. FLeavePicture.Assign(Value);
  3376. end;
  3377. procedure TRealICQContacterListView.SetBusyPicture(Value: TIcon);
  3378. begin
  3379. FBusyPicture.Assign(Value);
  3380. end;
  3381. procedure TRealICQContacterListView.SetMutePicture(Value: TIcon);
  3382. begin
  3383. FMutePicture.Assign(Value);
  3384. end;
  3385. procedure TRealICQContacterListView.SetCameraIcon(Value: TIcon);
  3386. begin
  3387. FCameraIcon.Assign(Value);
  3388. end;
  3389. procedure TRealICQContacterListView.SetTelephoneIcon(Value: TIcon);
  3390. begin
  3391. FTelephoneIcon.Assign(Value);
  3392. end;
  3393. procedure TRealICQContacterListView.SetMobilePhoneIcon(Value: TIcon);
  3394. begin
  3395. FMobilePhoneIcon.Assign(Value);
  3396. end;
  3397. procedure TRealICQContacterListView.SetEmailIcon(Value: TIcon);
  3398. begin
  3399. FEmailIcon.Assign(Value);
  3400. end;
  3401. //-----------------------------------------------------------------
  3402. procedure TRealICQContacterListView.SetAddFriendIcon(Value: TIcon);
  3403. begin
  3404. FAddFriendIcon.Assign(Value);
  3405. end;
  3406. procedure TRealICQContacterListView.SetSMSIcon(Value: TIcon);
  3407. begin
  3408. FSMSIcon.Assign(Value);
  3409. end;
  3410. procedure TRealICQContacterListView.SetTopIndex(Value: Integer);
  3411. begin
  3412. FNoScrollListBox.TopIndex := Value;
  3413. end;
  3414. function TRealICQContacterListView.GetTopIndex: Integer;
  3415. begin
  3416. Result := FNoScrollListBox.TopIndex;
  3417. end;
  3418. function TRealICQContacterListView.GetSelCount: Integer;
  3419. begin
  3420. Result := FNoScrollListBox.SelCount;
  3421. end;
  3422. procedure TRealICQContacterListView.DoSelectItemChanged(Item: TRealICQContacterListItem);
  3423. begin
  3424. if Assigned(FOnSelectItemChanged) then
  3425. FOnSelectItemChanged(Item);
  3426. end;
  3427. procedure TRealICQContacterListView.DoItemClick(Item: TRealICQContacterListItem);
  3428. begin
  3429. if Assigned(FOnItemClick) then
  3430. FOnItemClick(Item);
  3431. end;
  3432. procedure TRealICQContacterListView.DoItemDoubleClick(Item: TRealICQContacterListItem);
  3433. begin
  3434. if Assigned(FOnItemDoubleClick) then
  3435. FOnItemDoubleClick(Item);
  3436. end;
  3437. procedure TRealICQContacterListView.DoHeadImageMouseEnter(Item: TRealICQContacterListItem);
  3438. begin
  3439. if Assigned(FOnHeadImageMouseEnter) then
  3440. FOnHeadImageMouseEnter(Item);
  3441. end;
  3442. procedure TRealICQContacterListView.DoHeadImageMouseLeave(Item: TRealICQContacterListItem);
  3443. begin
  3444. if Assigned(FOnHeadImageMouseLeave) then
  3445. FOnHeadImageMouseLeave(Item);
  3446. end;
  3447. procedure TRealICQContacterListView.DoItemMouseEnter(Item: TRealICQContacterListItem);
  3448. begin
  3449. if Assigned(FOnItemMouseEnter) then
  3450. FOnItemMouseEnter(Item);
  3451. end;
  3452. procedure TRealICQContacterListView.DoItemMouseLeave(Item: TRealICQContacterListItem);
  3453. begin
  3454. if Assigned(FOnItemMouseLeave) then
  3455. FOnItemMouseLeave(Item);
  3456. end;
  3457. procedure TRealICQContacterListView.DoItemFlashCaption(Item: TRealICQContacterListItem);
  3458. begin
  3459. if Assigned(FOnItemFlashCaption) then
  3460. FOnItemFlashCaption(Item);
  3461. end;
  3462. procedure TRealICQContacterListView.DoItemOnline(Item: TRealICQContacterListItem);
  3463. begin
  3464. if Assigned(FOnItemOnline) then
  3465. FOnItemOnline(Item);
  3466. end;
  3467. procedure TRealICQContacterListView.DoItemOffline(Item: TRealICQContacterListItem);
  3468. begin
  3469. if Assigned(FOnItemOffline) then
  3470. FOnItemOffline(Item);
  3471. end;
  3472. procedure TRealICQContacterListView.DoItemIconButtonClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
  3473. begin
  3474. if Assigned(FOnItemIconButtonClick) then
  3475. FOnItemIconButtonClick(Self, Item, IconButtonType);
  3476. end;
  3477. procedure TRealICQContacterListView.DoItemIconButtonDblClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
  3478. begin
  3479. if Assigned(FOnItemIconButtonDblClick) then
  3480. FOnItemIconButtonDblClick(Self, Item, IconButtonType);
  3481. end;
  3482. procedure TRealICQContacterListView.DoItemShowHint(Item: TRealICQContacterListItem; var HintStr: string);
  3483. begin
  3484. if Assigned(FOnItemShowHint) then
  3485. FOnItemShowHint(Self, Item, HintStr);
  3486. end;
  3487. procedure TRealICQContacterListView.DropFiles(var Message: TMessage);
  3488. begin
  3489. DoDropFiles(Message);
  3490. end;
  3491. procedure TRealICQContacterListView.DoDropFiles(var Message: TMessage);
  3492. begin
  3493. if Assigned(FOnDropFiles) then
  3494. FOnDropFiles(Self, Message);
  3495. end;
  3496. function TRealICQContacterListView.ItemAtPos(Pos: TPoint; Existing: Boolean): Integer;
  3497. var
  3498. P: TPoint;
  3499. begin
  3500. P := FNoScrollListBox.ScreenToClient(Pos);
  3501. Result := FNoScrollListBox.ItemAtPos(P, Existing);
  3502. end;
  3503. procedure TRealICQContacterListView.ReDrawAll;
  3504. begin
  3505. if (FNoScrollListBox <> nil) then
  3506. begin
  3507. FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
  3508. FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
  3509. FNoScrollListBox.Invalidate;
  3510. end;
  3511. end;
  3512. procedure TRealICQContacterListView.ChangeUIColor(AColor: TColor);
  3513. begin
  3514. FIconBtnDefaultColor := ConvertColorToColor(FIconBtnDefaultColor, AColor);
  3515. FIconBtnLightColor := ConvertColorToColor(FIconBtnLightColor, AColor);
  3516. FIconBtnShadownColor := ConvertColorToColor(FIconBtnShadownColor, AColor);
  3517. HeadImageBorderColor := ConvertColorToColor(HeadImageBorderColor, AColor);
  3518. HeadImageBackColor := ConvertColorToColor(HeadImageBackColor, AColor);
  3519. SelectedItemBorderColor := ConvertColorToColor(SelectedItemBorderColor, AColor);
  3520. SelectedItemBorderInnerColor := ConvertColorToColor(SelectedItemBorderInnerColor, AColor);
  3521. SelectedItemBackColor := ConvertColorToColor(SelectedItemBackColor, AColor);
  3522. ConvertBitmapToColor(FSelectedItemBackgroud.Bitmap, AColor);
  3523. ConvertBitmapToColor(FScrollTopButtonPictureNormal.Bitmap, AColor);
  3524. ConvertBitmapToColor(FScrollTopButtonPictureHover.Bitmap, AColor);
  3525. ConvertBitmapToColor(FScrollTopButtonPictureDown.Bitmap, AColor);
  3526. ConvertBitmapToColor(FScrollBottomButtonPictureNormal.Bitmap, AColor);
  3527. ConvertBitmapToColor(FScrollBottomButtonPictureHover.Bitmap, AColor);
  3528. ConvertBitmapToColor(FScrollBottomButtonPictureDown.Bitmap, AColor);
  3529. ConvertBitmapToColor(FScrollBarButtonTopPictureNormal.Bitmap, AColor);
  3530. ConvertBitmapToColor(FScrollBarButtonTopPictureHover.Bitmap, AColor);
  3531. ConvertBitmapToColor(FScrollBarButtonTopPictureDown.Bitmap, AColor);
  3532. ConvertBitmapToColor(FScrollBarButtonMiddlePictureNormal.Bitmap, AColor);
  3533. ConvertBitmapToColor(FScrollBarButtonMiddlePictureHover.Bitmap, AColor);
  3534. ConvertBitmapToColor(FScrollBarButtonMiddlePictureDown.Bitmap, AColor);
  3535. ConvertBitmapToColor(FScrollBarButtonBottomPictureNormal.Bitmap, AColor);
  3536. ConvertBitmapToColor(FScrollBarButtonBottomPictureHover.Bitmap, AColor);
  3537. ConvertBitmapToColor(FScrollBarButtonBottomPictureDown.Bitmap, AColor);
  3538. ConvertBitmapToColor(FScrollBackgroundPictureNormal.Bitmap, AColor);
  3539. ConvertBitmapToColor(FScrollBackgroundPictureHover.Bitmap, AColor);
  3540. ConvertBitmapToColor(FScrollBackgroundPictureDown.Bitmap, AColor);
  3541. FListBoxScrollBar.FAssignedPicture := False;
  3542. FListBoxScrollBar.DrawScrollBar;
  3543. FNoScrollListBox.Repaint;
  3544. end;
  3545. constructor TRealICQContacterListView.Create(AOwner: TComponent);
  3546. begin
  3547. inherited Create(AOwner);
  3548. Color := clWhite;
  3549. DoubleBuffered := True;
  3550. BevelInner := bvNone;
  3551. BevelOuter := bvNone;
  3552. AutoSize := True;
  3553. Width := 200;
  3554. Height := 300;
  3555. FTimer := TTimer.Create(Self);
  3556. FTimer.Interval := 600;
  3557. FTimer.Enabled := False;
  3558. FTimer.OnTimer := TimerOnTimer;
  3559. FHintWindow := TSingleBorderHintWindow.Create(Self);
  3560. FHintWindow.Visible := False;
  3561. FTimerItemIndex := -1;
  3562. FScrollTopButtonPictureNormal := TPicture.Create;
  3563. FScrollTopButtonPictureHover := TPicture.Create;
  3564. FScrollTopButtonPictureDown := TPicture.Create;
  3565. FScrollBottomButtonPictureNormal := TPicture.Create;
  3566. FScrollBottomButtonPictureHover := TPicture.Create;
  3567. FScrollBottomButtonPictureDown := TPicture.Create;
  3568. FScrollBarButtonTopPictureNormal := TPicture.Create;
  3569. FScrollBarButtonTopPictureHover := TPicture.Create;
  3570. FScrollBarButtonTopPictureDown := TPicture.Create;
  3571. FScrollBarButtonMiddlePictureNormal := TPicture.Create;
  3572. FScrollBarButtonMiddlePictureHover := TPicture.Create;
  3573. FScrollBarButtonMiddlePictureDown := TPicture.Create;
  3574. FScrollBarButtonBottomPictureNormal := TPicture.Create;
  3575. FScrollBarButtonBottomPictureHover := TPicture.Create;
  3576. FScrollBarButtonBottomPictureDown := TPicture.Create;
  3577. FScrollBackgroundPictureNormal := TPicture.Create;
  3578. FScrollBackgroundPictureHover := TPicture.Create;
  3579. FScrollBackgroundPictureDown := TPicture.Create;
  3580. FSelectedItemBackgroud := TPicture.Create;
  3581. FDefaultPictureBig := TPicture.Create;
  3582. FDefaultPictureMiddle := TPicture.Create;
  3583. FDefaultPictureSmall := TPicture.Create;
  3584. FDefaultPictureBigOffline := TPicture.Create;
  3585. FDefaultPictureMiddleOffline := TPicture.Create;
  3586. FDefaultPictureSmallOffline := TPicture.Create;
  3587. FLeavePicture := TIcon.Create;
  3588. FBusyPicture := TIcon.Create;
  3589. FMutePicture := TIcon.Create;
  3590. FLeavePictureBig := TIcon.Create;
  3591. FBusyPictureBig := TIcon.Create;
  3592. FMutePictureBig := TIcon.Create;
  3593. FCameraIcon := TIcon.Create;
  3594. FTelephoneIcon := TIcon.Create;
  3595. FMobilePhoneIcon := TIcon.Create;
  3596. FEmailIcon := TIcon.Create;
  3597. FSMSIcon := TIcon.Create;
  3598. FAddFriendIcon := TIcon.Create;
  3599. FShowHeadImageButton := False;
  3600. FShowEmailButton := True;
  3601. FShowSMSButton := True;
  3602. FShowTelButton := True;
  3603. FShowMobileButton := True;
  3604. FShowCameraButton := True;
  3605. FShowAddFriendButton := False;
  3606. FIconBtnDefaultColor := clWhite;
  3607. FIconBtnLightColor := clSilver;
  3608. FIconBtnShadownColor := cl3DDkShadow;
  3609. FItems := TRealICQContacterListItems.Create(Self);
  3610. FNoScrollListBox := TNoScrollListBox.Create(Self);
  3611. FNoScrollListBox.Parent := Self;
  3612. FNoScrollListBox.Align := alClient;
  3613. FNoScrollListBox.DoubleBuffered := False;
  3614. FNoScrollListBox.BorderStyle := bsNone;
  3615. FNoScrollListBox.Style := lbOwnerDrawFixed;
  3616. FNoScrollListBox.MultiSelect := True;
  3617. FNoScrollListBox.ExtendedSelect := True;
  3618. FNoScrollListBox.AutoComplete := False;
  3619. FNoScrollListBox.FListView := Self;
  3620. FListBoxScrollBar := TListBoxScrollBar.Create(Self);
  3621. FListBoxScrollBar.Parent := Self;
  3622. FListBoxScrollBar.Align := alRight;
  3623. FListBoxScrollBar.DoubleBuffered := True;
  3624. FListBoxScrollBar.FListView := Self;
  3625. FNoScrollListBox.OnResize := FListBoxScrollBar.ListBoxResize;
  3626. FNoScrollListBox.OnConstrainedResize := FListBoxScrollBar.ListBoxConstrainedResize;
  3627. FNoScrollListBox.OnMouseWheelDown := FListBoxScrollBar.ListBoxMouseWheelDown;
  3628. FNoScrollListBox.OnMouseWheelUp := FListBoxScrollBar.ListBoxMouseWheelUp;
  3629. Style := lsMiddleHeadImage;
  3630. CaptionStyle := csDisplayName;
  3631. FAdjustPosition := True;
  3632. FFlashCaptionOnOnline := False;
  3633. FOnlineNumeric := 0;
  3634. FNoScrollListBox.OnClick := WhenClick;
  3635. FNoScrollListBox.OnDblClick := WhenDoubleClick;
  3636. FNoScrollListBox.OnMouseMove := WhenMouseMove;
  3637. FNoScrollListBox.OnMouseLeave := WhenMouseLeave;
  3638. FNoScrollListBox.OnMouseDown := WhenMouseDown;
  3639. FNoScrollListBox.OnMouseUp := WhenMouseUp;
  3640. end;
  3641. destructor TRealICQContacterListView.Destroy;
  3642. begin
  3643. try
  3644. FNoScrollListBox.OnResize := nil;
  3645. FNoScrollListBox.OnConstrainedResize := nil;
  3646. FNoScrollListBox.OnMouseWheelDown := nil;
  3647. FNoScrollListBox.OnMouseWheelUp := nil;
  3648. FreeAndNil(FTimer);
  3649. FreeAndNil(FNoScrollListBox);
  3650. FreeAndNil(FListBoxScrollBar);
  3651. FItems.Clear;
  3652. FreeAndNil(FItems);
  3653. FreeAndNil(FCameraIcon);
  3654. FreeAndNil(FTelephoneIcon);
  3655. FreeAndNil(FMobilePhoneIcon);
  3656. FreeAndNil(FEmailIcon);
  3657. FreeAndNil(FSMSIcon);
  3658. FreeAndNil(FAddFriendIcon);
  3659. FreeAndNil(FSelectedItemBackgroud);
  3660. FreeAndNil(FScrollBackgroundPictureDown);
  3661. FreeAndNil(FScrollBackgroundPictureHover);
  3662. FreeAndNil(FScrollBackgroundPictureNormal);
  3663. FreeAndNil(FScrollBarButtonBottomPictureDown);
  3664. FreeAndNil(FScrollBarButtonBottomPictureHover);
  3665. FreeAndNil(FScrollBarButtonBottomPictureNormal);
  3666. FreeAndNil(FScrollBarButtonMiddlePictureDown);
  3667. FreeAndNil(FScrollBarButtonMiddlePictureHover);
  3668. FreeAndNil(FScrollBarButtonMiddlePictureNormal);
  3669. FreeAndNil(FScrollBarButtonTopPictureDown);
  3670. FreeAndNil(FScrollBarButtonTopPictureHover);
  3671. FreeAndNil(FScrollBarButtonTopPictureNormal);
  3672. FreeAndNil(FScrollBottomButtonPictureDown);
  3673. FreeAndNil(FScrollBottomButtonPictureHover);
  3674. FreeAndNil(FScrollBottomButtonPictureNormal);
  3675. FreeAndNil(FScrollTopButtonPictureDown);
  3676. FreeAndNil(FScrollTopButtonPictureHover);
  3677. FreeAndNil(FScrollTopButtonPictureNormal);
  3678. FreeAndNil(FLeavePicture);
  3679. FreeAndNil(FBusyPicture);
  3680. FreeAndNil(FMutePicture);
  3681. FreeAndNil(FLeavePictureBig);
  3682. FreeAndNil(FBusyPictureBig);
  3683. FreeAndNil(FMutePictureBig);
  3684. FreeAndNil(FDefaultPictureSmallOffline);
  3685. FreeAndNil(FDefaultPictureMiddleOffline);
  3686. FreeAndNil(FDefaultPictureBigOffline);
  3687. FreeAndNil(FDefaultPictureSmall);
  3688. FreeAndNil(FDefaultPictureMiddle);
  3689. FreeAndNil(FDefaultPictureBig);
  3690. FHintWindow.ReleaseHandle;
  3691. FHintWindow.Free;
  3692. except
  3693. end;
  3694. inherited Destroy;
  3695. end;
  3696. { TRealICQFlashCaption }
  3697. constructor TRealICQFlashCaption.Create(ARealICQContacterListItem: TRealICQContacterListItem);
  3698. begin
  3699. inherited Create(True);
  3700. FRealICQContacterListItem := ARealICQContacterListItem;
  3701. FreeOnTerminate := True;
  3702. Resume;
  3703. end;
  3704. destructor TRealICQFlashCaption.Destroy;
  3705. var
  3706. ListItem: TRealICQContacterListItem;
  3707. FListView: TRealICQContacterListView;
  3708. Rect: TRect;
  3709. begin
  3710. try
  3711. if FRealICQContacterListItem <> nil then
  3712. begin
  3713. FRealICQContacterListItem.FCaptionColor := $00FFFFFF;
  3714. ListItem := FRealICQContacterListItem;
  3715. FListView := ListItem.FListView;
  3716. Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
  3717. InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
  3718. FRealICQContacterListItem.FFlashCaptionThread := nil;
  3719. end;
  3720. except
  3721. end;
  3722. inherited Destroy;
  3723. end;
  3724. procedure TRealICQFlashCaption.FlashCaptionColor;
  3725. var
  3726. ListItem: TRealICQContacterListItem;
  3727. FListView: TRealICQContacterListView;
  3728. Rect: TRect;
  3729. begin
  3730. if Terminated then
  3731. exit;
  3732. ListItem := FRealICQContacterListItem;
  3733. if ListItem = nil then
  3734. exit;
  3735. FListView := ListItem.FListView;
  3736. if not FListView.Visible then
  3737. exit;
  3738. if FListView.Height = 0 then
  3739. exit;
  3740. Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
  3741. if Rect.Bottom < 0 then
  3742. Exit;
  3743. if Rect.Top > FListView.Height then
  3744. Exit;
  3745. FRealICQContacterListItem.FCaptionColor := FlashColors[FColorIndex];
  3746. InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
  3747. end;
  3748. procedure TRealICQFlashCaption.Execute;
  3749. var
  3750. iLoop, jLoop: Integer;
  3751. begin
  3752. for iLoop := 1 to 3 do
  3753. for jLoop := 1 to FlashColorCount do
  3754. begin
  3755. if Terminated then
  3756. exit;
  3757. FColorIndex := jLoop;
  3758. Synchronize(FlashCaptionColor);
  3759. Sleep(400);
  3760. end;
  3761. end;
  3762. { TRealICQFlashImage }
  3763. constructor TRealICQFlashImage.Create(ARealICQContacterListItem: TRealICQContacterListItem);
  3764. begin
  3765. inherited Create(True);
  3766. FRealICQContacterListItem := ARealICQContacterListItem;
  3767. FreeOnTerminate := True;
  3768. Resume;
  3769. end;
  3770. destructor TRealICQFlashImage.Destroy;
  3771. var
  3772. ListItem: TRealICQContacterListItem;
  3773. FListView: TRealICQContacterListView;
  3774. Rect: TRect;
  3775. begin
  3776. try
  3777. if FRealICQContacterListItem <> nil then
  3778. begin
  3779. FRealICQContacterListItem.FHeadImagePosition := 0;
  3780. ListItem := FRealICQContacterListItem;
  3781. FListView := ListItem.FListView;
  3782. Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
  3783. InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
  3784. FRealICQContacterListItem.FFlashImageThread := nil;
  3785. end;
  3786. except
  3787. end;
  3788. inherited Destroy;
  3789. end;
  3790. procedure TRealICQFlashImage.FlashImagePosition;
  3791. var
  3792. ListItem: TRealICQContacterListItem;
  3793. FListView: TRealICQContacterListView;
  3794. Rect: TRect;
  3795. begin
  3796. if Terminated then
  3797. exit;
  3798. ListItem := FRealICQContacterListItem;
  3799. if ListItem = nil then
  3800. exit;
  3801. FListView := ListItem.FListView;
  3802. if not FListView.Visible then
  3803. exit;
  3804. if FListView.Height = 0 then
  3805. exit;
  3806. Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
  3807. if Rect.Bottom < 0 then
  3808. Exit;
  3809. if Rect.Top > FListView.Height then
  3810. Exit;
  3811. FRealICQContacterListItem.FHeadImagePosition := FPosition;
  3812. InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
  3813. end;
  3814. procedure TRealICQFlashImage.Execute;
  3815. var
  3816. iAdd: Integer;
  3817. begin
  3818. iAdd := 0;
  3819. FPosition := 1;
  3820. while not Terminated do
  3821. begin
  3822. if FPosition = 3 then
  3823. iAdd := -1;
  3824. if FPosition = 1 then
  3825. iAdd := 1;
  3826. FPosition := FPosition + iAdd;
  3827. Synchronize(FlashImagePosition);
  3828. sleep(300);
  3829. end;
  3830. end;
  3831. procedure Register;
  3832. begin
  3833. RegisterComponents('RealICQ UI', [TRealICQContacterListView]);
  3834. end;
  3835. end.