谁做过GridListWidget,能传个例子给我吗?谢谢

wishifef 2009-11-23 06:01:31
谁做过GridListWidget,能传个例子给我吗?谢谢,QQ:125462916@qq.com
...全文
1873 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qzlyc 2009-12-09
  • 打赏
  • 举报
回复
我顶啊,............
FLYUP_CHEN 2009-11-28
  • 打赏
  • 举报
回复
/*===========================================================================

FILE: helloformapp.c
===========================================================================*/


/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */

#include "AEE.h" // Standard AEE Declarations
#include "AEEShell.h" // AEE Shell Services
#include "AEEFont.h" // AEE Font Services
#include "AEEDisp.h" // AEE Display Services
#include "AEEStdLib.h" // AEE StdLib Services
#include "AEERootForm.h"
#include "AEEStaticWidget.h"
#include "AEEImageWidget.h"
#include "AEEImageStaticWidget.h"
#include "AEETitleWidget.h"
#include "AEESoftkeyWidget.h"
#include "AEEVectorModel.h"
#include "AEEWModel.h"
#include "AEECLSID_GRIDWIDGET.bid"
#include "../inc/helloformapp.bid"

#ifndef RELEASEIF
#define RELEASEIF(p) ReleaseIf((IBase**)&p)
static void ReleaseIf(IBase **ppif) {
if (*ppif) {
IBASE_Release(*ppif);
*ppif = 0;
}
}
#endif

/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "me->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _helloformapp {

IApplet ia;
IAppletVtbl iavt;
int nRefs;
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface
IModule *pIModule;
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information

// add your own variables here...
IRootForm *piRootForm; // root form
IForm *piForm; // form to be displayed
IVectorModel *piVectorModel;
IValueModel *piValueModel;

ModelListener nModelListener;
IWidget *piwGrid;
IWidget *piwItem;
} helloformapp;

static const AECHAR awchSoftkey1[] = {'T','e','s','t', 0};
static const AECHAR awchSoftkey2[] = {'E','x','i','t', 0};
static const AECHAR awchTitle[] = {'S','a','m','p','l','e',' ','F','o','r','m', 0};
static const AECHAR awchText[] = { 'H','e','l','l','o',' ','t','h','e','r','e',',',' ','c','a','n',' ','y','o','u',' ','s','e','e',' ','m','e','?', 0};
static const AECHAR awchNewText[] = { 'W','e','l','l',',',' ','I',' ','s','u','p','p','o','s','e',' ','y','o','u',' ','s','a','w',' ','m','e',' ',':',')', 0};
const RGBAVAL rgbFrmBg = MAKE_RGBA(0,0,128,255);
const RGBAVAL rgbFrmFg = MAKE_RGBA(255,255,0,255);
const RGBAVAL rgbFrmBrd = MAKE_RGBA(255,255,255,255);

/*-------------------------------------------------------------------
Function prototypes
-------------------------------------------------------------------*/
static uint32 helloformapp_AddRef (IApplet *po);
static uint32 helloformapp_Release (IApplet *po);
static boolean helloformapp_HandleEvent (IApplet *pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);

static boolean helloformapp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
helloformapp *me = (helloformapp *)pi;
IWidget *piw = NULL;

switch (eCode) {
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
return(TRUE);

// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);

// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);

// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);


// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);

// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
switch (wParam) {
// UP
case AVK_UP:
return TRUE;

// DOWN
case AVK_DOWN:
return TRUE;

// LEFT
case AVK_LEFT:
return TRUE;

// RIGHT
case AVK_RIGHT:
return TRUE;

// SELECT
case AVK_SELECT:
return TRUE;

// CLEAR
case AVK_CLR:
return TRUE;

// SOFTKEY 1
case AVK_SOFT1:
// will change the text here
IFORM_GetWidget(me->piForm, WID_FORM, &piw);
IWIDGET_SetText(piw, awchNewText, TRUE);
RELEASEIF(piw);
return TRUE;

// SOFTKEY 2
case AVK_SOFT2:
IROOTFORM_PopForm(me->piRootForm);
ISHELL_CloseApplet(me->pIShell, FALSE);
return TRUE;
}

return (TRUE);

// If nothing fits up to this point then we'll just break out
default:
break;
}

return FALSE;
}
static void GridWidget_Index(void *po,int nindex,boolean blselect)
{
helloformapp *pMe = (helloformapp*)po;

if(blselect)
{
IWIDGET_SetBGColor(pMe->piwItem,MAKE_RGB(0,255,0));
}
else
{
IWIDGET_SetBGColor(pMe->piwItem,MAKE_RGB(255,0,0));
}
}
static int helloformapp_CreateForm(helloformapp *me)
{
int nErr = SUCCESS;
IWidget *piw = NULL;
IWidget *piwGrid = NULL;
IWidget *piwImage = NULL;

// create the root form
nErr = ISHELL_CreateInstance(me->pIShell, AEECLSID_ROOTFORM, (void **)&me->piRootForm);
nErr += ISHELL_CreateInstance(me->pIShell,AEECLSID_VECTORMODEL,(void**)&me->piVectorModel);
nErr += ISHELL_CreateInstance(me->pIShell,AEECLSID_VALUEMODEL,(void**)&me->piValueModel);
// create the form
if(SUCCESS == nErr) {
nErr = ISHELL_CreateInstance(me->pIShell, AEECLSID_FORM, (void **)&me->piForm);
}

// set some primary widget properties
nErr = ISHELL_CreateInstance(me->pIShell, AEECLSID_GRIDWIDGET, (void **)&me->piwGrid);
nErr += ISHELL_CreateInstance(me->pIShell, AEECLSID_STATICWIDGET, (void **)&me->piwItem);
if(SUCCESS == nErr)
{
WExtent we = {240,300};
IDECORATOR_SetWidget((IDecorator*)me->piwGrid,me->piwItem);
IWIDGET_SetIndexer(me->piwGrid,GridWidget_Index,me);
IWIDGET_SetItemHeight(me->piwGrid,40);
IWIDGET_SetItemWidth(me->piwGrid,40);
IWIDGET_SetExtent(me->piwGrid,&we);
IWIDGET_SetBGColor(me->piwItem,MAKE_RGB(255,0,0));
}
{
int i = 0;
AECHAR *ptext = NULL;

for(i = 0;i<6;i++)
{
ptext = MALLOC(10*sizeof(AECHAR));

WSTRCPY(ptext,L"Test");
IVECTORMODEL_Add(me->piVectorModel,ptext);
}
}
IWIDGET_SetModel(me->piwGrid,(IModel*)me->piVectorModel);
IWIDGET_SetModel(me->piwItem,(IModel*)me->piValueModel);
IFORM_SetWidget(me->piForm, WID_FORM, me->piwGrid);

// set some keys and titles
IFORM_SetText(me->piForm, FID_TITLE, awchTitle);
IFORM_SetText(me->piForm, FID_SOFTKEY1, awchSoftkey1);
IFORM_SetText(me->piForm, FID_SOFTKEY2, awchSoftkey2);

// push the form to the root form
nErr = IROOTFORM_PushForm(me->piRootForm, me->piForm);

// if there have been no failures up to this point then return success
return nErr;
}

// Destroy samplehtmlwidgetapp object
static void helloformapp_Dtor(helloformapp *me)
{
RELEASEIF(me->piForm);
RELEASEIF(me->piRootForm);
RELEASEIF(me->pIDisplay);
RELEASEIF(me->pIModule);
RELEASEIF(me->pIShell);
}

static int helloformapp_Construct(helloformapp *me, IModule * piModule, IShell * piShell)
{
me->ia.pvt = &me->iavt;
me->iavt.AddRef = helloformapp_AddRef;
me->iavt.Release = helloformapp_Release;
me->iavt.HandleEvent = helloformapp_HandleEvent;

me->nRefs = 1;

me->pIShell = piShell;
ISHELL_AddRef(piShell);

me->pIModule = piModule;
IMODULE_AddRef(piModule);

helloformapp_CreateForm(me);

return 0;
}

static uint32 helloformapp_AddRef(IApplet *po)
{
helloformapp *me = (helloformapp *)po;
return ++me->nRefs;
}


static uint32 helloformapp_Release(IApplet *po)
{
helloformapp *me = (helloformapp *)po;
uint32 nRefs = --me->nRefs;
if (nRefs == 0) {
helloformapp_Dtor(me);
FREE(me);
}
return nRefs;
}


#include "xmod.h"

int xModule_CreateInstance(IModule *module, IShell *shell, AEECLSID idClass, void **pp)
{
if (idClass == AEECLSID_HELLOFORMAPP) {
helloformapp *me = MALLOCREC(helloformapp);

if (me == 0) {
return ENOMEMORY;
} else {
*pp = &me->ia;
return helloformapp_Construct(me, module, shell);
}
}

*pp = 0;
return ECLASSNOTSUPPORT;
}
wishifef 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 chenmeimei_8899 的回复:]
GridListWidget其实和一般list的显示基本上是一样的,有时间我写一个贴上来,不过最近比较忙,过几天吧。
[/Quote]
好!期待中……
jn2003052210 2009-11-24
  • 打赏
  • 举报
回复
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "myform1.h"
#include "AEEFile.h"

/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _Window2 {
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface
IRootForm *pRootForm;

//about MainWindow
IForm *pWindow2;
IXYContainer *pWindow2Container;

IWidget *pGridWidget;

HandlerDesc Window2Handler;

} Window2;

static boolean Window2_Ctor(Window2 *pMe);
static void Window2_Delete(Window2 *pMe);
static boolean Window2_HandleEvent(Window2 *pMe, AEEEvent evt, uint16 wParam, uint32 dwParam);
static void Window2_GridAdaptSet(void *pvCtx, void *pValueIn, int nLen, void **ppValueOut, int *pnLenOut, PFNVALUEFREE *ppfn);
static void Window2_GridItemFree(void * pUser);


boolean Window2_New(IForm **pForm, IShell *pIShell, IDisplay *pIDisplay, IRootForm *pRootForm)
{
Window2 *pMe = MALLOC(sizeof(Window2));

pMe->pIDisplay = pIDisplay;
pMe->pIShell = pIShell;
pMe->pRootForm = pRootForm;

pMe->pWindow2 = NULL;
pMe->pWindow2Container = NULL;

if(Window2_Ctor(pMe))
{
*pForm = pMe->pWindow2;
return TRUE;
}

return FALSE;
}

static void Window2_Delete(Window2 *pMe)
{
if(pMe->pGridWidget)
{
IWIDGET_Release(pMe->pGridWidget);
pMe->pGridWidget = NULL;
}

if(pMe->pWindow2Container)
{
IXYCONTAINER_Release(pMe->pWindow2Container);
pMe->pWindow2Container = NULL;
}

if(pMe)
FREE(pMe);
}

static boolean Window2_Ctor(Window2 *pMe)
{
int result;
IWidget *containerWdg = NULL;
WidgetPos wp;
WExtent we;

IWidget *pImageStaticWidget;
IWidget *pScrollBarWidget;

IVectorModel *pVectorModel;
IValueModel *pValueModel;

IImage *pImage;

result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FORM, (void **)&pMe->pWindow2);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_XYCONTAINER, (void **)&pMe->pWindow2Container);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGESTATICWIDGET, (void **)&pImageStaticWidget);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SCROLLBARWIDGET, (void **)&pScrollBarWidget);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_GRIDWIDGET, (void **)&pMe->pGridWidget);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_VECTORMODEL, (void **)&pVectorModel);

if(result != 0)
return FALSE;

IFORM_SetResText(pMe->pWindow2, FID_TITLE,MYFORM1_RES_FILE, IDS_WINDOW2);
IFORM_SetSoftkeys(pMe->pWindow2, MYFORM1_RES_FILE, IDS_SOFTKEY1, IDS_SOFTKEY2);

IFORM_SetCancelKey(pMe->pWindow2, AVK_SOFT2);

HANDLERDESC_Init(&pMe->Window2Handler, Window2_HandleEvent, pMe, Window2_Delete);
IFORM_SetHandler(pMe->pWindow2, &pMe->Window2Handler);

//relate the widgets and models
{
IDECORATOR_SetWidget((IDecorator *)pMe->pGridWidget, pImageStaticWidget);

IWIDGET_SetModel(pMe->pGridWidget, (IModel *)pVectorModel);
IWIDGET_GetModel(pImageStaticWidget, AEEIID_VALUEMODEL, (IModel **)&pValueModel);

IVALUEMODEL_AdaptSet(pValueModel, Window2_GridAdaptSet, pMe);
IVALUEMODEL_Release(pValueModel);
}

//get all image files and add their IImage ptr to vector model
{
IFileMgr *pFileMgr;
FileInfo fileInfo;
char *pFileName;

if(ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR, (void **)&pFileMgr) != SUCCESS)
return FALSE;

IVECTORMODEL_EnsureCapacity(pVectorModel, 20, 5);

IFILEMGR_EnumInit(pFileMgr, "image", FALSE);
while(IFILEMGR_EnumNext(pFileMgr, &fileInfo))
{
pImage = ISHELL_LoadImage(pMe->pIShell, fileInfo.szName);
if(pImage != NULL)
{
pFileName = MALLOC(100);
STRCPY(pFileName, fileInfo.szName);
IVECTORMODEL_Add(pVectorModel, pFileName);
IIMAGE_Release(pImage);
}
}
IFILEMGR_Release(pFileMgr);

IVECTORMODEL_SetPfnFree(pVectorModel, Window2_GridItemFree);
}

//Set Properties
{
IBitmap *pArrawBitmap = NULL;

IWIDGET_SetItemWidth(pMe->pGridWidget, 200);
IWIDGET_SetItemHeight(pMe->pGridWidget, 200);
IWIDGET_SetCols(pMe->pGridWidget, 1);
IWIDGET_SetRows(pMe->pGridWidget, 1);
IWIDGET_SetBorderColor(pMe->pGridWidget, MAKE_RGB(155, 155, 155));
IWIDGET_SetProperty(pMe->pGridWidget, PROP_BGCOLOR, MAKE_RGB(231, 231, 231));
IWIDGET_GetPreferredExtent(pMe->pGridWidget, &we);
IWIDGET_SetExtent(pMe->pGridWidget, &we);

we.height = 30;
we.width = 30;
IWIDGET_SetExtent(pImageStaticWidget, &we);
IWIDGET_SetPadding(pImageStaticWidget, 2);
IWIDGET_SetFlags(pImageStaticWidget, ISWF_NOTEXT);

IWIDGET_SetBorderWidth(pImageStaticWidget, 2);
IWIDGET_SetBorderColor(pImageStaticWidget, MAKE_RGB(231, 231, 231));
IWIDGET_SetBGColor(pImageStaticWidget, MAKE_RGB(155, 155, 155));
IWIDGET_SetSelectedBGColor(pImageStaticWidget, MAKE_RGB(200, 0, 155));


IWIDGET_SetProperty(pScrollBarWidget, PROP_SCROLLPAD, 0);
IWIDGET_SetProperty(pScrollBarWidget, PROP_SCROLLHANDLEWIDTH, 14);
IWIDGET_SetProperty(pScrollBarWidget, PROP_SCROLLBARENDPAD, 5);
IWIDGET_SetProperty(pScrollBarWidget, PROP_SCROLLFILLCOLOR, MAKE_RGB(212, 208, 200));
IWIDGET_SetProperty(pScrollBarWidget, PROP_SCROLLHANDLECOLOR, MAKE_RGB(0, 0, 255));
IWIDGET_SetProperty(pScrollBarWidget, PROP_ACTIVE_SCROLLCOLOR, MAKE_RGB(0, 0, 0));
IWIDGET_SetFlags(pScrollBarWidget, SBWF_ARROWS|SBWF_NOAUTOHIDE);


pArrawBitmap = ISHELL_LoadResBitmap(pMe->pIShell, MYFORM1_RES_FILE, IDB_ARRAW);
IWIDGET_SetProperty(pScrollBarWidget, PROP_IMAGESTRIP_V, (uint32)pArrawBitmap);
IBITMAP_Release(pArrawBitmap);
}

IDECORATOR_SetWidget((IDecorator *)pScrollBarWidget, pMe->pGridWidget);

wp.bVisible = TRUE;
wp.x = 4;
wp.y = 2;
IXYCONTAINER_Insert(pMe->pWindow2Container, pScrollBarWidget, WIDGET_ZNORMAL, &wp);

result = IXYCONTAINER_QueryInterface(pMe->pWindow2Container, AEEIID_WIDGET, &containerWdg);
result += IFORM_SetWidget(pMe->pWindow2, WID_FORM, containerWdg);
if(result != 0)
return FALSE;

IWIDGET_Release(containerWdg);
IWIDGET_Release(pImageStaticWidget);
IWIDGET_Release(pScrollBarWidget);
IVECTORMODEL_Release(pVectorModel);
DBGPRINTF("&&&&&&&&&&&&&&&&&&&&&&&&&window2 created! %x",pMe->pWindow2Container);
return TRUE;
}

static boolean Window2_HandleEvent(Window2 *pMe, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
if(evt == EVT_POPMENU_SELECTED)
IROOTFORM_PopForm(pMe->pRootForm);

return HANDLERDESC_Call(&pMe->Window2Handler, evt, wParam, dwParam);
}

static void Window2_GridAdaptSet(void *pvCtx, void *pValueIn, int nLen, void **ppValueOut, int *pnLenOut, PFNVALUEFREE *ppfn)
{
Window2 *pMe = (Window2 *)pvCtx;
char *pFileName = (char *)pValueIn;
IWidget *pItemWidget;
IWidget *pImageWidget;
IImage *pImage;

pImage = ISHELL_LoadImage(pMe->pIShell, pFileName);
if(pImage == NULL)
return;
IDECORATOR_GetWidget((IDecorator *)pMe->pGridWidget, (IWidget **)&pItemWidget);
IWIDGET_GetImageStaticImageWidget(pItemWidget, (IWidget **)&pImageWidget);

IWIDGET_SetImage(pImageWidget, pImage);

IIMAGE_Release(pImage);
IWIDGET_Release(pItemWidget);
IWIDGET_Release(pImageWidget);
}

static void Window2_GridItemFree(void * pUser)
{
FREE((char *)pUser);
}
FLYUP_CHEN 2009-11-23
  • 打赏
  • 举报
回复
GridListWidget其实和一般list的显示基本上是一样的,有时间我写一个贴上来,不过最近比较忙,过几天吧。
bencharluo 2009-11-23
  • 打赏
  • 举报
回复
没有,顶一下

4,652

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧