- 积分
- 322
- 实力分
- 点
- 金钱数
- 两
- 技术分
- 分
- 贡献分
- 分
|
楼主 |
发表于 2010-11-14 10:01:20
|
显示全部楼层
源代码
- #include "..\inc\swilib.h"
- extern const SOFTKEY_DESC SOFTKEYS[];
- const SOFTKEYSTAB tview_skt=
- {
- SOFTKEYS, 0
- };
- const int softkeys[]={0,1,2};
- const HEADER_DESC tview_hdr={0, 0, 0x00000083, 0x00000015, NULL, LGP_NULL, LGP_NULL};
- int tview_OnKey(void *data, GUI_MSG *msg)
- {
- if(msg->keys==0x1
- ||msg->keys==0x18
- ||msg->keys==0x3D
- )
- return 1;
- return 0;
- }
- void tview_GHook(void *data, int cmd)
- {
- }
- void tview_locret()
- {
- }
- const TVIEW_DESC tview_desc=
- {
- 8,
- tview_OnKey,
- tview_GHook,
- tview_locret,
- softkeys,
- &tview_skt,
- {0,0x00000017+0x16,0x00000083,0x000000B0-0x00000016-1},
- FONT_SMALL,
- 0x64,
- 0x65,
- 0,
- 0
- };
- const char fname[]="2:\\about.txt";
- const char sz_notitle[]="无标题";
- const char sz_notfile[]="2:\\about.txt文件不存在或文件操作失败";
- const char sz_notext[]="无内容";
- void GetTextAndTitle(WSHDR** text, WSHDR** title)
- {
- int len;
- unsigned int err;
- int fhdl;
- char* buf;
- char* p;
- char* p1;
- int c;
- int len1;
- WSHDR* txt;
- WSHDR* ttl;
- if ((fhdl = fopen(fname, A_ReadOnly, P_READ, &err)) == -1)
- {
- DEFAULT:
- txt = AllocWS(32);
- ttl = AllocWS(8);
- *text = txt;
- *title = ttl;
- gb2ws(txt, sz_notfile, 32);
- gb2ws(ttl, sz_notitle, 8);
- return;
- }
- len = lseek(fhdl, 0, S_END, &err, &err);
- if (len <= 0)
- {
- F_ERR:
- fclose(fhdl, &err);
- goto DEFAULT;
- }
- lseek(fhdl, 0, S_SET, &err, &err);
- buf = malloc(len + 1);
- if (fread(fhdl, buf, len, &err) != len)
- {
- mfree(buf);
- goto F_ERR;
- }
- fclose(fhdl, &err);
- buf[len] = '\0';
- p = buf;
- p1 = buf;
- while (c = *p)
- {
- if ((c == '\r') || (c == '\n'))
- break;
- p++;
- }
- if ((len1 = p - p1) == 0)
- {
- ttl = AllocWS(8);
- gb2ws(ttl, sz_notitle, 8);
- }
- else
- {
- ttl = AllocWS(len1);
- *p = '\0';
- gb2ws(ttl, p1, len1);
- }
- p++;
- while (c = *p)
- {
- if (c > ' ')
- break;
- p++;
- }
- c = *p;
- if ((c == '\0') || (p == (buf + len)))
- {
- txt = AllocWS(8);
- gb2ws(txt, sz_notext, 8);
- }
- else
- {
- len1 = buf + len - p;
- txt = AllocWS(len1);
- gb2ws(txt, p, len1);
- }
- mfree(buf);
- *text = txt;
- *title = ttl;
- }
- void* tview_GetGUI(void)
- {
- WSHDR* text;
- WSHDR* title;
- void *ma=malloc_adr();
- void *mf=mfree_adr();
- void *gui=TViewGetGUI(ma, mf);
- GetTextAndTitle(&text, &title);
- TViewSetDefinition(gui, &tview_desc);
- TViewSetText(gui, text, ma, mf);
- SetHeaderToMenu(gui, &tview_hdr, ma);
- SetHeaderText(GetHeaderPointer(gui), title, ma, mf);
- return gui;
- }
- extern int ICONS[];
- void AddToTab(void* tab_gui)
- {
- SetGUIToTabGUI(tab_gui, 4, ICONS, tview_GetGUI());
- }
复制代码
- #ifdef NEWSGOLD
- #ifdef ELKA
- #define ICON_BLANK 0x538
- #else
- #ifdef S68
- #define ICON_BLANK 0x574
- #else
- #define ICON_BLANK 0x564
- #endif
- #endif
- #endif
- #define LGP_NULL 0x7FFFFFFF
- EXTERN AddToTab
- RSEG CODE_G
- DATA
- DCB "*#06# Tab+ by BingK. (bingkx@gmail.com)"
-
- PUBLIC ICONS
- ICONS:
- DCD ICON_BLANK
- DCD ICON_BLANK
- DCD ICON_BLANK
- DCD ICON_BLANK
-
- PUBLIC SOFTKEYS
- SOFTKEYS:
- DCW 0x18
- DCW 0x0
- DCD LGP_NULL
- DCW 0x1
- DCW 0x0
- DCD LGP_NULL
- DCW 0x3D
- DCW 0x0
- DCD LGP_NULL
-
- CODE32
- ENTRY:
- ADD LR, LR, #4
- STMFD SP!, {LR}
- MOV R0, R4
- BL AddToTab
- MOVS R1, #0
- MOVS R0, R4
- SWI 0x2BF
- MOVS R1, #0
- LDMFD SP!, {R0}
- BX R0
-
- RSEG PATCH
- CODE16
- LDR R0, =ENTRY
- BLX R0
-
- END
复制代码- -carm
- -Z(CODE)CODE_G,CODE,DATA_C,CODE_C=0xA1565200-FFFFFFFF
- -Z(CODE)PATCH=0xA02D5FFC-FFFFFFFF
复制代码 |
|