Amiga-Development

Please login or register.

Login with username, password and session length
Advanced search  

News:

Created for developers of all Amiga camps

Author Topic: Simplest MUI example  (Read 4363 times)

0 Members and 1 Guest are viewing this topic.

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Simplest MUI example
« on: July 28, 2013, 10:39:28 PM »

Im trying to program with MUI and although I understand its basics Im a bit confused.
Can anyone write to me the simplest MUI example that open a window. With no text in the window, no buttons...nothing.

Thanks mates.
Logged

thomas

  • Newbie
  • *
  • Gender: Male
  • Posts: 10
    • View Profile
Re: Simplest MUI example
« Reply #1 on: July 28, 2013, 11:17:52 PM »

Here it is:

Code: [Select]
/*                                                                            */

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*----------------------------------------------------------------------------*/

#include <proto/exec.h>
#include <proto/muimaster.h>
#include <libraries/mui.h>
#include <dos/dos.h>
#include <libraries/iffparse.h> /* for MAKE_ID */
#include <clib/alib_protos.h>

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*----------------------------------------------------------------------------*/

int main (void)

{
Object *app;
Object *win;

app = ApplicationObject,
MUIA_Application_Title      , "Empty Window Example",
MUIA_Application_Base       , "EMPTYWIN",

SubWindow, win = WindowObject,
MUIA_Window_Title, "Empty Window",
MUIA_Window_ID   , MAKE_ID('E','W','I','N'),

WindowContents, VGroup,

End,
End,
End;

if (app)
{
ULONG muisig = 0;
BOOL cont = TRUE;

DoMethod (win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);

set (win,MUIA_Window_Open,TRUE);

do {
if (muisig)
{
if (Wait (muisig | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
cont = FALSE;
}

switch (DoMethod (app,MUIM_Application_Input,&muisig))
{
case MUIV_Application_ReturnID_Quit:
cont = FALSE;
break;
}
}
while (cont);

MUI_DisposeObject(app);
}

return (RETURN_OK);
}

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*----------------------------------------------------------------------------*/

But it probably does not do what you expect. In MUI the window size is derived from the window content. If you create a window without contents, it is so small that you cannot even reach the close button. You have to add at least one resizable object so that the window will be resizable and not fixed to its minimum size.

Well, you got what you asked for.
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Simplest MUI example
« Reply #2 on: July 29, 2013, 01:22:22 PM »

Thanks thomas. You are faaaast.
I understand what you mean but It seems exactly what I was asking. Only one question.
I have looked at various MUI examples and never seen included iffparse fir Make_id. Perhaps that is the reason I have always errors in that function.

I'll try it tonight.

Thaaaanks.
Logged

thomas

  • Newbie
  • *
  • Gender: Male
  • Posts: 10
    • View Profile
Re: Simplest MUI example
« Reply #3 on: July 29, 2013, 01:47:40 PM »


MAKE_ID is not a function but a macro. Only very simple programs are missing the macro definition. As soon as you use for example datatypes, the include file which contains the macro definition is included automatically. If you don't want to include iffparse.h (because you don't use any IFF things) you can as well add this to your code:

Code: [Select]
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((a)<<24 |  (b)<<16 |  (c)<<8 | (d))
#endif


If you change the window definition like this, you get a resizable window which takes up half of the width/height of the visible area of the screen:

Code: [Select]
app = ApplicationObject,
MUIA_Application_Title      , "Empty Window Example",
MUIA_Application_Base       , "EMPTYWIN", /* name of the prefs file in env:mui */

SubWindow, win = WindowObject,
MUIA_Window_Title, "Empty Window",
MUIA_Window_ID   , MAKE_ID('E','W','I','N'), /* used to remember the window size inside the prefs file */

MUIA_Window_Width , MUIV_Window_Width_Visible(50),
MUIA_Window_Height, MUIV_Window_Height_Visible(50),

WindowContents, VGroup,

Child, HVSpace,

End,
End,
End;


Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Simplest MUI example
« Reply #4 on: July 29, 2013, 03:45:15 PM »

Clear as the glass. Very well explained. Thanks mate.
Logged

munk

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Simplest MUI example
« Reply #5 on: February 04, 2016, 05:21:23 PM »

I use MOS 3.9 with the SDK 3.10. I compile this example and get these messages:
gcc -o window window.c
/t/cc4dnShx.o: In function `main':
/t/cc4dnShx.o(.text+0x1ea): undefined reference to `MUIMasterBase'
/t/cc4dnShx.o(.text+0x1ee): undefined reference to `MUIMasterBase'
collect2: ld returned 1 exit status

I guess this relates to line 8:
    #include <proto/muimaster.h>

This file is found in these places:
System:Development/GG/os-include/proto/muimaster.h
System:Development/GG/os-include/ppcinline/muimaster.h

To me it looks like the first of these is taken by line 8 because of 'proto'.
What does the error mean and how can I compile it?
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Simplest MUI example
« Reply #6 on: February 04, 2016, 07:00:47 PM »

Try compiling with -noixemul
Logged

munk

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Simplest MUI example
« Reply #7 on: February 16, 2016, 06:42:04 PM »

Thank you. That works. Why (and when) do I have to set this?
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Simplest MUI example
« Reply #8 on: February 16, 2016, 06:57:34 PM »

If you are coding for Amiga you should use It always. Ixemul is a linux style library. If you set -noixemul you use Amiga native libs.
Logged

munk

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Simplest MUI example
« Reply #9 on: February 18, 2016, 08:57:26 PM »

So the default method is to use ixemul.library on Amiga systems? Shouldn't it be the default to use the native libs?
Logged

tolkien

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Simplest MUI example
« Reply #10 on: February 18, 2016, 09:03:46 PM »

Perhaps I have not explained well!  ;)
Default for Amiga -noixemul. With that you use Amiga native libs instead ixemul.library.
Logged