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

wishifef 2009-11-23 06:01:31
谁做过GridListWidget,能传个例子给我吗?谢谢,QQ:125462916@qq.com
...全文
1870 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
  • 打赏
  • 举报
回复
没有,顶一下
资源下载链接为: https://pan.quark.cn/s/d9ef5828b597 四路20秒声光显示计分抢答器Multisim14仿真源文件+设计文档资料摘要 数字抢答器由主体电路与扩展电路组成。优先编码电路、锁存器、译码电路将参赛队的输入信号在显示器上输出;用控制电路和主持人开关启动报警电路,以上两部分组成主体电路。通过定时电路和译码电路将秒脉冲产生的信号在显示器上输出实现计时功能,构成扩展电路。经过布线、焊接、调试等工作后数字抢答器成形。关键字:开关阵列电路;触发锁存电路;解锁电路;编码电路;显示电路 一、设计目的 本设计是利用已学过的数电知识,设计的4人抢答器。(1)重温自己已学过的数电知识;(2)掌握数字集成电路的设计方法和原理;(3)通过完成该设计任务掌握实际问题的逻辑分析,学会对实际问题进行逻辑状态分配、化简;(4)掌握数字电路各部分电路与总体电路的设计、调试、模拟仿真方法。 二、整体设计 (一)设计任务与要求: 抢答器同时供4名选手或4个代表队比赛,分别用4个按钮S0 ~ S3表示。 设置一个系统清除和抢答控制开关S,该开关由主持人控制。 抢答器具有锁存与显示功能。即选手按动按钮,锁存相应的编号,并在LED数码管上显示,同时扬声器发出报警声响提示。选手抢答实行优先锁存,优先抢答选手的编号一直保持到主持人将系统清除为止。 参赛选手在设定的时间内进行抢答,抢答有效,定时器停止工作,显示器上显示选手的编号和抢答的时间,并保持到主持人将系统清除为止。 如果定时时间已到,无人抢答,本次抢答无效。 (二)设计原理与参考电路 抢答器的组成框图如下图所示。它主要由开关阵列电路、触发锁存电路、解锁电路、编码电路和显示电路等几部分组成。

3,202

社区成员

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

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