/* Simple MUI window with menu ghh 2017 */
OPT PREPROCESS
MODULE 'libraries/asl'
MODULE 'amigaLib/boopsi'
MODULE 'dos/var'
MODULE 'muimaster', 'libraries/mui'
MODULE 'utility/tagitem', 'utility/hooks'
MODULE 'intuition/classes', 'intuition/classusr'
MODULE 'libraries/gadtools'
ENUM ID_CANCEL=1,ID_ABOUT,ID_USE,ID_ASLUSE
ENUM ER_NONE, ER_MUILIB, ER_APP /* exception handling */
DEF app,win,infopole,popaslpole,btuse,btquit,popfbut /* gui */
DEF menuAbout,menuAboutmui,menuOpen,menuUse,menuHide,menuQuit,menuMUI /* menu */
PROC main() HANDLE
DEF signals,result
DEF running=TRUE
IF (muimasterbase := OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))=NIL THEN Raise(ER_MUILIB)
/* /// *************************************************** AmigaOS4 ****/
#ifdef __AMIGAOS4__
muimasteriface := GetInterface(muimasterbase, 'main', 1, NIL)
#endif
/* /// */
/* /// *************************************************** Main GUI ****/
app:= ApplicationObject,
MUIA_Application_Title , 'MyEMUIWin',
MUIA_Application_Version , '$VER: MyEWin 0.01 (17.11.17)',
MUIA_Application_Copyright , 'c2017, ghh',
MUIA_Application_Author , 'ghh',
MUIA_Application_Description, 'My first E MUI program.',
MUIA_Application_Base , 'MYFRSTWN',
/*************************************************** Pull down Menu ****/
MUIA_Application_Menustrip,
MenustripObject, /* pulldownmenu strip */
MUIA_Family_Child, /* zacatek slozky */
MenuitemObject,
MUIA_Menuitem_Title, 'File', /* nazev slozky */
MUIA_Family_Child,
menuAbout:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'About...', /* nazev polozky */
MUIA_Menuitem_Shortcut, '?', /* klavesova zkratka */
End,
MUIA_Family_Child,
menuAboutmui:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'About MUI...', /* nazev polozky */
MUIA_Menuitem_Shortcut, '!', /* klavesova zkratka */
End,
MUIA_Family_Child,
MenuitemObject, /* bar polozka bez jmena */
MUIA_Menuitem_Title,
Mui_MakeObjectA(MUIO_HBar,0), /* misto nazvu objekt HBar */
End,
MUIA_Family_Child,
menuOpen:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'Open...', /* nazev polozky */
MUIA_Menuitem_Shortcut, 'O', /* klavesova zkratka */
End,
MUIA_Family_Child,
menuUse:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'Use', /* nazev polozky */
End,
MUIA_Family_Child,
MenuitemObject, /* bar polozka bez jmena */
MUIA_Menuitem_Title,
Mui_MakeObjectA(MUIO_HBar,0), /* objekt HBar */
End,
MUIA_Family_Child,
menuHide:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'Hide', /* nazev polozky */
MUIA_Menuitem_Shortcut, 'H', /* klavesova zkratka */
End,
MUIA_Family_Child,
menuQuit:= MenuitemObject, /* polozka */
MUIA_Menuitem_Title, 'Quit', /* nazev polozky */
MUIA_Menuitem_Shortcut, 'Q', /* klavesova zkratka */
End,
End,
MUIA_Family_Child, /* zacatek dalsi slozky */
MenuitemObject,
MUIA_Menuitem_Title, 'MUI', /* nazev slozky */
MUIA_Family_Child,
menuMUI:= MenuitemObject,
MUIA_Menuitem_Title, 'MUI Settings...',
End,
End,
End,
/*********************************************** pulldownmenu konec ****/
SubWindow, win:= WindowObject,
MUIA_Window_Title , 'E MUI Win',
MUIA_Window_ScreenTitle , 'MyEMUIWin',
MUIA_Window_ID , 'MYWN',
WindowContents, VGroup,
Child, VGroup,
Child, VGroup,
Child, infopole:= TextObject,
MUIA_Text_Contents, 'Amiga E MUI :)',
MUIA_Text_PreParse, MUIX_C, /* centered */
MUIA_ShortHelp, 'Toto je infopole.', /* napoveda v bubline */
End,
Child, popaslpole:= PopaslObject,
MUIA_Popasl_Type, ASL_FILEREQUEST, /* asl module parametr ne MUI */
MUIA_Popstring_String,StringMUI('',256),
MUIA_Popstring_Button, popfbut:=PopButton(MUII_PopUp),
ASLFR_TITLETEXT, 'Select text or picture..', /* asl module parametr ne MUI */
MUIA_ShortHelp, 'Toto je popasl objekt.', /* napoveda v bubline */
End,
Child, VSpace(2),
Child, HGroup, MUIA_Group_SameSize, MUI_TRUE,
Child, HGroup,
Child, btuse:= SimpleButton('_Use'),
MUIA_ShortHelp, 'Tlacitko Use.', /* napoveda v bubline */
End,
Child, HSpace(2),
Child, HGroup,
Child, btquit:= SimpleButton('_Quit'),
MUIA_ShortHelp, 'Tlacitko Quit.', /* napoveda v bubline */
End,
End,
End,
End,
End,
End,
End
IF (app=NIL) THEN Raise(ER_APP)
/* /// */
/* /// ***************************************************** Notify ****/
doMethodA(win,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,app,2,MUIM_Application_ReturnID,ID_CANCEL]) /* zavreni hlavniho okna */
doMethodA(btuse, [MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,ID_USE])
doMethodA(btquit, [MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,ID_CANCEL])
doMethodA(popfbut,[MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,ID_ASLUSE])
doMethodA(menuAbout, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,2,MUIM_Application_ReturnID,ID_ABOUT])
doMethodA(menuAboutmui,[MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,2,MUIM_Application_AboutMUI])
doMethodA(menuOpen, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,win,3,MUIM_Set,MUIA_Window_ActiveObject,popfbut])
doMethodA(menuUse, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,2,MUIM_Application_ReturnID,ID_USE])
doMethodA(menuHide, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,3,MUIM_Set,MUIA_Application_Iconified,MUI_TRUE])
doMethodA(menuQuit, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,2,MUIM_Application_ReturnID,ID_CANCEL])
doMethodA(menuMUI, [MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,app,1,MUIM_Application_OpenConfigWindow])
/* /// */
doMethodA(win,[MUIM_Window_SetCycleChain,popaslpole,btuse,btquit,popfbut,NIL]) /* cyclechain klavesa tab */
set(win,MUIA_Window_Open,MUI_TRUE) /* open main win */
WHILE running
result:=doMethodA(app,[MUIM_Application_Input,{signals}])
SELECT result
CASE MUIV_Application_ReturnID_Quit
running:=FALSE
CASE ID_ABOUT
Mui_RequestA(app, win, 0, NIL, 'OK', ' My MUI E window \nFREEWARE ghh 2017',NIL)
CASE ID_USE /* provede funkci prohl */
prohl()
CASE ID_ASLUSE
set(win,MUIA_Window_Sleep,MUI_TRUE) /* uspi hlavni okno po zmacknuti popasl tlacitka */
CASE ID_CANCEL
running:=FALSE
ENDSELECT
aslwake() /* probudi uspane hlavni okno po pouziti asl requesteru */
IF (running AND signals) THEN Wait(signals) /* dulezite ne OR ale AND pozn ghh */
ENDWHILE
set(win,MUIA_Window_Open,FALSE) /* zavre hlavni okno po obdrzeni quit */
Raise (ER_NONE)
/* /// ************************************************** Shut down ****/
EXCEPT
IF app THEN Mui_DisposeObject(app)
#ifdef __AMIGAOS4__
DropInterface(muimasteriface)
#endif
IF muimasterbase THEN CloseLibrary(muimasterbase)
SELECT exception
CASE ER_MUILIB
WriteF('Failed to open \s.\n',MUIMASTER_NAME)
CleanUp(20)
CASE ER_APP
WriteF('Failed to create application.\n')
CleanUp(20)
ENDSELECT
/* /// */
ENDPROC
PROC aslwake()
DEF sl
get(popaslpole,MUIA_Popasl_Active,{sl})
IF sl=0 THEN set(win,MUIA_Window_Sleep,FALSE)
ENDPROC
/* /// ************************************************* prohl func ****/
PROC prohl()
DEF aslfile, fajl
DEF tbuf[256]:STRING /* estring [delka] pro text contents */
DEF buffer[512]:STRING /* estring [delka] pro execute */
get(popaslpole,MUIA_String_Contents,{fajl}) /* zjisti obsah popaslpole a ulozi do fajl */
IF FileLength(fajl) /* overeni jestli je popaslpole prazdny nebo ne */
IF aslfile:= Open(fajl,OLDFILE) /* otevre soubor */
StringF(tbuf,'\q\s\q',fajl) /* textbuffer pro text contents */
doMethodA(infopole,[MUIM_Group_InitChange])
set(infopole,MUIA_Text_Contents,tbuf) /* zobrazi text v infopoli */
doMethodA(infopole,[MUIM_Group_ExitChange])
StringF(buffer,'echo \q\s\q',fajl) /* buffer pro AmigaDOS prikaz */
Execute(buffer,0,0) /* provede prikazy co jsou v bufferu */
doMethodA(win,[MUIM_Window_ToFront])
ELSE
StringF(tbuf,'Could not open file: \q\s\q ',fajl) /* pokud soubor nejde otevrit */
doMethodA(infopole,[MUIM_Group_InitChange])
set(infopole,MUIA_Text_Contents,tbuf) /* zobrazi text v infopoli */
doMethodA(infopole,[MUIM_Group_ExitChange])
ENDIF
ELSE /* pokud je popaslpole prazdny */
doMethodA(infopole,[MUIM_Group_InitChange])
set(infopole,MUIA_Text_Contents,'Amiga E MUI :)') /* zobrazi text v infopoli */
doMethodA(infopole,[MUIM_Group_ExitChange])
ENDIF
ENDPROC
/* /// */
|