Un-official

MUI (Micro User Interface)

Manual

 

 

 

 

 

 

 

Written by : Leong Chen Ki @ roger

(source: http://reality.sgi.com/mjk/tips/mui/mui.html

by Steve baker)

rogerlck@tm.net.my

anastasiaromanovs@yahoo.com

 

 

 

 

 

 

Disclaim

This document is written based on the original document written by Steve Baker. This document is aimed to aid MUI users concern with some basic functionality of MUI. I provide no support or any responsibility for the content of this document.

 

Introduction

The Micro User Interface (MUI) was written by Tom Davis (SGI) and comes as a part of the GLUT (OpenGL Utilities Toolkit) release 3.6. MUI's major drawback is that it is completely undocumented. The significance of MUI is that it is written entirely on top of GLUT and OpenGL - and as such should port cleanly across a wide range of UNIX, Mac, VMS and PC operating systems and be completely window-system independant.

To the user, MUI has a look-and-feel similar to X-Motif. All functions use the usual SGI naming conventions with a 'mui' prefix. The API is strongly object-oriented - but uses a C syntax.

MUI, however, is being abandoned by most of it followers as there are no proper documentation for MUI. Tom Davis (one of the founder of Silicon graphics Inc) had stopped developing MUI and leaves SGI few years ago. Thus, MUI can be considered dead although it is still include with GLUT 3.7 beta package.

Proclaim: I do not provide any responsibility with the content of this page as all of the explanations below are based on my experiment on MUI. This article is aimed to aid MUI new comers to learn MUI based on the original article written by Steve Baker at http://reality.sgi.com/mjk/tips/mui/mui.html .

 

 

MUI installation and setup

1, download open-gl SDK (glut 3.7) http://reality.sgi.com/opengl/glut3/glut3.htmland MUI.lib from http://trant.sgi.com/opengl/toolkits/glut-3.5/progs/mui/mui.html

2, make sure there are folders named GL in included in the glut package

3, copy the folders to the include folder where the visual c++ is installed

4, copy the folders in the lib folders in glut3.7 package to the lib folder in the visual c++ folder and copy the mui.h to the "include" folder in visual c++ and mui.lib from the mui package to the "Lib"  folder in visual c++

5, setup the copied folder in vc++: tools > option > directories  to include the relevant folder in LIB and INCLUDE so the compiler will know where the header file (.h) and library file locate at (.lib)

6, Start VC++ and create a new project.

7. The project has to be a "Win32 Console Application"

8. Type in the name of the project and where it will be on your hard drive.

9. Chose an empty project and click next or finish

10. First thing you need to do when the project opens up is to click on the "Project" menu item from the top.

11. Chose "Settings" (a window will come up)

12. On the left side of the window there are tabs, chose the "Link" tab

13. The string field labeled "Object/library modules" has a few lib files already set in it

14. Go to the end of this string field and enter:

opengl32.lib glut32.lib glu32.lib mui.lib

15, Make sure the header file is included with project> add files everytime mui.h is needed as mui.h is not a pre-compiled library.

 

Getting start

MUI comprises a bunch of header files (currently in the "include/mui" directory within the GLUT release), plus a single library file ('libmui.a' under UNIX, 'mui.lib' under Windoze).

A simple MUI program must start off by doing all the usual GLUT initialisations - for example:

  #include <stdio.h>
  #include <stdlib.h>
  #include <GL/gl.h>
  #include <GL/glu.h>
  #include <GL/glut.h>
  #include <mui/mui.h>
 
  int main ( int argc, char **argv ) //int argc, char **argv pass parameter from OS
  {
    glutInitWindowSize  ( 640, 480 ) ; //window size
    glutInit            ( &argc, argv ) ;  
    glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ; //set display to 
                                                    //RGB, double buffer, Z-buffer  
    glutCreateWindow    ( "My Application"  ) ; //Name of the console window
 

The next step is to construct all the MUI objects that comprise your user interface - I'll cover that in the next section (below).

Finally, you should call 'muiInit()' and enter the GLUT main loop:

    muiInit () ;
    glutMainLoop () ;
    return 0 ;
  }
 
 
 
MUI object

muiObject *b1, *b2, *b3;      //define object of button

Above are the example of mui object. MUI object need to be declared so the compiler will know about its existence.

Eg,

#include <stdio.h>

#include <GL/glut.h>

#include <mui/mui.h>

#include <iostream.h>

 

muiObject *b1, *b2, *b3;      //define object of button

muiObject *rb1, *rb2, *rb3; //define object

muiObject *t, *t1, *t2;                          //define object of text box

muiObject *l, *l1, *l2;                           //define object of label

muiObject *pd;                      //define object of pull down menu

.

.

.

<functions and statements>

 

 

Button

 

Create a button

 

Standard function of button:

 
muiObject *muiNewButton ( int xmin, int xmax, int ymin, int ymax ) ;

 

 

Example:

 
b1 = muiNewButton(10, 100, 110, 135); //draw a button on screen and assigned it to mui object of *b1
  
 
 
Label the button:
 
Standard function of button:
 
void muiLoadButton ( muiObject *button, char *label ) ;
 
Example:
 
muiLoadButton(b1, "Test1");
 
 
Button call back:
 
This function has a MUI object and function as arguments. When the button is presses, the function in the argument list will be excuted.
 
Standard function of button:
 
void muiSetCallback ( muiObject *obj, void (*cb)(muiObject *, enum muiReturnValue) ) ;
 

Example:

 

muiSetCallback(b3, bcallback3);

 

 

Text box

 

Text box (like the one in window family) allow the end user to enter data to provide input for the program. It is basically the GUI version of the cin function of the <iostream.h> library. Text box retrieve string type of input from the user.

 

Creating a text box:

 

Standard function:

 

muiObject *muiNewTextbox ( int xmin, int xmax, int ymin);

 

Example:

 

t1 = muiNewTextbox(10, 290, 335);//(x-cord, length, y-cord) t1 is the mui object defined by the programmer

 

 

Assigning the string from the function to an array:

 

Standard function:

 

char*muiGetTBString ( muiObject *obj ) ;

 

Example:

 

a= muiGetTBString(t); // assign to sting a

 

 

 

 

List box

 

List box is the rectangular space to display the string from the program. Text box is for the input while list box is for the output.

 

Drawing a list box

 

Standard function:

 

muiObject *muiNewTextList (int xmin, int ymin, int xmax, int listheight ) ;

 

Example:

 

lbox =muiNewTextList (10, 10, 300, 3) ;  //lbox is the mui object

 

 

Passing/displaying a string to the list box:

 

Standard function:

 

Void muiSetTLStrings ( muiObject *obj, char **s ) ;

 

Example:

 

char *a;

char **s;

a= muiGetTBString(t);

s= &a;

muiSetTLStrings (lbox,s);

 

 

 

Pull down menu

 

MUI pull down menu is very similar with those in Win9X family but they are cross platform in nature. MUI menu bars are built from a bunch of GLUT popup menus, which are then bound to a MUI object. Before creating pull down menu, you will need to declare an object that will be assigned to MUI pull down menu. MUI pull down menu object can be declare like this:

 

muiObject *pd;                      //define object of pull down menu

 

How to use MUI pull down menu:

  int menus_for_menubar [ 3 ] ;
 
  /* Build three GLUT popups... */
 
  menus_for_menubar [ 0 ] = glutCreateMenu ( menu_cb  ) ;
  glutAddMenuEntry ( "New"      , MENU_FILE_NEW       ) ;
  glutAddMenuEntry ( "Open..."  , MENU_FILE_OPEN      ) ;
  glutAddMenuEntry ( "Save"     , MENU_FILE_SAVE      ) ;
  glutAddMenuEntry ( "SaveAs...", MENU_FILE_SAVEAS    ) ;
  glutAddMenuEntry ( "Exit"     , MENU_FILE_EXIT      ) ;
 
  menus_for_menubar [ 1 ] = glutCreateMenu ( menu_cb  ) ;
  glutAddMenuEntry ( "Cut"      , MENU_EDIT_CUT       ) ;
  glutAddMenuEntry ( "Copy"     , MENU_EDIT_COPY      ) ;
  glutAddMenuEntry ( "Paste"    , MENU_EDIT_PASTE     ) ;
 
  menus_for_menubar [ 2 ] = glutCreateMenu ( menu_cb  ) ;
  glutAddMenuEntry ( "About..." , MENU_HELP_ABOUT     ) ;
  glutAddMenuEntry ( "Help"     , MENU_HELP_HELP      ) ;
 

In this case, all the MENU_* constants would be #defined somewhere and the 'menu_cb' function would probably just be a big switch statement that performs the appropriate actions as each menu item is invoked. All of this is covered in the GLUT documentation.

Next, you have to attach the GLUT menus to a menu bar:

  muiObject *menubar = muiNewPulldown () ;
  muiAddPulldownEntry ( menubar, "File", menus_for_menubar[0], 0 ) ;
  muiAddPulldownEntry ( menubar, "Edit", menus_for_menubar[1], 0 ) ;
  muiAddPulldownEntry ( menubar, "Help", menus_for_menubar[2], 1 ) ;
 

The final argument to 'muiAddPulldownEntry' is a boolean which is TRUE for the 'HELP' menu (which is always on the extreme right of the menu bar in traditional GUI's) - and FALSE for all the other entries which are simply packed onto the bar from left to right.

Here is the menu bar API in full:

  muiObject *muiNewPulldown      () ;
  void       muiAddPulldownEntry ( muiObject *obj, char *title,
                                   int glut_menu, int is_help ) ;
 
 
Example of MUI pulls down menu in real world programming:
 
The bold words in the following example are the codes that related in creating pull down menu:
 
#include <stdio.h>
#include <GL/glut.h>
#include <mui/mui.h>
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
#include <fstream.h>
#include <string.h>
 
//////////Micro user interface's object declearation///////////
muiObject *b1, *b2;                             //define object of button
muiObject *t1, *t2;                               //define object of text box
muiObject *l1, *l2, *l3, *l4, *l5, *l6;     //define object of label
muiObject *title;                                    //define the title
muiObject *pd;                                    //define object of pull down menu
muiObject *lbox1, *lbox2, *lbox3, *lbox4;        // for the list box 
 
int M1, M2, M3;                                   //intialise menu group
///////////////////////////////////////////////////////////////
 
 
 
//////////Initialisation for calculation function//////////////
char *a;
char *a1 = new char [6];
char *a2; 
char **s; 
int temp_total = 0;
///////////////////////////////////////////////////////////////
 
 
////////////Initialisation for display function////////////////
char array_book_name [50];
char *ptr_name ;
char *ptr_price ;
char *ptr_quantity;
char **NamePtr_ptr;
char **PricePtr_ptr;
char **QuantityPtr_ptr;
///////////////////////////////////////////////////////////////
 
 
/////////data received from text file/////////////
char *ISBN=new char[];
char *book_name = new char[];
char *str_quantity= new char[];
int quantity = 0;
char *str_price = new char[];
double price = 0;
char *author= new char[];
char *publisher = new char[];
///////////////////////////////////////////////////////////////
 
 
void menucallback(int x)
{
    if (x==1)
                               exit(1);
}
 
 
 
/////////////////////////Create menu//////////////////////////
void maketestmenus(void)
{
    M1 = glutCreateMenu(menucallback);
    glutAddMenuEntry("Exit", 1);
 
    M2 = glutCreateMenu(menucallback);
    glutAddMenuEntry("Developed by Altaire Software Inc", 2);
               glutAddMenuEntry("", 3); 
               glutAddMenuEntry("Project manager: Leong Chen Ki", 4);
               glutAddMenuEntry("Group members  : Ngeow Ai Jui", 5);
               glutAddMenuEntry("                           : Kuo Yoke Lee", 6);
               glutAddMenuEntry("                           : Victor Seow", 7);
               glutAddMenuEntry("                           : Wilson Cheong", 8);
}
 
 
 
//////// Function to replace space in text file with | ////////
void CreateSpace (char* receive, char str_temp[])
{
                               int limit = strlen(receive);
 
                               for (int n = 0; n < limit ; n++)
                               {
                                              str_temp[n] = *(receive+n);
                                              if (str_temp[n] == '|')
                                                             str_temp[n] = ' ';
                               }
 
                               for (int m = limit ; m <50 ; m++)
                               {
                                              str_temp[m] = '\0';
                               }
}
 
 
 
//////////////display the book records on list box/////////////////
void display(muiObject *obj, enum muiReturnValue r)
{
               ISBN = muiGetTBString(t1);
               ifstream inClientFile( ISBN, ios::in );
               inClientFile >> book_name >> str_price >> str_quantity>> author >> publisher;
               
               CreateSpace (book_name, array_book_name);
               ptr_name = array_book_name;
               NamePtr_ptr = &ptr_name;   
               muiSetTLStrings (lbox1,NamePtr_ptr);
 
               ptr_price = str_price;
               PricePtr_ptr = &ptr_price;     
               muiSetTLStrings (lbox2,PricePtr_ptr);
 
               ptr_quantity = str_quantity;
               QuantityPtr_ptr = &ptr_quantity;           
               muiSetTLStrings (lbox3,QuantityPtr_ptr);
}
 
 
 
//////////////Calculate the total and display result/////////////////
void calculate(muiObject *obj, enum muiReturnValue r)
{              
               double total=0;
               char *string_result = new char[5];
 
               ISBN = muiGetTBString(t1);
               ifstream inClientFile( ISBN, ios::in );
               inClientFile >> book_name >> str_price >> str_quantity>> author >> publisher;
 
               a1 = str_price;
               price = atof(a1);
 
               a2= muiGetTBString(t2);
               quantity = atof(a2);
                               
               total = quantity * price;
               _gcvt(total, 4, string_result);
               
               a = string_result;
               s = &a;
               
               muiSetTLStrings (lbox4,s); 
               
               temp_total = atof (str_quantity) - quantity;
               ofstream outData(ISBN, ios::out);
               _gcvt(temp_total, 4, str_quantity);
 
                               
               outData<<book_name<<' '<<str_price<<' '<<str_quantity<<' '<<author<<' '<<publisher<<endl;
}
 
 
////////////////Micro user interface rendering function////////////
void maketestui(void)
{
               maketestmenus();
    
               muiNewUIList(1);   /* makes an MUI display list (number 1) */
               
 
               b1 = muiNewButton(10, 150, 65, 90);
               b2 = muiNewButton(10, 150, 30, 55);
   
 
               title = muiNewBoldLabel(10, 415, "Point of sales");
               
 
               l1 = muiNewLabel(10, 380, "Item ID");//(x-cord, y-cord)
               t1 = muiNewTextbox(10, 150, 345);//(x-cord, length, y-cord) 
    
 
               l2 = muiNewLabel(10, 332, "Quantity");//(x-cord, y-cord)
               t2 = muiNewTextbox(10, 150, 300);//(x-cord, length, y-cord) 
                                              
    
               l3 = muiNewLabel(10, 275, "Book Name");//(x-cord, y-cord)
               lbox1 =muiNewTextList (10, 245, 340, 1) ; //int xmin, int ymin, int xmax, int row ) ;
               
 
               l4 = muiNewLabel(10, 230, "Price (RM)");//(x-cord, y-cord)
               lbox2 =muiNewTextList (10, 200, 150, 1) ; //int xmin, int ymin, int xmax, int row ) ;
 
               l5 = muiNewLabel(170, 230, "Quantity left");//(x-cord, y-cord)
               lbox3 =muiNewTextList (170, 200, 310, 1) ; //int xmin, int ymin, int xmax, int row ) ;
 
               l6 = muiNewLabel(10, 183, "Total (RM):");//(x-cord, y-cord)
               lbox4 =muiNewTextList (10, 137, 250, 2) ; //int xmin, int ymin, int xmax, int row ) ;
 
 
               muiLoadButton(b1, "Verify Book name");
               muiLoadButton(b2, "Total");
 
               muiSetCallback(b1, display);
               muiSetCallback(b2, calculate);
 
               pd = muiNewPulldown();
                muiAddPulldownEntry(pd, "File", M1, 0);
                muiAddPulldownEntry(pd, "About", M2, 1);
}
 
 
void main(int argc, char **argv)
{
               glutInit(&argc, argv);
               glutInitWindowPosition(10, 20);//(x length, y length)
               glutInitWindowSize(348, 460);//(x length, y length)
               glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
               glutCreateWindow("Bacray Bookstore System");
               maketestui();
               muiInit();
               glutMainLoop();
}
 
 

NB. There seems to be a bug in MUI - if the GLUT window is ever resized - the menu bar can get hidden - or positioned somewhere in the middle of the window instead of at the very top where it belongs.

 

 

Downloadable example of MUI real world application:

 

 

Bacray small bookstore system execution files written by Leong Chen Ki @ Roger (Bacray_book.zip – 394kB)

 

Bacray small bookstore system source codes written by Leong Chen Ki @ Roger :

 

Bacray.cpp

 

Bacray_inv.cpp

 

Bacray_rqst.cpp

 

 

 

 

( Under construction )