Delphi QQ表情框管理控件的实现源码

简介:

在首页区,看到很多实现QQ表情列表管理功能的代码,但是貌似没发现Delphi的实现版本,这里我将我以前写的IM中的表情管理的一个表情框控件共享出来,提供给对Delphi还有感情的爱好者参考使用。介绍我就不多说了,有兴趣的直接下代码看吧,用法也简单,直接使用TDxFaceGrid就行。代码中集合了表情包的实现逻辑(包括表情包的导入和导出等),具体例子我是没写,有兴趣的可以参考参考!

复制代码
代码

   
   
{ ******************************************************* }
{ }
{ 表情编辑框控件 }
{ 作者:不得闲 }
{ 日期: 2009.06.18 }
{ 版权所有 (C) 2009 得闲工作室 }
{ }
{ ******************************************************* }

unit DxFaceControl;

interface
uses Windows,SysUtils,Messages,Classes,Controls,Graphics,GIFImg,ExtCtrls,Nativexml,frxmd5,AES;

type
// 表情节点
TDxFace
= class
private
FFaceFileName:
string ;
FFaceFileMD5:
string ;
FFaceTags: TStringList;
procedure SetFaceFileName( const Value: string );
procedure SetFaceTags( const Value: TStringList);
public
constructor Create;
destructor Destroy; override ;
// 表情文件的MD5码
property FaceFileMD5: string read FFaceFileMD5;
property FaceFileName: string read FFaceFileName write SetFaceFileName; // 表情文件的位置
property FaceTags: TStringList read FFaceTags write SetFaceTags;
end ;

TDxFaces
= class
private
FacesList: TList;
FPackageName:
string ;
Width: Integer;
Height: Integer;
RowCount: Integer;
ColCount: Integer;
FaceFilePack:
string ;
procedure InitFaces(FilePackName: string );
procedure clearFace;
function GetFaces(index: integer): TDxFace;
procedure SetFaces(index: integer;Value: TDxFace);
function GetCount: Integer;
public
constructor Create(FilePackName: string );
destructor Destroy; override ;
property PackageName: string read FPackageName;
property Faces[index: integer]: TDxFace read GetFaces write SetFaces;
property Count: Integer read GetCount;
procedure AddFaces(FaceFile: string ;FaceName: string ); // 添加表情信息
end ;

// 表情包列表
TDxFacePackages
= class
private
FacePackages: TStringList;
// 表情包列表
UserId:
string ;
procedure ClearPackages;
procedure LoadPacks;
function GetCount: Integer;
function GetFaces(index: integer): TDxFaces;
public
constructor Create(ClientUserId: string ); // 根据进入的用户来获得表情包
destructor Destroy; override ;
procedure DeleteFacePackage(PakName: string );
procedure AddPackage(FacePack: TDxFaces); overload ; // 添加表情包
function AddPackage(PackFileName: string ): TDxFaces; overload ; // 通过xml文件来创建添加包
property Count: Integer read GetCount;
property Faces[index: integer]: TDxFaces read GetFaces;
end ;

TOnGetFaceEvent
= procedure (Sender: TObject;Face: TDxFace) of object ;
TDxFaceGrid
= class (TCustomControl)
private
FFaceWidth: Integer;
FFaceHeight: Integer;
FRowCount: Integer;
FColCount: Integer;
FImages: TList;
Faces: TDxFaces;
CurSelectRect: TRect;
FFrameColor: TColor;
FGridLineColor: TColor;
FSelFrameColor: TColor;
FOnGetFace: TOnGetFaceEvent;
FPageIndex: Integer;
TotalCount: Integer;
FaceSelfCreate: Boolean;
procedure SetFaceWidth( const Value: Integer);
procedure SetFaceHeight( const Value: Integer);
procedure SetRowCount( const Value: Integer);
procedure SetColCount( const Value: Integer);
function GetImage(ACol, ARow: Integer): TImage;
procedure SetFrameColor( const Value: TColor);
procedure SetGridLine( const Value: TColor);
procedure SetSelFrameColor( const Value: TColor);
function GetPageCount: Integer;
procedure SetPageIndex( const Value: Integer);
protected
procedure CreateWnd; override ;
procedure CalcWH;
procedure InitImageItems;
procedure Paint; override ;
procedure DoImgEnter(Sender: TObject);
procedure DoImgLeave(Sender: TObject);
procedure DoImgClick(Sender: TObject);
public
constructor Create(AOwner: TComponent); overload ; override ;
constructor Create(AOwner: TComponent;PackFileName: string ); reintroduce ; overload ;
constructor Create(AOwner: TComponent;FacePack: TDxFaces); reintroduce ; overload ;
destructor Destroy; override ;
property FaceWidth: Integer read FFaceWidth write SetFaceWidth default 24 ;
property FaceHeight: Integer read FFaceHeight write SetFaceHeight default 24 ;
property RowCount: Integer read FRowCount write SetRowCount default 8 ;
property ColCount: Integer read FColCount write SetColCount default 15 ;
property Image[ACol,ARow: Integer]: TImage read GetImage;
property FrameColor: TColor read FFrameColor write SetFrameColor default $AEAEAE;
property GridLine: TColor read FGridLineColor write SetGridLine default $F6E6DF;
property SelFrameColor: TColor read FSelFrameColor write SetSelFrameColor default clBlue;
property OnGetFace: TOnGetFaceEvent read FOnGetFace write FOnGetFace;
property PageCount: Integer read GetPageCount; // 页面数量
property PageIndex: Integer read FPageIndex write SetPageIndex default 0 ;
end ;
implementation
end .
复制代码

 


本文转自 不得闲 博客园博客,原文链接:  http://www.cnblogs.com/DxSoft/archive/2010/01/07/1641052.html ,如需转载请自行联系原作者


相关文章
|
前端开发
清明节,如何用代码让网页变灰
清明节,如何用代码让网页变灰
VB编程:仿QQ聊天框的抖动效果-58
VB编程:仿QQ聊天框的抖动效果-58
VB编程:仿QQ聊天框的抖动效果
VB编程:仿QQ聊天框的抖动效果
146 0
VB编程:仿QQ聊天框的抖动效果
|
算法
高仿微信聊天界面长按弹框样式
效果图 背景 在公司做的项目里面,刚好有需要用到微信聊天界面长按弹框样式这种UI的。 网上找了一下,没找到。 Android现成的 ListPopupWindow又不能满足需求。
2290 0
|
C#
用C#开发类似QQ输入法的不规则窗体的程序详解+代码打包分享
QQ窗体是圆角的,Kugoo窗体也是圆角的,QQ的输入法皮肤窗体是不规则的。。。等N多日常使用的程序主窗体都不是四四方方的,其实都是调用2D绘画函数按指定的路径画出来的,那么这一课我给入门级学者讲解的是关于C#实现这一功能。
985 0