ecxtlacitka.png (2658 bytes) Ecx EcxDocs EcxMUI EcxExamples Back to Amiga E home page
/* AmigaE MUI appwindow example ghh 2018 */
OPT PREPROCESS

MODULE 'amigaLib/boopsi'
MODULE 'muimaster', 'libraries/mui'
MODULE 'utility/tagitem', 'utility/hooks','tools/installhook',
       'workbench/workbench','workbench/startup'

ENUM ID_CANCEL=1
ENUM ER_NONE, ER_MUILIB, ER_APP                        /* exception handling */
  DEF app,win,infopole

PROC appMsgFunc(hook,obj,meslist:PTR TO LONG)     /* appMsgFunc pro appMsgHook */
  DEF apmsg:PTR TO appmessage,          /* appmessage (workbench module) */
      warg:PTR TO wbarg,                /* wbarg (startup module) */
      buff[256]:STRING,                 /* jmeno dropnute ikony-souboru */
      path[256]:STRING,                 /* cesta k souboru */
      nua                               /* numargs */

  hook:=NIL;obj:=NIL
  nua:=0
  apmsg:=meslist[]
  warg:=apmsg.arglist                         /* arglist (appmesage wbarg) */
  WHILE (nua<apmsg.numargs)                   /* numargs (appmesage) */
    NameFromLock(warg.lock,buff,StrMax(buff)) /* pouze cesta k souboru */
    StringF(path,'\s',buff)                   /* prevod buff na string path */
    AddPart(buff,warg.name,StrMax(buff))      /* cesta+nazev souboru (warg.name)*/
    set(infopole,MUIA_Text_Contents,buff)     /* vyplni infopole textem z buff (cesta+nazev) */
    warg++                                    /* navyseni o 1 */
    nua++                                     /* navyseni o 1 */
    vypis(buff,path)                          /* provede funkci vypis s parametry buff a path */
  ENDWHILE
ENDPROC

PROC main() HANDLE
  DEF appMsgHook:hook
  DEF signals=0,result                        /* MUI */
  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

  installhook(appMsgHook,{appMsgFunc})    /* pri volani appMsgHook se provede funkce appMsgFunc */
/**** Main GUI ****/
  app:= ApplicationObject,
    MUIA_Application_Title      , 'EMUIappwindow',
    MUIA_Application_Version    , '$VER: EMUIappwindow 0.01 (04.07.18)',
    MUIA_Application_Copyright  , 'c2018, ghh',
    MUIA_Application_Author     , 'ghh',
    MUIA_Application_Description, 'E MUI appwindow example.',
    MUIA_Application_Base       , 'MYAWN',

    SubWindow, win:= WindowObject,
      MUIA_Window_Title         , 'E MUI appwindow',
      MUIA_Window_ScreenTitle   , 'E MUI appwindow',
      MUIA_Window_ID            , 'MYWN',
      MUIA_Window_AppWindow, MUI_TRUE,        /* dulezite pro drop do okna */
      WindowContents, VGroup,
        MUIA_ShortHelp, 'Dropzone.',          /* napoveda v bubline pro hlavni skupinu*/
        Child, VGroup,GroupFrame,
          Child, VSpace(0),
            Child, infopole:= TextObject,
              MUIA_Text_Contents, 'Drop icon here:)',
              MUIA_Text_PreParse, MUIX_C,     /* centered */
            End,
          Child, VSpace(0),
        End,
      End,
    End,
  End

  IF (app=NIL) THEN Raise(ER_APP)
  /* notify */
  /* zavreni hlavniho okna */
  doMethodA(win,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,app,2,MUIM_Application_ReturnID,ID_CANCEL])
  /* po vhozeni ikony se provede appMsgHook */
  doMethodA(win,[MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime, infopole,3,MUIM_CallHook,appMsgHook,MUIV_TriggerValue])

  /* open main win */
  set(win,MUIA_Window_Open,MUI_TRUE)

  WHILE running
    result:=doMethodA(app,[MUIM_Application_Input,{signals}])
    SELECT result
      CASE MUIV_Application_ReturnID_Quit
        running:=FALSE
      CASE ID_CANCEL
        running:=FALSE
    ENDSELECT
    IF (running AND signals) THEN Wait(signals)
  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   /* main end */

PROC vypis(meno,cesta)  /* funkce vypis prijma dva parametry */
  WriteF('jmeno: \s\n',meno)
  WriteF('cesta: \s\n',cesta)
ENDPROC
ghh don'tpanic