MUI uses the functions such as NewObject, MakeObject, DispostObject, DoMethod and Request for most of operations, from developing the user interface to dealing with events. To save typing a lot of the functions are written using aliases using the #define statement, these are defined in libraries/mui.h header file.
For example, to start a MUI application, it can be written in the program as:
APTR app; init(); app = ApplicationObject, MUIA_Application_Title , "MyProgram", MUIA_Application_Version , "$VER: MyProgram 41.0 (27.02.09)", MUIA_Application_Copyright , "©2009 Peter Hutchison", MUIA_Application_Author , "Peter Hutchison", MUIA_Application_Description, "MUI Program", MUIA_Application_Base , "PROGRAM",
This is equivalent to:
APTR app; init(); app = MUI_NewObject(MUIC_Application, MUIA_Application_Title , "MyProgram", MUIA_Application_Version , "$VER: MyProgram 41.0 (27.02.09)", MUIA_Application_Copyright , "©2009 Peter Hutchison", MUIA_Application_Author , "Peter Hutchison", MUIA_Application_Description, "MUI Program", MUIA_Application_Base , "PROGRAM",
This code section provides some basic information about the program and it will appear in the Program's version information.
The init() function is needed to initialise a MUI program by enabling break and opening the mui library. Not that opening a new Application Object will return a value called app. This is used by the fail() function to check to see if the MUI program has started ok and by DoMethod functions when dealing with events. The majority of objects in a MUI program are usually of type APTR.
Notice that the defines follow a pattern:
MUIC = A MUI Class e.g. Window, button, text box, image, pen etc.
MUIA = A MUI Attribute e.g. Window name, height, width, label etc.
MUIV = A MUI Value is a pre-specified mui value for some attributes.
MUIM = A MUI Method is a function specific for a MUI Class
MUIP = A MUI Parameter list for a method.
MUIE = A MUI Error code
MUII = A MUI Image
MUIX = Control codes for text strings
MUIO = A MUI Object type for MUI_MakeObject()
So, when creating an new instance of a class, such as a new StringObject, you need to provide some attributes. There are two for StringObject, these are MUIA_String_Contents and MUIA_String_MaxLen. Each attribute will require a value, for example, "Name:", 10.
When adding new classes to a MUI interface, you may have noticed the words Child and End a lot. These state the start and end of a sub-entry for an interface item such as menus, pull down menus, members of a group of items when organising items in the interface.
When adding items to a MUI menu, you may want to store its address in a variable for access later. You can use APTR variables to store the addresses e.g. APTR text1 = StringObject("some text", 10)
Once the interface is built, you can then deal with events such as a user entering some text in a string box or a numeric box, ticking check boxes, selecting things from a list and so on.