/********************************************************************* * * FRAMEWIN_AddMenu */ void FRAMEWIN_AddMenu(FRAMEWIN_Handle hObj, WM_HWIN hMenu) { if (hObj) { FRAMEWIN_Obj* pObj; WM_LOCK(); pObj = FRAMEWIN_H2P(hObj); if (pObj) { int TitleHeight, BorderSize, IBorderSize = 0; int x0, y0, xSize; TitleHeight = FRAMEWIN__CalcTitleHeight(pObj); BorderSize = pObj->Props.BorderSize; if (pObj->Widget.State & FRAMEWIN_SF_TITLEVIS) { IBorderSize = pObj->Props.IBorderSize; } x0 = BorderSize; y0 = BorderSize + TitleHeight + IBorderSize; xSize = WM__GetWindowSizeX(&pObj->Widget.Win); xSize -= BorderSize * 2; pObj->hMenu = hMenu; if (pObj->cb) { MENU_SetOwner(hMenu, pObj->hClient); } MENU_Attach(hMenu, hObj, x0, y0, xSize, 0, 0); WM_SetAnchor(hMenu, WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_RIGHT); FRAMEWIN__UpdatePositions(pObj); FRAMEWIN_Invalidate(hObj); } WM_UNLOCK(); } }
/********************************************************************* * * _CreateMenu */ static WM_HWIN _CreateMenu(WM_HWIN hParent) { MENU_Handle hMenu, hMenuFile, hMenuEdit, hMenuHelp, hMenuRecent; // Create main menu hMenu = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_HORIZONTAL, ID_MENU); // Create sub menus hMenuFile = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_VERTICAL, 0); hMenuEdit = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_VERTICAL, 0); hMenuHelp = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_VERTICAL, 0); hMenuRecent = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_VERTICAL, 0); // Add menu items to menu 'Recent' _AddMenuItem(hMenuRecent, 0, "File 0", ID_MENU_RECENT_0, 0); _AddMenuItem(hMenuRecent, 0, "File 1", ID_MENU_RECENT_1, 0); _AddMenuItem(hMenuRecent, 0, "File 2", ID_MENU_RECENT_2, 0); _AddMenuItem(hMenuRecent, 0, "File 3", ID_MENU_RECENT_3, 0); // Add menu items to menu 'File' _AddMenuItem(hMenuFile, 0, "New", ID_MENU_FILE_NEW, 0); _AddMenuItem(hMenuFile, 0, "Open", ID_MENU_FILE_OPEN, 0); _AddMenuItem(hMenuFile, 0, "Close", ID_MENU_FILE_CLOSE, 0); _AddMenuItem(hMenuFile, 0, 0, 0, MENU_IF_SEPARATOR); _AddMenuItem(hMenuFile, hMenuRecent, "Files...", ID_MENU_FILE_RECENT, 0); _AddMenuItem(hMenuFile, 0, 0, 0, MENU_IF_SEPARATOR); _AddMenuItem(hMenuFile, 0, "Exit", ID_MENU_FILE_EXIT, 0); // Add menu items to menu 'Edit' _AddMenuItem(hMenuEdit, 0, "Undo", ID_MENU_EDIT_UNDO, 0); _AddMenuItem(hMenuEdit, 0, "Redo", ID_MENU_EDIT_REDO, 0); _AddMenuItem(hMenuEdit, 0, 0, 0, MENU_IF_SEPARATOR); _AddMenuItem(hMenuEdit, 0, "Copy", ID_MENU_EDIT_COPY, 0); _AddMenuItem(hMenuEdit, 0, "Paste", ID_MENU_EDIT_PASTE, 0); _AddMenuItem(hMenuEdit, 0, "Delete", ID_MENU_EDIT_DELETE, 0); // Add menu items to menu 'Help' _AddMenuItem(hMenuHelp, 0, "About", ID_MENU_HELP_ABOUT, 0); // Add menu items to main menu _AddMenuItem(hMenu, hMenuFile, "File", 0, 0); _AddMenuItem(hMenu, hMenuEdit, "Edit", 0, 0); _AddMenuItem(hMenu, hMenuHelp, "Help", 0, 0); // Attach menu to parent window MENU_Attach(hMenu, hParent, 0, 0, WM_GetWindowSizeX(hParent), 0, 0); return hMenu; }
/********************************************************************* * * CreateWindow */ WM_HWIN PrintWinCreate(void) { WM_HWIN hWin; hWin = WM_CreateWindow(0, 0, 800, 480,WM_CF_SHOW, _cbDialog, 0); hPrintMenu = MENU_CreateEx(0,0,0,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_PrintMenu); //主菜单 PrintHintText = TEXT_CreateAsChild(40,440,800,40,hWin,ID_PrintText,WM_CF_SHOW,"",TEXT_CF_LEFT); TEXT_SetFont(PrintHintText,&GUI_Font24); //WIDGET_SetEffect(hMenu,&WIDGET_Effect_3D1L); hFre = MENU_CreateEx(0,0,0,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_Print_Frequency); //频率分类 hSite = MENU_CreateEx(0,0,0,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_Print_Site); //站点分类 hInfo = MENU_CreateEx(0,0,0,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_Print_Info); //信息分类 hSiteSet = MENU_CreateEx(0,0,100,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_Print_Site_SiteSet); //站点打印设置 hInfoSet = MENU_CreateEx(0,0,100,0,WM_UNATTACHED,WM_CF_SHOW,MENU_CF_VERTICAL,ID_Print_Info_InfoSet); //信息打印设置 //菜单回调 WM_SetCallback(hPrintMenu,&MenuCall); WM_SetCallback(hFre,&MenuCall); WM_SetCallback(hSite,&MenuCall); WM_SetCallback(hInfo,&MenuCall); WM_SetCallback(hSiteSet,&MenuCall); WM_SetCallback(hInfoSet,&MenuCall); //左右间距 MENU_SetBorderSize(hPrintMenu,MENU_BI_LEFT,20); MENU_SetBorderSize(hPrintMenu,MENU_BI_RIGHT,20); MENU_SetBorderSize(hFre,MENU_BI_LEFT,20); MENU_SetBorderSize(hFre,MENU_BI_RIGHT,20); MENU_SetBorderSize(hSite,MENU_BI_LEFT,20); MENU_SetBorderSize(hSite,MENU_BI_RIGHT,20); MENU_SetBorderSize(hInfo,MENU_BI_LEFT,20); MENU_SetBorderSize(hInfo,MENU_BI_RIGHT,20); MENU_SetBorderSize(hSiteSet,MENU_BI_LEFT,10); MENU_SetBorderSize(hSiteSet,MENU_BI_RIGHT,10); MENU_SetBorderSize(hInfoSet,MENU_BI_LEFT,10); MENU_SetBorderSize(hInfoSet,MENU_BI_RIGHT,10); //添加菜单项 _AddMenuItem(hPrintMenu, 0, "所有储存信息", ID_Print_All , 0); _AddMenuItem(hPrintMenu, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hPrintMenu, 0, "正在显示的信息", ID_Print_Showing , 0); _AddMenuItem(hPrintMenu, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hPrintMenu, hFre, "按频率分类打印", ID_Print_Frequency , 0); _AddMenuItem(hPrintMenu, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hPrintMenu, hSite, "按站点分类打印", ID_Print_Site , 0); _AddMenuItem(hPrintMenu, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hPrintMenu, hInfo, "按信息分类打印", ID_Print_Info , 0); _AddMenuItem(hFre, 0, "国际频道(518KHz)", ID_Print_Fre_Int , 0); _AddMenuItem(hFre, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hFre, 0, "本地频道I(490KHz)", ID_Print_Fre_Loc1 , 0); _AddMenuItem(hFre, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hFre, 0, "本地频道II(4209.5KHz)", ID_Print_Fre_Loc2 , 0); _AddMenuItem(hFre, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hFre, 0, "中文频道(486KHz)", ID_Print_Fre_Chs , 0); _AddMenuItem(hSite, 0, "打印", ID_Print_Site_Prt , 0); _AddMenuItem(hSite, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hSite, hSiteSet, "站点设置", ID_Print_Site_SiteSet , 0); _AddMenuItem(hSiteSet, 0, "A打印", ID_Print_Site_SiteSet_Prt_0 , 0); _AddMenuItem(hSiteSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hSiteSet, 0, "B打印", ID_Print_Site_SiteSet_Prt_1 , 0); _AddMenuItem(hSiteSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hSiteSet, 0, "C打印", ID_Print_Site_SiteSet_Prt_2 , 0); _AddMenuItem(hSiteSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hSiteSet, 0, "D打印", ID_Print_Site_SiteSet_Prt_3 , 0); _AddMenuItem(hSiteSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hSiteSet, 0, "E打印", ID_Print_Site_SiteSet_Prt_4 , 0); _AddMenuItem(hInfo, 0, "打印", ID_Print_Info_Prt , 0); _AddMenuItem(hInfo, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hInfo, hInfoSet, "信息设置", ID_Print_Info_InfoSet , 0); _AddMenuItem(hInfoSet, 0, "A打印", ID_Print_Info_InfoSet_Prt_0 , 0); _AddMenuItem(hInfoSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hInfoSet, 0, "B打印", ID_Print_Info_InfoSet_Prt_1 , 0); _AddMenuItem(hInfoSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hInfoSet, 0, "C打印", ID_Print_Info_InfoSet_Prt_2 , 0); _AddMenuItem(hInfoSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hInfoSet, 0, "D打印", ID_Print_Info_InfoSet_Prt_3, 0); _AddMenuItem(hInfoSet, 0, 0, 0, MENU_IF_SEPARATOR); //分割线 _AddMenuItem(hInfoSet, 0, "E打印", ID_Print_Info_InfoSet_Prt_4 , 0); MENU_Attach (hPrintMenu,hWin,0,60,0,0,0); WM_SetFocus(hPrintMenu); // MENU_SetSel(hMenu, 0); return hWin; }