
#include <exec/types.h>
#if defined __MAXON__ || defined __STORM__
#include <pragma/exec_lib.h>
#else
#include <proto/exec.h>
#endif
#include <exec/libraries.h>
#if defined __MAXON__ || defined __STORM__
#include <pragma/muimaster_lib.h>
#else
#include <proto/muimaster.h>
#endif
#include <libraries/mui.h>
#if defined __MAXON__ || defined __STORM__
#include <pragma/intuition_lib.h>
#else
#include <proto/intuition.h>
#endif
#include <intuition/classusr.h>
#if defined __MAXON__ || defined __STORM__
#include <pragma/dos_lib.h>
#else
#include <proto/dos.h>
#endif
#include <dos/dos.h>
#include <clib/alib_protos.h>
#include <string.h>
#include <stdlib.h>
#if defined __MAXON__ || defined __STORM__
#include <wbstartup.h>
#endif

#include <mui/ImageButton_mcc.h>


Object         *apMain        = NULL;
Object         *  wiMain;
Object         *    ibButton;
Object         *    ibButton2;
Object         *    ibButton3;
Object         *    cyLabel;
Object         *    cyLabel2;
Object         *    cyLabel3;
Object         *    chImage;
Object         *    chImage2;
Object         *    chImage3;
Object         *    chLabel;
Object         *    chLabel2;
Object         *    chLabel3;
Object         *    txInfo;

struct Library *MUIMasterBase = NULL;


int main(void)
{
  int                           ret             = RETURN_FAIL;
  static const STRPTR           txt_rgMain[]    =
  {
    "Setting attributes",
    "Just kidding",
    NULL
  };
  static const STRPTR           txt_cyLabel[]   =
  {
    "Bottom",
    "Right",
    "Left",
    "Top",
    NULL
  };
  struct MUIS_ImageButton_Image image;
  struct MUIS_ImageButton_Image image2;
  struct MUIS_ImageButton_Image image3;
  static const UBYTE            image2_data[]   =
  {
    0xf8,0xff,0x00,0x80,0xf7,0x00,0xf7,0x00,0xfc,0xff,0x04,0xef,0xdf,0xff,0xff,
    0x80,0xfc,0x00,0x01,0x20,0x10,0xfe,0x00,0xfc,0x00,0x01,0x1f,0xe0,0xfe,0x00,
    0xfb,0xff,0x03,0xfb,0xff,0xff,0x80,0xfc,0x00,0x01,0x80,0x02,0xfe,0x00,0x06,
    0x00,0x7f,0xff,0x80,0x00,0x7f,0xfc,0xfe,0x00,0x09,0xff,0xf7,0xfb,0xff,0xff,
    0xf7,0xbf,0xff,0xff,0x80,0xfd,0x00,0x02,0x02,0x18,0x61,0xfe,0x00,0x06,0x00,
    0x0f,0xfc,0x00,0x01,0xe0,0x1e,0xfe,0x00,0xfc,0xff,0x04,0xdf,0xef,0xff,0xff,
    0x80,0xfd,0x00,0x05,0x08,0x20,0x10,0x40,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,
    0x07,0xc0,0x0f,0x80,0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,0x10,0x40,
    0x08,0x20,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0x0f,0x80,0x07,0xc0,0x00,0x00,
    0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,0x20,0x00,0x00,0x10,0x00,0x00,0x09,0x00,
    0x07,0xf8,0x00,0x1f,0x80,0x07,0xe0,0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,
    0x05,0x40,0x80,0x04,0x08,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0x3f,0x00,0x03,
    0xf0,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,0x00,0x7f,
    0x00,0x03,0xf8,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,
    0x00,0xff,0x00,0x03,0xfc,0x00,0x00,0xfd,0xff,0x05,0xfe,0xff,0xfd,0xff,0xff,
    0x80,0xfe,0x00,0x00,0x01,0xfe,0x00,0x02,0x02,0x00,0x00,0x09,0x00,0x07,0xf8,
    0x00,0xff,0x00,0x03,0xfc,0x00,0x00,0xfd,0xff,0x05,0xfe,0xff,0xfd,0xff,0xff,
    0x80,0xfd,0x00,0x02,0x01,0x00,0x02,0xfe,0x00,0x09,0x00,0x07,0xf8,0x01,0xfe,
    0x00,0x01,0xfe,0x00,0x00,0xfe,0xff,0x00,0xfd,0xfe,0xff,0x02,0xfe,0xff,0x80,
    0xfe,0x00,0x00,0x02,0xfe,0x00,0x02,0x01,0x00,0x00,0x09,0x00,0x07,0xf8,0x01,
    0xfe,0x00,0x01,0xfe,0x00,0x00,0xfe,0xff,0x00,0xfd,0xfc,0xff,0x00,0x80,0xfa,
    0x00,0x02,0x01,0x00,0x00,0x09,0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,0xfe,0x00,
    0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,
    0xff,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,0x03,0xfe,
    0x00,0x01,0xff,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,
    0x03,0xfe,0x00,0x01,0xff,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x09,0x00,
    0x07,0xf8,0x03,0xfe,0x00,0x01,0xff,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,
    0x09,0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,0xff,0x00,0x00,0xf8,0xff,0x00,0x80,
    0xf7,0x00,0x09,0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,0xff,0x00,0x00,0xf8,0xff,
    0x00,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,0xff,0x00,0x00,
    0xfe,0xff,0x00,0xfd,0xfc,0xff,0x00,0x80,0xfa,0x00,0x02,0x01,0x00,0x00,0x09,
    0x00,0x07,0xf8,0x03,0xfe,0x00,0x01,0xfe,0x00,0x00,0xfe,0xff,0x00,0xfd,0xfe,
    0xff,0x02,0xfe,0xff,0x80,0xfe,0x00,0x00,0x02,0xfe,0x00,0x02,0x01,0x00,0x00,
    0x09,0x00,0x07,0xf8,0x01,0xfe,0x00,0x01,0xfe,0x00,0x00,0xf8,0xff,0x00,0x80,
    0xf7,0x00,0x09,0x00,0x07,0xf8,0x01,0xfe,0x00,0x01,0xfe,0x00,0x00,0xfd,0xff,
    0x05,0xfe,0xff,0xfd,0xff,0xff,0x80,0xfe,0x00,0xff,0x01,0x04,0x00,0x02,0x02,
    0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0xfe,0x00,0x01,0xfc,0x00,0x00,0xfd,0xff,
    0x05,0xfe,0xff,0xfd,0xff,0xff,0x80,0xf7,0x00,0x09,0x00,0x07,0xf8,0x00,0xff,
    0x00,0x03,0xfc,0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,0x80,0x00,0x00,
    0x04,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0x7f,0x00,0x03,0xf8,0x00,0x00,0xf8,
    0xff,0x00,0x80,0xfd,0x00,0x05,0x40,0x00,0x00,0x08,0x00,0x00,0x09,0x00,0x07,
    0xf8,0x00,0x3f,0x00,0x03,0xf0,0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,
    0x20,0x80,0x04,0x10,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0x1f,0x00,0x03,0xe0,
    0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,0x10,0x00,0x00,0x20,0x00,0x00,
    0x09,0x00,0x07,0xf8,0x00,0x0f,0x80,0x07,0xc0,0x00,0x00,0xf8,0xff,0x00,0x80,
    0xfd,0x00,0x05,0x08,0x40,0x08,0x40,0x00,0x00,0x09,0x00,0x07,0xf8,0x00,0x07,
    0x80,0x07,0x80,0x00,0x00,0xf8,0xff,0x00,0x80,0xfd,0x00,0x05,0x04,0x20,0x10,
    0x80,0x00,0x00,0x06,0x00,0x07,0xf8,0x00,0x03,0xc0,0x0f,0xfe,0x00,0x09,0xff,
    0xf7,0xfb,0xff,0xff,0xe7,0x9f,0xff,0xff,0x80,0xfd,0x00,0x02,0x01,0x08,0x42,
    0xfe,0x00,0x06,0x00,0x0f,0xfc,0x00,0x00,0xf0,0x3c,0xfe,0x00,0xf8,0xff,0x00,
    0x80,0xfc,0x00,0x01,0x40,0x08,0xfe,0x00,0x06,0x00,0x7f,0xff,0x80,0x00,0x3f,
    0xf0,0xfe,0x00,0xf8,0xff,0x00,0x80,0xfc,0x00,0x00,0x10,0xfd,0x00,0xfc,0x00,
    0x01,0x0f,0xe0,0xfe,0x00,0xf8,0xff,0x00,0x80,0xfc,0x00,0x01,0x08,0x10,0xfe,
    0x00,0xfc,0x00,0x01,0x07,0xe0,0xfe,0x00,0xf8,0xff,0x00,0x80,0xfc,0x00,0x01,
    0x10,0x08,0xfe,0x00,0x00,0x7f,0xfd,0xff,0x04,0xe0,0x07,0xff,0xff,0x00,0xf8,
    0xff,0x00,0x80,0xfc,0x00,0x01,0x08,0x04,0xfe,0x00,0x00,0x7f,0xfd,0xff,0x04,
    0xf0,0x03,0xff,0xff,0x00,0xf8,0xff,0x00,0x80,0xfc,0x00,0x01,0x04,0x02,0xfe,
    0x00,0x00,0x7f,0xfd,0xff,0x04,0xf8,0x01,0xff,0xff,0x00,0xfa,0xff,0x02,0x3f,
    0xff,0x80,0xfc,0x00,0x04,0x02,0x00,0x80,0x00,0x00,0x00,0x7f,0xfd,0xff,0x04,
    0xfc,0x00,0x7f,0xff,0x00,0xf8,0xff,0x00,0x80,0xfb,0x00,0x03,0x80,0x04,0x00,
    0x00,0x00,0x7f,0xfc,0xff,0x03,0x00,0x03,0xff,0x00,0xfb,0xff,0x03,0xcf,0xff,
    0xff,0x80,0xfb,0x00,0x03,0x10,0x04,0x00,0x00,0x00,0x7f,0xfc,0xff,0x03,0xe0,
    0x03,0xff,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x00,0x7f,0xf9,0xff,0x00,0x00,
    0x04,0xf7,0xee,0xff,0xff,0xbf,0xfe,0xff,0x01,0x7f,0x80,0xf7,0x00,0x09,0x78,
    0x71,0xc7,0x10,0x62,0x20,0x22,0x63,0x87,0x00,0x09,0xea,0xd5,0x5f,0xd7,0x6a,
    0xb2,0x6a,0xaa,0xaf,0x80,0xf7,0x00,0x09,0x77,0x6e,0xe7,0x3b,0xb7,0x6d,0xb7,
    0x77,0x77,0x00,0x02,0xf7,0xee,0xfa,0xfd,0xff,0x02,0xdf,0x7f,0x80,0xf7,0x00,
    0x09,0x6f,0xdf,0x67,0x3b,0xb7,0x7d,0xf7,0x36,0xff,0x00,0xff,0xff,0x07,0xf7,
    0x7f,0x7f,0xff,0xff,0xbf,0xff,0x80,0xf7,0x00,0x09,0x6f,0xdf,0x6a,0xbb,0xb7,
    0x7d,0xf7,0x56,0xff,0x00,0xfd,0xff,0x05,0xbf,0xff,0xff,0xef,0xff,0x80,0xf7,
    0x00,0x09,0x6f,0xdf,0x6a,0xb8,0x77,0x7d,0xf7,0x56,0xe3,0x00,0x02,0xf7,0xee,
    0xfd,0xfd,0xff,0x02,0xdf,0x6b,0x80,0xf7,0x00,0x09,0x6f,0xdf,0x6a,0xbb,0xf7,
    0x7d,0xf7,0x66,0xf7,0x00,0x09,0xea,0xd5,0x52,0x55,0xfa,0xfa,0xea,0xae,0xaf,
    0x80,0xf7,0x00,0x09,0x77,0x6e,0xed,0xbb,0xf7,0x7d,0xf7,0x77,0x77,0x00,0x09,
    0xf7,0x6e,0xff,0xff,0xf7,0x7f,0xff,0xff,0x77,0x80,0xf7,0x00,0x09,0x78,0xf1,
    0xc5,0x11,0xf8,0xf8,0xe2,0x37,0x8f,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x00,
    0x7f,0xf9,0xff,0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0x00,0x7f,0xf9,0xff,
    0x00,0x00,0xf8,0xff,0x00,0x80,0xf7,0x00,0xf7,0x00
  };
  static const ULONG            image2_colors[] =
  {
    0x00000000,0x00000000,0x64646464,
    0x00000000,0x00000000,0x00000000,
    0x40404040,0x40404040,0x40404040,
    0x80808080,0x80808080,0x80808080,
    0xbfbfbfbf,0xbfbfbfbf,0xbfbfbfbf,
    0xffffffff,0xffffffff,0xffffffff,
    0xffffffff,0xffffffff,0xffffffff,
    0xffffffff,0xffffffff,0xffffffff
  };

  image.ibi_ImageType = MUIV_ImageButton_ImageType_File;
  image.ibi_Precision = PRECISION_EXACT;
  image.ibi_UseFriend = TRUE;
  image.ibi_Filename  = "Ok.img";

  image2.ibi_ImageType    = MUIV_ImageButton_ImageType_Body;
  image2.ibi_Precision    = PRECISION_EXACT;
  image2.ibi_UseFriend    = TRUE;
  image2.ibi_Body         = (UBYTE *) &image2_data;
  image2.ibi_Width        = 73;
  image2.ibi_Height       = 54;
  image2.ibi_Depth        = 3;
  image2.ibi_Masking      = 3;
  image2.ibi_Compression  = 1;
  image2.ibi_Transparent  = MUIV_ImageButton_Transparent_None;
  image2.ibi_SourceColors = (ULONG *) &image2_colors;
  image2.ibi_MappingTable = NULL;

  image3.ibi_ImageType       = MUIV_ImageButton_ImageType_Image;
  image3.ibi_FontMatchWidth  = FALSE;
  image3.ibi_FontMatchHeight = FALSE;
  image3.ibi_FreeHoriz       = TRUE;
  image3.ibi_FreeVert        = TRUE;
  image3.ibi_OldImage        = NULL;
  image3.ibi_Spec            = (STRPTR) MUII_PopUp;
  image3.ibi_State           = 0;

  if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)))
    goto bye;

  if (!(apMain = ApplicationObject,
    MUIA_Application_Title,       "ImageButton-Demo",
    MUIA_Application_Version,     "$VER: ImageButton-Demo 1.1 (14.7.97) © by Maik \"BLiZZeR\" Schreiber",
    MUIA_Application_Copyright,   "Copyright © 14-Jul-1997 by Maik Schreiber <BLiZZeR@dame.de>",
    MUIA_Application_Author,      "Maik Schreiber <BLiZZeR@dame.de>",
    MUIA_Application_Description, "Demonstrates ImageButton.mcc's features",
    MUIA_Application_Base,        "IMAGEBUTTONDEMO",

    SubWindow, wiMain = WindowObject,
      MUIA_Window_Title, "ImageButton-Demo 1.1",
      WindowContents, VGroup,
        Child, RegisterGroup(txt_rgMain),
          MUIA_Register_Frame, TRUE,
          MUIA_CycleChain, TRUE,
          Child, VGroup,
            GroupFrame,
            MUIA_Background, MUII_PageBack,
            Child, HGroup,
              Child, VGroup,
                Child, MUI_MakeObject(MUIO_BarTitle, "Loaded via DataTypes"),
                Child, ibButton = ImageButtonObject,
                  MUIA_ImageButton_Image, &image,
                  MUIA_ImageButton_Label, "_DataTypes",
                  MUIA_ImageButton_LabelPos, MUIV_ImageButton_LabelPos_Right,
                  MUIA_CycleChain, TRUE,
                End,
                Child, VSpace(2),
                Child, ColGroup(2),
                  Child, KeyLabel("Image:", 'm'),
                  Child, HGroup,
                    Child, chImage = KeyCheckMark(TRUE, 'm'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label:", 'l'),
                  Child, HGroup,
                    Child, chLabel = KeyCheckMark(TRUE, 'l'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label position:", 'p'),
                  Child, cyLabel = CycleObject,
                    MUIA_Cycle_Entries, txt_cyLabel,
                    MUIA_Cycle_Active, 1,
                    MUIA_ControlChar, 'p',
                    MUIA_CycleChain, TRUE,
                  End,
                End,
              End,
              Child, HSpace(8),
              Child, VGroup,
                Child, MUI_MakeObject(MUIO_BarTitle, "ILBM BODY type"),
                Child, ibButton2 = ImageButtonObject,
                  MUIA_ImageButton_Image, &image2,
                  MUIA_ImageButton_Label, "BOD_Y",
                  MUIA_CycleChain, TRUE,
                End,
                Child, ColGroup(2),
                  Child, KeyLabel("Image:", 'g'),
                  Child, HGroup,
                    Child, chImage2 = KeyCheckMark(TRUE, 'g'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label:", 'a'),
                  Child, HGroup,
                    Child, chLabel2 = KeyCheckMark(TRUE, 'a'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label position:", 'o'),
                  Child, cyLabel2 = CycleObject,
                    MUIA_Cycle_Entries, txt_cyLabel,
                    MUIA_ControlChar, 'o',
                    MUIA_CycleChain, TRUE,
                  End,
                End,
              End,
              Child, HSpace(8),
              Child, VGroup,
                Child, MUI_MakeObject(MUIO_BarTitle, "Image type"),
                Child, ibButton3 = ImageButtonObject,
                  MUIA_ImageButton_Image, &image3,
                  MUIA_ImageButton_Label, "_Image",
                  MUIA_CycleChain, TRUE,
                End,
                Child, ColGroup(2),
                  Child, KeyLabel("Image:", 'e'),
                  Child, HGroup,
                    Child, chImage3 = KeyCheckMark(TRUE, 'e'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label:", 'b'),
                  Child, HGroup,
                    Child, chLabel3 = KeyCheckMark(TRUE, 'b'),
                    Child, HSpace(0),
                  End,
                  Child, KeyLabel("Label position:", 's'),
                  Child, cyLabel3 = CycleObject,
                    MUIA_Cycle_Entries, txt_cyLabel,
                    MUIA_ControlChar, 's',
                    MUIA_CycleChain, TRUE,
                  End,
                End,
              End,
            End,
            Child, VSpace(8),
            Child, txInfo = TextObject,
              TextFrame,
              MUIA_Background, MUII_TextBack,
              MUIA_Text_Contents, "Try clicking the image buttons...",
            End,
          End,
          Child, HGroup,
            GroupFrame,
            MUIA_Background, MUII_PageBack,
            Child, VGroup,
              Child, MUI_MakeObject(MUIO_BarTitle, "Special fonts"),
              Child, ImageButtonObject,
                MUIA_ImageButton_Image, &image2,
                MUIA_ImageButton_Label, "Another _font...",
                MUIA_Font, MUIV_Font_Big,
                MUIA_CycleChain, TRUE,
              End,
              Child, ImageButtonObject,
                MUIA_ImageButton_Image, &image2,
                MUIA_ImageButton_Label, "...than _usual",
                MUIA_Font, MUIV_Font_Tiny,
                MUIA_CycleChain, TRUE,
              End,
            End,
            Child, HSpace(8),
            Child, VGroup,
              Child, MUI_MakeObject(MUIO_BarTitle, "Special frames"),
              Child, ImageButtonObject,
                MUIA_ImageButton_Image, &image2,
                MUIA_ImageButton_Label, "Custom _background",
                MUIA_Background, MUII_MARKHALFSHINE,
                MUIA_CycleChain, TRUE,
              End,
              Child, VSpace(8),
              Child, MUI_MakeObject(MUIO_BarTitle, "Special backgrounds"),
              Child, ImageButtonObject,
                MUIA_ImageButton_Image, &image2,
                MUIA_ImageButton_Label, "Custom fr_ame",
                StringFrame,
                MUIA_CycleChain, TRUE,
              End,
            End,
          End,
        End,
      End,
    End,

  End))
    goto bye;

  set(chImage,  MUIA_CycleChain, TRUE);
  set(chImage2, MUIA_CycleChain, TRUE);
  set(chImage3, MUIA_CycleChain, TRUE);
  set(chLabel,  MUIA_CycleChain, TRUE);
  set(chLabel2, MUIA_CycleChain, TRUE);
  set(chLabel3, MUIA_CycleChain, TRUE);

  DoMethod(cyLabel,  MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, ibButton,  3, MUIM_Set, MUIA_ImageButton_LabelPos, MUIV_TriggerValue);
  DoMethod(cyLabel2, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, ibButton2, 3, MUIM_Set, MUIA_ImageButton_LabelPos, MUIV_TriggerValue);
  DoMethod(cyLabel3, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, ibButton3, 3, MUIM_Set, MUIA_ImageButton_LabelPos, MUIV_TriggerValue);

  DoMethod(chImage,  MUIM_Notify, MUIA_Selected, TRUE,  ibButton,  3, MUIM_Set, MUIA_ImageButton_Image, &image);
  DoMethod(chImage,  MUIM_Notify, MUIA_Selected, FALSE, ibButton,  3, MUIM_Set, MUIA_ImageButton_Image, NULL);
  DoMethod(chImage2, MUIM_Notify, MUIA_Selected, TRUE,  ibButton2, 3, MUIM_Set, MUIA_ImageButton_Image, &image2);
  DoMethod(chImage2, MUIM_Notify, MUIA_Selected, FALSE, ibButton2, 3, MUIM_Set, MUIA_ImageButton_Image, NULL);
  DoMethod(chImage3, MUIM_Notify, MUIA_Selected, TRUE,  ibButton3, 3, MUIM_Set, MUIA_ImageButton_Image, &image3);
  DoMethod(chImage3, MUIM_Notify, MUIA_Selected, FALSE, ibButton3, 3, MUIM_Set, MUIA_ImageButton_Image, NULL);

  DoMethod(chLabel,  MUIM_Notify, MUIA_Selected, TRUE,  ibButton,  3, MUIM_Set, MUIA_ImageButton_Label, "_DataTypes");
  DoMethod(chLabel,  MUIM_Notify, MUIA_Selected, FALSE, ibButton,  3, MUIM_Set, MUIA_ImageButton_Label, NULL);
  DoMethod(chLabel2, MUIM_Notify, MUIA_Selected, TRUE,  ibButton2, 3, MUIM_Set, MUIA_ImageButton_Label, "BOD_Y");
  DoMethod(chLabel2, MUIM_Notify, MUIA_Selected, FALSE, ibButton2, 3, MUIM_Set, MUIA_ImageButton_Label, NULL);
  DoMethod(chLabel3, MUIM_Notify, MUIA_Selected, TRUE,  ibButton3, 3, MUIM_Set, MUIA_ImageButton_Label, "_Image");
  DoMethod(chLabel3, MUIM_Notify, MUIA_Selected, FALSE, ibButton3, 3, MUIM_Set, MUIA_ImageButton_Label, NULL);

  DoMethod(ibButton,  MUIM_Notify, MUIA_Pressed, FALSE, txInfo, 3, MUIM_Set, MUIA_Text_Contents, "You clicked on \"DataTypes\".");
  DoMethod(ibButton2, MUIM_Notify, MUIA_Pressed, FALSE, txInfo, 3, MUIM_Set, MUIA_Text_Contents, "You clicked on \"BODY\".");
  DoMethod(ibButton3, MUIM_Notify, MUIA_Pressed, FALSE, txInfo, 3, MUIM_Set, MUIA_Text_Contents, "You clicked on \"Image\".");

  DoMethod(wiMain, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, apMain, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

  ret = RETURN_ERROR;

  {
    ULONG open;

    set(wiMain, MUIA_Window_Open, TRUE);
    get(wiMain, MUIA_Window_Open, &open);
    if (!open)
      goto bye;
  }

  {
    ULONG sigs    = 0UL;
    BOOL  running = TRUE;

    while (running)
    {
      switch (DoMethod(apMain, MUIM_Application_NewInput, &sigs))
      {
        case MUIV_Application_ReturnID_Quit:
          running = FALSE;
          break;
      }

      if (running && sigs)
      {
        sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);

        if (sigs & SIGBREAKF_CTRL_C)
          running = FALSE;
        if (sigs & SIGBREAKF_CTRL_F)
          set(apMain, MUIA_Application_Iconified, FALSE);
        else if (sigs & SIGBREAKF_CTRL_E)
          set(apMain, MUIA_Application_Iconified, TRUE);
      }
    }
  }

  ret = RETURN_OK;

  bye:
  if (apMain)        MUI_DisposeObject(apMain);
  if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  exit(ret);
}

