📄 testxres.cpp
字号:
outputfile->Write((char*)*bmp,strlen(*bmp));
outputfile->Close();
delete outputfile;
}
else
{
printf("Could not create file object.\r");
}
delete bmp;
#endif
}
return 0;
}
if (strcmp(argv[1],"ICON")==0)
{
if (HXR_OK != theFile->Open(argv[2]))
{
printf("ERROR: file could not be opened.\n");
}
else
{
ULONG32 id=atoi(argv[3]);
#ifdef _MACINTOSH
short index=0;
GrafPtr saveport; GetPort(&saveport);
Rect wRect={50,50,600,800};
WindowPtr myWind=NewWindow(NULL,&wRect,"\pStringParsing",TRUE,2,(WindowPtr)-1L, FALSE,NULL);
ShowWindow(myWind);
SetPort(myWind);
//
// Load the icon first
//
IHXXResource* iconresource;
if (HXR_OK==theFile->GetResource(HX_RT_GROUPICON,id,&rsrc))
{
//
// Create an Icon parser object
//
CHXXIcon* icon;
icon=CHXXIcon::create(rsrc);
#if 0 /* needs to be re-worked with new icon drawing code */
if (icon)
{
CIconHandle macicon;
macicon=icon->GetIconHandle();
Rect aRect={0,0,31,31};
FillRect(&aRect,&qd.ltGray);
PlotCIcon(&aRect,macicon);
aRect.top+=32;
aRect.bottom+=32;
FillRect(&aRect,&qd.gray);
PlotCIcon(&aRect,macicon);
aRect.top+=32;
aRect.bottom+=32;
FillRect(&aRect,&qd.dkGray);
PlotCIcon(&aRect,macicon);
aRect.top+=32;
aRect.bottom+=32;
FillRect(&aRect,&qd.white);
PlotCIcon(&aRect,macicon);
aRect.top+=32;
aRect.bottom+=32;
FillRect(&aRect,&qd.black);
PlotCIcon(&aRect,macicon);
while (!Button())
{
EventRecord theEvent;
WaitNextEvent(everyEvent,&theEvent,0xFF,NULL);
}
HX_DELETE(icon);
}
#endif //
HX_RELEASE(rsrc);
}
DisposeWindow(myWind);
SetPort(saveport);
#endif
}
return 0;
}
//
// Menu test
//
if (strcmp(argv[1],"MENU")==0)
{
if (HXR_OK != theFile->Open(argv[2]))
{
printf("ERROR: File could not be openend.\n");
}
ULONG32 id=atoi(argv[3]);
IHXXResource* rsrc=NULL;
if (HXR_OK == theFile->GetResource(HX_RT_MENU,id,&rsrc))
{
#ifdef _MACINTOSH
CHXXMenu* pMenu=CHXXMenu::create(rsrc);
rsrc->Release();
if (!pMenu)
{
return;
}
UINT16 menuid=atoi(argv[3]);
UINT16 index=0;
MenuHandle mainmenu;
MenuHandle submenus[10];
HX_MenuItem* mi=NULL;
ConstStr255Param pstring;
UINT16 curitem=1;
memset(submenus,0,sizeof(submenus));
if (HXR_OK==pMenu->GetNthMenuItem(&mi,0))
{
CHXString thestring;
thestring=mi->szItemText;
pstring=thestring;
mainmenu=NewMenu(menuid,pstring);
index=1;
while (HXR_OK==pMenu->GetNthMenuItem(&mi,index))
{
pstring=mi->szItemText;
if (!IS_POPUP_MENUITEM(mi))
{
if (IS_SEPARATOR_MENUITEM(mi))
{
AppendMenu(mainmenu,"\p-");
}
AppendMenu(mainmenu,pstring);
if (IS_DISABLED_MENUITEM(mi))
{
DisableItem(mainmenu,curitem);
}
if (IS_CHECKED_MENUITEM(mi))
{
CheckItem(mainmenu,curitem,TRUE);
}
if (mi->wKey && (mi->fKeyFlags & HX_FCONTROL))
{
SetItemCmd(mainmenu,curitem,mi->wKey);
}
}
else
{
AddSubMenu(mainmenu,pMenu,&index);
}
index++;
curitem++;
}
InsertMenu(mainmenu,0);
EventRecord theEvent;
DrawMenuBar();
while (true)
{
if (WaitNextEvent(everyEvent,&theEvent,0xFF,NULL))
{
if (theEvent.what==autoKey)
{
break;
}
if (theEvent.what==mouseDown)
{
WindowPtr whichWin;
short part = FindWindow(theEvent.where,&whichWin);
if (part == inMenuBar)
{
MenuSelect(theEvent.where);
}
}
}
}
}
#endif
#if 0
//#ifdef _UNIX
CHXXMenu* pMenu=CHXXMenu::create(rsrc);
HX_MenuItem* mi=NULL;
if (HXR_OK==pMenu->GetNthMenuItem(&mi,0))
printf ("Menu: 0x%x\nItem: %s %s %s\n", pMenu, mi->szItemText, mi->szAcceleratorText, mi->szStatusText);
#endif
}
}
if (strcmp(argv[1],"MENUBAR")==0)
{
if (HXR_OK != theFile->Open(argv[2]))
{
printf("ERROR: file could not be opened.\n");
}
ULONG32 id=atoi(argv[3]);
IHXXResource* rsrc=NULL;
if (HXR_OK == theFile->GetResource(HX_RT_MENU,id,&rsrc))
{
#ifdef _MACINTOSH
CHXXMenuBar* menubar=CHXXMenuBar::create(rsrc);
ULONG32 index=0;
CHXXMenu* menu=NULL;
gSubLevel=0;
while (HXR_OK==menubar->GetMenuByIndex(&menu,index))
{
gSubLevel=0;
UINT16 itemindex=0;
AddSubMenu(NULL,menu,&itemindex);
index++;
}
EventRecord theEvent;
DrawMenuBar();
while (true)
{
if (WaitNextEvent(everyEvent,&theEvent,0xFF,NULL))
{
if (theEvent.what==autoKey)
{
break;
}
if (theEvent.what==mouseDown)
{
WindowPtr whichWin;
short part = FindWindow(theEvent.where,&whichWin);
if (part == inMenuBar)
{
MenuSelect(theEvent.where);
}
}
}
}
#endif
#if 0
//#ifdef _UNIX
CHXXMenuBar* menubar=CHXXMenuBar::create(rsrc);
#endif
}
theFile->Close();
return 0;
}
if (strcmp(argv[1],"CURSOR")==0)
{
if (HXR_OK != theFile->Open(argv[2]))
{
printf("ERROR: file could not be opened.\n");
}
ULONG32 id=atoi(argv[3]);
IHXXResource* rsrc=NULL;
if (HXR_OK == theFile->GetResource(HX_RT_GROUPCURSOR,id,&rsrc))
{
CHXXCursor* theCursor=CHXXCursor::create(rsrc);
#ifdef _MACINTOSH
HX_ASSERT(theCursor);
if (theCursor)
{
SetCursor(*theCursor);
}
while (!Button())
{
EventRecord theEvent;
WaitNextEvent(everyEvent,&theEvent,0xFF,NULL);
}
#endif
}
theFile->Close();
return 0;
}
if (strcmp(argv[1],"STRING")==0)
{
if (HXR_OK != theFile->Open(argv[2]))
{
printf("ERROR: File could not be opened.\n");
}
IHXXResource* res;
ID= atoi(argv[3]);
res=theFile->GetString(ID);
if (res)
{
printf("%s",(char*)res->ResourceData());
res->Release();
}
theFile->Close();
return 0;
}
return 0;
}
#ifdef _MACINTOSH
void AddSubMenu(MenuHandle menu, CHXXMenu* pMenu,UINT16* index)
{
HX_MenuItem* mi=NULL;
pMenu->GetNthMenuItem(&mi,*index);
MenuHandle submenu=NewMenu(gSubMenuID++,mi->szItemText);
ULONG32 curitem=1;
if (menu)
{
InsertMenu (submenu,-1);
AppendMenu(menu,mi->szItemText);
UINT16 thisitem=CountMenuItems(menu);
SetItemCmd(menu,thisitem,hMenuCmd);
SetItemMark(menu,thisitem,(char)(gSubMenuID-1));
}
else
{
InsertMenu (submenu,0);
}
gSubLevel++;
(*index)++;
while (HXR_OK==pMenu->GetNthMenuItem(&mi,*index))
{
if (IS_SEPARATOR_MENUITEM(mi))
{
AppendMenu(submenu,"\p-");
}
if (mi->wSubLevel < gSubLevel)
{
(*index)--;
gSubLevel--;
return;
}
if (IS_POPUP_MENUITEM(mi))
{
AddSubMenu(submenu,pMenu,index);
}
else
{
AppendMenu(submenu,mi->szItemText);
if (IS_DISABLED_MENUITEM(mi))
{
DisableItem(submenu,curitem);
}
if (IS_CHECKED_MENUITEM(mi))
{
CheckItem(submenu,curitem,TRUE);
}
if (mi->wKey && (mi->fKeyFlags & HX_FCONTROL))
{
SetItemCmd(submenu,curitem,mi->wKey);
}
}
curitem++;
(*index)++;
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -