Exemplo n.º 1
0
static void FillReqStruct(struct AHIAudioModeRequesterExt *req, struct TagItem *tags)
{
  ULONG obsolete_userdata;

// Check all known tags
  req->SrcWindow=(struct Window *)GetTagData(AHIR_Window,(ULONG)req->SrcWindow,tags);
  req->PubScreenName=(STRPTR)GetTagData(AHIR_PubScreenName,(ULONG)req->PubScreenName,tags);
  req->Screen=(struct Screen *)GetTagData(AHIR_Screen,(ULONG)req->Screen,tags);
  req->IntuiMsgFunc=(struct Hook *)GetTagData(AHIR_IntuiMsgFunc,(ULONG)req->IntuiMsgFunc,tags);

  obsolete_userdata = GetTagData( AHIR_ObsoleteUserData, 0, tags );
  req->Req.ahiam_ObsoleteUserData[ 0 ] = obsolete_userdata >> 16;
  req->Req.ahiam_ObsoleteUserData[ 1 ] = obsolete_userdata & 0xffff;

  req->Req.ahiam_UserData=(void *)GetTagData(AHIR_UserData,(ULONG)req->Req.ahiam_UserData,tags);
  req->TextAttr=(struct TextAttr *)GetTagData(AHIR_TextAttr,(ULONG)req->TextAttr,tags);
  req->Locale=(struct Locale *)GetTagData(AHIR_Locale,(ULONG)req->Locale,tags);
  req->TitleText=(STRPTR)GetTagData(AHIR_TitleText,(ULONG)req->TitleText,tags);
  req->PositiveText=(STRPTR)GetTagData(AHIR_PositiveText,(ULONG)req->PositiveText,tags);
  req->NegativeText=(STRPTR)GetTagData(AHIR_NegativeText,(ULONG)req->NegativeText,tags);
  req->Req.ahiam_LeftEdge=GetTagData(AHIR_InitialLeftEdge,req->Req.ahiam_LeftEdge,tags);
  req->Req.ahiam_TopEdge=GetTagData(AHIR_InitialTopEdge,req->Req.ahiam_TopEdge,tags);
  req->Req.ahiam_Width=GetTagData(AHIR_InitialWidth,req->Req.ahiam_Width,tags);
  req->Req.ahiam_Height=GetTagData(AHIR_InitialHeight,req->Req.ahiam_Height,tags);
  req->Req.ahiam_AudioID=GetTagData(AHIR_InitialAudioID,req->Req.ahiam_AudioID,tags);
  req->Req.ahiam_MixFreq=GetTagData(AHIR_InitialMixFreq,req->Req.ahiam_MixFreq,tags);
  req->Req.ahiam_InfoOpened=GetTagData(AHIR_InitialInfoOpened,req->Req.ahiam_InfoOpened,tags);
  req->Req.ahiam_InfoLeftEdge=GetTagData(AHIR_InitialInfoLeftEdge,req->Req.ahiam_InfoLeftEdge,tags);
  req->Req.ahiam_InfoTopEdge=GetTagData(AHIR_InitialInfoTopEdge,req->Req.ahiam_InfoTopEdge,tags);
//  req->Req.ahiam_InfoWidth=GetTagData(AHIR_InitialInfoWidth,req->Req.ahiam_InfoWidth,tags);
//  req->Req.ahiam_InfoHeight=GetTagData(AHIR_InitialInfoHeight,req->Req.ahiam_InfoHeight,tags);
  req->FilterTags=(struct TagItem *)GetTagData(AHIR_FilterTags,(ULONG)req->FilterTags,tags);
  req->FilterFunc=(struct Hook *)GetTagData(AHIR_FilterFunc,(ULONG)req->FilterFunc,tags);
  req->Flags=PackBoolTags(req->Flags,tags,reqboolmap);
}
Exemplo n.º 2
0
IPTR Set(struct IClass *cl, Object *obj, struct opSet *msg)
{
  struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
  struct TagItem *tags, *tag;
  char IntegerString[12];
  IPTR ti_Data;

  struct TagItem boolMap[] =
  {
    { MUIA_Disabled,                  FLG_Ghosted     },
    { MUIA_String_AdvanceOnCR,        FLG_AdvanceOnCr },
    { MUIA_String_Secret,             FLG_Secret      },
    { MUIA_BetterString_StayActive,   FLG_StayActive  },
    { MUIA_BetterString_NoInput,      FLG_NoInput     },
    { MUIA_BetterString_NoShortcuts,  FLG_NoShortcuts },
    { TAG_DONE,                       0               }
  };

  tags = msg->ops_AttrList;
  data->Flags = PackBoolTags(data->Flags, tags, boolMap);

  while((tag = NextTagItem((APTR)&tags)))
  {
    ti_Data = tag->ti_Data;
    switch(tag->ti_Tag)
    {
      case MUIA_Disabled:
        MUI_Redraw(obj, MADF_DRAWOBJECT);
      break;

      case MUIA_String_AttachedList:
        data->ForwardObject = (Object *)ti_Data;
      break;

      case MUIA_String_Accept:
        data->Accept = (STRPTR)ti_Data;
      break;

      case MUIA_String_BufferPos:
        data->BufferPos = (UWORD)ti_Data;
        clearFlag(data->Flags, FLG_BlockEnabled);
      break;

      case MUIA_BetterString_Columns:
        data->Width = (UWORD)ti_Data;
      break;

      case MUIA_String_Integer:
        tag->ti_Tag = TAG_IGNORE;

        // we are using snprintf() here not only to be on the safe
        // side, but also because modern C runtime libraries should definitly
        // support it!
        snprintf(IntegerString, sizeof(IntegerString), "%d", (int)ti_Data);
        ti_Data = (ULONG)IntegerString;

        // The missing break is intended!

      case MUIA_String_Contents:
      {
        STRPTR new_str = (STRPTR)ti_Data;
        BOOL circular = FALSE;

        if(new_str != NULL)
        {
          circular = !strcmp(data->Contents, new_str);
          if(circular == FALSE && data->MaxLength && strlen(new_str) > data->MaxLength)
            circular = !strncmp(data->Contents, new_str, data->MaxLength);
        }

        if(circular == FALSE)
        {
          // we don't have a valid block anymore
          clearFlag(data->Flags, FLG_BlockEnabled);

          if(new_str != NULL)
          {
            WORD extra = strlen(new_str)-strlen(data->Contents);

            if(extra > 0)
              data->Contents = (STRPTR)ExpandPool(data->Pool, data->Contents, extra);

            strcpy(data->Contents, new_str);
            data->BufferPos = strlen(data->Contents);
            data->DisplayPos = 0;
            if(data->MaxLength != 0 && data->BufferPos >= data->MaxLength)
            {
              data->Contents[data->MaxLength-1] = '\0';
              data->BufferPos = data->MaxLength-1;
            }

            // the start of a block cannot be behind the last character
            if(data->BlockStart > strlen(data->Contents))
              data->BlockStart = strlen(data->Contents);
          }
          else
          {
            data->Contents[0] = '\0';
            data->BlockStart = 0;
            data->BlockStop = 0;
            data->BufferPos = 0;
            data->DisplayPos = 0;
          }
        }
        else
        {
//        if(data->Contents != (STRPTR)ti_Data)
          tag->ti_Tag = TAG_IGNORE;
        }
      }
      break;

      case MUIA_ControlChar:
        data->CtrlChar = (UBYTE)ti_Data;
      break;

      case MUIA_String_DisplayPos:
        data->DisplayPos = (UWORD)ti_Data;
      break;

      case MUIA_String_Format:
        data->Alignment = (WORD)ti_Data;
      break;

      case MUIA_String_MaxLen:
        data->MaxLength = (UWORD)ti_Data;
      break;

      case MUIA_String_Reject:
        data->Reject = (STRPTR)ti_Data;
      break;

      case MUIA_String_EditHook:
        data->EditHook = (struct Hook *)ti_Data;
      break;

      case MUIA_BetterString_KeyUpFocus:
        data->KeyUpFocus = (Object *)ti_Data;
      break;

      case MUIA_BetterString_KeyDownFocus:
        data->KeyDownFocus = (Object *)ti_Data;
      break;

      case MUIA_BetterString_InactiveContents:
        data->InactiveContents = (STRPTR)ti_Data;
      break;

      case MUIA_BetterString_SelectSize:
      {
        data->BlockStart = data->BufferPos;
        setFlag(data->Flags, FLG_BlockEnabled);

        data->BlockStop = data->BufferPos+ti_Data;

        if(data->BlockStop < 0)
          data->BlockStop = 0;

        if((ULONG)data->BlockStop > strlen(data->Contents))
          data->BlockStop = strlen(data->Contents);
      }
      break;

      case MUIA_BetterString_SelectOnActive:
      {
         if(ti_Data == FALSE)
         {
            setFlag(data->Flags, FLG_ForceSelectOff);
            clearFlag(data->Flags, FLG_ForceSelectOn);
         }
         else
         {
            setFlag(data->Flags, FLG_ForceSelectOn);
            clearFlag(data->Flags, FLG_ForceSelectOff);
         }
      }
      break;

      case 0x80420d71: /* MUIA_String_Popup */
        data->Popup = (Object *)ti_Data;
      break;

    }
  }

  if(data->BufferPos > strlen(data->Contents))
    data->BufferPos = strlen(data->Contents);

  MUI_Redraw(obj, MADF_DRAWUPDATE);
  return(0);
}