Exemple #1
0
// Find a menu by userdata ID
struct MenuItem *find_menu_item(
	struct Menu *menu,
	UWORD id)
{
	// Go through all menus
	for (;menu;menu=menu->NextMenu)
	{
		struct MenuItem *item;

		// Is this what we're looking for?
		if (id==(UWORD)GTMENU_USERDATA(menu)) return (struct MenuItem *)menu;

		// Go through items
		for (item=menu->FirstItem;item;item=item->NextItem)
		{
			struct MenuItem *sub;

			// Is this what we're looking for?
			if (id==(UWORD)GTMENUITEM_USERDATA(item)) return item;

			// Go through sub items
			for (sub=item->SubItem;sub;sub=sub->NextItem)
			{
				// Is this what we're looking for?
				if (id==(UWORD)GTMENUITEM_USERDATA(sub)) return sub;
			}
		}
	}

	// Not found
	return 0;
}
Exemple #2
0
// Check to disable a menu item
void menu_check_disable(struct MenuItem *item,unsigned long type)
{
	short key;
	unsigned long id;

	// Get menu ID
	id=(unsigned long)GTMENUITEM_USERDATA(item);

	// Go through keys
	for (key=0;menu_disable_keys[key+1];key+=2)
	{
		// Does ID match?
		if (menu_disable_keys[key+1]==id)
		{
			// Disable this item?
			if ((menu_disable_keys[key]&type)!=type)
			{
				// Disable it
				item->Flags&=~ITEMENABLED;
			}

			// Enable it
			else item->Flags|=ITEMENABLED;
			return;
		}
	}
}
Exemple #3
0
bool
CheckMenuItemSpecial(struct MenuItem *item, STRPTR t)
{
	struct AppMenuEntry *ame;
	long   len;
	STRPTR s;

	if (!item || !(ame = GTMENUITEM_USERDATA(item)))
		return false;

	cmis_num = NUM_SESSION;

	if (!zstrnicmp(t, ame->am_AppCmd, len = strlen(t)) && (!*(s = ame->am_AppCmd+len) || isspace(*s))) {
		STRPTR s = ame->am_AppCmd + len;

		for (; *s; s++) {
			if (isdigit(*s)) {
				cmis_num = atol(s);
				if (cmis_num > 20)
					cmis_num = 20;
				break;
			}
		}
		return true;
	}
	return false;
}
Exemple #4
0
static struct MenuItem *FindMenuItem(ULONG id) {
  struct Menu     *menu = NULL;
  struct MenuItem *item;

  GetAttr( WINDOW_MenuStrip, WO_Window, (ULONG *) &menu);
  while(menu) {
    for(item = menu->FirstItem; item; item = item->NextItem) {
      if(GTMENUITEM_USERDATA(item) == (APTR) id) {
        return item;
      }
    }
    menu = menu->NextMenu;
  }

  return NULL;
}
Exemple #5
0
static struct MenuItem *FindMenuItem(ULONG id) {
  struct Menu     *menu;
  struct MenuItem *item;

  menu = Menu;

  while(menu) {
    for(item = menu->FirstItem; item; item = item->NextItem) {
      if(GTMENUITEM_USERDATA(item) == (APTR) id) {
        return item;
      }
    }
    menu = menu->NextMenu;
  }

  return NULL;
}
Exemple #6
0
static void vsid_event_handling(void)
{
    int done = 1;
    unsigned long imCode, imClass;
    struct IntuiMessage *imsg;

    /* Check for IDCMP messages */
    while ((imsg = (struct IntuiMessage *)GetMsg(vsid_window->UserPort))) {
        imClass = imsg->Class;
        imCode = imsg->Code;

        switch (imClass) {
            case IDCMP_MENUPICK:
                pointer_to_default();
                while (imCode != MENUNULL) {
                    struct MenuItem *n = ItemAddress(vsid_menu, imCode);
                    vsid_menu_handle((int)GTMENUITEM_USERDATA(n));
                    imCode = n->NextSelect;
                }
                vsid_menu_update();
                done = 1;
                break;
            default:
                break;
        }

        ReplyMsg((struct Message *)imsg);

        switch (imClass) {
            case IDCMP_CLOSEWINDOW:
                do_quit_vice = 1;
                break;
            default:
                break;
        }
    }

    if (do_quit_vice) {
        exit(0); // I think it's safe to quit here
    }
}
static BOOL HandleReq( struct AHIAudioModeRequesterExt *req )

// Returns FALSE if requester was cancelled

{
  BOOL done=FALSE,rc=TRUE;
  ULONG class,sec,oldsec=0,micro,oldmicro=0,oldid=AHI_INVALID_ID;
  UWORD code;
  UWORD qual;
  struct Gadget *pgsel;
  struct IntuiMessage *imsg;
  struct IDnode *idnode;
  LONG   sliderlevels,sliderlevel,i,selected;
  struct MenuItem *item;

  while(!done)
  {
    Wait(1L << req->Window->UserPort->mp_SigBit);

    while ((imsg=GT_GetIMsg(req->Window->UserPort)) != NULL )
    {

      if(imsg->IDCMPWindow == req->InfoWindow)
      {
        class = imsg->Class;
        GT_ReplyIMsg(imsg);

        switch(class)
        {
        case IDCMP_CLOSEWINDOW:
          CloseInfoWindow(req);
          break;
        case IDCMP_REFRESHWINDOW :
          GT_BeginRefresh(req->InfoWindow);
          GT_EndRefresh(req->InfoWindow,TRUE);
          break;
        }
        continue; // Get next IntuiMessage
      }

      else if(imsg->IDCMPWindow != req->Window) // Not my window!
      {
        if(req->IntuiMsgFunc)
          CallHookPkt(req->IntuiMsgFunc,req,imsg);
        // else what to do??? Reply and forget? FIXIT!
        continue;
      }

      sec=imsg->Seconds;
      micro=imsg->Micros;
      qual=imsg->Qualifier;
      class=imsg->Class;
      code=imsg->Code;
      pgsel=(struct Gadget *)imsg->IAddress; // pgsel illegal if not gadget
      GT_ReplyIMsg(imsg);

      switch ( class )
      {
      case IDCMP_RAWKEY:
        switch (code)
        {
        case 0x4c: // Cursor Up
          selected=GetSelected(req);
          if(selected == ~0)
            selected=0;
          if(selected > 0)
            selected--;
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<selected;i++)
            idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,TRUE);
          break;
        case 0x4d: // Cursor Down
          selected=GetSelected(req);
          selected++; // ~0 => 0
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<selected;i++)
            if(idnode->node.ln_Succ->ln_Succ)
              idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,TRUE);
          break;
        case 0x4e: // Cursor Right
          GetSliderAttrs(req,&sliderlevels,&sliderlevel);
          sliderlevel += (qual & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT) ? 10 :1);
          if(sliderlevel >= sliderlevels)
            sliderlevel=sliderlevels-1;
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,sliderlevel,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          SetSelected(req,FALSE);
          break;
        case 0x4f: // Cursor Left
          GetSliderAttrs(req,&sliderlevels,&sliderlevel);
          sliderlevel -= (qual & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT) ? 10 :1);
          if(sliderlevel < 0)
            sliderlevel=0;
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,sliderlevel,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          SetSelected(req,FALSE);
          break;
        }
        break;
      case IDCMP_GADGETUP :
        switch ( pgsel->GadgetID )
        {
        case OKBUTTON:
          done=TRUE;
          break;
        case CANCELBUTTON:
          done=TRUE;
          rc=FALSE;
          break;
        case FREQSLIDER:
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,code,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          break;
        case LISTVIEW:
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<code;i++)
            idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,FALSE);
          // Test doubleclick and save timestamp
          if( (oldid == req->tempAudioID) && DoubleClick(oldsec,oldmicro,sec,micro))
            done=TRUE;
          oldsec=sec;
          oldmicro=micro;
          oldid=req->tempAudioID;

          break;
        }
        break;

      case IDCMP_NEWSIZE:
        if(!(LayOutReq(req,req->TextAttr)))
          if(!(LayOutReq(req,&Topaz80)))
          {
            // ERROR! Quit.
            done=TRUE;
            break;
          }
        break;
      case IDCMP_CLOSEWINDOW:
        done=TRUE;
        rc=FALSE;
        break;
      case IDCMP_REFRESHWINDOW :
        GT_BeginRefresh(req->Window);
        GT_EndRefresh(req->Window,TRUE);
        break;
      case IDCMP_SIZEVERIFY:
        break;
      case IDCMP_MENUPICK:
        while((code != MENUNULL) && !done)
        {
          item=ItemAddress(req->Menu, code);
          switch((ULONG)GTMENUITEM_USERDATA(item))
          {
          case LASTMODEITEM:
            selected=GetSelected(req);
            if(selected == ~0)
              selected=0;
            if(selected > 0)
              selected--;
            idnode=(struct IDnode *)req->list->mlh_Head;
            for(i=0;i<selected;i++)
              idnode=(struct IDnode *)idnode->node.ln_Succ;
            req->tempAudioID=idnode->ID;
            SetSelected(req,TRUE);
            break;
          case NEXTMODEITEM:
            selected=GetSelected(req);
            selected++; // ~0 => 0
            idnode=(struct IDnode *)req->list->mlh_Head;
            for(i=0;i<selected;i++)
              if(idnode->node.ln_Succ->ln_Succ)
                idnode=(struct IDnode *)idnode->node.ln_Succ;
            req->tempAudioID=idnode->ID;
            SetSelected(req,TRUE);
            break;
          case PROPERTYITEM:
            OpenInfoWindow(req);
            break;
          case RESTOREITEM:
            req->tempAudioID=req->Req.ahiam_AudioID;
            req->tempFrequency=req->Req.ahiam_MixFreq;
            SetSelected(req,TRUE);
            break;
          case OKITEM:
            done=TRUE;
            break;
          case CANCELITEM:
            done=TRUE;
            rc=FALSE;
            break;
          }
          code = item->NextSelect;
        }
        break;
      }
    }
  }
Exemple #8
0
void EventLoop(void) {
  ULONG signal  = NULL, rc;
  WORD  code;
  BOOL  running = TRUE;

  GetAttr( WINDOW_SigMask, WO_Window, &signal );
  if(signal) {
    do {
      if(Wait(signal | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C ) {
        running=FALSE;
      }

      while (( rc = CA_HandleInput( WO_Window, &code)) != WMHI_LASTMSG) {

        switch(rc & WMHI_CLASSMASK) {

          case WMHI_CLOSEWINDOW:
            running=FALSE;
            break;

          case WMHI_GADGETUP:
          case WMHI_MENUPICK:
          {

            if((rc & WMHI_CLASSMASK) == WMHI_MENUPICK) {
              struct MenuItem *mi;
              
              mi = ItemAddress(Menu, rc & WMHI_MENUMASK);
              
              if(mi) {
                rc = (ULONG) GTMENUITEM_USERDATA(mi);
              }
            }


            switch( rc & WMHI_GADGETMASK) {

#if 0
              case ACTID_OPEN:
              {
                if(DoMethod( openreq, FRM_DOREQUEST ) == FRQ_OK) {
                  char *file = NULL;
    
                  GetAttr( FRQ_Path, openreq, (ULONG *) &file);
                  NewSettings(file);
                  GUINewSettings();
                }
                break;
              }
    
              case ACTID_SAVEAS:
              {
                FillUnit();
                if(DoMethod( savereq, FRM_DOREQUEST ) == FRQ_OK) {
                  char *file = NULL;
    
                  GetAttr( FRQ_Path, savereq, (ULONG *) &file);
                  SaveSettings(file, UnitList);
                  if(SaveIcons) {
                    WriteIcon(file);
                  }
                }
                break;
              
              }
              
#endif
              case ACTID_ABOUT:
                Req( (char *) msgButtonOK,
                    (char *) msgTextCopyright,
                    "",(char *) msgTextProgramName,
                    "1996-2003 Martin Blom" );
                break;

              case ACTID_SAVE:
                FillUnit();
                SaveSettings(ENVFILE, UnitList);
                SaveSettings(ENVARCFILE, UnitList);
                running=FALSE;
                break;
    
              case ACTID_USE:
                FillUnit();
                SaveSettings(ENVFILE, UnitList);
                running=FALSE;
                break;
    
              case ACTID_QUIT:
                running=FALSE;
                break;
    
              case ACTID_DEFAULT:
                SetAttrs( WO_Window, WA_BusyPointer, TRUE, TAG_DONE);
                NewSettings(NULL);    // This is VERY slow!!
                SetAttrs( WO_Window, WA_BusyPointer, FALSE, TAG_DONE);
                GUINewSettings();
                break;
    
              case ACTID_LASTSAVED:
                NewSettings(ENVARCFILE);
                GUINewSettings();
                break;
    
              case ACTID_RESTORE:
                NewSettings(args.from);
                GUINewSettings();
                break;

              case ACTID_ICONS:
              {
                struct MenuItem *item;
    
                item = FindMenuItem(ACTID_ICONS);
    
                if(item) {
                  if(item->Flags & CHECKED)
                    SaveIcons = TRUE;
                  else
                    SaveIcons = FALSE;
                }
                break;
              }

#if 0
    
              case ACTID_HELP: {
                APTR lock = BGUI_LockWindow(Window);
                if(!BGUI_Help( Window, HELPFILE, "AHI", NULL)) {
                  Req( (char *) msgButtonOK, (char *) msgTextNoFind, HELPFILE);
                }
                BGUI_UnlockWindow(lock);
                break;
              }
    
              case ACTID_GUIDE: {
                APTR lock = BGUI_LockWindow(Window);
                if(!BGUI_Help( Window, HELPFILE, NULL, NULL)) {
                  Req( (char *) msgButtonOK, (char *) msgTextNoFind, HELPFILE);
                }
                BGUI_UnlockWindow(lock);
                break;
              }
    
              case ACTID_HELPINDEX: {
                APTR lock = BGUI_LockWindow(Window);
                if(!BGUI_Help( Window, HELPFILE, "Concept Index", 0)) {
                  Req( (char *) msgButtonOK, (char *) msgTextNoFind, HELPFILE);
                }
                BGUI_UnlockWindow(lock);
                break;
              }
#endif
    
              case ACTID_UNIT: {
                FillUnit();
                NewUnit(code);
                GUINewUnit();
                break;
              }
    
              case ACTID_MODE: {
                FillUnit();
                NewMode(code);
                GUINewMode();
                break;
              }

              case ACTID_DEBUG:
              case ACTID_SURROUND:
              case ACTID_ECHO:
              case ACTID_CPULIMIT:
              case ACTID_CLIPMV:
              {
                ULONG debug = AHI_DEBUG_NONE, surround = FALSE, echo = 0, cpu = 90;
                ULONG clip = FALSE;
    
                GetAttr( CHOOSER_Active, Window_Objs[ACTID_DEBUG],    &debug);
                GetAttr( CHOOSER_Active, Window_Objs[ACTID_SURROUND], &surround);
                GetAttr( CHOOSER_Active, Window_Objs[ACTID_ECHO],     &echo);
                GetAttr( CHOOSER_Active, Window_Objs[ACTID_CLIPMV],   &clip);
                GetAttr( INTEGER_Number, Window_Objs[ACTID_CPULIMIT], &cpu);
    
                globalprefs.ahigp_DebugLevel      = debug;
                globalprefs.ahigp_DisableSurround = surround;
                globalprefs.ahigp_DisableEcho     = (echo == 2);
                globalprefs.ahigp_FastEcho        = (echo == 1);
                globalprefs.ahigp_MaxCPU = (cpu << 16) / 100;
                globalprefs.ahigp_ClipMasterVolume= clip;
    
                break;
              }
            } /* switch(GADGETMASK) */
          }
        } /* switch(CLASSMASK) */
      } /* HandleInput */
    } while(running);
  }
}
Exemple #9
0
int main(int argc,char **argv)
{
	font_data *data;

	// Need dopus library
	if (!(DOpusBase=OpenLibrary("dopus5.library",LIB_VERSION)))
		if (!(DOpusBase=OpenLibrary("dopus5:libs/dopus5.library",55)))
			return(10);
#ifdef __amigaos4__
	if (!(IDOpus = (struct DOpusIFace *)GetInterface(DOpusBase, "main", 1, NULL)))
	{
		CloseLibrary(DOpusBase);
		return(10);
	}
#endif

	// Allocate data
	if (!(data=AllocVec(sizeof(font_data),MEMF_CLEAR)))
	{
		font_free(0);
		return(5);
	}

	// Parse arguments
	data->args=
		ReadArgs(
			"FONT,SIZE/N,B=BOLD/S,I=ITALIC/S,U=ULINE/S,PUBSCREEN/K",
			(APTR)data->arg_array,
			NULL);

	// Default to topaz 8
#ifdef __AROS__
	strcpy(data->font_name,"ttcourier.font");
#else
	strcpy(data->font_name,"topaz.font");
#endif
	data->font_size=8;

	// Got font name?
	if (data->arg_array[ARG_FONT])
		font_get_name(data,(char *)data->arg_array[ARG_FONT]);

	// Got a font size?
	if (data->arg_array[ARG_SIZE] && *((long *)data->arg_array[ARG_SIZE]))
	{
		data->font_size=*((long *)data->arg_array[ARG_SIZE]);
		data->first=TRUE;
	}

	// Initialise locale
	init_locale_data(&data->locale);

	// Got locale library?
	if (LocaleBase)
	{
		BPTR lock;

		// Change PROGDIR: to dopus5:
		if ((lock=Lock("dopus5:",ACCESS_READ)))
#ifdef __AROS__
			// the lock returned here is the initial PROGDIR: which belongs to the system,
			// so it's not a very good idea to just UnLock it
			SetProgramDir(lock);
#else
			UnLock(SetProgramDir(lock));
#endif

		// Initialise
		data->locale.li_LocaleBase=LocaleBase;
		data->locale.li_Catalog=OpenCatalogA(0,"viewfont.catalog",0);
		data->locale.li_Locale=OpenLocale(0);
	}

	// Create message port
	data->appport=CreateMsgPort();

	// Open window
	if (!(font_open(data)))
	{
		font_free(data);
		return(5);
	}

	// Initial gadget settings
	if (data->arg_array[ARG_BOLD]) SetGadgetValue(data->list,GAD_FONT_BOLD,1);
	if (data->arg_array[ARG_ITALIC]) SetGadgetValue(data->list,GAD_FONT_ITALIC,1);
	if (data->arg_array[ARG_ULINE]) SetGadgetValue(data->list,GAD_FONT_ULINE,1);

	// Show font
	font_show_font(data,FALSE);

	// Initialise refresh hook
	data->refresh_hook.h_Entry=(ULONG (*)())font_refresh;
	data->refresh_hook.h_Data=data;

	// Event loop
	FOREVER
	{
		struct IntuiMessage *msg;
		BOOL quit_flag=FALSE;

		// AppWindow?
		if (data->appwindow)
		{
			struct AppMessage *amsg;

			// Get messages
			while ((amsg=(struct AppMessage *)GetMsg(data->appport)))
			{
				// Got file?
				if (amsg->am_NumArgs>0)
				{
					char buf[256];

					// Get name
					DevNameFromLockDopus(amsg->am_ArgList[0].wa_Lock,buf,256);
					if (amsg->am_ArgList[0].wa_Name && *amsg->am_ArgList[0].wa_Name)
						AddPart(buf,amsg->am_ArgList[0].wa_Name,256);

					// Get font name
					font_get_name(data,buf);

					// Get new font
					font_get_font(data);
					font_show_font(data,FALSE);
				}

				// Reply to message
				ReplyMsg((struct Message *)amsg);
			}
		}

		// Requester?
		if (data->about)
		{
			// Handle requester
			if (SysReqHandler(data->about,0,0)>=0)
			{
				// Close requester
				FreeSysRequest(data->about);
				data->about=NULL;
			}
		}

		// Intuition messages
		if (data->window)
		{
			while ((msg=GetWindowMsg(data->window->UserPort)))
			{
				struct IntuiMessage msg_copy;
				UWORD id=0;

				// Copy message and reply
				msg_copy=*msg;
				ReplyWindowMsg(msg);

				// Get gadget ID
				if (msg_copy.Class==IDCMP_GADGETUP)
					id=((struct Gadget *)msg_copy.IAddress)->GadgetID;

				// Look at message
				switch (msg_copy.Class)
				{
					// Close window
					case IDCMP_CLOSEWINDOW:
						quit_flag=TRUE;
						break;


					// New size
					case IDCMP_NEWSIZE:

						// Redraw font
						font_show_font(data,FALSE);

						// Set flag to say we resized
						data->resized=TRUE;
						break;


					// Menu
					case IDCMP_MENUPICK:
						{
							struct MenuItem *item;

							// Get item
							if (!(item=ItemAddress(data->window->MenuStrip,msg_copy.Code)))
								break;

							// Get ID
							id=GTMENUITEM_USERDATA(item);

							// Fall through
						}

					// Gadget
					case IDCMP_GADGETUP:
						switch (id)
						{
							// Show requester
							case GAD_FONT_FONT_POPUP:
							case MENU_OPEN_FONT:

								// Ask for name
								font_ask_name(data);
								break;


							// Font name typed
							case GAD_FONT_FONT:

								// Get name
								font_get_name(data,(char *)GetGadgetValue(data->list,GAD_FONT_FONT));

								// Get new font
								font_get_font(data);
								font_show_font(data,FALSE);
								break;


							// Font size up/down
							case GAD_FONT_UP:
							case GAD_FONT_DOWN:
								{
									short size;

									// Get next size
									size=font_get_size(data,(id==GAD_FONT_UP)?1:-1);

									// No change?
									if (size==data->font_size) break;

									// Use this size
									data->font_size=size;
									SetGadgetValue(data->list,GAD_FONT_SIZE,size);
								}

							// Font size given
							case GAD_FONT_CYCLE:

								// Check id
								if (id==GAD_FONT_CYCLE)
								{
									short size;

									// Get size
									if (!(size=atoi(data->size_labels[msg_copy.Code])))
										break;

									// Refresh gadget
									data->font_size=size;
									SetGadgetValue(data->list,GAD_FONT_SIZE,data->font_size);
								}

							// Font size
							case GAD_FONT_SIZE:

								// Entered size
								if (id==GAD_FONT_SIZE)
								{
									// Bounds check gadget
									data->font_size=
										BoundsCheckGadget(
											data->list,
											GAD_FONT_SIZE,
											4,
											255);
								}

								// Get new font
								font_get_font(data);
								font_show_font(data,FALSE);
								break;

							// Styles changed
							case GAD_FONT_BOLD:
							case GAD_FONT_ITALIC:
							case GAD_FONT_ULINE:

								// Redraw font
								font_show_font(data,FALSE);
								break;


							// Save settings
							case MENU_SAVE_SETTINGS:
								font_save_settings(data);
								break;


							// Quit
							case MENU_QUIT:
								quit_flag=TRUE;
								break;


							// About
							case MENU_ABOUT:
								font_show_about(data);
								break;
						}
						break;


					// Rawkey
					case IDCMP_RAWKEY:

						// Help?
						if (msg_copy.Code==0x5f)
							font_show_about(data);

					// Key
					case IDCMP_VANILLAKEY:

						// Escape does quit
						if (msg_copy.Code==0x1b) quit_flag=TRUE;
						break;


					// Refresh
					case IDCMP_REFRESHWINDOW:

						// Have we just resized?
						if (data->resized)
						{
							// Don't need to refresh
							BeginRefresh(data->window);
							EndRefresh(data->window,TRUE);
							data->resized=FALSE;
							break;
						}

						// Refresh font display
						font_show_font(data,TRUE);
						break;
				}

				// Check window is still valid
				if (!data->window) break;
			}
		}

		if (quit_flag) break;

		// Wait for signal (ctrl-c breaks)
		if ((Wait(SIGBREAKF_CTRL_C|
					((data->window)?(1<<data->window->UserPort->mp_SigBit):0)|
					((data->about)?(1<<data->about->UserPort->mp_SigBit):0)|
					((data->appwindow)?(1<<data->appport->mp_SigBit):0)))&SIGBREAKF_CTRL_C) break;
	}

	// Free stuff
	font_free(data);
	return(0);
}
Exemple #10
0
struct MenuItem * makemenuitem(struct NewMenu * newmenu,
                               BOOL is_image,
                               struct TagItem * taglist,
                               struct GadToolsBase_intern * GadToolsBase)
{
    struct MenuItem	* menuitem = NULL;
    ULONG		allocsize;
    ULONG		* p;

    /* Note: 2 IntuiTexts must be alloced, because CreateMenusA can depend on it
             if a subitem mark (">>") must be added */

    if (newmenu->nm_Label == NM_BARLABEL) is_image = TRUE;

    allocsize = sizeof(ULONG) + sizeof(struct MenuItem) + sizeof(APTR);
    if (!is_image) allocsize += sizeof(struct IntuiText) * 2; /* for text + (commandstring OR ">>") */

    p = (ULONG *)AllocMem(allocsize, MEMF_CLEAR);

    if (NULL != p)
    {
	*p = allocsize;
	menuitem = (struct MenuItem *)(p + 1);

	DEBUG_ALLOCMENUS(bug("makemenuitem: MenuItem %p\n",menuitem));
	menuitem->Flags = (newmenu->nm_Flags & (NM_ITEMDISABLED | CHECKIT | MENUTOGGLE | CHECKED)) ^
    			  ITEMENABLED;

	menuitem->Flags |= HIGHCOMP;

	if (newmenu->nm_CommKey)
	{
            if (!(newmenu->nm_Flags & NM_COMMANDSTRING))
	    {
		menuitem->Flags |= COMMSEQ;
		menuitem->Command = newmenu->nm_CommKey[0];
	    }
	}

	menuitem->MutualExclude = newmenu->nm_MutualExclude;
	GTMENUITEM_USERDATA(menuitem) = newmenu->nm_UserData;

	if (FALSE == is_image)
	{
	    /*
	    ** Text
	    */
	    struct IntuiText * it = (struct IntuiText *)(((UBYTE *)menuitem) +
      							 sizeof(struct MenuItem) +
							 sizeof(APTR));

	    DEBUG_ALLOCMENUS(bug("makemenuitem: Text MenuItem\n"));
	    menuitem->ItemFill = (APTR)it;

	    it->FrontPen = GetTagData(GTMN_FrontPen, 0, taglist);
	    it->DrawMode = JAM1;

	    it->IText    = newmenu->nm_Label;
	    DEBUG_ALLOCMENUS(bug("makemenuitem: FillName <%s>\n",it->IText));

	    menuitem->Flags |= ITEMTEXT;

	    if (newmenu->nm_CommKey && (newmenu->nm_Flags & NM_COMMANDSTRING))
	    {
        	struct IntuiText *it2 = it + 1;

		*it2 = *it;
		it2->IText = newmenu->nm_CommKey;
		it->NextText = it2;
	    }

	} /* if (FALSE == is_image) */
	else
	{
	    DEBUG_ALLOCMENUS(bug("makemenuitem: Image MenuItem\n"));
	    menuitem->Flags &= ~ITEMTEXT;

	    if (newmenu->nm_Label != NM_BARLABEL)
	    {
		/*
		** An image.
		*/
		menuitem->ItemFill = (APTR)newmenu->nm_Label;
		DEBUG_ALLOCMENUS(bug("makemenuitem: FillImage 0x%lx\n",menuitem->ItemFill));
	    }
	    else
	    {
        	/*
		** A barlabel image.
		*/

		struct TagItem barlabel_tags[] =
		{
		    {IA_Left	, ITEXT_EXTRA_LEFT	},
		    {IA_Top	, 3			},
		    {IA_Width	, 20			},
		    {IA_Height	, 2			},
		    {TAG_DONE				}
		};

		menuitem->Flags &= ~ITEMENABLED;

		menuitem->ItemFill = NewObjectA(NULL, MENUBARLABELCLASS, barlabel_tags);

		DEBUG_ALLOCMENUS(bug("makemenuitem: BarImage 0x%lx\n",menuitem->ItemFill));

		if (!menuitem->ItemFill)
		{
		    DEBUG_ALLOCMENUS(bug("makemenuitem: barimage failed\n"));
		    FreeVec(menuitem);
		    menuitem = NULL;
		}
	    }

	} /* is_image */

    } /* if (NULL != menuitem) */

    return menuitem;
}
Exemple #11
0
/*** Handle events coming from main window: ***/
void dispatch_events()
{
	extern ULONG sigmainwnd, swinsig;
	extern UBYTE record;
	BYTE  scrolldisp=0, state=0, cnt=0, mark=0, quit = 0;

	while( quit == 0 )
	{
		/* Active collect, when pressing arrow gadgets */
		sigrcvd = (state==0 ? Wait(sigbits) : sigmainwnd);

/*		if(sigrcvd & SIGBREAKF_CTRL_C) break;

		else */ if(sigrcvd & sigport) { handle_port(); continue; }

		else if(sigrcvd & swinsig) { handle_search(); continue; }

		/* Collect messages posted to the window port */
		while( ( msg = (struct IntuiMessage *) GetMsg(Wnd->UserPort) ) )
		{
			/* Copy the entire message into the buffer */
			CopyMemQuick(msg, &msgbuf, sizeof(msgbuf));
			ReplyMsg( (struct Message *) msg );

			switch( msgbuf.Class )
			{
				case IDCMP_CLOSEWINDOW: handle_menu(112); break;
				case IDCMP_RAWKEY:
					handle_kbd(edit);
					if(record) {
						if(record == 1) reg_act_com(MAC_ACT_SHORTCUT, msgbuf.Code, msgbuf.Qualifier);
						else record &= 0x7f;
					}
					break;
				case IDCMP_INTUITICKS:
					/* An error message which needs to be removed? */
					if(err_time == 0) err_time = msgbuf.Seconds;
					if(err_time && msgbuf.Seconds-err_time>4) StopError(Wnd);
					break;
				case IDCMP_MOUSEBUTTONS:
					/* Click somewhere in the text */
					switch( msgbuf.Code )
					{
						case SELECTDOWN:
							/* Click over the project bar ? */
							if(msgbuf.MouseY < gui.top)
							{
								edit = select_panel(edit, msgbuf.MouseX);
								break;
							}

							click(edit, msgbuf.MouseX, msgbuf.MouseY, FALSE);

							/* Shift-click to use columnar selection */
							if( ( move_selection = SwitchSelect(edit, msgbuf.Qualifier & SHIFTKEYS ? 1:0, 1) ) )
								mark=TRUE;
							break;
						case SELECTUP:
							if(mark) unclick(edit);
							mark=FALSE; scrolldisp=0; break;
					}
					break;
				case IDCMP_NEWSIZE:
					new_size(EDIT_ALL);
					break;
				case IDCMP_GADGETDOWN:       /* Left scroll bar */
					if(msgbuf.IAddress == (APTR) &Prop->down) state=1;
					if(msgbuf.IAddress == (APTR) &Prop->up)   state=2;
					break;
				case IDCMP_GADGETUP:        /* Arrows or prop gadget */
					state=0;
					if(msgbuf.IAddress == (APTR) Prop)
						scroll_disp(edit, FALSE), scrolldisp=0;
					break;
				case IDCMP_MOUSEMOVE:
					if(mark) scrolldisp=2;
					else
						if(Prop->scroller.Flags & GFLG_SELECTED) scrolldisp=1;
					break;
				case IDCMP_MENUPICK:
				{	struct MenuItem * Item;
					ULONG             MenuId;

					/* Multi-selection of menu entries */
					while(msgbuf.Code != MENUNULL)
						if( (Item = ItemAddress( Menu, msgbuf.Code )) )
						{
							/* stegerg: get NextSelect here in case menu action causes screen
							   to be closed/reopened in which case item becomes invalid.
							   Also assuming here that user in such case will not use
							   multiselection, ie. that nextselect will be MENUNULL.
							   
							   If that's not the case it would mean more trouble and to protect
							   against that one would need to check if during handle_menu() the
							   screen has been closed/reopened and in that case break out of
							   the menu multiselection loop here. */
							   							   
							UWORD nextselect = Item->NextSelect;
							
							MenuId = (ULONG)GTMENUITEM_USERDATA( Item );
							handle_menu( MenuId );

							if(record) reg_act_com(MAC_ACT_COM_MENU, MenuId, msgbuf.Qualifier);
							else record &= 0x7f;

							msgbuf.Code = nextselect;
						}
				}
			}
		}
		/* Reduces the number of IDCMP mousemove messages to process */
		if(scrolldisp==1) scroll_disp(edit, FALSE), scrolldisp=0;
		if(scrolldisp==2) { scrolldisp=0; goto moveit; }

		/* User may want to auto-scroll the display using arrow gadgets */
		if(state && (mark || (((struct Gadget *)Prop)[state].Flags & GFLG_SELECTED))) {
			/* Slow down animation: */
			WaitTOF(); cnt++;
			if(cnt>1) {
				cnt=0;
				if(autoscroll(edit,state==1 ? 1:-1)==0) state=0;
				else if(mark) {
					LONG x , y; moveit:
					/* Adjust mouse position */
					x = (msgbuf.MouseX-gui.left) / XSIZE;
					y = (msgbuf.MouseY-gui.top) / YSIZE;
					if(x < 0) x =  0; if(x >= gui.nbcol)  x = gui.nbcol-1;
					if(y < 0) y = -1; if(y >  gui.nbline) y = gui.nbline;
					edit->nbrwc = (x += edit->left_pos);
					y += (LONG)edit->top_line;
					if( x != edit->ccp.xc || y != edit->ccp.yc )
						/* Move the selected stream */
						if( !(state = move_selection(edit,x,y)) )
							set_cursor_line(edit, y, edit->top_line),
							inv_curs(edit,TRUE);
				}
			}
		}	/* endif: arrow gadget pressed or autoscroll */
	}
}
Exemple #12
0
STATIC ULONG FOHandleEvents(struct LayoutData *ld, struct AslBase_intern *AslBase)
{
    struct IntuiMessage 	*imsg = ld->ld_Event;
    struct FOUserData 		*udata = (struct FOUserData *)ld->ld_UserData;
    struct IntFontReq 		*iforeq = (struct IntFontReq *)ld->ld_IntReq;
    WORD 			gadid;
    ULONG 			retval = GHRET_OK;

    EnterFunc(bug("FOHandleEvents: Class: %d\n", imsg->Class));
    
    switch (imsg->Class)
    {
	case IDCMP_CLOSEWINDOW:
	    retval = FALSE;
	    break;

        case IDCMP_RAWKEY:
	    switch (imsg->Code)
	    {
	        case CURSORUP:
		    FOChangeActiveFont(ld, -1, imsg->Qualifier, FALSE, AslBase);
		    break;
		    
		case RAWKEY_PAGEUP:
		    FOChangeActiveFont(ld, -1, IEQUALIFIER_LSHIFT, FALSE, AslBase);
		    break;
		    
		case RAWKEY_HOME:
		    FOChangeActiveFont(ld, -1, IEQUALIFIER_LALT, FALSE, AslBase);
		    break;
		    
		case RAWKEY_NM_WHEEL_UP:
		    FOChangeActiveFont(ld, -3, imsg->Qualifier, FALSE, AslBase);
		    break;
		
		case CURSORDOWN:
		    FOChangeActiveFont(ld, 1, imsg->Qualifier, FALSE, AslBase);
		    break;
		    
		case RAWKEY_PAGEDOWN:
		    FOChangeActiveFont(ld, 1, IEQUALIFIER_LSHIFT, FALSE, AslBase);
		    break;
		    
		case RAWKEY_END:
		    FOChangeActiveFont(ld, 1, IEQUALIFIER_LALT, FALSE, AslBase);
		    break;
		    
		case RAWKEY_NM_WHEEL_DOWN:
		    FOChangeActiveFont(ld, 3, imsg->Qualifier, FALSE, AslBase);
		    break;
	    }
	    break;

	case IDCMP_VANILLAKEY:
	    switch(imsg->Code)
	    {
	        case 27:
		    retval = FALSE;
		    break;
	    }
	    break;
	
	case IDCMP_GADGETUP:
	    gadid = ((struct Gadget *)imsg->IAddress)->GadgetID;

	    D(bug("GADGETUP! gadgetid=%d code=%d\n", gadid, imsg->Code));

	    switch (gadid)
	    {
		case ID_BUTCANCEL:
		    retval = FALSE;
		    break;

		case ID_BUTOK:
		    retval = FOGetSelectedFont(ld, AslBase);
		    break;

		case ID_NAMELISTVIEW:		
		    {
	        	struct ASLLVFontReqNode	*fontnode;
			IPTR 			active;
    	    	    	IPTR	    	    	size;
			
			GetAttr(ASLLV_Active, udata->NameListview, &active);
    	    	    	GetAttr(STRINGA_LongVal, udata->SizeString, &size);
			
			if ((fontnode = (struct ASLLVFontReqNode *)FindListNode(&udata->NameListviewList, (WORD)active)))
			{
			    FOActivateFont(ld, active, (LONG)size, AslBase);
			
			    if (imsg->Code) /* TRUE if double clicked */
			    {
				retval = FOGetSelectedFont(ld, AslBase);
			    }
			}
			ActivateGadget((struct Gadget *)udata->NameString, ld->ld_Window, NULL);
		    }
		    break;
		
		case ID_SIZELISTVIEW:
		    if (udata->ActiveFont)
		    {
	        	struct Node	*node;
			IPTR 	    active;

			GetAttr(ASLLV_Active, udata->SizeListview, &active);

			if ((node = FindListNode(&udata->ActiveFont->SizeList, (WORD)active)))
			{
			    FOSetSizeString((LONG)node->ln_Name, ld, AslBase);
			    FOUpdatePreview(ld, AslBase);
			    
			    if (imsg->Code) /* TRUE if double clicked */
			    {
				retval = FOGetSelectedFont(ld, AslBase);
			    }
			}
			ActivateGadget((struct Gadget *)udata->SizeString, ld->ld_Window, NULL);
		    }
		    break;
		    
		case ID_NAMESTRING:
		    if (imsg->Code == STRINGCODE_CURSORUP)
		    {
		    	FOChangeActiveFont(ld, -1, imsg->Qualifier, TRUE, AslBase);
			ActivateGadget((struct Gadget *)udata->NameString, ld->ld_Window, NULL);
			break;
		    }
		    else if (imsg->Code == STRINGCODE_CURSORDOWN)
		    {
		    	FOChangeActiveFont(ld, 1, imsg->Qualifier, TRUE, AslBase);
			ActivateGadget((struct Gadget *)udata->NameString, ld->ld_Window, NULL);
			break;
		    }
		    else if ((imsg->Code == 0) || (imsg->Code == 9))
		    {
    	    	    	FOUpdatePreview(ld, AslBase);
			break;
		    }
		    break;
		
		case ID_SIZESTRING:
		    if (imsg->Code == STRINGCODE_CURSORUP)
		    {
		    	FOChangeActiveSize(ld, -1, imsg->Qualifier, AslBase);
			ActivateGadget((struct Gadget *)udata->SizeString, ld->ld_Window, NULL);
			break;
		    }
		    else if (imsg->Code == STRINGCODE_CURSORDOWN)
		    {
		    	FOChangeActiveSize(ld, 1, imsg->Qualifier, AslBase);
			ActivateGadget((struct Gadget *)udata->SizeString, ld->ld_Window, NULL);
			break;
		    }
		    else if ((imsg->Code == 0) || (imsg->Code == 9))
		    {
		    	IPTR val;
			LONG size;
			
		    	GetAttr(STRINGA_LongVal, udata->SizeString, (IPTR *)&val);
    	    	    	size = (LONG)val;
			
			if ((size < iforeq->ifo_MinHeight) || (size > iforeq->ifo_MaxHeight))
			{
			    if (size < iforeq->ifo_MinHeight) size = iforeq->ifo_MinHeight;
			    if (size > iforeq->ifo_MaxHeight) size = iforeq->ifo_MaxHeight;			    
			    FOSetSizeString(size, ld, AslBase);
			}
			
			FOActivateSize(ld, -size, AslBase);
			
		    	break;
		    }
		    break;
		 
		 case ID_STYLE:
		 case ID_FRONTPEN:
		 case ID_BACKPEN:
		    FOUpdatePreview(ld, AslBase);
		    break;
		    
	    } /* switch (gadget ID) */

	    break; /* case IDCMP_GADGETUP: */

	case IDCMP_MENUPICK:
	    if (ld->ld_Menu)
	    {
	        UWORD men = imsg->Code;

		while(men != MENUNULL)
		{
		    struct MenuItem *item;
		    
		    if ((item = ItemAddress(ld->ld_Menu, men)))
		    {
			switch((IPTR)GTMENUITEM_USERDATA(item))
			{
			    /* Control menu */
			    
			    case FOMEN_LASTFONT:
			    	FOChangeActiveFont(ld, -1, 0, FALSE, AslBase);
			        break;
				
			    case FOMEN_NEXTFONT:
		    		FOChangeActiveFont(ld, 1, 0, FALSE, AslBase);
			        break;
			
			    case FOMEN_RESTORE:
			        FORestore(ld, iforeq->ifo_TextAttr.ta_Name, iforeq->ifo_TextAttr.ta_YSize, AslBase);
			        break;

			    case FOMEN_RESCAN:
			    	FOGetFonts(ld, AslBase);
			        break;
				
			    case FOMEN_OK:
			        retval = FOGetSelectedFont(ld, AslBase);
				break;

			    case FOMEN_CANCEL:
			        retval = FALSE;
				break;
			    
			} /* switch id */

		        men = item->NextSelect;
		    } /* if ((item = ItemAddress(ld->ld_Menu, men))) */
		    else
		    {
		        men = MENUNULL;
		    }
		    
		} /* while(men != MENUNULL) */
		
	    } /* if (ld->ld_Menu) */
	    
	    break; /* case IDCMP_MENUPICK: */

    } /* switch (imsg->Class) */

    ReturnInt ("FOHandleEvents", ULONG, retval);
}
// Group handler
void __saveds backdrop_group_handler(void)
{
	IPCData *ipc;
	GroupData *group=0;

	// Do group
	if (ipc=IPC_ProcStartup((ULONG *)&group,backdrop_group_init))
	{
		// Read objects
		SetBusyPointer(group->window);
		backdrop_read_group_objects(group);
		ClearPointer(group->window);

		// Event loop
		FOREVER
		{
			IPCMessage *msg;
			BOOL quit_flag=0;

			// Got an AppWindow?
			if (group->appwindow)
			{
				DOpusAppMessage *amsg;
				BOOL beep=0;

				// AppMessages?
				while (amsg=(DOpusAppMessage *)GetMsg(group->appport))
				{
					short arg;
					char path[256];
					BackdropObject *drop_obj;

					// Lock backdrop list
					lock_listlock(&group->info->objects,1);

					// Set busy pointer
					if (group->window) SetBusyPointer(group->window);

					// Dropped on an object?
					if (drop_obj=backdrop_get_object(group->info,amsg->da_Msg.am_MouseX,amsg->da_Msg.am_MouseY,0))
					{
						USHORT qual;

						// Get qualifiers
						qual=(InputBase)?PeekQualifier():0;
	
						// Is shift/alt down?
						if (qual&(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT)==(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT))
						{
							// Get path of first file
							GetWBArgPath(&amsg->da_Msg.am_ArgList[0],path,256);

							// Replace the image
							backdrop_replace_icon_image(group->info,path,drop_obj);
						}

						// Run program with args
						else
						backdrop_object_open(
							group->info,
							drop_obj,
							0,
							0,
							amsg->da_Msg.am_NumArgs,
							amsg->da_Msg.am_ArgList);
					}

					// Otherwise, adding objects to the group
					else
					for (arg=0;arg<amsg->da_Msg.am_NumArgs;arg++)
					{
						// Valid name?
						if (*amsg->da_Msg.am_ArgList[arg].wa_Name)
						{
							short x,y;

							// Get full path name
							GetWBArgPath(&amsg->da_Msg.am_ArgList[arg],path,256);

							// Default to no position
							x=-1;
							y=-1;

							// Dopus app message?
							if (CheckAppMessage(amsg))
							{
								// Get icon position
								x=amsg->da_DragOffset.x+amsg->da_Msg.am_MouseX+amsg->da_DropPos[arg].x;
								y=amsg->da_DragOffset.y+amsg->da_Msg.am_MouseY+amsg->da_DropPos[arg].y;
							}

							// Add group object
							backdrop_group_add_object(group->name,group->info,path,x,y);
						}

						// Otherwise, set beep flag for error
						else
						if (!beep)
						{
							beep=1;
							DisplayBeep(group->window->WScreen);
						}
					}

					// Clear busy pointer
					if (group->window) ClearPointer(group->window);

					// Unlock backdrop list
					unlock_listlock(&group->info->objects);

					// Reply to message
					ReplyMsg((struct Message *)amsg);
				}
			}

			// Icon notification
			if (group->info->notify_req)
			{
				DOpusNotify *notify;

				// Get notify message	
				if (notify=(DOpusNotify *)GetMsg(group->info->notify_port))
					backdrop_check_notify(group->info,notify,0);
			}

			// IPC messages?
			while (msg=(IPCMessage *)GetMsg(ipc->command_port))
			{
				// Look at message
				switch (msg->command)
				{
					// Activate
					case IPC_ACTIVATE:

						// Bring window to front
						if (group->window)
							backdrop_show_group(group);
						break;


					// Quit
					case IPC_QUIT:
						quit_flag=1;
						group->got_quit=1;
						break;


					// Hide
					case IPC_HIDE:
						backdrop_hide_group(group);
						break;


					// Show
					case IPC_SHOW:
						group->screen=(struct Screen *)msg->data;
						backdrop_show_group(group);
						break;


					// Reset (menus)
					case IPC_RESET:

						// Gotta window?
						if (group->window)
						{
							// Reset menus?
							if (msg->flags)
							{
								display_free_menu(group->window);
								display_get_menu(group->window);
							}

							// Fix menus
							display_fix_menu(group->window,WINDOW_GROUP,0);
						}
						break;


					// New font
					case GROUP_NEW_FONT:

						// Get new font
						backdrop_get_font(group->info);

						// Redraw objects
						backdrop_show_objects(group->info,BDSF_CLEAR|BDSF_RESET);
						break;


					// New name
					case GROUP_NEW_NAME:

						// Copy name
						strcpy(group->name,msg->data_free);

						// Update window title
						if (group->window) SetWindowTitles(group->window,group->name,(char *)-1);
						break;


					// Add a new icon
					case GROUP_ADD_ICON:

						// Lock backdrop list
						lock_listlock(&group->info->objects,1);

						// Set busy pointer
						if (group->window) SetBusyPointer(group->window);

						// Add object
						backdrop_group_add_object(group->name,group->info,msg->data_free,-1,-1);

						// Clear busy pointer
						if (group->window) ClearPointer(group->window);

						// Unlock backdrop list
						unlock_listlock(&group->info->objects);
						break;


					// New backfill pattern
					case LISTER_BACKFILL_CHANGE:

						// Window open?
						if (group->window)
						{
							// Install appropriate hook
							InstallLayerHook(
								group->window->WLayer,
								(msg->flags)?&group->pattern.hook:LAYERS_BACKFILL);

							// Redraw window
							erase_window(group->window);

							// Redraw icons
							backdrop_show_objects(group->info,0);
						}
						break;


					// Delete from group
					case GROUP_DELETE:
						SetBusyPointer(group->window);
						backdrop_remove_group_objects(group,(BackdropObject *)msg->data);
						ClearPointer(group->window);
						break;


					// Help
					case IPC_HELP:

						// Show help for group
						help_show_help(HELP_PROGRAM_GROUP,0);
						break;


					// Do a function
					case LISTER_DO_FUNCTION:

						// Arrange icons?
						if (msg->data>=(APTR)MENU_LISTER_ARRANGE_NAME &&
							msg->data<=(APTR)MENU_LISTER_ARRANGE_SIZE)
						{
							// Do cleanup
							backdrop_cleanup(group->info,BSORT_NAME+(((ULONG)msg->data)-MENU_LISTER_ARRANGE_NAME),0);
						}
						break;
				}

				// Reply to message
				IPC_Reply(msg);
			}

			// Is window open?
			if (group->window)
			{
				struct IntuiMessage *imsg;

				// Check timer
				if (CheckTimer(group->timer))
				{
					// Dragging something?
					if (group->info->flags&BDIF_DRAGGING)
					{
						// Check for deadlocks
						if (group->info->last_tick==group->info->tick_count)
						{
							// Stop drag
							backdrop_stop_drag(group->info);
						}

						// Remember tick count
						group->info->last_tick=group->info->tick_count;
					}

					// Re-start timer
					StartTimer(group->timer,0,500000);
				}

				// Window messages
				while (imsg=(struct IntuiMessage *)GetMsg(group->window->UserPort))
				{
					struct IntuiMessage msg_copy;
					struct MenuItem *item;

					// Copy message
					msg_copy=*imsg;

					// Menu verify?
					if (imsg->Class==IDCMP_MENUVERIFY)
					{
						// See if we want to swallow it
						if (!backdrop_test_rmb(group->info,imsg,&msg_copy,TRUE))
						{
							// Did event happen over the window?
							if (imsg->MouseX>=0 &&
								imsg->MouseY>=0 &&
								imsg->MouseX<group->window->Width &&
								imsg->MouseY<group->window->Height &&
								imsg->Qualifier&IEQUALIFIER_RBUTTON)
							{
								// Cancel menu event
								imsg->Code=MENUCANCEL;

								// Change our copy to MOUSEBUTTONS
								msg_copy.Class=IDCMP_MOUSEBUTTONS;
								msg_copy.Code=MENUDOWN;

								// Kludge for MagicMenu
								if (msg_copy.Seconds==0)
									CurrentTime(&msg_copy.Seconds,&msg_copy.Micros);
							}
						}
					}

					// Resize/refresh?
					if (imsg->Class==IDCMP_NEWSIZE ||
						imsg->Class==IDCMP_REFRESHWINDOW)
					{
						// Handle message
						backdrop_idcmp(group->info,imsg,0);

						// Reply to message
						ReplyMsg((struct Message *)imsg);
						continue;
					}

					// Reply to message
					ReplyMsg((struct Message *)imsg);

					// Is it a backdrop message?
					if (backdrop_idcmp(group->info,&msg_copy,0))
						continue;

					// Look at message class
					switch (msg_copy.Class)
					{
						// Window closed
						case IDCMP_CLOSEWINDOW:
							quit_flag=1;
							break;


						// Window is inactive
						case IDCMP_INACTIVEWINDOW:

							// Abort timer if running
							StopTimer(group->timer);
							break;


						// Window is active
						case IDCMP_ACTIVEWINDOW:

							// Start timer if not running
							StartTimer(group->timer,1,0);
							break;


						// Key press
						case IDCMP_RAWKEY:

							// Help?
							if (msg_copy.Code==0x5f &&
								!(msg_copy.Qualifier&VALID_QUALIFIERS))	
							{
								help_get_help(
									msg_copy.MouseX+group->window->LeftEdge,
									msg_copy.MouseY+group->window->TopEdge,
									msg_copy.Qualifier);
							}

							// Close?
							else
							if (msg_copy.Code==0x45 &&
								msg_copy.Qualifier&IEQUAL_ANYSHIFT) quit_flag=1;
							break;


						// Button pressed
						case IDCMP_MOUSEBUTTONS:

							// Right button?
							if (msg_copy.Code==MENUDOWN)
							{
								USHORT res;

								// Do popup menu
								if (group->popup &&
									(res=DoPopUpMenu(group->window,&group->popup->ph_Menu,NULL,MENUDOWN))!=(USHORT)-1)
								{
									// Help?
									if (res&POPUP_HELPFLAG)
									{
										// Get help ID
										res&=~POPUP_HELPFLAG;

										// Do help
										help_menu_help(res,0);
										break;
									}

									// Do the function
									quit_flag=backdrop_group_do_function(group,res,0);
								}
							}
							break;


						// Menu event
						case IDCMP_MENUPICK:
						case IDCMP_MENUHELP:
							{
								struct Menu *oldstrip=group->window->MenuStrip;
								USHORT nextselect;

								// Get item
								nextselect=msg_copy.Code;
								while (item=ItemAddress(group->window->MenuStrip,nextselect))
								{
									// get next
									nextselect=item->NextSelect;

									// Help?
									if (msg_copy.Class==IDCMP_MENUHELP)
									{
										help_menu_help((long)GTMENUITEM_USERDATA(item),0);
										break;
									}

									// Do the function
									quit_flag=backdrop_group_do_function(group,(ULONG)GTMENUITEM_USERDATA(item),item);

									// Check valid next
									if (!nextselect || !group->window || oldstrip!=group->window->MenuStrip)
										break;
								}
							}
							break;
					}
				}
			}

			// Check quit flag
			if (quit_flag) break;

			// Wait for event
			Wait(	1<<ipc->command_port->mp_SigBit|
					1<<group->timer->port->mp_SigBit|
					((group->info->notify_req)?(1<<group->info->notify_port->mp_SigBit):0)|
					((group->window)?(1<<group->window->UserPort->mp_SigBit):0)|
					((group->appwindow)?(1<<group->appport->mp_SigBit):0));
		}

		// Close window
		backdrop_free_group(group);

		// Send goodbye
		IPC_Goodbye(ipc,&main_ipc,0);
	}