MTK皮肤使用说明.docx

上传人:b****8 文档编号:24012930 上传时间:2023-05-23 格式:DOCX 页数:29 大小:27.58KB
下载 相关 举报
MTK皮肤使用说明.docx_第1页
第1页 / 共29页
MTK皮肤使用说明.docx_第2页
第2页 / 共29页
MTK皮肤使用说明.docx_第3页
第3页 / 共29页
MTK皮肤使用说明.docx_第4页
第4页 / 共29页
MTK皮肤使用说明.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

MTK皮肤使用说明.docx

《MTK皮肤使用说明.docx》由会员分享,可在线阅读,更多相关《MTK皮肤使用说明.docx(29页珍藏版)》请在冰豆网上搜索。

MTK皮肤使用说明.docx

MTK皮肤使用说明

“皮肤”使用说明

1、简介:

Skin(皮肤)控件,为大家提供了一种图形界面更为灵活,交互操作更为方便,效率也更高的机制。

它实质上相当于一个容器,用户可以在其中加入多种自己所需要的控件,并且可以方便的设置控件以及整个皮肤的外观表现。

目前Skin中支持的控件有Button,CheckButton,Lable,ImageLable,Slider,RotationSlider,MScontrol。

Button:

普通的按钮控件,可以有点击,抬起,无效,高亮四种状态,用户需要为其提供相应的图片。

CheckButton:

相当于CheckBox的控件,有Check,点击,高亮,无效四种状态,用户需要为其提供相应的图片。

Lable:

显示文字的控件,用户设置文字的内容,以及文字的字体和颜色。

ImageLable:

一种灵活的显示文字的控件,用户自己建立文字表,并提供每个字符的图片与其对应。

然后设置文字内容,最终显示出多种形式的文字效果。

Slider:

普通的滑竿控件。

Rotation:

圆形的滑竿控件。

MScontrol:

外界的窗口控件,通过这个接口,用户可以在Skin中使用外界所提供的各种控件。

2、数据结构:

1.skin_head_t是Skin的数据结构(如下所示),其中提供了整个Skin所需要的所有数据。

包括名称,Skin中的控件数组,Skin所使用的图片数组,字体数组,Skin的回调函数,消息处理函数等等。

/**Skinheaderinformationstructure*/

structskin_head_s

{

/**Thenameoftheskin.*/

char*name;

/**

*Thestyleoftheskin,canbeOR'edbythefollowingvalues:

*-SKIN_STYLE_TOOLTIP

*Theskinhastooltipwindow.

*/

DWORDstyle;

/**Thepointertothearrayofthebitmapsusedbytheskin.*/

constHBITMAP*bmps;

/**Thepointertothearrayofthelogicalfontsusedbytheskin.*/

constHFONT*fonts;

/**Theindexofthebackgroundbitmapinthebitmaparray.*/

intbk_bmp_index;

/**Thenumberoftheitemsinthisskin.*/

intnr_items;

/**Thepointertothearrayofskinitems.*/

skin_item_t*items;

/**Theattachedprivatedatawiththeskinbyapplication.*/

DWORDattached;

/********startofinternalfields********/

/*Theeventcallbackfunctionoftheskin.*/

skin_event_cb_tevent_cb;

/*Thewindowmessageprocedureoftheskinwindow.*/

skin_msg_cb_tmsg_cb;

/****Thefieldsinitializedwhenskin_initcalled.****/

/*Therectangleheapforhit-testregions.*/

//BLOCKHEAPrc_heap;

/****Thefieldsinitializedwhencreate_skin_main_windoworcreate_skin_controlcalled.****/

/*Thehandleofwindowinwhichtheskinlocates.*/

HWNDhwnd;

/*Thehandleoftooltipwindow.*/

HWNDtool_tip;

/*Theoldxandy.*/

intoldx,oldy;

/*Thecurrenthilighteditem.*/

skin_item_t*hilighted;

/*cachedidentifier.*/

intcached_id;

/*theitemwhoseidentifieriscached_id.*/

skin_item_t*cached_item;

};

2.skin_item_t是Skin中每项控件的数据结构(如下所示),其中记录了每个控件的特性,重要的有控件的id,控件左上角的坐标,控件点击区域的位置大小,控件所示用的图片id,控件的属性,以及typeData属性,该属性一般记录了控件各自的特性的属性。

以上提到的这些属性是需要用户在初始的时候设置的参数,其余的一些参数用户调用BOOLskin_init(skin_head_t*skin,skin_event_cb_tevent_cb,skin_msg_cb_tmsg_cb)由系统来进行设置。

/**Skiniteminformationstructure*/

typedefstructskin_item_s

{

/**Theidentifieroftheitem.*/

intid;

/**

*Thestyleoftheitem.

*

*Thestyleofanitemiscomposedoffiveclassesofinformation:

*

*-Thetypeofanitem.

*-Thehit-testshapetype.

*-Thecommonstatus.

*-Theitemspecificstatus.

*-Theitemspecificstyle.

*

*Thetypeofanitemcanbeoneofthefollowingvalues:

*

*-SI_TYPE_NRMLABEL\n

*Theitemisanormallabel.

*-SI_TYPE_BMPLABEL\n

*Theitemisabitmaplabel.

*-SI_TYPE_CMDBUTTON\n

*Theitemisacommandbutton.

*-SI_TYPE_CHKBUTTON\n

*Theitemisacheckbutton.

*-SI_TYPE_NRMSLIDER\n

*Theitemisanormalslider.

*-SI_TYPE_ROTSLIDER\n

*Theitemisarotationslider.

*

*Thehit-testshapetypecanbeoneofthefollowingvalues:

*

*-SI_TEST_SHAPE_RECT\n

*Thehit-testshapeisarect.

*-SI_TEST_SHAPE_ELLIPSE\n

*Thehit-testshapeisanellipse.

*-SI_TEST_SHAPE_LOZENGE\n

*Thehit-testshapeisalozenge.

*-SI_TEST_SHAPE_LTRIANGLE\n

*Thehit-testshapeisalefttriangle.

*-SI_TEST_SHAPE_RTRIANGLE\n

*Thehit-testshapeisarighttriangle.

*-SI_TEST_SHAPE_UTRIANGLE\n

*Thehit-testshapeisauptriangle.

*-SI_TEST_SHAPE_DTRIANGLE\n

*Thehit-testshapeisadowntriangle.

*

*ThecommonstatusofanitemcanbeOR'edwiththefollowingvalues:

*

*-SI_STATUS_OK\n

*Thebasicstatusofanitem,alwaysbethere.

*-SI_STATUS_VISIBLE\n

*Theitemisvisble.

*-SI_STATUS_DISABLED\n

*Theitemisdisabled.

*-SI_STATUS_HILIGHTED\n

*Theitemishilighted.

*

*Theitemspecificstatuscanbeoneofthefollowingvalues:

*

*-SI_BTNSTATUS_CLICKED\n

*Thethree-statebuttonisclicked.

*-SI_BTNSTATUS_CHECKED\n

*Thecheckbuttonisckecked.

*

*TheitemspecificstylecanbeavaluedOR'edwiththefollowingvalues:

*

*-SI_NRMSLIDER_HORZ\n

*Thenormalsliderishorizontal.

*-SI_NRMSLIDER_VERT\n

*Thenormalsliderisvertical.

*-SI_NRMSLIDER_STATIC\n

*Thenormalsliderisstatic,i.e.,theslideractslikeaprogressbar.

*-SI_ROTSLIDER_CW\n

*Therotationsliderisclockwise.

*-SI_ROTSLIDER_ANTICW\n

*Therotationsliderisanti-clockwise.

*-SI_ROTSLIDER_STATIC\n

*Therotationsliderisstatic,i.e.,theslideractslikeaprogressbar.

*/

DWORDstyle;

/**X-coordinateoftheitemintheskin.*/

intx;

/**Y-coordinateoftheitemintheskin.*/

inty;

/**Thehit-testrectangleoftheitem.*/

RECTrc_hittest;

/**Theindexoftheitembitmapintheskinbitmaparray.*/

intbmp_index;

/**Thetiptext.*/

char*tip;

/**Theattachedprivatedatawiththeitembyapplication.*/

DWORDattached;

/**

*Thetype-specificdataoftheitem,

*usedtodefineextrainformationoftheitem.

*/

void*type_data;

/********startofinternalfields********/

/*Theboundingrectangleoftheitem.*/

RECTshape;

/*Theregionformousehittest.*/

HRGNregion;

/*Theoperationroutinesoftheitem.*/

skin_item_ops_t*ops;

/*Theparentskin.*/

skin_head_t*hostskin;

}skin_item_t;

skin_set_t是皮肤集的数据结构,其中记录了数据集所使用的图片数组,字体数组,皮肤数组,以及皮肤集的一些标题信息。

/**Skinheaderinformationstructure*/

typedefstructskin_set_s

{

/**Theversionoftheskin,currentlyis3.*/

intversion;

/**Theauthoroftheskin.*/

char*author;

/**Thepointertothearrayofthebitmapsusedbytheskinset.*/

HBITMAPbmps;

/**Thepointertothearrayofthelogicalfontsusedbytheskinset.*/

LOGFONT*fonts;

/**Thenumberoftheskinsintheset.*/

intnr_skins;

/**Thepointertotheskinobjectsarray.*/

skin_head_t*skins;

}skin_set_t;

3.sie_slider_t是Slider控件的结构,其中记录滑动的范围,和当前滑块的位置。

该控件的基本信息需要用户在初始的时候进行设置,并放入skin_item_t结构中的typedata属性中。

/**Sliderinformationstructure*/

typedefstructsie_slider_s

{

/**Theminimalpositionofthethumb.*/

intmin_pos;

/*Themaximalpositionofthethumb.*/

intmax_pos;

/*Thecurrentpositionofthethumb.*/

intcur_pos;

}sie_slider_t;

4.si_nrmlabel_t是Lable控件的结构,其中记录文字的内容,以及显示的格式等属性。

该控件的基本信息需要用户在初始的时候进行设置,并放入skin_item_t结构中的typedata属性中。

/**Normallabeliteminfostructure*/

typedefstructsi_nrmlabel_s

{

/**Thelabelstring.*/

char*label;

/**Thenormaltextcolor.*/

DWORDcolor;

/**Thefocustextcolor.*/

DWORDcolor_focus;

/**Theclicktextcolor.*/

DWORDcolor_click;

/**Theindexofthelogicalfontintheskinfontsarray.*/

intfont_index;

}si_nrmlabel_t;

5.si_bmplabel_t是ImageLable控件的结构,其中记录文字的内容,以及用户自己给出的字符表属性。

该控件的基本信息需要用户在初始的时候进行设置,并放入skin_item_t结构中的typedata属性中。

/**Bitmaplabeliteminfostructure*/

typedefstructsi_bmplabel_s

{

/**Thelabelstring.*/

char*label;

/**Alllabelcharactersinthebitmap.*/

constchar*label_chars;

}si_bmplabel_t;

6.si_nrmslider_t是Slider控件的结构,其中记录滑动的范围,和当前滑块的位置。

该控件的基本信息需要用户在初始的时候进行设置,并放入skin_item_t结构中的typedata属性中。

/**Normalslideriteminfostructure*/

typedefstructsi_nrmslider_s

{

/**Thesliderinformation*/

sie_slider_tslider_info;

/**Theindexofthethumbbitmapintheskinbitmapsarray.*/

intthumb_bmp_index;

}si_nrmslider_t;

7.si_rotslider_t是RotateSlider控件的结构,其中记录滑动的范围,和当前滑块的位置。

该控件的基本信息需要用户在初始的时候进行设置,并放入skin_item_t结构中的typedata属性中。

/**Rotationslideriteminfostructure*/

typedefstructsi_rotslider_s

{

/**Therotationradius.*/

intradius;

/**Thestartdegree.*/

intstart_deg;

/**Theenddegree.*/

intend_deg;

/**Thecurrentdegree.*/

intcur_pos;

/**Theindexofthethumbbitmapintheskinbitmapsarray.*/

intthumb_bmp_index;

}si_rotslider_t;

上面介绍的是用户在使用过程中所使用到的一些数据结构,用户首先要将给出上面的结构,并给出前面所提到的必须的数据,然后可以调用SkinInit()函数对结构进行初始化,最后可以调用接口函数:

create_skin_control(),create_skin_main_window(),来创建控件。

3、Skin的消息处理

在Sin_head_t结构中有两个函数指针

skin_event_cb_tevent_cb

skin_msg_cb_tmsg_cb

他们的函数结构分别为:

typedefint(*skin_event_cb_t)(HWNDhwnd,skin_item_t*item,intevent,void*data);

typedefint(*skin_msg_cb_t)(HWNDhwnd,intmessage,WPARAMwparam,LPARAMlparam,int*result);

这两个函数分别是Skin的回调函数和消息处理函数,这两个函数需要用户在初始的时候设置。

在这里要说明一下这两个函数的区别:

(1)even_cb是回调函数,由于Skin对自身提供的几种控件的事件处理使用的是回调函数的机制,所以该函数主要用来处理Skin自身控件的用户事件,在这里,主要有以下的几种event:

SIE_BUTTON_CLICKED//点击事件

SIE_SLIDER_CHANGED//滑竿位置改变

SIE_GAIN_FOCUS//控件得到焦点

SIE_LOST_FOCUS//控件失去焦点

(2)msg_cb是Skin的消息处理函数,由于Skin本身也是一个窗口,会收到系统发来的各种窗口消息,如果用户需要特殊处理的话,可以进行处理。

更为重要的是,由于Skin中可以使用传统的MS控件,这些控件会向其父窗口Skin发出消息通知码,那么对这些消息通知码的处理一般会放在该函数中。

4、Skin控件的接口函数

以下是Skin目前的接口函数,通过这些函数,可以对Skin中的各种控件进行状态的设置。

/**

*\fnskin_head_t*skin_set_find_skin(skin_set_t*skin_set,constchar*skin_name)

*\briefFindsaskinobjectinaskinset.

*

*Thisfunctionfindsaskinobjectwhichmatchesthename\askin_nameinaskinset.

*

*\saskin_set_load

*/

skin_head_t*skin_set_find_skin(skin_set_t*skin_set,constchar*skin_name);

/**

*\fnBOOLskin_init(skin_head_t*skin,skin_event_cb_tevent_cb,skin_msg_cb_tmsg_cb)

*\briefInitializesaskin.

*

*Thisfunctioninitializesaskin\askinbeforeitcanbeused.

*Theinitializationofaskinincludesskinitemsinitialization,etc,

*suchascreatingthehit-testregion,allocatingspaceforlabel,andsoon.

*

*\paramskinThepointertotheskinobject.Theskincanbe

*aobjectreturnedby\askin_set_find_skinorahard-coded

*skin_head_tstructure.

*\paramevent_cbTheitem

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1