在BREW中打造自己的GUI(2)-TabPane的实现
2008-03-04 11:11
302 查看
再来讨论一下那个TabPane效果的实现。根据我们作IGMenuCtl的经验,应该并不难。
同样是定义一下几个实体结构:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//自定义菜单项
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
typedef struct
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IImage * pImage; // Image
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 wItemID;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint32 dwData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
} GTabItem;
这个好简单啊,就是一张大图片罢了。 然后整个TabPane是这样定义的:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
struct _IGTabPaneCtl ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
const AEEVTBL(IGTabPaneCtl) * pvt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint32 m_nRefs;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IShell *m_pIShell;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IDisplay *m_pIDisplay;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IModule *m_pIModule;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TQueueList *m_pDataList;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int m_Index;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean m_isActive;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AEERect m_Rect;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
可比菜单简单了不少,除了那个m_pDataList以外就只有m_Index了。那定义的方法肯定也多不到哪去了,如下所示:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
AEEINTERFACE(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DECLARE_IBASE(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DECLARE_ICONTROL(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*AddItemEx) (IGTabPaneCtl * po, GTabItem * pai);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*GetItemData) (IGTabPaneCtl * po, uint16 nItemID, uint32 * plData);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void (*SetSel) (IGTabPaneCtl * po, uint16 nItemID);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 (*GetSel) (IGTabPaneCtl * po);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int (*GetItemCount) (IGTabPaneCtl * po);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 (*GetItemID) (IGTabPaneCtl * po, int nIdx);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*GetItem) (IGTabPaneCtl * po, uint16 wID, GTabItem * pai);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
OK,这里同样要注意的两个函数之一HandleEvent中我们需要处理的是左右方向键,同样只需要修改一下m_Index即可。这儿连SELECT都可以不用处理了。
而在Redraw中呢,也只是根据m_Index显示m_pDataList中相应记录的图片罢了,就不多说了。
其实这里的关键在于,这个TabPane本身并没有任何功能性的东西,因为它只是提供一个容器罢了,所以它的关键在于保存在它里面的那个dwData指针所指向的另一个组件。
也就是说,我们需要将一个组件(比如IGMenuCtl、IHtmlViewer等等)的指针放在一个GTabItem中的dwData中,这样当这个TabItem成为当前页时,我们还需要去显示这个绑定的组件。
一般的操作如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static void buildTabMenu(unione * pMe)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TQueueList *p;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GTabItem ci;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//构造当前的TAB菜单
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!pMe->pMenuTab)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if( SUCCESS==IGTabPaneCtl_New(0,pMe->a.m_pIShell,pMe->a.m_pIModule,(IModule**)&pMe->pMenuTab) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AEERect rec;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SETAEERECT(&rec,0,0,pMe->DeviceInfo.cxScreen,pMe->DeviceInfo.cyScreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_SetRect(pMe->pMenuTab,&rec);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pMe->pMenuTab)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//STEP1: 清掉原有的绑定的数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cleanMenuTabOption(pMe->pMenuTab);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_Reset(pMe->pMenuTab);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
p=pMe->pTabList;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(p)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TImageData * pImgData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TItemData * pData=(TItemData*)p->pData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pImgData=NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pData->icon>0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pImgData= MainImageQueue_FindByCode(pMe->pIcoList,pData->icon);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TOptionTab * pTOpt = (TOptionTab*)MALLOC(sizeof(TOptionTab));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!pTOpt)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ZEROAT(pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//读每个项目对应文件的头数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LoadConfigListA(pMe,pData->type,pData->id,&pTOpt->tabData,&pTOpt->itemCount,&pTOpt->pItemList,&pTOpt->iconCount,&pTOpt->pIconList,&pTOpt->imageCount,&pTOpt->pImageList);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pData->type==TYPE_CONTROL)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildMusicPane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if( pData->type==TYPE_ONE )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildOnePane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if( pData->type==TYPE_PICTURE )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildPicturePane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildMenuPane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.dwData=(uint32)pTOpt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.pImage=pImgData->img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.wItemID=pData->id;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_AddItemEx(pMe->pMenuTab,&ci);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
p=p->pNext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
构造TabPane然后,一个个将构造的组件加下它的Tab页上,如buildOnePane、buildPicturePane等等。
然后在HandleEvent时,将KEY事件传给TabPane处理,如果它处理了(说明是左右方向键被按下了),那还需要loadMenu一下(就是根据当前改变的Tab的Index加载相应的组件)。如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
if( IGTABPANECTL_HandleEvent(pMe->pApp->pMenuTab,eCode,wParam,dwParam) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
loadMenu(pMe,wParam);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
这样就可以了。
同样是定义一下几个实体结构:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//自定义菜单项
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
typedef struct
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IImage * pImage; // Image
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 wItemID;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint32 dwData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
} GTabItem;
这个好简单啊,就是一张大图片罢了。 然后整个TabPane是这样定义的:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
struct _IGTabPaneCtl ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
const AEEVTBL(IGTabPaneCtl) * pvt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint32 m_nRefs;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IShell *m_pIShell;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IDisplay *m_pIDisplay;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IModule *m_pIModule;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TQueueList *m_pDataList;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int m_Index;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean m_isActive;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AEERect m_Rect;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
可比菜单简单了不少,除了那个m_pDataList以外就只有m_Index了。那定义的方法肯定也多不到哪去了,如下所示:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
AEEINTERFACE(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DECLARE_IBASE(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DECLARE_ICONTROL(IGTabPaneCtl)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*AddItemEx) (IGTabPaneCtl * po, GTabItem * pai);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*GetItemData) (IGTabPaneCtl * po, uint16 nItemID, uint32 * plData);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void (*SetSel) (IGTabPaneCtl * po, uint16 nItemID);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 (*GetSel) (IGTabPaneCtl * po);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int (*GetItemCount) (IGTabPaneCtl * po);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
uint16 (*GetItemID) (IGTabPaneCtl * po, int nIdx);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
boolean (*GetItem) (IGTabPaneCtl * po, uint16 wID, GTabItem * pai);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
OK,这里同样要注意的两个函数之一HandleEvent中我们需要处理的是左右方向键,同样只需要修改一下m_Index即可。这儿连SELECT都可以不用处理了。
而在Redraw中呢,也只是根据m_Index显示m_pDataList中相应记录的图片罢了,就不多说了。
其实这里的关键在于,这个TabPane本身并没有任何功能性的东西,因为它只是提供一个容器罢了,所以它的关键在于保存在它里面的那个dwData指针所指向的另一个组件。
也就是说,我们需要将一个组件(比如IGMenuCtl、IHtmlViewer等等)的指针放在一个GTabItem中的dwData中,这样当这个TabItem成为当前页时,我们还需要去显示这个绑定的组件。
一般的操作如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static void buildTabMenu(unione * pMe)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TQueueList *p;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GTabItem ci;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//构造当前的TAB菜单
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!pMe->pMenuTab)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if( SUCCESS==IGTabPaneCtl_New(0,pMe->a.m_pIShell,pMe->a.m_pIModule,(IModule**)&pMe->pMenuTab) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AEERect rec;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SETAEERECT(&rec,0,0,pMe->DeviceInfo.cxScreen,pMe->DeviceInfo.cyScreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_SetRect(pMe->pMenuTab,&rec);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pMe->pMenuTab)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//STEP1: 清掉原有的绑定的数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
cleanMenuTabOption(pMe->pMenuTab);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_Reset(pMe->pMenuTab);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
p=pMe->pTabList;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while(p)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TImageData * pImgData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TItemData * pData=(TItemData*)p->pData;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pImgData=NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pData->icon>0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pImgData= MainImageQueue_FindByCode(pMe->pIcoList,pData->icon);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TOptionTab * pTOpt = (TOptionTab*)MALLOC(sizeof(TOptionTab));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(!pTOpt)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ZEROAT(pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//读每个项目对应文件的头数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LoadConfigListA(pMe,pData->type,pData->id,&pTOpt->tabData,&pTOpt->itemCount,&pTOpt->pItemList,&pTOpt->iconCount,&pTOpt->pIconList,&pTOpt->imageCount,&pTOpt->pImageList);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pData->type==TYPE_CONTROL)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildMusicPane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if( pData->type==TYPE_ONE )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildOnePane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else if( pData->type==TYPE_PICTURE )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildPicturePane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
buildMenuPane(pMe,pTOpt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.dwData=(uint32)pTOpt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.pImage=pImgData->img;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ci.wItemID=pData->id;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
IGTABPANECTL_AddItemEx(pMe->pMenuTab,&ci);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
p=p->pNext;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
构造TabPane然后,一个个将构造的组件加下它的Tab页上,如buildOnePane、buildPicturePane等等。
然后在HandleEvent时,将KEY事件传给TabPane处理,如果它处理了(说明是左右方向键被按下了),那还需要loadMenu一下(就是根据当前改变的Tab的Index加载相应的组件)。如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
if( IGTABPANECTL_HandleEvent(pMe->pApp->pMenuTab,eCode,wParam,dwParam) )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
loadMenu(pMe,wParam);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
这样就可以了。
相关文章推荐
- 在BREW中打造自己的GUI(1)-图形化菜单的实现
- 在BREW中打造自己的GUI(7)-动态效果的实现
- 在BREW中打造自己的GUI(4)-IGStatic的实现
- 在BREW中打造自己的GUI(5)-滚动条的实现
- 在BREW中打造自己的GUI(5)-滚动条的实现
- 在BREW中打造自己的GUI(6)-单选框与复选框的实现
- 在BREW中打造自己的GUI(8)-IWEB的封装
- 在BREW中打造自己的GUI(3)-做一个跑马灯的效果
- 在ASP.NET中实现OAuth2.0(二)之打造自己的API安全策略
- 打造自己php的开发框架--php的MVC简单实现
- 基于Ogre::Bites实现自己的GUI系统(3)
- 如何才能学到Qt的精髓——信号槽之间的无关性,提供了绝佳的对象间通讯方式,QT的GUI全是自己的一套,并且完全开源,提供了一个绝好机会窥视gui具体实现
- Python最短代码实现人脸识别,打造自己专用人脸识别!
- Android 打造自己的个性化应用(五):仿墨迹天气实现续--> 使用Ant实现zip/tar的压缩与解压
- Android 打造自己的个性化应用(四):仿墨迹天气实现-->自定义扩展名的zip格式的皮肤
- 打造自己的wave音频播放器-使用waveOutOpen与waveOutWrite实现
- Android 打造自己的个性化应用(二):应用程序内置资源实现换肤功能
- Android 打造自己的个性化应用(二):应用程序内置资源实现换肤功能
- 自己动手打造ORM(五) —实现
- Android 打造自己的个性化应用(四):仿墨迹天气实现-->自定义扩展名的zip格式的皮肤