| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483 |
- {
- 文件名:RealICQContacterListView.pas
- 功 能:用于显示即时消息软件(RealICQ)中用户列表的自定义组件,支持多种显示方式。
- 建 立:尹进
- 历 史:
- 2005.12.23:补文件说明信息(尹进)
- }
- unit RealICQContacterListView;
- interface
- uses
- RealICQHoverImage, SingleBorderHintWindow, RealICQUtils, RealICQModel,
- RealICQUIColor, RealICQColors, RealICQClient, Messages, SysUtils, Forms,
- Windows, Classes, Controls, ExtCtrls, StdCtrls, Buttons, Graphics;
- {$INCLUDE ..\..\Client\LXTalk.inc}
- const
- cntHeightOfBigHeadImage = 35;
- cntHeightOfMiddleHeadImage = 35;
- cntHeightOfSmallHeadImage = 27;
- cntHeightOfNoHeadImage = 27;
- FlashColorCount = 6;
- FlashColors: array[1..FlashColorCount] of TColor = (clYellow, clLime, clFuchsia, clAqua, clBlue, clRed);
- CityLevels: WideString = '省市区县';
- type
- TRealICQContacterListView = class;
- TRealICQContacterListItemStyle = (lsBigHeadImage, lsMiddleHeadImage, lsSmallHeadImage, lsNoHeadImage);
- TRealICQContacterListItemCaptionStyle = (csDisplayName, csLoginName, csDisplayNameAndLoginName);
- TRealICQFlashStyle = (fsJump, fsDisappear);
- TNoScrollListBox = class(TCustomListBox)
- private
- FBufferedBitmap: TBitMap;
- FListView: TRealICQContacterListView;
- FMouseInDown: Boolean;
- procedure DrawContacterItem(ACanvas: TCanvas; Index: Integer; Rect: TRect; State: TOwnerDrawState);
- protected
- procedure WMEraseBKGND(var Message: TWMEraseBKGND); message WM_ERASEBKGND;
- procedure WMSIZE(var Message: TWMSIZE); message WM_SIZE;
- procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
- procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
- procedure WMMouseDown(var Message: TWMLBUTTONDOWN); message WM_LBUTTONDOWN;
- procedure CreateParams(var Params: TCreateParams); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- end;
- TListBoxScrollBar = class(TCustomPanel)
- private
- FListView: TRealICQContacterListView;
- //ListBox的可滚动的高度
- FClientRange: Integer;
- //滚动条可移动的高度
- FScrollRange: Integer;
- FTrackingBarTopRange: Integer;
- FAssignedPicture: Boolean;
- FButtonDown: Boolean;
- FTrackingBarDown: Boolean;
- FTrackingBarDonwY: Integer;
- FMovedYValue: Integer;
- FTopButtonImage: TRealICQHoverImage;
- FBottomButtonImage: TRealICQHoverImage;
- FBarButtonTopImage: TRealICQHoverImage;
- FBarButtonMiddleImage: TRealICQHoverImage;
- FBarButtonBottomImage: TRealICQHoverImage;
- FBackgroundImage: TRealICQHoverImage;
- FDrawing: Boolean;
- procedure DrawScrollBar;
- procedure ListBoxResize(Sender: TObject);
- procedure ListBoxConstrainedResize(Sender: TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer);
- procedure ListBoxMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
- procedure ListBoxMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
- procedure TopButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure TopButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure TopButtonImageMouseEnter(Sender: TObject);
- procedure TopButtonImageMouseLeave(Sender: TObject);
- procedure BottomButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BottomButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BottomButtonImageMouseEnter(Sender: TObject);
- procedure BottomButtonImageMouseLeave(Sender: TObject);
- procedure BarButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BarButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BarButtonImageMouseEnter(Sender: TObject);
- procedure BarButtonImageMouseLeave(Sender: TObject);
- procedure BarButtonImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- procedure BackgroundImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BackgroundImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure BackgroundImageMouseEnter(Sender: TObject);
- procedure BackgroundImageMouseLeave(Sender: TObject);
- protected
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- end;
- TRealICQContacterListItem = class
- private
- FListView: TRealICQContacterListView;
- FAdjustPositioned: Boolean;
- FCaptionColor: TColor;
- FHeadImagePosition: Integer;
- FFlashStyle: TRealICQFlashStyle;
- FFlashCaptionThread: TThread;
- FFlashImageThread: TThread;
- FMouseInRect: Boolean;
- FHint: string;
- FLoginName: string;
- FDisplayName: string;
- FWatchword: string;
- FLoginState: TRealICQLoginState;
- FLeaveMessage: string;
- FHeadImagePicture: TPicture;
- FHasCamera: Boolean;
- FHasTelephone: Boolean;
- FHasMobilePhone: Boolean;
- FHasEmail: Boolean;
- FHasSMS: Boolean;
- FHasAddFriend: Boolean;
- FStateIndex: Integer;
- FHeadImageRect: TRect;
- FCameraRect: TRect;
- FTelephoneRect: TRect;
- FMobilePhoneRect: TRect;
- FEmailRect: TRect;
- FSMSRect: TRect;
- FTextRect: TRect;
- FAddFriendRect: TRect;
- FMouseOver: Boolean;
- FMouseInTextRect: Boolean;
- FMouseInHeadImageRect: Boolean;
- FMouseInCameraRect: Boolean;
- FMouseInTelephoneRect: Boolean;
- FMouseInMobilePhoneRect: Boolean;
- FMouseInEmailRect: Boolean;
- FMouseInSMSRect: Boolean;
- FMouseInAddFriendRect: Boolean;
- FTel, FMobile: string;
- FCompany, FBranch: string;
- FHeadImageHint, FCameraHint, FTelephoneHint, FMobilePhoneHint, FEmailHint, FSMSHint: string;
- FAddFriendHint: string;
- FServerName: string;
- procedure SetDisplayName(Value: string);
- procedure SetWatchword(Value: string);
- procedure SetHeadImagePicture(Value: TPicture);
- function GetItemIndex: Integer;
- function GetSelected: Boolean;
- procedure SetSelected(Value: Boolean);
- procedure SetLoginState(Value: TRealICQLoginState);
- procedure HeadImagePictureChange(Sender: TObject);
- procedure AdjustPosition;
- function GetStatePosition(ALoginState: TRealICQLoginState): Integer;
- procedure SetBranch(const Value: string);
- protected
- public
- Data: Pointer;
- constructor Create(ALoginName: string; AListView: TRealICQContacterListView);
- destructor Destroy; override;
- procedure Flash(AStyle: TRealICQFlashStyle);
- procedure StopFlash;
- procedure ReDrawItem;
- procedure MoveToTop;
- property Branch: string read FBranch write SetBranch;
- published
- property LoginName: string read FLoginName;
- property DisplayName: string read FDisplayName write SetDisplayName;
- property Watchword: string read FWatchword write SetWatchword;
- property Selected: Boolean read GetSelected write SetSelected;
- property LoginState: TRealICQLoginState read FLoginState write SetLoginState;
- property LeaveMessage: string read FLeaveMessage write FLeaveMessage;
- property HeadImagePicture: TPicture read FHeadImagePicture write SetHeadImagePicture;
- property ItemIndex: Integer read GetItemIndex;
- property ListView: TRealICQContacterListView read FListView;
- property Mobile: string read FMobile write FMobile;
- property Tel: string read FTel write FTel;
- property StateIndex: Integer read FStateIndex write FStateIndex;
- property HasCamera: Boolean read FHasCamera write FHasCamera;
- property HasTelephone: Boolean read FHasTelephone write FHasTelephone;
- property HasMobilePhone: Boolean read FHasMobilePhone write FHasMobilePhone;
- property HasEmail: Boolean read FHasEmail write FHasEmail;
- property HasSMS: Boolean read FHasSMS write FHasSMS;
- property HasAddFriend: Boolean read FHasAddFriend write FHasAddFriend;
- property HeadImageHint: string read FHeadImageHint write FHeadImageHint;
- property CameraHint: string read FCameraHint write FCameraHint;
- property TelephoneHint: string read FTelephoneHint write FTelephoneHint;
- property MobilePhoneHint: string read FMobilePhoneHint write FMobilePhoneHint;
- property EmailHint: string read FEmailHint write FEmailHint;
- property SMSHint: string read FSMSHint write FSMSHint;
- property AddFriendHint: string read FAddFriendHint write FAddFriendHint;
- property Company: string read FCompany write FCompany;
- property ServerName: string read FServerName write FServerName;
- end;
- TRealICQContacterListItems = class(TStrings)
- private
- FRealICQContacterListView: TRealICQContacterListView;
- protected
- function GetObject(Index: Integer): TObject; override;
- procedure Put(Index: Integer; const S: string); override;
- function Get(Index: Integer): string; override;
- function GetCount: Integer; override;
- public
- constructor Create(ARealICQContacterListView: TRealICQContacterListView);
- destructor Destroy; override;
- function Add(const S: string): Integer; override;
- procedure Insert(Index: Integer; const S: string); override;
- procedure Clear; override;
- procedure Delete(Index: Integer); override;
- function IndexOf(const S: string): Integer; override;
- procedure Move(CurIndex, NewIndex: Integer); override;
- end;
- TRealICQContacterListItemNotifyEvent = procedure(Item: TRealICQContacterListItem) of object;
- TRealICQContacterListItemIconButtonType = (ltCamera, ltTel, ltMobile, ltEmail, ltSMS, ltHeadImage, ltAddFriend);
- TRealICQContacterListItemIconButtonEvent = procedure(Sender: TObject; Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType) of object;
- TRealICQContacterListItemShowHintEvent = procedure(Sender: TObject; Item: TRealICQContacterListItem; var HintStr: string) of object;
- TRealICQContacterListViewDropFilesEvent = procedure(Sender: TObject; var Message: TMessage) of object;
- TRealICQContacterListView = class(TPanel, IRealICQUIColor)
- private
- FNoScrollListBox: TNoScrollListBox;
- FListBoxScrollBar: TListBoxScrollBar;
- FAdjustPosition: Boolean;
- FFlashCaptionOnOnline: Boolean;
- FOnlineNumeric: Cardinal;
- FStyle: TRealICQContacterListItemStyle;
- FCaptionStyle: TRealICQContacterListItemCaptionStyle;
- FSelectedItemBorderColor: TColor;
- FSelectedItemBorderInnerColor: TColor;
- FSelectedItemBackColor: TColor;
- FHeadImageBorderColor: TColor;
- FHeadImageBackColor: TColor;
- FSelectedItemBackgroud: TPicture;
- FDefaultPictureBig: TPicture;
- FDefaultPictureMiddle: TPicture;
- FDefaultPictureSmall: TPicture;
- FDefaultPictureBigOffline: TPicture;
- FDefaultPictureMiddleOffline: TPicture;
- FDefaultPictureSmallOffline: TPicture;
- FLeavePicture: TIcon;
- FBusyPicture: TIcon;
- FMutePicture: TIcon;
- FLeavePictureBig: TIcon;
- FBusyPictureBig: TIcon;
- FMutePictureBig: TIcon;
- FCameraIcon: TIcon;
- FTelephoneIcon: TIcon;
- FMobilePhoneIcon: TIcon;
- FEmailIcon: TIcon;
- FSMSIcon: TIcon;
- FAddFriendIcon: TIcon;
- FShowHeadImageButton: Boolean;
- FShowTelButton: Boolean;
- FShowMobileButton: Boolean;
- FShowCameraButton: Boolean;
- FShowEmailButton: Boolean;
- FShowSMSButton: Boolean;
- FShowAddFriendButton: Boolean;
- FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor: TColor;
- FItems: TStrings;
- FTimer: TTimer;
- FHintWindow: TSingleBorderHintWindow;
- FTimerItemIndex: Integer;
- FOnSelectItemChanged: TRealICQContacterListItemNotifyEvent;
- FOnItemClick: TRealICQContacterListItemNotifyEvent;
- FOnItemDoubleClick: TRealICQContacterListItemNotifyEvent;
- FOnItemMouseEnter: TRealICQContacterListItemNotifyEvent;
- FOnItemMouseLeave: TRealICQContacterListItemNotifyEvent;
- FOnItemFlashCaption: TRealICQContacterListItemNotifyEvent;
- FOnItemOnline: TRealICQContacterListItemNotifyEvent;
- FOnItemOffline: TRealICQContacterListItemNotifyEvent;
- FOnItemIconButtonClick: TRealICQContacterListItemIconButtonEvent;
- FOnItemIconButtonDblClick: TRealICQContacterListItemIconButtonEvent;
- FOnItemShowHint: TRealICQContacterListItemShowHintEvent;
- FOnDropFiles: TRealICQContacterListViewDropFilesEvent;
- FOnItemMouseDown: TMouseEvent;
- FOnItemMouseUp: TMouseEvent;
- FOnHeadImageMouseEnter: TRealICQContacterListItemNotifyEvent;
- FOnHeadImageMouseLeave: TRealICQContacterListItemNotifyEvent;
- FScrollTopButtonPictureNormal: TPicture;
- FScrollTopButtonPictureHover: TPicture;
- FScrollTopButtonPictureDown: TPicture;
- FScrollBottomButtonPictureNormal: TPicture;
- FScrollBottomButtonPictureHover: TPicture;
- FScrollBottomButtonPictureDown: TPicture;
- FScrollBarButtonTopPictureNormal: TPicture;
- FScrollBarButtonTopPictureHover: TPicture;
- FScrollBarButtonTopPictureDown: TPicture;
- FScrollBarButtonMiddlePictureNormal: TPicture;
- FScrollBarButtonMiddlePictureHover: TPicture;
- FScrollBarButtonMiddlePictureDown: TPicture;
- FScrollBarButtonBottomPictureNormal: TPicture;
- FScrollBarButtonBottomPictureHover: TPicture;
- FScrollBarButtonBottomPictureDown: TPicture;
- FScrollBackgroundPictureNormal: TPicture;
- FScrollBackgroundPictureHover: TPicture;
- FScrollBackgroundPictureDown: TPicture;
- procedure SetScrollTopButtonPictureNormal(Value: TPicture);
- procedure SetScrollTopButtonPictureHover(Value: TPicture);
- procedure SetScrollTopButtonPictureDown(Value: TPicture);
- procedure SetScrollBottomButtonPictureNormal(Value: TPicture);
- procedure SetScrollBottomButtonPictureHover(Value: TPicture);
- procedure SetScrollBottomButtonPictureDown(Value: TPicture);
- procedure SetScrollBarButtonTopPictureNormal(Value: TPicture);
- procedure SetScrollBarButtonTopPictureHover(Value: TPicture);
- procedure SetScrollBarButtonTopPictureDown(Value: TPicture);
- procedure SetScrollBarButtonMiddlePictureNormal(Value: TPicture);
- procedure SetScrollBarButtonMiddlePictureHover(Value: TPicture);
- procedure SetScrollBarButtonMiddlePictureDown(Value: TPicture);
- procedure SetScrollBarButtonBottomPictureNormal(Value: TPicture);
- procedure SetScrollBarButtonBottomPictureHover(Value: TPicture);
- procedure SetScrollBarButtonBottomPictureDown(Value: TPicture);
- procedure SetScrollBackgroundPictureNormal(Value: TPicture);
- procedure SetScrollBackgroundPictureHover(Value: TPicture);
- procedure SetScrollBackgroundPictureDown(Value: TPicture);
- procedure SetStyle(Value: TRealICQContacterListItemStyle);
- procedure SetCaptionStyle(Value: TRealICQContacterListItemCaptionStyle);
- procedure SetSelectedItemBorderColor(Value: TColor);
- procedure SetSelectedItemBorderInnerColor(Value: TColor);
- procedure SetSelectedItemBackColor(Value: TColor);
- procedure SetHeadImageBorderColor(Value: TColor);
- procedure SetHeadImageBackColor(Value: TColor);
- procedure SetSelectedItemBackgroud(Value: TPicture);
- procedure SetDefaultPictureBig(Value: TPicture);
- procedure SetDefaultPictureMiddle(Value: TPicture);
- procedure SetDefaultPictureSmall(Value: TPicture);
- procedure SetDefaultPictureBigOffline(Value: TPicture);
- procedure SetDefaultPictureMiddleOffline(Value: TPicture);
- procedure SetDefaultPictureSmallOffline(Value: TPicture);
- procedure SetLeavePicture(Value: TIcon);
- procedure SetBusyPicture(Value: TIcon);
- procedure SetMutePicture(Value: TIcon);
- procedure SetLeavePictureBig(Value: TIcon);
- procedure SetBusyPictureBig(Value: TIcon);
- procedure SetMutePictureBig(Value: TIcon);
- procedure SetCameraIcon(Value: TIcon);
- procedure SetTelephoneIcon(Value: TIcon);
- procedure SetMobilePhoneIcon(Value: TIcon);
- procedure SetEmailIcon(Value: TIcon);
- procedure SetSMSIcon(Value: TIcon);
- procedure SetAddFriendIcon(Value: TIcon);
- function GetSelCount: Integer;
- procedure SetTopIndex(Value: Integer);
- function GetTopIndex: Integer;
- procedure WhenClick(Sender: TObject);
- procedure WhenDoubleClick(Sender: TObject);
- procedure WhenMouseLeave(Sender: TObject);
- procedure WhenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- procedure WhenMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure WhenMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure TimerOnTimer(Sender: TObject);
- procedure ShowCustomHint(Item: TRealICQContacterListItem);
- function GetCopyRight: string;
- protected
- procedure DoHeadImageMouseEnter(Item: TRealICQContacterListItem);
- procedure DoHeadImageMouseLeave(Item: TRealICQContacterListItem);
- procedure DoSelectItemChanged(Item: TRealICQContacterListItem);
- procedure DoItemClick(Item: TRealICQContacterListItem);
- procedure DoItemDoubleClick(Item: TRealICQContacterListItem);
- procedure DoItemMouseEnter(Item: TRealICQContacterListItem);
- procedure DoItemMouseLeave(Item: TRealICQContacterListItem);
- procedure DoItemFlashCaption(Item: TRealICQContacterListItem);
- procedure DoItemOnline(Item: TRealICQContacterListItem);
- procedure DoItemOffline(Item: TRealICQContacterListItem);
- procedure DoItemIconButtonClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
- procedure DoItemIconButtonDblClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
- procedure DoItemShowHint(Item: TRealICQContacterListItem; var HintStr: string);
- procedure DoDropFiles(var Message: TMessage);
- procedure DropFiles(var Message: TMessage); message WM_DropFiles;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure ChangeUIColor(AColor: TColor);
- function ItemAtPos(Pos: TPoint; Existing: Boolean): Integer;
- procedure ReDrawAll;
- property FlashCaptionOnOnline: Boolean read FFlashCaptionOnOnline write FFlashCaptionOnOnline;
- property OnlineNumeric: Cardinal read FOnlineNumeric;
- property Items: TStrings read FItems;
- property SelCount: Integer read GetSelCount;
- property TopIndex: Integer read GetTopIndex write SetTopIndex;
- published
- property CopyRight: string read GetCopyRight;
- property Caption;
- property Color;
- property Align;
- property Anchors;
- property Style: TRealICQContacterListItemStyle read FStyle write SetStyle;
- property CaptionStyle: TRealICQContacterListItemCaptionStyle read FCaptionStyle write SetCaptionStyle;
- property SelectedItemBorderInnerColor: TColor read FSelectedItemBorderInnerColor write SetSelectedItemBorderInnerColor;
- property SelectedItemBorderColor: TColor read FSelectedItemBorderColor write SetSelectedItemBorderColor;
- property SelectedItemBackColor: TColor read FSelectedItemBackColor write SetSelectedItemBackColor;
- property HeadImageBorderColor: TColor read FHeadImageBorderColor write SetHeadImageBorderColor;
- property HeadImageBackColor: TColor read FHeadImageBackColor write SetHeadImageBackColor;
- property SelectedItemBackgroud: TPicture read FSelectedItemBackgroud write SetSelectedItemBackgroud;
- property DefaultPictureBig: TPicture read FDefaultPictureBig write SetDefaultPictureBig;
- property DefaultPictureMiddle: TPicture read FDefaultPictureMiddle write SetDefaultPictureMiddle;
- property DefaultPictureSmall: TPicture read FDefaultPictureSmall write SetDefaultPictureSmall;
- property DefaultPictureBigOffline: TPicture read FDefaultPictureBigOffline write SetDefaultPictureBigOffline;
- property DefaultPictureMiddleOffline: TPicture read FDefaultPictureMiddleOffline write SetDefaultPictureMiddleOffline;
- property DefaultPictureSmallOffline: TPicture read FDefaultPictureSmallOffline write SetDefaultPictureSmallOffline;
- property AdjustPosition: Boolean read FAdjustPosition write FAdjustPosition;
- property LeavePicture: TIcon read FLeavePicture write SetLeavePicture;
- property BusyPicture: TIcon read FBusyPicture write SetBusyPicture;
- property MutePicture: TIcon read FMutePicture write SetMutePicture;
- property LeavePictureBig: TIcon read FLeavePictureBig write SetLeavePictureBig;
- property BusyPictureBig: TIcon read FBusyPictureBig write SetBusyPictureBig;
- property MutePictureBig: TIcon read FMutePictureBig write SetMutePictureBig;
- property CameraIcon: TIcon read FCameraIcon write SetCameraIcon;
- property TelephoneIcon: TIcon read FTelephoneIcon write SetTelephoneIcon;
- property MobilePhoneIcon: TIcon read FMobilePhoneIcon write SetMobilePhoneIcon;
- property EmailIcon: TIcon read FEmailIcon write SetEmailIcon;
- property SMSIcon: TIcon read FSMSIcon write SetSMSIcon;
- property AddFriendIcon: TIcon read FAddFriendIcon write SetAddFriendIcon;
- property ShowHeadImageButton: Boolean read FShowHeadImageButton write FShowHeadImageButton;
- property ShowTelButton: Boolean read FShowTelButton write FShowTelButton;
- property ShowMobileButton: Boolean read FShowMobileButton write FShowMobileButton;
- property ShowCameraButton: Boolean read FShowCameraButton write FShowCameraButton;
- property ShowEmailButton: Boolean read FShowEmailButton write FShowEmailButton;
- property ShowSMSButton: Boolean read FShowSMSButton write FShowSMSButton;
- property ShowAddFriendButton: Boolean read FShowAddFriendButton write FShowAddFriendButton;
- property ScrollTopButtonPictureNormal: TPicture read FScrollTopButtonPictureNormal write SetScrollTopButtonPictureNormal;
- property ScrollTopButtonPictureHover: TPicture read FScrollTopButtonPictureHover write SetScrollTopButtonPictureHover;
- property ScrollTopButtonPictureDown: TPicture read FScrollTopButtonPictureDown write SetScrollTopButtonPictureDown;
- property ScrollBottomButtonPictureNormal: TPicture read FScrollBottomButtonPictureNormal write SetScrollBottomButtonPictureNormal;
- property ScrollBottomButtonPictureHover: TPicture read FScrollBottomButtonPictureHover write SetScrollBottomButtonPictureHover;
- property ScrollBottomButtonPictureDown: TPicture read FScrollBottomButtonPictureDown write SetScrollBottomButtonPictureDown;
- property ScrollBarButtonTopPictureNormal: TPicture read FScrollBarButtonTopPictureNormal write SetScrollBarButtonTopPictureNormal;
- property ScrollBarButtonTopPictureHover: TPicture read FScrollBarButtonTopPictureHover write SetScrollBarButtonTopPictureHover;
- property ScrollBarButtonTopPictureDown: TPicture read FScrollBarButtonTopPictureDown write SetScrollBarButtonTopPictureDown;
- property ScrollBarButtonMiddlePictureNormal: TPicture read FScrollBarButtonMiddlePictureNormal write SetScrollBarButtonMiddlePictureNormal;
- property ScrollBarButtonMiddlePictureHover: TPicture read FScrollBarButtonMiddlePictureHover write SetScrollBarButtonMiddlePictureHover;
- property ScrollBarButtonMiddlePictureDown: TPicture read FScrollBarButtonMiddlePictureDown write SetScrollBarButtonMiddlePictureDown;
- property ScrollBarButtonBottomPictureNormal: TPicture read FScrollBarButtonBottomPictureNormal write SetScrollBarButtonBottomPictureNormal;
- property ScrollBarButtonBottomPictureHover: TPicture read FScrollBarButtonBottomPictureHover write SetScrollBarButtonBottomPictureHover;
- property ScrollBarButtonBottomPictureDown: TPicture read FScrollBarButtonBottomPictureDown write SetScrollBarButtonBottomPictureDown;
- property ScrollBackgroundPictureNormal: TPicture read FScrollBackgroundPictureNormal write SetScrollBackgroundPictureNormal;
- property ScrollBackgroundPictureHover: TPicture read FScrollBackgroundPictureHover write SetScrollBackgroundPictureHover;
- property ScrollBackgroundPictureDown: TPicture read FScrollBackgroundPictureDown write SetScrollBackgroundPictureDown;
- property OnSelectItemChanged: TRealICQContacterListItemNotifyEvent read FOnSelectItemChanged write FOnSelectItemChanged;
- property OnItemClick: TRealICQContacterListItemNotifyEvent read FOnItemClick write FOnItemClick;
- property OnItemDoubleClick: TRealICQContacterListItemNotifyEvent read FOnItemDoubleClick write FOnItemDoubleClick;
- property OnItemMouseEnter: TRealICQContacterListItemNotifyEvent read FOnItemMouseEnter write FOnItemMouseEnter;
- property OnItemMouseLeave: TRealICQContacterListItemNotifyEvent read FOnItemMouseLeave write FOnItemMouseLeave;
- property OnItemFlashCaption: TRealICQContacterListItemNotifyEvent read FOnItemFlashCaption write FOnItemFlashCaption;
- property OnItemOnline: TRealICQContacterListItemNotifyEvent read FOnItemOnline write FOnItemOnline;
- property OnItemOffline: TRealICQContacterListItemNotifyEvent read FOnItemOffline write FOnItemOffline;
- property OnItemIconButtonClick: TRealICQContacterListItemIconButtonEvent read FOnItemIconButtonClick write FOnItemIconButtonClick;
- property OnItemIconButtonDblClick: TRealICQContacterListItemIconButtonEvent read FOnItemIconButtonDblClick write FOnItemIconButtonDblClick;
- property OnItemShowHint: TRealICQContacterListItemShowHintEvent read FOnItemShowHint write FOnItemShowHint;
- property OnDropFiles: TRealICQContacterListViewDropFilesEvent read FOnDropFiles write FOnDropFiles;
- property OnItemMouseDown: TMouseEvent read FOnItemMouseDown write FOnItemMouseDown;
- property OnItemMouseUp: TMouseEvent read FOnItemMouseUp write FOnItemMouseUp;
- property OnHeadImageMouseEnter: TRealICQContacterListItemNotifyEvent read FOnHeadImageMouseEnter write FOnHeadImageMouseEnter;
- property OnHeadImageMouseLeave: TRealICQContacterListItemNotifyEvent read FOnHeadImageMouseLeave write FOnHeadImageMouseLeave;
- property ListBox: TNoScrollListBox read FNoScrollListBox;
- end;
- TRealICQFlashCaption = class(TThread)
- private
- FRealICQContacterListItem: TRealICQContacterListItem;
- FColorIndex: Integer;
- procedure FlashCaptionColor;
- protected
- procedure Execute; override;
- public
- constructor Create(ARealICQContacterListItem: TRealICQContacterListItem);
- destructor Destroy; override;
- end;
- TRealICQFlashImage = class(TThread)
- private
- FRealICQContacterListItem: TRealICQContacterListItem;
- FPosition: Integer;
- procedure FlashImagePosition;
- protected
- procedure Execute; override;
- public
- constructor Create(ARealICQContacterListItem: TRealICQContacterListItem);
- destructor Destroy; override;
- end;
- procedure Register;
- implementation
- uses
- StrUtils;
- function TRealICQContacterListView.GetCopyRight: string;
- begin
- Result := '版权所有(C) 2002-2016 浙江万赛软件科技有限公司 保留所有权利。';
- end;
- {TNoScrollListBox}
- constructor TNoScrollListBox.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Color := clWhite;
- FBufferedBitmap := TBitMap.Create;
- end;
- destructor TNoScrollListBox.Destroy;
- begin
- try
- FreeAndNil(FBufferedBitmap);
- except
- end;
- inherited Destroy;
- end;
- procedure TNoScrollListBox.CreateParams(var Params: TCreateParams);
- begin
- inherited CreateParams(Params);
- with Params do
- begin
- Style := Style - WS_VSCROLL;
- end;
- end;
- procedure TNoScrollListBox.WMPaint(var Message: TWMPaint);
- begin
- inherited;
- end;
- procedure TNoScrollListBox.WMMouseDown(var Message: TWMLBUTTONDOWN);
- begin
- try
- if Assigned(FListView.FOnItemMouseDown) then
- FListView.FOnItemMouseDown(FListView, mbLeft, [], Message.XPos, Message.YPos);
- finally
- inherited;
- end;
- end;
- procedure TNoScrollListBox.WMEraseBKGND(var Message: TWMEraseBKGND);
- var
- ACanvas: TCanvas;
- begin
- ACanvas := TCanvas.Create;
- try
- ACanvas.Handle := Message.DC;
- ACanvas.Pen.Color := clWhite;
- ACanvas.Brush.Color := clWhite;
- ACanvas.FillRect(Rect(0, ItemHeight * Items.Count, ClientWidth, ClientHeight));
- finally
- ACanvas.Free;
- end;
- Message.Result := 1; // 已处理
- end;
- procedure TNoScrollListBox.WMSIZE(var Message: TWMSIZE);
- begin
- inherited;
- Invalidate;
- end;
- procedure TNoScrollListBox.DrawContacterItem(ACanvas: TCanvas; Index: Integer; Rect: TRect; State: TOwnerDrawState);
- var
- ListItem: TRealICQContacterListItem;
- R: TRect;
- ACaption: string;
- ACaptionWidth: Integer;
- AHeadPicture: TPicture;
- AddLeft, AddTop: Integer;
- DrawHeadImage: Boolean;
- NeedDrawImageBorder: Boolean;
- Icon: TIcon;
- P: TPoint;
- AStateIcon: TIcon;
- b, n: string;
- function GetCaption(AServerName, ABranchName, ADisplayName: WideString): string;
- begin
- {$IFDEF LSSBGZS}
- if AServerName <> '' then
- begin
- if ABranchName <> '' then
- begin
- if Pos(LeftStr(ABranchName, 1), CityLevels) > 0 then
- begin
- Delete(ABranchName, 1, 1);
- Result := ADisplayName + '(' + AServerName + ABranchName + ')';
- end
- else if Pos(AServerName, ABranchName) > 0 then
- begin
- Result := ADisplayName + '(' + ABranchName + ')';
- end
- else if (Pos(RightStr(AServerName, 1), CityLevels) > 1) and (Pos(LeftStr(AServerName, Length(AServerName) - 1), ABranchName) > 0) then
- Result := ADisplayName + '(' + ABranchName + ')'
- else
- begin
- Result := ADisplayName + '(' + AServerName + ABranchName + ')';
- end;
- end
- else
- Result := ADisplayName + '(' + AServerName + ')';
- end
- else
- {$ENDIF}
- begin
- if ABranchName <> '' then
- begin
- Result := ADisplayName + '(' + ABranchName + ')'
- end
- else
- Result := ADisplayName;
- end;
- end;
- begin
- ListItem := Items.Objects[Index] as TRealICQContacterListItem;
- if ListItem = nil then
- exit;
- P.X := Mouse.CursorPos.X;
- P.Y := Mouse.CursorPos.Y;
- P := ScreenToClient(P);
- with ListItem do
- begin
- FHeadImageRect.Left := 0;
- FHeadImageRect.Top := 0;
- FHeadImageRect.Right := 0;
- FHeadImageRect.Bottom := 0;
- FCameraRect.Left := 0;
- FCameraRect.Top := 0;
- FCameraRect.Right := 0;
- FCameraRect.Bottom := 0;
- FTelephoneRect.Left := 0;
- FTelephoneRect.Top := 0;
- FTelephoneRect.Right := 0;
- FTelephoneRect.Bottom := 0;
- FMobilePhoneRect.Left := 0;
- FMobilePhoneRect.Top := 0;
- FMobilePhoneRect.Right := 0;
- FMobilePhoneRect.Bottom := 0;
- FSMSRect.Left := 0;
- FSMSRect.Top := 0;
- FSMSRect.Right := 0;
- FSMSRect.Bottom := 0;
- FTextRect.Left := 0;
- FTextRect.Top := 0;
- FTextRect.Right := 0;
- FTextRect.Bottom := 0;
- FAddFriendRect.Left := 0;
- FAddFriendRect.Top := 0;
- FAddFriendRect.Right := 0;
- FAddFriendRect.Bottom := 0;
- end;
- NeedDrawImageBorder := False;
- ACanvas.FillRect(Rect);
-
- {$region '绘制选中状态的背景'}
- if (odSelected in State) or ListItem.FMouseOver then
- begin
- NeedDrawImageBorder := True;
- if (odSelected in State) then
- begin
- ACanvas.Pen.Color := FListView.FSelectedItemBorderColor;
- ACanvas.Brush.Color := FListView.FSelectedItemBackColor;
- end
- else
- begin
- ACanvas.Pen.Color := RealICQColors.ConvertColorToLighter(FListView.FSelectedItemBorderColor, 12);
- ACanvas.Brush.Color := RealICQColors.ConvertColorToLighter(FListView.FSelectedItemBackColor, 6);
- end;
- R.Left := Rect.Left;
- R.Top := Rect.Top + 1;
- R.Right := Rect.Right - 1;
- R.Bottom := Rect.Bottom;
- ACanvas.RoundRect(R.Left, R.Top, R.Right, R.Bottom, 5, 5);
- R.Left := Rect.Left + 2;
- R.Top := Rect.Top + 3;
- R.Right := Rect.Right - 3;
- R.Bottom := Rect.Bottom - 2;
- // ACanvas.StretchDraw(R, FListView.FSelectedItemBackgroud.Graphic);
- ACanvas.Pen.Color := FListView.SelectedItemBorderInnerColor;
- ACanvas.Brush.Style := bsClear;
- ACanvas.RoundRect(R.Left - 1, R.Top - 1, R.Right + 1, R.Bottom + 1, 3, 3);
- end;
- {$endregion'}
- {$region '计算头像的位置,头像跳动时用到'}
- DrawHeadImage := True;
- AddLeft := 0;
- AddTop := 0;
- if ListItem.FFlashStyle = fsJump then
- begin
- case ListItem.FHeadImagePosition of
- 1:
- begin
- AddLeft := -1;
- AddTop := +1;
- end;
- 2:
- begin
- AddLeft := 0;
- AddTop := -1;
- end;
- 3:
- begin
- AddLeft := +1;
- AddTop := +1;
- end;
- end;
- end
- else
- begin
- if ListItem.FHeadImagePosition mod 2 = 0 then
- DrawHeadImage := True
- else
- DrawHeadImage := False;
- end;
- {$endregion'}
- AHeadPicture := TPicture.Create;
- try
- case FListView.Style of
- lsBigHeadImage:
- begin
- {$region '绘制 48*48 高度的Item'}
- if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
- begin
- NeedDrawImageBorder := True;
- AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
- end
- else
- begin
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddle.Graphic);
- end;
- if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- begin
- if (FListView.FDefaultPictureMiddleOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddleOffline.Graphic)
- else
- RealICQColors.Grayscale(AHeadPicture.Bitmap);
- end;
- if NeedDrawImageBorder or ListItem.FMouseOver then
- begin
- //画头像边框
- ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
- ACanvas.Brush.Color := FListView.FHeadImageBackColor;
- R.Left := Rect.Left + 3 + AddLeft;
- R.Top := Rect.Top + 4 + AddTop;
- R.Right := R.Left + 28;
- R.Bottom := R.Top + 28;
- ACanvas.Rectangle(R);
- end;
- R.Left := Rect.Left + 5 + AddLeft;
- R.Top := Rect.Top + 6 + AddTop;
- R.Right := R.Left + 24;
- R.Bottom := R.Top + 24;
- if DrawHeadImage then
- ACanvas.StretchDraw(R, AHeadPicture.Graphic);
- ListItem.FHeadImageRect := R;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
- ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 28;
- ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 28;
- if PtInRect(ListItem.FHeadImageRect, P) then
- begin
- if not ListItem.FMouseInHeadImageRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInHeadImageRect := True;
- if FListView.FShowHeadImageButton then
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
- end;
- end;
- end;
- if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
- begin
- AStateIcon := nil;
- if ListItem.FLoginState = stLeave then
- AStateIcon := FListView.FLeavePictureBig;
- if ListItem.FLoginState = stBusy then
- AStateIcon := FListView.FBusyPictureBig;
- if ListItem.FLoginState = stMute then
- AStateIcon := FListView.FMutePictureBig;
- if ListItem.FLoginState = stMobileOnline then
- AStateIcon := FListView.FMobilePhoneIcon;
- if AStateIcon <> nil then
- begin
- R.Left := R.Right - 11;
- R.Top := R.Bottom - 11;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 11, 11, 0, 0, DI_NORMAL);
- end;
- end;
- //TextRect
- R.Left := Rect.Left;
- R.Top := Rect.Top;
- R.Right := Rect.Right - 3;
- R.Bottom := Rect.Bottom;
- if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
- ACaption := ListItem.FLoginName
- else if FListView.FCaptionStyle = csDisplayName then
- ACaption := ListItem.FDisplayName
- else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
- ACaption := ListItem.FDisplayName;
- //else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
- // ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
- ACanvas.Brush.Style := bsClear;
- ACanvas.Font := FListView.Font;
- if ListItem.FCaptionColor <> $00FFFFFF then
- ACanvas.Font.Color := ListItem.FCaptionColor
- else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- ACanvas.Font.Color := clGray
- else
- ACanvas.Font.Color := clBlack;
- ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 5, ACaption);
- ACaptionWidth := ACanvas.TextWidth(ACaption);
- ListItem.FHint := ACaption;
- if FListView.FCaptionStyle = csDisplayNameAndLoginName then
- begin
- ACaption := '<' + ListItem.FLoginName + '>';
- ACanvas.Font.Color := clRed;
- ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 5, ACaption);
- ACaptionWidth := ACaptionWidth + ACanvas.TextWidth(ACaption);
- end;
- if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
- ACaption := '(' + ListItem.FLeaveMessage + ')'
- else if (ListItem.FLoginState = stMute) then
- ACaption := '(' + StateValues[4] + ')'
- else
- ACaption := '';
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 5, ACaption);
- ListItem.FHint := ListItem.FHint + ACaption;
- if (Length(ListItem.FWatchword) = 0) then
- ACaption := ''
- else
- ACaption := ListItem.FWatchword;
- //ACaption:= '(' + ListItem.FWatchword + ')';
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 22, ACaption);
- ListItem.FHint := ListItem.FHint + ACaption;
- {$region '文字区域'}
- ListItem.FTextRect := R;
- ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTextRect.Left := ListItem.FTextRect.Left + 35;
- ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + 35;
- {$endregion}
- R.Left := Rect.Left + 35 - 20;
- R.Top := Rect.Top + 39;
- {$region '绘制短信图标'}
- if ListItem.HasSMS and FListView.ShowSMSButton then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FSMSRect := R;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
- ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
- ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
- if PtInRect(ListItem.FSMSRect, P) then
- begin
- if not ListItem.FMouseInSMSRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInSMSRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制信箱图标'}
- if ListItem.HasEmail and FListView.ShowEmailButton then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FEmailRect := R;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
- ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
- ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
- if PtInRect(ListItem.FEmailRect, P) then
- begin
- if not ListItem.FMouseInEmailRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInEmailRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制手机图标'}
- if ListItem.FHasMobilePhone and FListView.ShowMobileButton then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FMobilePhoneRect := R;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
- ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
- ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
- if PtInRect(ListItem.FMobilePhoneRect, P) then
- begin
- if not ListItem.FMouseInMobilePhoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInMobilePhoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制坐机图标'}
- if ListItem.FHasTelephone and FListView.ShowTelButton then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.TelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FTelephoneRect := R;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
- ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
- ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
- if PtInRect(ListItem.FTelephoneRect, P) then
- begin
- if not ListItem.FMouseInTelephoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInTelephoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制摄像头图标'}
- if ListItem.FHasCamera and FListView.ShowCameraButton then
- begin
- if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FCameraRect := R;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
- ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
- ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
- if PtInRect(ListItem.FCameraRect, P) then
- begin
- if not ListItem.FMouseInCameraRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInCameraRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
- end;
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制增加好友图标'}
- if ListItem.FHasAddFriend and FListView.ShowAddFriendButton then
- begin
- R.Left := R.Left + 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FAddFriendRect := R;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
- ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
- ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
- if PtInRect(ListItem.FAddFriendRect, P) then
- begin
- if not ListItem.FMouseInAddFriendRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInAddFriendRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- end;
- lsMiddleHeadImage:
- begin
- {$region '绘制 24*24 高度的Item'}
- if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
- begin
- NeedDrawImageBorder := True;
- AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
- end
- else
- begin
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddle.Graphic);
- end;
- if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- begin
- if (FListView.FDefaultPictureMiddleOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureMiddleOffline.Graphic)
- else
- RealICQColors.Grayscale(AHeadPicture.Bitmap);
- end;
- if NeedDrawImageBorder or ListItem.FMouseOver then
- begin
- //画头像边框
- ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
- ACanvas.Brush.Color := FListView.FHeadImageBackColor;
- R.Left := Rect.Left + 3 + AddLeft;
- R.Top := Rect.Top + 4 + AddTop;
- R.Right := R.Left + 28;
- R.Bottom := R.Top + 28;
- ACanvas.Rectangle(R);
- end;
- R.Left := Rect.Left + 5 + AddLeft;
- R.Top := Rect.Top + 6 + AddTop;
- R.Right := R.Left + 24;
- R.Bottom := R.Top + 24;
- if DrawHeadImage then
- ACanvas.StretchDraw(R, AHeadPicture.Graphic);
- ListItem.FHeadImageRect := R;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
- ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 28;
- ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 28;
- if PtInRect(ListItem.FHeadImageRect, P) then
- begin
- if not ListItem.FMouseInHeadImageRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInHeadImageRect := True;
- if FListView.FShowHeadImageButton then
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
- end;
- end;
- end;
- if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
- begin
- AStateIcon := nil;
- if ListItem.FLoginState = stLeave then
- AStateIcon := FListView.FLeavePictureBig;
- if ListItem.FLoginState = stBusy then
- AStateIcon := FListView.FBusyPictureBig;
- if ListItem.FLoginState = stMute then
- AStateIcon := FListView.FMutePictureBig;
- if ListItem.FLoginState = stMobileOnline then
- AStateIcon := FListView.FMobilePhoneIcon;
- if AStateIcon <> nil then
- begin
- R.Left := R.Right - 11;
- R.Top := R.Bottom - 11;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 11, 11, 0, 0, DI_NORMAL);
- end;
- end;
- //TextRect
- R.Left := Rect.Left;
- R.Top := Rect.Top;
- R.Right := Rect.Right - 3;
- R.Bottom := Rect.Bottom;
- if ListItem.FHasCamera then
- if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
- R.Right := R.Right - 24;
- if ListItem.FHasTelephone then
- R.Right := R.Right - 24;
- if ListItem.FHasMobilePhone then
- R.Right := R.Right - 24;
- if ListItem.FHasEmail then
- R.Right := R.Right - 24;
- if ListItem.FHasSMS then
- R.Right := R.Right - 24;
- R.Right := R.Right - 4;
- if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
- ACaption := ListItem.FLoginName
- else if FListView.FCaptionStyle = csDisplayName then
- ACaption := ListItem.FDisplayName
- else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
- ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
- ACanvas.Brush.Style := bsClear;
- ACanvas.Font := FListView.Font;
- if ListItem.FCaptionColor <> $00FFFFFF then
- ACanvas.Font.Color := ListItem.FCaptionColor
- else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- ACanvas.Font.Color := clGray
- else
- ACanvas.Font.Color := clBlack;
- ACanvas.TextRect(R, Rect.Left + 35, Rect.Top + 12, ACaption);
- ACaptionWidth := ACanvas.TextWidth(ACaption);
- ListItem.FHint := ACaption;
- if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
- ACaption := '(' + ListItem.FLeaveMessage + ')'
- else if (ListItem.FLoginState = stMute) then
- ACaption := '(' + StateValues[4] + ')'
- else
- ACaption := '';
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 12, ACaption);
- Inc(ACaptionWidth, ACanvas.TextWidth(ACaption));
- ListItem.FHint := ListItem.FHint + ACaption;
- if (Length(ListItem.FWatchword) = 0) then
- ACaption := ''
- else
- ACaption := ' - ' + ListItem.FWatchword;
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 35 + ACaptionWidth, Rect.Top + 12, ACaption);
- ListItem.FHint := ListItem.FHint + ACaption;
- {$region '文字区域'}
- ListItem.FTextRect := R;
- ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTextRect.Left := ListItem.FTextRect.Left + 35;
- ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + ItemHeight;
- {$endregion}
- R.Left := Rect.Right;
- R.Top := Rect.Top + 9;
-
- {$region '绘制摄像头图标'}
- if ListItem.FHasCamera then
- begin
- if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FCameraRect := R;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
- ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
- ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
- if PtInRect(ListItem.FCameraRect, P) then
- begin
- if not ListItem.FMouseInCameraRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInCameraRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
- end;
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制坐机图标'}
- if ListItem.HasTelephone then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FTelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FTelephoneRect := R;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
- ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
- ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
- if PtInRect(ListItem.FTelephoneRect, P) then
- begin
- if not ListItem.FMouseInTelephoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInTelephoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制手机图标'}
- if ListItem.HasMobilePhone then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FMobilePhoneRect := R;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
- ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
- ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
- if PtInRect(ListItem.FMobilePhoneRect, P) then
- begin
- if not ListItem.FMouseInMobilePhoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInMobilePhoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制信箱图标'}
- if ListItem.HasEmail then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FEmailRect := R;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
- ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
- ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
- if PtInRect(ListItem.FEmailRect, P) then
- begin
- if not ListItem.FMouseInEmailRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInEmailRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制短信图标'}
- if ListItem.HasSMS then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FSMSRect := R;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
- ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
- ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
- if PtInRect(ListItem.FSMSRect, P) then
- begin
- if not ListItem.FMouseInSMSRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInSMSRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$endregion}
- {$region '绘制增加好友图标'}
- if ListItem.FHasAddFriend then
- begin
- R.Left := R.Left - 28;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FAddFriendRect := R;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
- ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
- ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
- if PtInRect(ListItem.FAddFriendRect, P) then
- begin
- if not ListItem.FMouseInAddFriendRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInAddFriendRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- end;
- lsSmallHeadImage:
- begin
- {$region '绘制 16*16 高度的Item'}
- if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
- begin
- NeedDrawImageBorder := ListItem.StateIndex = 1;
- AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
- end
- else
- begin
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmall.Graphic);
- end;
- if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- begin
- if (FListView.FDefaultPictureSmallOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmallOffline.Graphic)
- else
- RealICQColors.Grayscale(AHeadPicture.Bitmap);
- end;
- if NeedDrawImageBorder or ListItem.FMouseOver then
- begin
- //画头像边框
- ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
- ACanvas.Brush.Color := FListView.FHeadImageBackColor;
- R.Left := Rect.Left + 3 + AddLeft;
- R.Top := Rect.Top + 4 + AddTop;
- R.Right := R.Left + 20;
- R.Bottom := R.Top + 20;
- ACanvas.Rectangle(R);
- end;
- R.Left := Rect.Left + 5 + AddLeft;
- R.Top := Rect.Top + 6 + AddTop;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- if DrawHeadImage then
- ACanvas.StretchDraw(R, AHeadPicture.Graphic);
- ListItem.FHeadImageRect := R;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
- ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 20;
- ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 20;
- if PtInRect(ListItem.FHeadImageRect, P) then
- begin
- if not ListItem.FMouseInHeadImageRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInHeadImageRect := True;
- if FListView.FShowHeadImageButton then
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
- end;
- end;
- end;
- if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
- begin
- AStateIcon := nil;
- if ListItem.FLoginState = stLeave then
- AStateIcon := FListView.FLeavePicture;
- if ListItem.FLoginState = stBusy then
- AStateIcon := FListView.FBusyPicture;
- if ListItem.FLoginState = stMute then
- AStateIcon := FListView.FMutePicture;
- if ListItem.FLoginState = stMobileOnline then
- AStateIcon := FListView.FMobilePhoneIcon;
- if AStateIcon <> nil then
- begin
- R.Left := R.Right - 9;
- R.Top := R.Bottom - 9;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 9, 9, 0, 0, DI_NORMAL);
- end;
- end;
- //TextRect
- R.Left := Rect.Left;
- R.Top := Rect.Top;
- R.Right := Rect.Right - 3;
- R.Bottom := Rect.Bottom;
- if ListItem.FHasCamera then
- if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
- R.Right := R.Right - 24;
- if ListItem.FHasTelephone then
- R.Right := R.Right - 24;
- if ListItem.FHasMobilePhone then
- R.Right := R.Right - 24;
- if ListItem.FHasEmail then
- R.Right := R.Right - 24;
- if ListItem.FHasSMS then
- R.Right := R.Right - 24;
- R.Right := R.Right - 4;
- if (Length(ListItem.FDisplayName) = 0) or (FListView.FCaptionStyle = csLoginName) then
- ACaption := ListItem.FLoginName
- else if FListView.FCaptionStyle = csDisplayName then
- ACaption := ListItem.FDisplayName
- else if FListView.FCaptionStyle = csDisplayNameAndLoginName then
- ACaption := ListItem.FDisplayName + '<' + ListItem.FLoginName + '>';
- ACanvas.Brush.Style := bsClear;
- ACanvas.Font := FListView.Font;
- if ListItem.FCaptionColor <> $00FFFFFF then
- ACanvas.Font.Color := ListItem.FCaptionColor
- else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- ACanvas.Font.Color := clGray
- else
- ACanvas.Font.Color := clBlack;
- ACanvas.TextRect(R, Rect.Left + 27, Rect.Top + 8, ACaption);
- ACaptionWidth := ACanvas.TextWidth(ACaption);
- ListItem.FHint := ACaption;
- if ((ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy)) and (Length(Trim(ListItem.FLeaveMessage)) > 0) then
- ACaption := '(' + ListItem.FLeaveMessage + ')'
- else if (ListItem.FLoginState = stMute) then
- ACaption := '(' + StateValues[4] + ')'
- else
- ACaption := '';
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 27 + ACaptionWidth, Rect.Top + 8, ACaption);
- Inc(ACaptionWidth, ACanvas.TextWidth(ACaption));
- ListItem.FHint := ListItem.FHint + ACaption;
- if (Length(ListItem.FWatchword) = 0) then
- ACaption := ''
- else
- ACaption := ' - ' + ListItem.FWatchword;
- ACanvas.Font.Color := clGray;
- ACanvas.TextRect(R, Rect.Left + 27 + ACaptionWidth, Rect.Top + 8, ACaption);
- ListItem.FHint := ListItem.FHint + ACaption;
- {$region '文字区域'}
- ListItem.FTextRect := R;
- ListItem.FTextRect.Top := ListItem.FTextRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTextRect.Left := ListItem.FTextRect.Left + 27;
- ListItem.FTextRect.Bottom := ListItem.FTextRect.Top + ItemHeight;
- {$endregion}
- R.Left := Rect.Right;
- R.Top := Rect.Top + 6;
- {$region '绘制摄像头图标'}
- if ListItem.FHasCamera then
- begin
- if (ListItem.FLoginState <> stOffline) and (ListItem.FLoginState <> stHidden) then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FCameraIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FCameraRect := R;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FCameraRect.Left := ListItem.FCameraRect.Left - 2;
- ListItem.FCameraRect.Top := ListItem.FCameraRect.Top - 2;
- ListItem.FCameraRect.Right := ListItem.FCameraRect.Left + 20;
- ListItem.FCameraRect.Bottom := ListItem.FCameraRect.Top + 20;
- if PtInRect(ListItem.FCameraRect, P) then
- begin
- if not ListItem.FMouseInCameraRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInCameraRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
- end;
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制坐机图标'}
- if ListItem.HasTelephone then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FTelephoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FTelephoneRect := R;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FTelephoneRect.Left := ListItem.FTelephoneRect.Left - 2;
- ListItem.FTelephoneRect.Top := ListItem.FTelephoneRect.Top - 2;
- ListItem.FTelephoneRect.Right := ListItem.FTelephoneRect.Left + 20;
- ListItem.FTelephoneRect.Bottom := ListItem.FTelephoneRect.Top + 20;
- if PtInRect(ListItem.FTelephoneRect, P) then
- begin
- if not ListItem.FMouseInTelephoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInTelephoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制手机图标'}
- if ListItem.HasMobilePhone then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FMobilePhoneIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- //ACanvas.StretchDraw(R, FListView.FCameraIconBitmap);
- ListItem.FMobilePhoneRect := R;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FMobilePhoneRect.Left := ListItem.FMobilePhoneRect.Left - 2;
- ListItem.FMobilePhoneRect.Top := ListItem.FMobilePhoneRect.Top - 2;
- ListItem.FMobilePhoneRect.Right := ListItem.FMobilePhoneRect.Left + 20;
- ListItem.FMobilePhoneRect.Bottom := ListItem.FMobilePhoneRect.Top + 20;
- if PtInRect(ListItem.FMobilePhoneRect, P) then
- begin
- if not ListItem.FMouseInMobilePhoneRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInMobilePhoneRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion}
- {$region '绘制信箱图标'}
- if ListItem.HasEmail then
- begin
- R.Left := R.Left - 24;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FEmailIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FEmailRect := R;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FEmailRect.Left := ListItem.FEmailRect.Left - 2;
- ListItem.FEmailRect.Top := ListItem.FEmailRect.Top - 2;
- ListItem.FEmailRect.Right := ListItem.FEmailRect.Left + 20;
- ListItem.FEmailRect.Bottom := ListItem.FEmailRect.Top + 20;
- if PtInRect(ListItem.FEmailRect, P) then
- begin
- if not ListItem.FMouseInEmailRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInEmailRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$region '绘制短信图标'}
- if ListItem.HasSMS then
- begin
- R.Left := R.Left - 23;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.FSMSIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FSMSRect := R;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FSMSRect.Left := ListItem.FSMSRect.Left - 2;
- ListItem.FSMSRect.Top := ListItem.FSMSRect.Top - 2;
- ListItem.FSMSRect.Right := ListItem.FSMSRect.Left + 20;
- ListItem.FSMSRect.Bottom := ListItem.FSMSRect.Top + 20;
- if PtInRect(ListItem.FSMSRect, P) then
- begin
- if not ListItem.FMouseInSMSRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInSMSRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- {$endregion}
- {$region '绘制增加好友图标'}
- if ListItem.FHasAddFriend then
- begin
- R.Left := R.Left - 23;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, FListView.AddFriendIcon.Handle, 16, 16, 0, 0, DI_NORMAL);
- ListItem.FAddFriendRect := R;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FAddFriendRect.Left := ListItem.FAddFriendRect.Left - 2;
- ListItem.FAddFriendRect.Top := ListItem.FAddFriendRect.Top - 2;
- ListItem.FAddFriendRect.Right := ListItem.FAddFriendRect.Left + 20;
- ListItem.FAddFriendRect.Bottom := ListItem.FAddFriendRect.Top + 20;
- if PtInRect(ListItem.FAddFriendRect, P) then
- begin
- if not ListItem.FMouseInAddFriendRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInAddFriendRect := True;
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
- end;
- end;
- end;
- end;
- {$endregion'}
- end;
- lsNoHeadImage:
- begin
- {$region '绘制 16*16 高度的Item'}
- if (ListItem.FHeadImagePicture.Graphic <> nil) and (FListView.Style <> lsNoHeadImage) then
- begin
- NeedDrawImageBorder := ListItem.StateIndex = 1;
- AHeadPicture.Bitmap.Assign(ListItem.FHeadImagePicture.Graphic);
- end
- else
- begin
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmall.Graphic);
- end;
- if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- begin
- if (FListView.FDefaultPictureSmallOffline.Graphic <> nil) and ((ListItem.FHeadImagePicture.Graphic = nil) or (FListView.Style = lsNoHeadImage)) then
- AHeadPicture.Bitmap.Assign(FListView.FDefaultPictureSmallOffline.Graphic)
- else
- RealICQColors.Grayscale(AHeadPicture.Bitmap);
- end;
- if NeedDrawImageBorder or ListItem.FMouseOver then
- begin
- //画头像边框
- ACanvas.Pen.Color := FListView.FHeadImageBorderColor;
- ACanvas.Brush.Color := FListView.FHeadImageBackColor;
- R.Left := Rect.Left + 3 + AddLeft;
- R.Top := Rect.Top + 4 + AddTop;
- R.Right := R.Left + 20;
- R.Bottom := R.Top + 20;
- ACanvas.Rectangle(R);
- end;
- R.Left := Rect.Left + 5 + AddLeft;
- R.Top := Rect.Top + 6 + AddTop;
- R.Right := R.Left + 16;
- R.Bottom := R.Top + 16;
- if DrawHeadImage then
- ACanvas.StretchDraw(R, AHeadPicture.Graphic);
- ListItem.FHeadImageRect := R;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top + Index * ItemHeight - FListView.TopIndex * ItemHeight;
- ListItem.FHeadImageRect.Left := ListItem.FHeadImageRect.Left - 2;
- ListItem.FHeadImageRect.Top := ListItem.FHeadImageRect.Top - 2;
- ListItem.FHeadImageRect.Right := ListItem.FHeadImageRect.Left + 20;
- ListItem.FHeadImageRect.Bottom := ListItem.FHeadImageRect.Top + 20;
- if PtInRect(ListItem.FHeadImageRect, P) then
- begin
- if not ListItem.FMouseInHeadImageRect then
- begin
- if FMouseInDown then
- begin
- ListItem.FMouseInHeadImageRect := True;
- if FListView.FShowHeadImageButton then
- DrawIconButton(Canvas, FListView.FIconBtnDefaultColor, FListView.FIconBtnLightColor, FListView.FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
- end;
- end;
- end;
- if (ListItem.FLoginState = stLeave) or (ListItem.FLoginState = stBusy) or (ListItem.FLoginState = stMute) or (ListItem.FLoginState = stMobileOnline) then
- begin
- AStateIcon := nil;
- if ListItem.FLoginState = stLeave then
- AStateIcon := FListView.FLeavePicture;
- if ListItem.FLoginState = stBusy then
- AStateIcon := FListView.FBusyPicture;
- if ListItem.FLoginState = stMute then
- AStateIcon := FListView.FMutePicture;
- if ListItem.FLoginState = stMobileOnline then
- AStateIcon := FListView.FMobilePhoneIcon;
- if AStateIcon <> nil then
- begin
- R.Left := R.Right - 9;
- R.Top := R.Bottom - 9;
- DrawIconEx(ACanvas.Handle, R.Left, R.Top, AStateIcon.Handle, 9, 9, 0, 0, DI_NORMAL);
- end;
- end;
- //TextRect
- R.Left := Rect.Left;
- R.Top := Rect.Top;
- R.Right := Rect.Right - 3;
- R.Bottom := Rect.Bottom;
- if ListItem.Company <> '' then
- b := ListItem.Company
- else if ListItem.Branch <> '' then
- b := ListItem.Branch;
- if ListItem.DisplayName <> '' then
- n := ListItem.DisplayName
- else
- n := ListItem.LoginName;
- ACaption := GetCaption(ListItem.ServerName, b, n);
- ACanvas.Brush.Style := bsClear;
- ACanvas.Font := FListView.Font;
- if ListItem.FCaptionColor <> $00FFFFFF then
- ACanvas.Font.Color := ListItem.FCaptionColor
- else if (ListItem.FLoginState = stOffline) or (ListItem.FLoginState = stHidden) then
- ACanvas.Font.Color := clGray
- else
- ACanvas.Font.Color := clBlack;
- ACanvas.TextRect(R, Rect.Left + 27, Rect.Top + 8, ACaption);
- ACaptionWidth := ACanvas.TextWidth(ACaption);
- end;
- end;
- finally
- AHeadPicture.Free;
- end;
- with ListItem do
- begin
- {if not FListView.FShowHeadImageButton then
- begin
- FHeadImageRect.Left := 0;
- FHeadImageRect.Top := 0;
- FHeadImageRect.Right := 0;
- FHeadImageRect.Bottom := 0;
- end;}
- if not FListView.FShowCameraButton then
- begin
- FCameraRect.Left := 0;
- FCameraRect.Top := 0;
- FCameraRect.Right := 0;
- FCameraRect.Bottom := 0;
- end;
- if not FListView.FShowTelButton then
- begin
- FTelephoneRect.Left := 0;
- FTelephoneRect.Top := 0;
- FTelephoneRect.Right := 0;
- FTelephoneRect.Bottom := 0;
- end;
- if not FListView.FShowMobileButton then
- begin
- FMobilePhoneRect.Left := 0;
- FMobilePhoneRect.Top := 0;
- FMobilePhoneRect.Right := 0;
- FMobilePhoneRect.Bottom := 0;
- end;
- if not FListView.FShowEmailButton then
- begin
- FEmailRect.Left := 0;
- FEmailRect.Top := 0;
- FEmailRect.Right := 0;
- FEmailRect.Bottom := 0;
- end;
- if not FListView.FShowSMSButton then
- begin
- FSMSRect.Left := 0;
- FSMSRect.Top := 0;
- FSMSRect.Right := 0;
- FSMSRect.Bottom := 0;
- end;
- if not FListView.FShowAddFriendButton then
- begin
- FAddFriendRect.Left := 0;
- FAddFriendRect.Top := 0;
- FAddFriendRect.Right := 0;
- FAddFriendRect.Bottom := 0;
- end;
- end;
- end;
- procedure TNoScrollListBox.CNDrawItem(var Message: TWMDrawItem);
- var
- State: TOwnerDrawState;
- R: TRect;
- begin
- with Message.DrawItemStruct^ do
- begin
- State := TOwnerDrawState(LongRec(itemState).Lo);
- Canvas.Handle := hDC;
- try
- //FBufferedBitmap.Canvas.Lock;
- //Canvas.Lock;
- Canvas.Font := Font;
- Canvas.Brush := Brush;
- if itemID >= Cardinal(Items.Count - 1) then
- begin
- R.Left := rcItem.Left;
- R.Top := rcItem.Bottom;
- R.Right := ClientWidth;
- R.Bottom := ClientHeight;
- Canvas.Brush.Color := clWhite;
- Canvas.FillRect(R);
- end;
- //启用缓冲,先在 FBufferedBitmap 绘好图形
- FBufferedBitmap.Width := rcItem.Right - rcItem.Left;
- FBufferedBitmap.Height := rcItem.Bottom - rcItem.Top;
- FBufferedBitmap.Canvas.Brush.Color := clWhite;
- FBufferedBitmap.Canvas.Pen.Color := clBlack;
- R.Left := 0;
- R.Top := 0;
- R.Right := FBufferedBitmap.Width;
- R.Bottom := FBufferedBitmap.Height;
- if Integer(itemID) >= 0 then
- DrawContacterItem(FBufferedBitmap.Canvas, itemID, R, State)
- else
- FBufferedBitmap.Canvas.FillRect(R);
- //将绘好的图形复制到Canvas上去
- Canvas.CopyRect(rcItem, FBufferedBitmap.Canvas, R);
- finally
- //Canvas.Unlock;
- //FBufferedBitmap.Canvas.Unlock;
- Canvas.Handle := 0;
- end;
- end;
- FListView.FListBoxScrollBar.DrawScrollBar;
- end;
- {TRealICQScrollBar}
- procedure TListBoxScrollBar.TopButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- WaitTimes: Integer;
- begin
- FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureDown);
- FButtonDown := True;
- WaitTimes := 0;
- while FButtonDown do
- begin
- if (WaitTimes = 0) or (WaitTimes > 10) then
- begin
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEUP, 0);
- DrawScrollBar;
- end;
- Application.ProcessMessages;
- Sleep(50);
- Inc(WaitTimes);
- end;
- end;
- procedure TListBoxScrollBar.TopButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureHover);
- FButtonDown := False;
- end;
- procedure TListBoxScrollBar.TopButtonImageMouseEnter(Sender: TObject);
- begin
- FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureHover);
- end;
- procedure TListBoxScrollBar.TopButtonImageMouseLeave(Sender: TObject);
- begin
- FTopButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollTopButtonPictureNormal);
- end;
- procedure TListBoxScrollBar.BottomButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- WaitTimes: Integer;
- begin
- FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureDown);
- FButtonDown := True;
- WaitTimes := 0;
- while FButtonDown do
- begin
- if (WaitTimes = 0) or (WaitTimes > 10) then
- begin
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
- DrawScrollBar;
- end;
- Application.ProcessMessages;
- Sleep(50);
- Inc(WaitTimes);
- end;
- end;
- procedure TListBoxScrollBar.BottomButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureHover);
- FButtonDown := False;
- end;
- procedure TListBoxScrollBar.BottomButtonImageMouseEnter(Sender: TObject);
- begin
- FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureHover);
- end;
- procedure TListBoxScrollBar.BottomButtonImageMouseLeave(Sender: TObject);
- begin
- FBottomButtonImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBottomButtonPictureNormal);
- end;
- procedure TListBoxScrollBar.BarButtonImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureDown);
- FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureDown);
- FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureDown);
- FTrackingBarDown := True;
- FTrackingBarDonwY := Y;
- end;
- procedure TListBoxScrollBar.BarButtonImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureHover);
- FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureHover);
- FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureHover);
- FTrackingBarDown := False;
- end;
- procedure TListBoxScrollBar.BarButtonImageMouseEnter(Sender: TObject);
- begin
- FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureHover);
- FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureHover);
- FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureHover);
- end;
- procedure TListBoxScrollBar.BarButtonImageMouseLeave(Sender: TObject);
- begin
- FBarButtonTopImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonTopPictureNormal);
- FBarButtonMiddleImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonMiddlePictureNormal);
- FBarButtonBottomImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBarButtonBottomPictureNormal);
- end;
- procedure TListBoxScrollBar.BarButtonImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- var
- MovedYValue, Increment, ModeValue, DivValue: Integer;
- begin
- if FTrackingBarDown then
- begin
- MovedYValue := (Y - FTrackingBarDonwY);
- FMovedYValue := FMovedYValue + MovedYValue;
- if FBarButtonTopImage.Top + MovedYValue < (FTopButtonImage.Height + 1) then
- FBarButtonTopImage.Top := (FTopButtonImage.Height + 1)
- else if FBarButtonTopImage.Top + MovedYValue > (FTopButtonImage.Height + 1) + FTrackingBarTopRange then
- FBarButtonTopImage.Top := (FTopButtonImage.Height + 1) + FTrackingBarTopRange
- else
- FBarButtonTopImage.Top := FBarButtonTopImage.Top + MovedYValue;
- FBarButtonMiddleImage.Top := FBarButtonTopImage.Top + FBarButtonTopImage.Height;
- FBarButtonBottomImage.Top := FBarButtonMiddleImage.Top + FBarButtonMiddleImage.Height;
- Increment := Round((FClientRange - FListView.Height) * (FMovedYValue / FTrackingBarTopRange));
- if ABS(Increment) < FListView.FNoScrollListBox.ItemHeight then
- Exit;
- ModeValue := Increment mod FListView.FNoScrollListBox.ItemHeight;
- if ModeValue <> 0 then
- begin
- if ModeValue > FListView.FNoScrollListBox.ItemHeight / 2 then
- begin
- Increment := Increment + (FListView.FNoScrollListBox.ItemHeight - ModeValue);
- end
- else
- begin
- Increment := Increment - ModeValue;
- end;
- end;
- Repaint;
- DivValue := Increment div FListView.FNoScrollListBox.ItemHeight;
- if FListView.FNoScrollListBox.TopIndex + DivValue < 0 then
- FListView.FNoScrollListBox.TopIndex := 0
- else if FListView.FNoScrollListBox.TopIndex + DivValue >= FListView.FNoScrollListBox.Items.Count then
- FListView.FNoScrollListBox.TopIndex := FListView.FNoScrollListBox.Items.Count - 1
- else
- FListView.FNoScrollListBox.TopIndex := FListView.FNoScrollListBox.TopIndex + DivValue;
- FTrackingBarDown := False;
- DrawScrollBar;
- FTrackingBarDown := True;
- Repaint;
- FMovedYValue := 0;
- end;
- end;
- procedure TListBoxScrollBar.BackgroundImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- WaitTimes: Integer;
- begin
- FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureDown);
- if (Y > FBarButtonTopImage.Top - 10) and (Y < (FBarButtonBottomImage.Top + FBarButtonBottomImage.Height) + 10) then
- exit;
- FButtonDown := True;
- WaitTimes := 0;
- while FButtonDown do
- begin
- if (WaitTimes = 0) or (WaitTimes > 10) then
- begin
- if Y < FBarButtonTopImage.Top then
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_PAGEUP, 0)
- else if Y > (FBarButtonBottomImage.Top + FBarButtonBottomImage.Height) then
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_PAGEDOWN, 0);
- DrawScrollBar;
- end;
- Application.ProcessMessages;
- Sleep(50);
- Inc(WaitTimes);
- end;
- end;
- procedure TListBoxScrollBar.BackgroundImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureHover);
- FButtonDown := False;
- end;
- procedure TListBoxScrollBar.BackgroundImageMouseEnter(Sender: TObject);
- begin
- FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureHover);
- end;
- procedure TListBoxScrollBar.BackgroundImageMouseLeave(Sender: TObject);
- begin
- FBackgroundImage.Picture.Assign((Owner as TRealICQContacterListView).FScrollBackgroundPictureNormal);
- end;
- procedure TListBoxScrollBar.ListBoxResize(Sender: TObject);
- begin
- DrawScrollBar;
- end;
- procedure TListBoxScrollBar.ListBoxConstrainedResize(Sender: TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer);
- begin
- //DrawScrollBar;
- end;
- procedure TListBoxScrollBar.ListBoxMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
- begin
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEUP, 0);
- DrawScrollBar;
- Handled := True;
- end;
- procedure TListBoxScrollBar.ListBoxMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
- begin
- PostMessage(FListView.FNoScrollListBox.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
- DrawScrollBar;
- Handled := True;
- end;
- procedure TListBoxScrollBar.DrawScrollBar;
- var
- FixedBarButtonHeight: Integer;
- begin
- if FTrackingBarDown then
- Exit;
- if FDrawing then
- Exit;
- FDrawing := True;
- FClientRange := FListView.Items.Count * FListView.FNoScrollListBox.ItemHeight;
- FListView.FNoScrollListBox.OnResize := nil;
- FListView.FNoScrollListBox.OnConstrainedResize := nil;
- DisableAlign;
- try
- if (FClientRange <= FListView.Height) or (FClientRange <= 0) then
- begin
- FListView.FNoScrollListBox.Width := FListView.Width;
- Width := 0;
- Exit;
- end;
- FixedBarButtonHeight := FTopButtonImage.Height + FBottomButtonImage.Height;
- if (FixedBarButtonHeight >= FListView.Height) then
- begin
- FListView.FNoScrollListBox.Width := FListView.Width;
- Width := 0;
- Exit;
- end;
- FixedBarButtonHeight := FixedBarButtonHeight + FListView.FScrollBarButtonTopPictureNormal.Height + FListView.FScrollBarButtonBottomPictureNormal.Height + 2;
- if (FixedBarButtonHeight >= FListView.Height) then
- begin
- FBarButtonTopImage.Visible := False;
- FBarButtonMiddleImage.Visible := False;
- FBarButtonBottomImage.Visible := False;
- end
- else
- begin
- FBarButtonTopImage.Visible := True;
- FBarButtonMiddleImage.Visible := True;
- FBarButtonBottomImage.Visible := True;
- end;
- FClientRange := FClientRange + FListView.Height mod FListView.FNoScrollListBox.ItemHeight;
- FScrollRange := FListView.Height - FixedBarButtonHeight;
- Visible := True;
- Width := FListView.FScrollTopButtonPictureNormal.Width;
- Height := FListView.Height;
- FListView.FNoScrollListBox.Width := FListView.Width - Width;
- if not FAssignedPicture then
- FTopButtonImage.Picture.Assign(FListView.FScrollTopButtonPictureNormal);
- FTopButtonImage.Left := 0;
- FTopButtonImage.Top := 0;
- if not FAssignedPicture then
- FBottomButtonImage.Picture.Assign(FListView.FScrollBottomButtonPictureNormal);
- FBottomButtonImage.Left := 0;
- FBottomButtonImage.Top := FListView.Height - FTopButtonImage.Height;
- if not FAssignedPicture then
- FBarButtonTopImage.Picture.Assign(FListView.FScrollBarButtonTopPictureNormal);
- FBarButtonTopImage.Left := 0;
- if not FAssignedPicture then
- FBarButtonMiddleImage.Picture.Assign(FListView.FScrollBarButtonMiddlePictureNormal);
- FBarButtonMiddleImage.Left := 0;
- FBarButtonMiddleImage.Height := Round(FScrollRange * (FListView.Height / FClientRange));
- FBarButtonMiddleImage.Width := FListView.FScrollBarButtonMiddlePictureNormal.Width;
- if not FAssignedPicture then
- FBarButtonBottomImage.Picture.Assign(FListView.FScrollBarButtonBottomPictureNormal);
- FBarButtonBottomImage.Left := 0;
- FTrackingBarTopRange := FScrollRange - FBarButtonMiddleImage.Height - 1;
- FBarButtonTopImage.Top := (FTopButtonImage.Height + 1) + Round(FTrackingBarTopRange * ((FListView.FNoScrollListBox.TopIndex * FListView.FNoScrollListBox.ItemHeight) / (FClientRange - FListView.Height)));
- FBarButtonMiddleImage.Top := FBarButtonTopImage.Top + FBarButtonTopImage.Height;
- FBarButtonBottomImage.Top := FBarButtonMiddleImage.Top + FBarButtonMiddleImage.Height;
- if not FAssignedPicture then
- FBackgroundImage.Picture.Assign(FListView.FScrollBackgroundPictureNormal);
- FBackgroundImage.SendToBack;
- FAssignedPicture := True;
- finally
- EnableAlign;
- FDrawing := False;
- FListView.FNoScrollListBox.OnResize := ListBoxResize;
- FListView.FNoScrollListBox.OnConstrainedResize := ListBoxConstrainedResize;
- end;
- end;
- constructor TListBoxScrollBar.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Width := 20;
- Height := 180;
- Caption := '';
- DoubleBuffered := True;
- ParentColor := True;
- BevelInner := bvNone;
- BevelOuter := bvNone;
- FDrawing := False;
- FTopButtonImage := TRealICQHoverImage.Create(Self);
- FTopButtonImage.Parent := Self;
- FTopButtonImage.AutoSize := True;
- FTopButtonImage.Transparent := True;
- FTopButtonImage.Anchors := [akLeft, akTop];
- FTopButtonImage.OnMouseEnter := TopButtonImageMouseEnter;
- FTopButtonImage.OnMouseLeave := TopButtonImageMouseLeave;
- FTopButtonImage.OnMouseDown := TopButtonImageMouseDown;
- FTopButtonImage.OnMouseUp := TopButtonImageMouseUp;
- FBottomButtonImage := TRealICQHoverImage.Create(Self);
- FBottomButtonImage.Parent := Self;
- FBottomButtonImage.AutoSize := True;
- FBottomButtonImage.Transparent := True;
- FBottomButtonImage.Anchors := [akLeft, akBottom];
- FBottomButtonImage.OnMouseEnter := BottomButtonImageMouseEnter;
- FBottomButtonImage.OnMouseLeave := BottomButtonImageMouseLeave;
- FBottomButtonImage.OnMouseDown := BottomButtonImageMouseDown;
- FBottomButtonImage.OnMouseUp := BottomButtonImageMouseUp;
- FBarButtonTopImage := TRealICQHoverImage.Create(Self);
- FBarButtonTopImage.Parent := Self;
- FBarButtonTopImage.AutoSize := True;
- FBarButtonTopImage.Transparent := False;
- FBarButtonTopImage.OnMouseEnter := BarButtonImageMouseEnter;
- FBarButtonTopImage.OnMouseLeave := BarButtonImageMouseLeave;
- FBarButtonTopImage.OnMouseDown := BarButtonImageMouseDown;
- FBarButtonTopImage.OnMouseUp := BarButtonImageMouseUp;
- FBarButtonTopImage.OnMouseMove := BarButtonImageMouseMove;
- FBarButtonMiddleImage := TRealICQHoverImage.Create(Self);
- FBarButtonMiddleImage.Parent := Self;
- FBarButtonMiddleImage.AutoSize := False;
- FBarButtonMiddleImage.Transparent := False;
- FBarButtonMiddleImage.Stretch := True;
- FBarButtonMiddleImage.OnMouseEnter := BarButtonImageMouseEnter;
- FBarButtonMiddleImage.OnMouseLeave := BarButtonImageMouseLeave;
- FBarButtonMiddleImage.OnMouseDown := BarButtonImageMouseDown;
- FBarButtonMiddleImage.OnMouseUp := BarButtonImageMouseUp;
- FBarButtonMiddleImage.OnMouseMove := BarButtonImageMouseMove;
- FBarButtonBottomImage := TRealICQHoverImage.Create(Self);
- FBarButtonBottomImage.Parent := Self;
- FBarButtonBottomImage.AutoSize := True;
- FBarButtonBottomImage.Transparent := False;
- FBarButtonBottomImage.OnMouseEnter := BarButtonImageMouseEnter;
- FBarButtonBottomImage.OnMouseLeave := BarButtonImageMouseLeave;
- FBarButtonBottomImage.OnMouseDown := BarButtonImageMouseDown;
- FBarButtonBottomImage.OnMouseUp := BarButtonImageMouseUp;
- FBarButtonBottomImage.OnMouseMove := BarButtonImageMouseMove;
- FBackgroundImage := TRealICQHoverImage.Create(Self);
- FBackgroundImage.Parent := Self;
- FBackgroundImage.AutoSize := False;
- FBackgroundImage.Stretch := True;
- FBackgroundImage.Transparent := False;
- FBackgroundImage.Align := alClient;
- FBackgroundImage.OnMouseEnter := BackgroundImageMouseEnter;
- FBackgroundImage.OnMouseLeave := BackgroundImageMouseLeave;
- FBackgroundImage.OnMouseDown := BackgroundImageMouseDown;
- FBackgroundImage.OnMouseUp := BackgroundImageMouseUp;
- FMovedYValue := 0;
- end;
- destructor TListBoxScrollBar.Destroy;
- begin
- try
- FreeAndNil(FBackgroundImage);
- FreeAndNil(FBarButtonBottomImage);
- FreeAndNil(FBarButtonMiddleImage);
- FreeAndNil(FBarButtonTopImage);
- FreeAndNil(FBottomButtonImage);
- FreeAndNil(FTopButtonImage);
- except
- end;
- inherited Destroy;
- end;
- {TRealICQContacterListItems}
- constructor TRealICQContacterListItems.Create(ARealICQContacterListView: TRealICQContacterListView);
- begin
- inherited Create;
- FRealICQContacterListView := ARealICQContacterListView;
- end;
- destructor TRealICQContacterListItems.Destroy;
- begin
- try
- Clear;
- except
- end;
- inherited Destroy;
- end;
- function TRealICQContacterListItems.GetObject(Index: Integer): TObject;
- begin
- if Index = -1 then
- Exit;
- Result := FRealICQContacterListView.FNoScrollListBox.Items.Objects[Index];
- end;
- procedure TRealICQContacterListItems.Put(Index: Integer; const S: string);
- begin
- end;
- function TRealICQContacterListItems.Get(Index: Integer): string;
- begin
- Result := FRealICQContacterListView.FNoScrollListBox.Items[Index];
- end;
- function TRealICQContacterListItems.GetCount: Integer;
- begin
- Result := FRealICQContacterListView.FNoScrollListBox.Items.Count;
- end;
- function TRealICQContacterListItems.Add(const S: string): Integer;
- var
- RealICQContacterListItem: TRealICQContacterListItem;
- begin
- RealICQContacterListItem := TRealICQContacterListItem.Create(S, FRealICQContacterListView);
- Result := FRealICQContacterListView.FNoScrollListBox.Items.AddObject(S, RealICQContacterListItem);
- end;
- procedure TRealICQContacterListItems.Insert(Index: Integer; const S: string);
- begin
- //位置按登录状态以及呢称进行排序,所以Insert方法功能同Add方法。
- Add(S);
- end;
- procedure TRealICQContacterListItems.Move(CurIndex, NewIndex: Integer);
- begin
- FRealICQContacterListView.FNoScrollListBox.Items.Move(CurIndex, NewIndex);
- end;
- procedure TRealICQContacterListItems.Clear;
- begin
- if FRealICQContacterListView.FNoScrollListBox = nil then
- Exit;
- while Count > 0 do
- begin
- Delete(0);
- end;
- FRealICQContacterListView.FNoScrollListBox.Items.Clear;
- end;
- procedure TRealICQContacterListItems.Delete(Index: Integer);
- var
- RealICQContacterListItem: TRealICQContacterListItem;
- begin
- RealICQContacterListItem := FRealICQContacterListView.FNoScrollListBox.Items.Objects[Index] as TRealICQContacterListItem;
- FreeAndNil(RealICQContacterListItem);
- FRealICQContacterListView.FNoScrollListBox.Items.Delete(Index);
- end;
- function TRealICQContacterListItems.IndexOf(const S: string): Integer;
- begin
- Result := FRealICQContacterListView.FNoScrollListBox.Items.IndexOf(S);
- end;
- {TRealICQContacterListItem}
- function TRealICQContacterListItem.GetStatePosition(ALoginState: TRealICQLoginState): Integer;
- begin
- Result := 0;
- case ALoginState of
- stOnline:
- Result := 5;
- stMute:
- Result := 4;
- stBusy:
- Result := 3;
- stLeave:
- Result := 2;
- stOffline, stHidden:
- Result := 1;
- end;
- end;
- procedure TRealICQContacterListItem.MoveToTop;
- begin
- FListView.Items.Move(ItemIndex, 0);
- ReDrawItem;
- end;
- procedure TRealICQContacterListItem.AdjustPosition;
- var
- RealICQContacterListItem: TRealICQContacterListItem;
- iLoop, CurrentItemStatePosition, LoopItemStatePosition: Integer;
- CurrentItemString, LoopItemString: string;
- begin
- if not FListView.FAdjustPosition then
- Exit;
- FAdjustPositioned := True;
- CurrentItemStatePosition := GetStatePosition(FLoginState);
- if Length(Trim(FDisplayName)) = 0 then
- CurrentItemString := Chr(255) + FLoginName //如果没有呢称,则排到最后面
- else
- CurrentItemString := FDisplayName;
- //调整位置
- for iLoop := 0 to FListView.Items.Count - 1 do
- begin
- RealICQContacterListItem := FListView.Items.Objects[iLoop] as TRealICQContacterListItem;
- if iLoop = ItemIndex then
- continue;
- if Length(Trim(RealICQContacterListItem.FDisplayName)) = 0 then
- LoopItemString := Chr(255) + RealICQContacterListItem.FLoginName //如果没有呢称,则排到最后面
- else
- LoopItemString := RealICQContacterListItem.FDisplayName;
- LoopItemStatePosition := GetStatePosition(RealICQContacterListItem.FLoginState);
- if CurrentItemStatePosition < LoopItemStatePosition then
- begin
- if iLoop = FListView.Items.Count - 1 then
- begin
- FListView.Items.Move(ItemIndex, iLoop);
- break;
- end
- else
- begin
- continue;
- end;
- end
- else if LoopItemStatePosition = CurrentItemStatePosition then
- begin
- if AnsiCompareStr(CurrentItemString, LoopItemString) < 0 then
- begin
- if ItemIndex < iLoop then
- FListView.Items.Move(ItemIndex, iLoop - 1)
- else
- FListView.Items.Move(ItemIndex, iLoop);
- break;
- end;
- if iLoop = FListView.Items.Count - 1 then
- begin
- FListView.Items.Move(ItemIndex, iLoop);
- break;
- end;
- end
- else if CurrentItemStatePosition > LoopItemStatePosition then
- begin
- if ItemIndex < iLoop then
- FListView.Items.Move(ItemIndex, iLoop - 1)
- else
- FListView.Items.Move(ItemIndex, iLoop);
- break;
- end;
- end;
- end;
- procedure TRealICQContacterListItem.SetLoginState(Value: TRealICQLoginState);
- var
- OldLoginState: TRealICQLoginState;
- iWaitTimes: Integer;
- begin
- if (FLoginState = Value) and FAdjustPositioned then
- Exit;
- OldLoginState := FLoginState;
- FLoginState := Value;
- //调整在线人数的值
- if ((Value <> stOffline) and (Value <> stHidden)) and ((OldLoginState = stOffline) or (OldLoginState = stHidden)) then
- begin
- Inc(FListView.FOnlineNumeric);
- FListView.Items.Move(ItemIndex, 0);
- FListView.DoItemOnline(Self);
- end;
- //调整在线人数的值
- if ((Value = stOffline) or (Value = stHidden)) and ((OldLoginState <> stOffline) and (OldLoginState <> stHidden)) then
- begin
- Dec(FListView.FOnlineNumeric);
- FListView.Items.Move(ItemIndex, FListView.Items.Count - 1);
- FListView.DoItemOffline(Self);
- end;
- //
- // if (FLoginState <> stOnline) and (FFlashCaptionThread <> nil) then
- // begin
- // FFlashCaptionThread.Terminate;
- // iWaitTimes := 0;
- // while FFlashCaptionThread <> nil do
- // begin
- // Sleep(100);
- // Application.ProcessMessages;
- // Inc(iWaitTimes);
- // if iWaitTimes > 100 then break; //最多等待连接线程结束10s时间
- // end;
- // end;
- //
- // AdjustPosition;
- //
- // if (FLoginState = stOnline) and (FListView.FlashCaptionOnOnline) then
- // begin
- // if FFlashCaptionThread = nil then FFlashCaptionThread := TRealICQFlashCaption.Create(Self);
- // FListView.DoItemFlashCaption(Self);
- // end;
- end;
- function TRealICQContacterListItem.GetItemIndex: Integer;
- begin
- Result := FListView.FNoScrollListBox.Items.IndexOf(FLoginName);
- end;
- function TRealICQContacterListItem.GetSelected: Boolean;
- begin
- Result := FListView.FNoScrollListBox.Selected[ItemIndex];
- end;
- procedure TRealICQContacterListItem.SetSelected(Value: Boolean);
- begin
- if Selected = Value then
- Exit;
- FListView.FNoScrollListBox.Selected[ItemIndex] := Value;
- FListView.DoSelectItemChanged(Self);
- end;
- procedure TRealICQContacterListItem.HeadImagePictureChange(Sender: TObject);
- begin
- //FListView.FNoScrollListBox.Invalidate;
- end;
- procedure TRealICQContacterListItem.SetBranch(const Value: string);
- begin
- FBranch := Value;
- end;
- procedure TRealICQContacterListItem.SetDisplayName(Value: string);
- begin
- if AnsiSameStr(FDisplayName, Trim(Value)) and FAdjustPositioned then
- Exit;
- FDisplayName := Trim(Value);
- // AdjustPosition;
- end;
- procedure TRealICQContacterListItem.SetWatchword(Value: string);
- begin
- FWatchword := Trim(Value);
- end;
- procedure TRealICQContacterListItem.SetHeadImagePicture(Value: TPicture);
- begin
- FHeadImagePicture.Assign(Value);
- end;
- procedure TRealICQContacterListItem.ReDrawItem;
- var
- ListItem: TRealICQContacterListItem;
- FListView: TRealICQContacterListView;
- Rect: TRect;
- begin
- ListItem := Self;
- if ListItem = nil then
- exit;
- FListView := ListItem.FListView;
- if not FListView.Visible then
- exit;
- if FListView.Height = 0 then
- exit;
- Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
- if Rect.Bottom < 0 then
- Exit;
- if Rect.Top > FListView.Height then
- Exit;
- InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
- end;
- procedure TRealICQContacterListItem.Flash(AStyle: TRealICQFlashStyle);
- begin
- FFlashStyle := AStyle;
- if FFlashImageThread = nil then
- begin
- FFlashImageThread := TRealICQFlashImage.Create(Self);
- end;
- end;
- procedure TRealICQContacterListItem.StopFlash;
- var
- iWaitTimes: Integer;
- begin
- if FFlashImageThread <> nil then
- begin
- FFlashImageThread.Terminate;
- iWaitTimes := 0;
- while FFlashImageThread <> nil do
- begin
- Inc(iWaitTimes);
- if iWaitTimes > 5000 then
- Exit;
- Sleep(10);
- Application.ProcessMessages;
- end;
- end;
- end;
- constructor TRealICQContacterListItem.Create(ALoginName: string; AListView: TRealICQContacterListView);
- begin
- FLoginName := ALoginName;
- FListView := AListView;
- FAdjustPositioned := False;
- FCaptionColor := $00FFFFFF;
- FHeadImagePosition := 0;
- FDisplayName := '';
- FWatchword := '';
- FHasCamera := False;
- FLoginState := stOffline;
- Data := nil;
- FMouseInRect := False;
- FStateIndex := 1;
- FHeadImagePicture := TPicture.Create;
- FHeadImagePicture.OnChange := HeadImagePictureChange;
- FMouseOver := False;
- FMouseInHeadImageRect := False;
- FMouseInCameraRect := False;
- FMouseInTelephoneRect := False;
- FMouseInMobilePhoneRect := False;
- FMouseInEmailRect := False;
- FMouseInSMSRect := False;
- FMouseInAddFriendRect := False;
- FHeadImageHint := '';
- FCameraHint := '';
- FTelephoneHint := '';
- FMobilePhoneHint := '';
- FEmailHint := '';
- FSMSHint := '';
- FCompany := '';
- FBranch := '';
- FHeadImageRect.Left := 0;
- FHeadImageRect.Top := 0;
- FHeadImageRect.Right := 0;
- FHeadImageRect.Bottom := 0;
- FCameraRect.Left := 0;
- FCameraRect.Top := 0;
- FCameraRect.Right := 0;
- FCameraRect.Bottom := 0;
- FTelephoneRect.Left := 0;
- FTelephoneRect.Top := 0;
- FTelephoneRect.Right := 0;
- FTelephoneRect.Bottom := 0;
- FMobilePhoneRect.Left := 0;
- FMobilePhoneRect.Top := 0;
- FMobilePhoneRect.Right := 0;
- FMobilePhoneRect.Bottom := 0;
- FEmailRect.Left := 0;
- FEmailRect.Top := 0;
- FEmailRect.Right := 0;
- FEmailRect.Bottom := 0;
- FSMSRect.Left := 0;
- FSMSRect.Top := 0;
- FSMSRect.Right := 0;
- FSMSRect.Bottom := 0;
- end;
- destructor TRealICQContacterListItem.Destroy;
- var
- iWaitTimes: Integer;
- begin
- try
- //调整在线人数的值
- if (FLoginState <> stOffline) and (FLoginState <> stHidden) then
- Dec(FListView.FOnlineNumeric);
- if FFlashCaptionThread <> nil then
- begin
- FFlashCaptionThread.Terminate;
- iWaitTimes := 0;
- while FFlashCaptionThread <> nil do
- begin
- Sleep(10);
- Application.ProcessMessages;
- Inc(iWaitTimes);
- if iWaitTimes > 100 then
- break; //最多等待连接线程结束10s时间
- end;
- end;
- if FFlashImageThread <> nil then
- begin
- FFlashImageThread.Terminate;
- while FFlashImageThread <> nil do
- begin
- Sleep(10);
- Application.ProcessMessages;
- end;
- end;
- FHeadImagePicture.OnChange := nil;
- FreeAndNil(FHeadImagePicture);
- except
- end;
- inherited Destroy;
- end;
- {TRealICQContacterListView}
- procedure TRealICQContacterListView.SetScrollTopButtonPictureNormal(Value: TPicture);
- begin
- FScrollTopButtonPictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollTopButtonPictureHover(Value: TPicture);
- begin
- FScrollTopButtonPictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollTopButtonPictureDown(Value: TPicture);
- begin
- FScrollTopButtonPictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBottomButtonPictureNormal(Value: TPicture);
- begin
- FScrollBottomButtonPictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBottomButtonPictureHover(Value: TPicture);
- begin
- FScrollBottomButtonPictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBottomButtonPictureDown(Value: TPicture);
- begin
- FScrollBottomButtonPictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonTopPictureNormal(Value: TPicture);
- begin
- FScrollBarButtonTopPictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonTopPictureHover(Value: TPicture);
- begin
- FScrollBarButtonTopPictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonTopPictureDown(Value: TPicture);
- begin
- FScrollBarButtonTopPictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureNormal(Value: TPicture);
- begin
- FScrollBarButtonMiddlePictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureHover(Value: TPicture);
- begin
- FScrollBarButtonMiddlePictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonMiddlePictureDown(Value: TPicture);
- begin
- FScrollBarButtonMiddlePictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureNormal(Value: TPicture);
- begin
- FScrollBarButtonBottomPictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureHover(Value: TPicture);
- begin
- FScrollBarButtonBottomPictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBarButtonBottomPictureDown(Value: TPicture);
- begin
- FScrollBarButtonBottomPictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBackgroundPictureNormal(Value: TPicture);
- begin
- FScrollBackgroundPictureNormal.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBackgroundPictureHover(Value: TPicture);
- begin
- FScrollBackgroundPictureHover.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetScrollBackgroundPictureDown(Value: TPicture);
- begin
- FScrollBackgroundPictureDown.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetCaptionStyle(Value: TRealICQContacterListItemCaptionStyle);
- begin
- FCaptionStyle := Value;
- FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
- FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
- FNoScrollListBox.Invalidate;
- end;
- procedure TRealICQContacterListView.SetStyle(Value: TRealICQContacterListItemStyle);
- begin
- FStyle := Value;
- case FStyle of
- lsBigHeadImage:
- FNoScrollListBox.ItemHeight := cntHeightOfBigHeadImage;
- lsMiddleHeadImage:
- FNoScrollListBox.ItemHeight := cntHeightOfMiddleHeadImage;
- lsSmallHeadImage:
- FNoScrollListBox.ItemHeight := cntHeightOfSmallHeadImage;
- lsNoHeadImage:
- FNoScrollListBox.ItemHeight := cntHeightOfNoHeadImage;
- end;
- FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
- FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
- FNoScrollListBox.Invalidate;
- end;
- procedure TRealICQContacterListView.WhenMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- P: TPoint;
- iIndex, iLoop: Integer;
- ListItem: TRealICQContacterListItem;
- begin
- FTimerItemIndex := -1;
- FTimer.Enabled := False;
- FHintWindow.ReleaseHandle;
- FHintWindow.Visible := False;
- if Button = mbLeft then
- FNoScrollListBox.FMouseInDown := True;
- //if Button = mbLeft then Exit;
- P.X := X;
- P.Y := Y;
- iIndex := FNoScrollListBox.ItemAtPos(P, True);
- if iIndex = -1 then
- begin
- DoItemClick(nil);
- if Button <> mbLeft then
- begin
- for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
- if FNoScrollListBox.Selected[iLoop] then
- if Button <> mbLeft then
- FNoScrollListBox.Selected[iLoop] := False;
- end;
- Exit;
- end;
- ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
- DoItemClick(ListItem);
- if (Button = mbLeft) then
- begin
- if ListItem.FMouseInHeadImageRect then
- begin
- if FNoScrollListBox.FListView.FShowHeadImageButton then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibDown);
- Exit;
- end;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibDown);
- Exit;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibDown);
- Exit;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibDown);
- Exit;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibDown);
- Exit;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibDown);
- Exit;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibDown);
- Exit;
- end;
- end;
- if (not FNoScrollListBox.Selected[iIndex]) and (Button <> mbLeft) then
- begin
- for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
- if FNoScrollListBox.Selected[iLoop] then
- FNoScrollListBox.Selected[iLoop] := False;
- FNoScrollListBox.Selected[iIndex] := True;
- end;
- end;
- procedure TRealICQContacterListView.WhenMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- P: TPoint;
- iIndex: Integer;
- ListItem: TRealICQContacterListItem;
- begin
- if Assigned(FOnItemMouseUp) then
- FOnItemMouseUp(Self, Button, Shift, X, Y);
- FNoScrollListBox.FMouseInDown := False;
- P.X := X;
- P.Y := Y;
- iIndex := FNoScrollListBox.ItemAtPos(P, True);
- if iIndex = -1 then
- begin
- Exit;
- end;
- ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
- if (Button = mbLeft) then
- begin
- if ListItem.FMouseInHeadImageRect then
- begin
- if FNoScrollListBox.FListView.FShowHeadImageButton then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibUp);
- Exit;
- end;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibUp);
- Exit;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibUp);
- Exit;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibUp);
- Exit;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibUp);
- Exit;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibUp);
- Exit;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibUp);
- Exit;
- end;
- end;
- end;
- procedure TRealICQContacterListView.WhenClick(Sender: TObject);
- var
- P: TPoint;
- iIndex: Integer;
- ListItem: TRealICQContacterListItem;
- begin
- P.X := Mouse.CursorPos.X;
- P.Y := Mouse.CursorPos.Y;
- P := FNoScrollListBox.ScreenToClient(P);
- iIndex := FNoScrollListBox.ItemAtPos(P, True);
- if iIndex <> -1 then
- begin
- ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
- if ListItem.FMouseInHeadImageRect then
- begin
- if FNoScrollListBox.FListView.FShowHeadImageButton then
- begin
- DoItemIconButtonClick(ListItem, ltHeadImage);
- Exit;
- end;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- DoItemIconButtonClick(ListItem, ltCamera);
- Exit;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- DoItemIconButtonClick(ListItem, ltTel);
- Exit;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- DoItemIconButtonClick(ListItem, ltMobile);
- Exit;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- DoItemIconButtonClick(ListItem, ltEmail);
- Exit;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- DoItemIconButtonClick(ListItem, ltSMS);
- Exit;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- DoItemIconButtonClick(ListItem, ltAddFriend);
- Exit;
- end;
- DoItemClick(ListItem);
- end;
- end;
- procedure TRealICQContacterListView.WhenDoubleClick(Sender: TObject);
- var
- P: TPoint;
- iIndex: Integer;
- ListItem: TRealICQContacterListItem;
- begin
- P.X := Mouse.CursorPos.X;
- P.Y := Mouse.CursorPos.Y;
- P := FNoScrollListBox.ScreenToClient(P);
- iIndex := FNoScrollListBox.ItemAtPos(P, True);
- if iIndex <> -1 then
- begin
- ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
- if ListItem.FMouseInHeadImageRect then
- begin
- if FNoScrollListBox.FListView.FShowHeadImageButton then
- begin
- DoItemIconButtonDblClick(ListItem, ltHeadImage);
- Exit;
- end;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltCamera);
- Exit;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltTel);
- Exit;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltMobile);
- Exit;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltEmail);
- Exit;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltSMS);
- Exit;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- DoItemIconButtonDblClick(ListItem, ltAddFriend);
- Exit;
- end;
- ListItem.StopFlash;
- DoItemDoubleClick(ListItem);
- end;
- end;
- procedure TRealICQContacterListView.TimerOnTimer(Sender: TObject);
- var
- P: TPoint;
- ItemIndex: Integer;
- begin
- FTimer.Enabled := False;
- P := FNoScrollListBox.ScreenToClient(Mouse.CursorPos);
- ItemIndex := FNoScrollListBox.ItemAtPos(P, True);
- if FTimerItemIndex <> ItemIndex then
- Exit;
- ShowCustomHint(Items.Objects[ItemIndex] as TRealICQContacterListItem);
- end;
- procedure TRealICQContacterListView.ShowCustomHint(Item: TRealICQContacterListItem);
- var
- P: TPoint;
- Rect: TRect;
- HintStr: string;
- TextWidth, TextHeight: Integer;
- HintStrList: TStringList;
- iLoop: Integer;
- begin
- if not ShowHint then
- Exit;
- if Item.StateIndex = 0 then
- Exit;
- if (Item.FMouseInTextRect) or (Item.FMouseInHeadImageRect and self.FShowHeadImageButton) then
- begin
- HintStr := Copy(Item.LoginName, AnsiPos('-', Item.LoginName) + 1, Length(Item.LoginName) - AnsiPos('-', Item.LoginName));
- if Item.FLoginState = stLeave then
- HintStr := HintStr + '(' + Item.FLeaveMessage + ')'
- else
- HintStr := HintStr + '(' + StateValues[Integer(Item.FLoginState) mod 5] + ')';
- if Length(Trim(Item.DisplayName)) > 0 then
- begin
- HintStr := HintStr + #$D#$A + Item.DisplayName;
- end;
- if Length(Trim(Item.Branch)) > 0 then
- HintStr := HintStr + #$D#$A + Item.Branch;
- if Length(Trim(Item.Watchword)) > 0 then
- begin
- HintStr := HintStr + #$D#$A + Item.Watchword;
- end;
- end
- else
- begin
- if Item.FMouseInHeadImageRect then
- HintStr := Item.FHeadImageHint;
- if Item.FMouseInCameraRect then
- HintStr := Item.FCameraHint;
- if Item.FMouseInTelephoneRect then
- HintStr := Item.FTelephoneHint;
- if Item.FMouseInMobilePhoneRect then
- HintStr := Item.FMobilePhoneHint;
- if Item.FMouseInEmailRect then
- HintStr := Item.FEmailHint;
- if Item.FMouseInSMSRect then
- HintStr := Item.FSMSHint;
- if Item.FMouseInAddFriendRect then
- HintStr := Item.FAddFriendHint;
- end;
- DoItemShowHint(Item, HintStr);
- if Length(Trim(HintStr)) = 0 then
- Exit;
- TextWidth := 0;
- TextHeight := 0;
- HintStrList := RealICQUtils.SplitString(HintStr, #$D#$A);
- try
- for iLoop := 0 to HintStrList.Count - 1 do
- begin
- if TextWidth < FHintWindow.Canvas.TextWidth(HintStrList.Strings[iLoop]) then
- TextWidth := FHintWindow.Canvas.TextWidth(HintStrList.Strings[iLoop]);
- Inc(TextHeight, FHintWindow.Canvas.TextHeight(HintStrList.Strings[iLoop]));
- end;
- finally
- HintStrList.Free;
- end;
- P.X := 0;
- P.Y := 0;
- P := FNoScrollListBox.ClientToScreen(P);
- Rect.Left := Mouse.CursorPos.X + 20;
- Rect.Top := FNoScrollListBox.ItemRect(FTimerItemIndex).Top + FNoScrollListBox.ItemHeight + P.Y + 10;
- Rect.Right := Rect.Left + TextWidth + 10;
- Rect.Bottom := Rect.Top + TextHeight + 5;
- FHintWindow.Color := clInfoBk;
- FHintWindow.ActivateHint(Rect, HintStr);
- FHintWindow.Visible := True;
- end;
- procedure TRealICQContacterListView.WhenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
- var
- P: TPoint;
- iIndex, iLoop: Integer;
- ListItem: TRealICQContacterListItem;
- procedure OpenHint;
- begin
- FTimerItemIndex := ListItem.ItemIndex;
- if FHintWindow.Visible then
- begin
- ShowCustomHint(ListItem);
- end
- else
- begin
- FTimer.Enabled := False;
- FTimer.Enabled := True;
- end;
- end;
- procedure CloseHint;
- begin
- FTimerItemIndex := -1;
- FTimer.Enabled := False;
- FHintWindow.ReleaseHandle;
- FHintWindow.Visible := False;
- end;
- procedure ResetMouseInRectState;
- begin
- ListItem.FMouseInTextRect := False;
- ListItem.FMouseInHeadImageRect := False;
- ListItem.FMouseInCameraRect := False;
- ListItem.FMouseInTelephoneRect := False;
- ListItem.FMouseInMobilePhoneRect := False;
- ListItem.FMouseInEmailRect := False;
- ListItem.FMouseInSMSRect := False;
- ListItem.FMouseInAddFriendRect := False;
- end;
- begin
- P.X := X;
- P.Y := Y;
- iIndex := FNoScrollListBox.ItemAtPos(P, True);
- for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
- begin
- ListItem := Items.Objects[iLoop] as TRealICQContacterListItem;
- if (iIndex = iLoop) then
- continue;
- if ListItem.FMouseOver then
- begin
- ListItem.FMouseOver := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInRect then
- begin
- ListItem.FMouseInRect := False;
- end;
- if ListItem.FMouseInTextRect then
- begin
- ListItem.FMouseInTextRect := False;
- DoItemMouseLeave(ListItem);
- end;
- if ListItem.FMouseInHeadImageRect then
- begin
- DoHeadImageMouseLeave(ListItem);
- ListItem.FMouseInHeadImageRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- ListItem.FMouseInCameraRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- ListItem.FMouseInTelephoneRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- ListItem.FMouseInMobilePhoneRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- ListItem.FMouseInEmailRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- ListItem.FMouseInSMSRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- ListItem.FMouseInAddFriendRect := False;
- ListItem.ReDrawItem;
- end;
- end;
- if iIndex >= 0 then
- begin
- ListItem := Items.Objects[iIndex] as TRealICQContacterListItem;
- if not ListItem.FMouseOver then
- begin
- ListItem.FMouseOver := True;
- ListItem.ReDrawItem;
- end;
- {$region '是否在头像图标区间'}
- if PtInRect(ListItem.FHeadImageRect, P) then
- begin
- if not ListItem.FMouseInHeadImageRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInHeadImageRect := True;
- DoHeadImageMouseEnter(ListItem);
- if FNoScrollListBox.FListView.FShowHeadImageButton then
- begin
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FHeadImageRect, ibUp);
- OpenHint;
- Exit;
- end;
- end;
- end
- else
- begin
- if ListItem.FMouseInHeadImageRect then
- begin
- DoHeadImageMouseLeave(ListItem);
- ListItem.FMouseInHeadImageRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- {$endregion}
- {$region '是否在摄像头图标区间'}
- if (ListItem.HasCamera) and (ListItem.LoginState <> stHidden) then
- begin
- if PtInRect(ListItem.FCameraRect, P) then
- begin
- if not ListItem.FMouseInCameraRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInCameraRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FCameraRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInCameraRect then
- begin
- ListItem.FMouseInCameraRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
- {$region '是否在坐机图标区间'}
- if (ListItem.HasTelephone) then
- begin
- //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);
- if PtInRect(ListItem.FTelephoneRect, P) then
- begin
- if not ListItem.FMouseInTelephoneRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInTelephoneRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FTelephoneRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInTelephoneRect then
- begin
- ListItem.FMouseInTelephoneRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
-
- {$region '是否在手机图标区间'}
- if (ListItem.HasMobilePhone) then
- begin
- if PtInRect(ListItem.FMobilePhoneRect, P) then
- begin
- if not ListItem.FMouseInMobilePhoneRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInMobilePhoneRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FMobilePhoneRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInMobilePhoneRect then
- begin
- ListItem.FMouseInMobilePhoneRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
- {$region '是否在信箱区间'}
- if (ListItem.FHasEmail) then
- begin
- if PtInRect(ListItem.FEmailRect, P) then
- begin
- if not ListItem.FMouseInEmailRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInEmailRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FEmailRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInEmailRect then
- begin
- ListItem.FMouseInEmailRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
- {$region '是否在短信区间'}
- if (ListItem.FHasSMS) then
- begin
- if PtInRect(ListItem.FSMSRect, P) then
- begin
- if not ListItem.FMouseInSMSRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInSMSRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FSMSRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInSMSRect then
- begin
- ListItem.FMouseInSMSRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
- {$region '是否在增加好友区间'}
- if (ListItem.FHasAddFriend) then
- begin
- if PtInRect(ListItem.FAddFriendRect, P) then
- begin
- if not ListItem.FMouseInAddFriendRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInAddFriendRect := True;
- DrawIconButton(FNoScrollListBox.Canvas, FIconBtnDefaultColor, FIconBtnLightColor, FIconBtnShadownColor, ListItem.FAddFriendRect, ibUp);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInAddFriendRect then
- begin
- ListItem.FMouseInAddFriendRect := False;
- ListItem.ReDrawItem;
- CloseHint;
- end;
- end;
- end;
- {$endregion}
- {$region '是否在文字区间'}
- if PtInRect(ListItem.FTextRect, P) then
- begin
- if not ListItem.FMouseInTextRect then
- begin
- ResetMouseInRectState;
- ListItem.FMouseInTextRect := True;
- DoItemMouseEnter(ListItem);
- OpenHint;
- Exit;
- end;
- end
- else
- begin
- if ListItem.FMouseInTextRect then
- begin
- ListItem.FMouseInTextRect := False;
- CloseHint;
- end;
- end;
- {$endregion}
- end
- else
- begin
- CloseHint;
- end;
- end;
- procedure TRealICQContacterListView.WhenMouseLeave(Sender: TObject);
- var
- iLoop: Integer;
- ListItem: TRealICQContacterListItem;
- begin
- FTimerItemIndex := -1;
- FTimer.Enabled := False;
- FHintWindow.ReleaseHandle;
- FHintWindow.Visible := False;
- for iLoop := 0 to FNoScrollListBox.Items.Count - 1 do
- begin
- ListItem := Items.Objects[iLoop] as TRealICQContacterListItem;
- if ListItem.FMouseOver then
- begin
- ListItem.FMouseOver := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInRect then
- begin
- ListItem.FMouseInRect := False;
- DoItemMouseLeave(ListItem);
- end;
- if ListItem.FMouseInHeadImageRect then
- begin
- DoHeadImageMouseLeave(ListItem);
- ListItem.FMouseInHeadImageRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInCameraRect then
- begin
- ListItem.FMouseInCameraRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInTelephoneRect then
- begin
- ListItem.FMouseInTelephoneRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInMobilePhoneRect then
- begin
- ListItem.FMouseInMobilePhoneRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInEmailRect then
- begin
- ListItem.FMouseInEmailRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInSMSRect then
- begin
- ListItem.FMouseInSMSRect := False;
- ListItem.ReDrawItem;
- end;
- if ListItem.FMouseInAddFriendRect then
- begin
- ListItem.FMouseInAddFriendRect := False;
- ListItem.ReDrawItem;
- end;
- end;
- end;
- procedure TRealICQContacterListView.SetSelectedItemBorderInnerColor(Value: TColor);
- begin
- if FSelectedItemBorderInnerColor = Value then
- Exit;
- FSelectedItemBorderInnerColor := Value;
- end;
- procedure TRealICQContacterListView.SetSelectedItemBorderColor(Value: TColor);
- begin
- if FSelectedItemBorderColor = Value then
- Exit;
- FSelectedItemBorderColor := Value;
- end;
- procedure TRealICQContacterListView.SetSelectedItemBackColor(Value: TColor);
- begin
- if FSelectedItemBackColor = Value then
- Exit;
- FSelectedItemBackColor := Value;
- end;
- procedure TRealICQContacterListView.SetHeadImageBorderColor(Value: TColor);
- begin
- if FHeadImageBorderColor = Value then
- Exit;
- FHeadImageBorderColor := Value;
- end;
- procedure TRealICQContacterListView.SetHeadImageBackColor(Value: TColor);
- begin
- if FHeadImageBackColor = Value then
- Exit;
- FHeadImageBackColor := Value;
- end;
- procedure TRealICQContacterListView.SetSelectedItemBackgroud(Value: TPicture);
- begin
- FSelectedItemBackgroud.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureBig(Value: TPicture);
- begin
- FDefaultPictureBig.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureMiddle(Value: TPicture);
- begin
- FDefaultPictureMiddle.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureSmall(Value: TPicture);
- begin
- FDefaultPictureSmall.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureBigOffline(Value: TPicture);
- begin
- FDefaultPictureBigOffline.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureMiddleOffline(Value: TPicture);
- begin
- FDefaultPictureMiddleOffline.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetDefaultPictureSmallOffline(Value: TPicture);
- begin
- FDefaultPictureSmallOffline.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetLeavePictureBig(Value: TIcon);
- begin
- FLeavePictureBig.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetBusyPictureBig(Value: TIcon);
- begin
- FBusyPictureBig.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetMutePictureBig(Value: TIcon);
- begin
- FMutePictureBig.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetLeavePicture(Value: TIcon);
- begin
- FLeavePicture.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetBusyPicture(Value: TIcon);
- begin
- FBusyPicture.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetMutePicture(Value: TIcon);
- begin
- FMutePicture.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetCameraIcon(Value: TIcon);
- begin
- FCameraIcon.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetTelephoneIcon(Value: TIcon);
- begin
- FTelephoneIcon.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetMobilePhoneIcon(Value: TIcon);
- begin
- FMobilePhoneIcon.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetEmailIcon(Value: TIcon);
- begin
- FEmailIcon.Assign(Value);
- end;
- //-----------------------------------------------------------------
- procedure TRealICQContacterListView.SetAddFriendIcon(Value: TIcon);
- begin
- FAddFriendIcon.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetSMSIcon(Value: TIcon);
- begin
- FSMSIcon.Assign(Value);
- end;
- procedure TRealICQContacterListView.SetTopIndex(Value: Integer);
- begin
- FNoScrollListBox.TopIndex := Value;
- end;
- function TRealICQContacterListView.GetTopIndex: Integer;
- begin
- Result := FNoScrollListBox.TopIndex;
- end;
- function TRealICQContacterListView.GetSelCount: Integer;
- begin
- Result := FNoScrollListBox.SelCount;
- end;
- procedure TRealICQContacterListView.DoSelectItemChanged(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnSelectItemChanged) then
- FOnSelectItemChanged(Item);
- end;
- procedure TRealICQContacterListView.DoItemClick(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemClick) then
- FOnItemClick(Item);
- end;
- procedure TRealICQContacterListView.DoItemDoubleClick(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemDoubleClick) then
- FOnItemDoubleClick(Item);
- end;
- procedure TRealICQContacterListView.DoHeadImageMouseEnter(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnHeadImageMouseEnter) then
- FOnHeadImageMouseEnter(Item);
- end;
- procedure TRealICQContacterListView.DoHeadImageMouseLeave(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnHeadImageMouseLeave) then
- FOnHeadImageMouseLeave(Item);
- end;
- procedure TRealICQContacterListView.DoItemMouseEnter(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemMouseEnter) then
- FOnItemMouseEnter(Item);
- end;
- procedure TRealICQContacterListView.DoItemMouseLeave(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemMouseLeave) then
- FOnItemMouseLeave(Item);
- end;
- procedure TRealICQContacterListView.DoItemFlashCaption(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemFlashCaption) then
- FOnItemFlashCaption(Item);
- end;
- procedure TRealICQContacterListView.DoItemOnline(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemOnline) then
- FOnItemOnline(Item);
- end;
- procedure TRealICQContacterListView.DoItemOffline(Item: TRealICQContacterListItem);
- begin
- if Assigned(FOnItemOffline) then
- FOnItemOffline(Item);
- end;
- procedure TRealICQContacterListView.DoItemIconButtonClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
- begin
- if Assigned(FOnItemIconButtonClick) then
- FOnItemIconButtonClick(Self, Item, IconButtonType);
- end;
- procedure TRealICQContacterListView.DoItemIconButtonDblClick(Item: TRealICQContacterListItem; IconButtonType: TRealICQContacterListItemIconButtonType);
- begin
- if Assigned(FOnItemIconButtonDblClick) then
- FOnItemIconButtonDblClick(Self, Item, IconButtonType);
- end;
- procedure TRealICQContacterListView.DoItemShowHint(Item: TRealICQContacterListItem; var HintStr: string);
- begin
- if Assigned(FOnItemShowHint) then
- FOnItemShowHint(Self, Item, HintStr);
- end;
- procedure TRealICQContacterListView.DropFiles(var Message: TMessage);
- begin
- DoDropFiles(Message);
- end;
- procedure TRealICQContacterListView.DoDropFiles(var Message: TMessage);
- begin
- if Assigned(FOnDropFiles) then
- FOnDropFiles(Self, Message);
- end;
- function TRealICQContacterListView.ItemAtPos(Pos: TPoint; Existing: Boolean): Integer;
- var
- P: TPoint;
- begin
- P := FNoScrollListBox.ScreenToClient(Pos);
- Result := FNoScrollListBox.ItemAtPos(P, Existing);
- end;
- procedure TRealICQContacterListView.ReDrawAll;
- begin
- if (FNoScrollListBox <> nil) then
- begin
- FNoScrollListBox.Width := FNoScrollListBox.Width - 1;
- FNoScrollListBox.Width := FNoScrollListBox.Width + 1;
- FNoScrollListBox.Invalidate;
- end;
- end;
- procedure TRealICQContacterListView.ChangeUIColor(AColor: TColor);
- begin
- FIconBtnDefaultColor := ConvertColorToColor(FIconBtnDefaultColor, AColor);
- FIconBtnLightColor := ConvertColorToColor(FIconBtnLightColor, AColor);
- FIconBtnShadownColor := ConvertColorToColor(FIconBtnShadownColor, AColor);
- HeadImageBorderColor := ConvertColorToColor(HeadImageBorderColor, AColor);
- HeadImageBackColor := ConvertColorToColor(HeadImageBackColor, AColor);
- SelectedItemBorderColor := ConvertColorToColor(SelectedItemBorderColor, AColor);
- SelectedItemBorderInnerColor := ConvertColorToColor(SelectedItemBorderInnerColor, AColor);
- SelectedItemBackColor := ConvertColorToColor(SelectedItemBackColor, AColor);
- ConvertBitmapToColor(FSelectedItemBackgroud.Bitmap, AColor);
- ConvertBitmapToColor(FScrollTopButtonPictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollTopButtonPictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollTopButtonPictureDown.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBottomButtonPictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBottomButtonPictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBottomButtonPictureDown.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonTopPictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonTopPictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonTopPictureDown.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonMiddlePictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonMiddlePictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonMiddlePictureDown.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonBottomPictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonBottomPictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBarButtonBottomPictureDown.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBackgroundPictureNormal.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBackgroundPictureHover.Bitmap, AColor);
- ConvertBitmapToColor(FScrollBackgroundPictureDown.Bitmap, AColor);
- FListBoxScrollBar.FAssignedPicture := False;
- FListBoxScrollBar.DrawScrollBar;
- FNoScrollListBox.Repaint;
- end;
- constructor TRealICQContacterListView.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Color := clWhite;
- DoubleBuffered := True;
- BevelInner := bvNone;
- BevelOuter := bvNone;
- AutoSize := True;
- Width := 200;
- Height := 300;
- FTimer := TTimer.Create(Self);
- FTimer.Interval := 600;
- FTimer.Enabled := False;
- FTimer.OnTimer := TimerOnTimer;
- FHintWindow := TSingleBorderHintWindow.Create(Self);
- FHintWindow.Visible := False;
- FTimerItemIndex := -1;
- FScrollTopButtonPictureNormal := TPicture.Create;
- FScrollTopButtonPictureHover := TPicture.Create;
- FScrollTopButtonPictureDown := TPicture.Create;
- FScrollBottomButtonPictureNormal := TPicture.Create;
- FScrollBottomButtonPictureHover := TPicture.Create;
- FScrollBottomButtonPictureDown := TPicture.Create;
- FScrollBarButtonTopPictureNormal := TPicture.Create;
- FScrollBarButtonTopPictureHover := TPicture.Create;
- FScrollBarButtonTopPictureDown := TPicture.Create;
- FScrollBarButtonMiddlePictureNormal := TPicture.Create;
- FScrollBarButtonMiddlePictureHover := TPicture.Create;
- FScrollBarButtonMiddlePictureDown := TPicture.Create;
- FScrollBarButtonBottomPictureNormal := TPicture.Create;
- FScrollBarButtonBottomPictureHover := TPicture.Create;
- FScrollBarButtonBottomPictureDown := TPicture.Create;
- FScrollBackgroundPictureNormal := TPicture.Create;
- FScrollBackgroundPictureHover := TPicture.Create;
- FScrollBackgroundPictureDown := TPicture.Create;
- FSelectedItemBackgroud := TPicture.Create;
- FDefaultPictureBig := TPicture.Create;
- FDefaultPictureMiddle := TPicture.Create;
- FDefaultPictureSmall := TPicture.Create;
- FDefaultPictureBigOffline := TPicture.Create;
- FDefaultPictureMiddleOffline := TPicture.Create;
- FDefaultPictureSmallOffline := TPicture.Create;
- FLeavePicture := TIcon.Create;
- FBusyPicture := TIcon.Create;
- FMutePicture := TIcon.Create;
- FLeavePictureBig := TIcon.Create;
- FBusyPictureBig := TIcon.Create;
- FMutePictureBig := TIcon.Create;
- FCameraIcon := TIcon.Create;
- FTelephoneIcon := TIcon.Create;
- FMobilePhoneIcon := TIcon.Create;
- FEmailIcon := TIcon.Create;
- FSMSIcon := TIcon.Create;
- FAddFriendIcon := TIcon.Create;
- FShowHeadImageButton := False;
- FShowEmailButton := True;
- FShowSMSButton := True;
- FShowTelButton := True;
- FShowMobileButton := True;
- FShowCameraButton := True;
- FShowAddFriendButton := False;
- FIconBtnDefaultColor := clWhite;
- FIconBtnLightColor := clSilver;
- FIconBtnShadownColor := cl3DDkShadow;
- FItems := TRealICQContacterListItems.Create(Self);
- FNoScrollListBox := TNoScrollListBox.Create(Self);
- FNoScrollListBox.Parent := Self;
- FNoScrollListBox.Align := alClient;
- FNoScrollListBox.DoubleBuffered := False;
- FNoScrollListBox.BorderStyle := bsNone;
- FNoScrollListBox.Style := lbOwnerDrawFixed;
- FNoScrollListBox.MultiSelect := True;
- FNoScrollListBox.ExtendedSelect := True;
- FNoScrollListBox.AutoComplete := False;
- FNoScrollListBox.FListView := Self;
- FListBoxScrollBar := TListBoxScrollBar.Create(Self);
- FListBoxScrollBar.Parent := Self;
- FListBoxScrollBar.Align := alRight;
- FListBoxScrollBar.DoubleBuffered := True;
- FListBoxScrollBar.FListView := Self;
- FNoScrollListBox.OnResize := FListBoxScrollBar.ListBoxResize;
- FNoScrollListBox.OnConstrainedResize := FListBoxScrollBar.ListBoxConstrainedResize;
- FNoScrollListBox.OnMouseWheelDown := FListBoxScrollBar.ListBoxMouseWheelDown;
- FNoScrollListBox.OnMouseWheelUp := FListBoxScrollBar.ListBoxMouseWheelUp;
- Style := lsMiddleHeadImage;
- CaptionStyle := csDisplayName;
- FAdjustPosition := True;
- FFlashCaptionOnOnline := False;
- FOnlineNumeric := 0;
- FNoScrollListBox.OnClick := WhenClick;
- FNoScrollListBox.OnDblClick := WhenDoubleClick;
- FNoScrollListBox.OnMouseMove := WhenMouseMove;
- FNoScrollListBox.OnMouseLeave := WhenMouseLeave;
- FNoScrollListBox.OnMouseDown := WhenMouseDown;
- FNoScrollListBox.OnMouseUp := WhenMouseUp;
- end;
- destructor TRealICQContacterListView.Destroy;
- begin
- try
- FNoScrollListBox.OnResize := nil;
- FNoScrollListBox.OnConstrainedResize := nil;
- FNoScrollListBox.OnMouseWheelDown := nil;
- FNoScrollListBox.OnMouseWheelUp := nil;
- FreeAndNil(FTimer);
- FreeAndNil(FNoScrollListBox);
- FreeAndNil(FListBoxScrollBar);
- FItems.Clear;
- FreeAndNil(FItems);
- FreeAndNil(FCameraIcon);
- FreeAndNil(FTelephoneIcon);
- FreeAndNil(FMobilePhoneIcon);
- FreeAndNil(FEmailIcon);
- FreeAndNil(FSMSIcon);
- FreeAndNil(FAddFriendIcon);
- FreeAndNil(FSelectedItemBackgroud);
- FreeAndNil(FScrollBackgroundPictureDown);
- FreeAndNil(FScrollBackgroundPictureHover);
- FreeAndNil(FScrollBackgroundPictureNormal);
- FreeAndNil(FScrollBarButtonBottomPictureDown);
- FreeAndNil(FScrollBarButtonBottomPictureHover);
- FreeAndNil(FScrollBarButtonBottomPictureNormal);
- FreeAndNil(FScrollBarButtonMiddlePictureDown);
- FreeAndNil(FScrollBarButtonMiddlePictureHover);
- FreeAndNil(FScrollBarButtonMiddlePictureNormal);
- FreeAndNil(FScrollBarButtonTopPictureDown);
- FreeAndNil(FScrollBarButtonTopPictureHover);
- FreeAndNil(FScrollBarButtonTopPictureNormal);
- FreeAndNil(FScrollBottomButtonPictureDown);
- FreeAndNil(FScrollBottomButtonPictureHover);
- FreeAndNil(FScrollBottomButtonPictureNormal);
- FreeAndNil(FScrollTopButtonPictureDown);
- FreeAndNil(FScrollTopButtonPictureHover);
- FreeAndNil(FScrollTopButtonPictureNormal);
- FreeAndNil(FLeavePicture);
- FreeAndNil(FBusyPicture);
- FreeAndNil(FMutePicture);
- FreeAndNil(FLeavePictureBig);
- FreeAndNil(FBusyPictureBig);
- FreeAndNil(FMutePictureBig);
- FreeAndNil(FDefaultPictureSmallOffline);
- FreeAndNil(FDefaultPictureMiddleOffline);
- FreeAndNil(FDefaultPictureBigOffline);
- FreeAndNil(FDefaultPictureSmall);
- FreeAndNil(FDefaultPictureMiddle);
- FreeAndNil(FDefaultPictureBig);
- FHintWindow.ReleaseHandle;
- FHintWindow.Free;
- except
- end;
- inherited Destroy;
- end;
- { TRealICQFlashCaption }
- constructor TRealICQFlashCaption.Create(ARealICQContacterListItem: TRealICQContacterListItem);
- begin
- inherited Create(True);
- FRealICQContacterListItem := ARealICQContacterListItem;
- FreeOnTerminate := True;
- Resume;
- end;
- destructor TRealICQFlashCaption.Destroy;
- var
- ListItem: TRealICQContacterListItem;
- FListView: TRealICQContacterListView;
- Rect: TRect;
- begin
- try
- if FRealICQContacterListItem <> nil then
- begin
- FRealICQContacterListItem.FCaptionColor := $00FFFFFF;
- ListItem := FRealICQContacterListItem;
- FListView := ListItem.FListView;
- Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
- InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
- FRealICQContacterListItem.FFlashCaptionThread := nil;
- end;
- except
- end;
- inherited Destroy;
- end;
- procedure TRealICQFlashCaption.FlashCaptionColor;
- var
- ListItem: TRealICQContacterListItem;
- FListView: TRealICQContacterListView;
- Rect: TRect;
- begin
- if Terminated then
- exit;
- ListItem := FRealICQContacterListItem;
- if ListItem = nil then
- exit;
- FListView := ListItem.FListView;
- if not FListView.Visible then
- exit;
- if FListView.Height = 0 then
- exit;
- Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
- if Rect.Bottom < 0 then
- Exit;
- if Rect.Top > FListView.Height then
- Exit;
- FRealICQContacterListItem.FCaptionColor := FlashColors[FColorIndex];
- InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
- end;
- procedure TRealICQFlashCaption.Execute;
- var
- iLoop, jLoop: Integer;
- begin
- for iLoop := 1 to 3 do
- for jLoop := 1 to FlashColorCount do
- begin
- if Terminated then
- exit;
- FColorIndex := jLoop;
- Synchronize(FlashCaptionColor);
- Sleep(400);
- end;
- end;
- { TRealICQFlashImage }
- constructor TRealICQFlashImage.Create(ARealICQContacterListItem: TRealICQContacterListItem);
- begin
- inherited Create(True);
- FRealICQContacterListItem := ARealICQContacterListItem;
- FreeOnTerminate := True;
- Resume;
- end;
- destructor TRealICQFlashImage.Destroy;
- var
- ListItem: TRealICQContacterListItem;
- FListView: TRealICQContacterListView;
- Rect: TRect;
- begin
- try
- if FRealICQContacterListItem <> nil then
- begin
- FRealICQContacterListItem.FHeadImagePosition := 0;
- ListItem := FRealICQContacterListItem;
- FListView := ListItem.FListView;
- Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
- InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
- FRealICQContacterListItem.FFlashImageThread := nil;
- end;
- except
- end;
- inherited Destroy;
- end;
- procedure TRealICQFlashImage.FlashImagePosition;
- var
- ListItem: TRealICQContacterListItem;
- FListView: TRealICQContacterListView;
- Rect: TRect;
- begin
- if Terminated then
- exit;
- ListItem := FRealICQContacterListItem;
- if ListItem = nil then
- exit;
- FListView := ListItem.FListView;
- if not FListView.Visible then
- exit;
- if FListView.Height = 0 then
- exit;
- Rect := FListView.FNoScrollListBox.ItemRect(ListItem.ItemIndex);
- if Rect.Bottom < 0 then
- Exit;
- if Rect.Top > FListView.Height then
- Exit;
- FRealICQContacterListItem.FHeadImagePosition := FPosition;
- InvalidateRect(FListView.FNoScrollListBox.Handle, @Rect, False);
- end;
- procedure TRealICQFlashImage.Execute;
- var
- iAdd: Integer;
- begin
- iAdd := 0;
- FPosition := 1;
- while not Terminated do
- begin
- if FPosition = 3 then
- iAdd := -1;
- if FPosition = 1 then
- iAdd := 1;
- FPosition := FPosition + iAdd;
- Synchronize(FlashImagePosition);
- sleep(300);
- end;
- end;
- procedure Register;
- begin
- RegisterComponents('RealICQ UI', [TRealICQContacterListView]);
- end;
- end.
|