跳轉到內容

Aros/Developer/Docs/Libraries/ASL

來自華夏公益教科書
Aros 華夏公益教科書的導航欄
Aros 使用者
Aros 使用者文件
Aros 使用者常見問題解答
Aros 使用者應用程式
Aros 使用者 DOS Shell
Aros/User/AmigaLegacy
Aros 開發文件
Aros 開發人員文件
從 AmigaOS/SDL 移植軟體
Zune 初學者指南
Zune .MUI 類
SDL 初學者指南
Aros 開發人員構建系統
特定平臺
Aros x86 完整系統 HCL
Aros x86 音訊/影片支援
Aros x86 網路支援
Aros Intel AMD x86 安裝
Aros 儲存支援 IDE SATA 等
Aros Poseidon USB 支援
x86-64 支援
摩托羅拉 68k Amiga 支援
Linux 和 FreeBSD 支援
Windows Mingw 和 MacOSX 支援
Android 支援
Arm Raspberry Pi 支援
PPC Power Architecture
其他
Aros 公共許可證

除了 Intuition 型別的請求器外,還有 Asl.library 請求器,它們內建了以下請求器:

  • 檔案開啟/儲存
  • 字型
  • 公共螢幕選擇
  • 等等

您需要使用 AllocAslRequestTags 設定 ASL 請求器,reqType 可以是 ASL_FileRequest、ASL_FontRequest 或 ASL_ScreenModeRequest,您可以在此處或在 AslRequest 函式中指定 ASL 請求器的可選引數,例如請求器的大小、標題文字、初始檔案、抽屜和檔案模式、字型資訊或初始螢幕資訊,如 libraries/asl_intern.h 標頭檔案所定義。

/* Internal requester structure */
struct IntReq
{
    UWORD		ir_ReqType;
    struct Window	*ir_Window;
    struct Screen	*ir_Screen;
    STRPTR		ir_PubScreenName;
    struct Hook 	*ir_IntuiMsgFunc;
    struct TextAttr	*ir_TextAttr;
    struct Locale	*ir_Locale;
    struct Catalog  	*ir_Catalog;
    APTR		ir_MemPool;
    ULONG		ir_MemPoolPuddle;  	/* if 0, no pool is created */
    ULONG		ir_MemPoolThresh;
    LONG    	    	ir_TitleID;
    STRPTR		ir_TitleText;
    STRPTR		ir_PositiveText;
    STRPTR		ir_NegativeText;
    WORD		ir_LeftEdge;
    WORD		ir_TopEdge;
    WORD		ir_Width;
    WORD		ir_Height;
    UBYTE		ir_Flags;

    APTR		ir_BasePtr;	/* Compatability: Saved copy of REG_A4 */
};

AllocAslRequster 將返回一個指標,該指標可以是指向 FileRequester、FontRequester 或 ScreenModeRequester 結構的指標(這些結構是隻讀的)。一旦設定了結構,就可以呼叫 AslRequest 函式來顯示請求器,並在之後從結構中檢索資料,例如檔名、字型或螢幕模式,以供您的程式使用。完成對請求器結構的操作後,您應該呼叫 FreeAslRequest。

AslRequest() 函式中 TagItem 的值

ASL_Dummy
ASL_Hail
ASL_Window
ASL_LeftEdge
ASL_TopEdge
ASL_Width
ASL_Height

ASL_HookFunc

ASL_File
ASL_Dir

ASL_Pattern

ASL_FontName
ASL_FontHeight
ASL_FontStyles
ASL_FontFlags
ASL_FrontPen
ASL_BackPen
ASL_MinHeight
ASL_MaxHeight

ASL_OKText
ASL_CancelText
ASL_FuncFlags
ASL_ModeList


請求器

[編輯 | 編輯原始碼]

檔案請求器

[編輯 | 編輯原始碼]
/* Internal filerequester struct */

struct IntFileReq
{
    struct IntReq	ifr_IntReq;

    STRPTR		ifr_File;
    STRPTR		ifr_Drawer;
    STRPTR		ifr_Pattern;
    STRPTR		ifr_AcceptPattern;
    STRPTR		ifr_RejectPattern;
    UBYTE		ifr_Flags1;
    UBYTE		ifr_Flags2;
    struct Hook 	*ifr_FilterFunc;

    ULONG 		(*ifr_HookFunc)(ULONG mask, APTR object, struct FileRequester *fr);
    			/* ASLFR_HookFunc = Combined callback function */

    ULONG		*ifr_GetSortBy;
    ULONG		*ifr_GetSortOrder;
    ULONG		*ifr_GetSortDrawers;
    UWORD		ifr_SortBy;
    UWORD		ifr_SortOrder;
    UWORD		ifr_SortDrawers;
    BOOL		ifr_InitialShowVolumes;        
};

字型請求器

[編輯 | 編輯原始碼]
struct IntFontReq
{
    struct IntReq	ifo_IntReq;
    struct TextAttr	ifo_TextAttr;
    UBYTE		ifo_FrontPen;
    UBYTE		ifo_BackPen;
    UBYTE		ifo_DrawMode;

    UBYTE		ifo_Flags;
    UWORD		ifo_MinHeight;
    UWORD		ifo_MaxHeight;
    struct Hook		*ifo_FilterFunc;

    ULONG		(*ifo_HookFunc)(ULONG, APTR, struct FontRequester *);

    UWORD		ifo_MaxFrontPen;
    UWORD		ifo_MaxBackPen;

    STRPTR		*ifo_ModeList;
    STRPTR  	    	 ifo_SampleText;
    UBYTE		*ifo_FrontPens;
    UBYTE		*ifo_BackPens;

    STRPTR		ifo_DrawModeJAM1Text;
    STRPTR		ifo_DrawModeJAM2Text;
    STRPTR  	    	ifo_DrawModeCOMPText;
    STRPTR		ifo_DrawMode0Text; 
};

FontRequester 的 ASL funcFlags

FONB_FrontColor
FONF_FrontColor
FONB_BackColor
FONF_BackColor
FONB_Styles
FONF_Styles
FONB_DrawMode
FONF_DrawMode
FONB_FixedWidth
FONF_FixedWidth
FONB_NewIDCMP
FONF_NewIDCMP
FONB_DoMsgFunc
FONF_DoMsgFunc
FONB_DoWildFunc
FONF_DoWildFunc

螢幕模式請求器

[編輯 | 編輯原始碼]
struct IntSMReq
{
    struct IntReq	ism_IntReq;
    struct List		*ism_CustomSMList;
    struct Hook		*ism_FilterFunc;		
    ULONG		ism_Flags;
    ULONG		ism_DisplayID;
    ULONG	 	ism_DisplayWidth;
    ULONG		ism_DisplayHeight;
    ULONG		ism_BitMapWidth;
    ULONG		ism_BitMapHeight;
    UWORD		ism_DisplayDepth;
    UWORD		ism_OverscanType;
    BOOL		ism_AutoScroll;
    ULONG		ism_PropertyFlags;
    ULONG		ism_PropertyMask;
    LONG		ism_MinDepth;
    LONG		ism_MaxDepth;
    LONG		ism_MinWidth;
    LONG		ism_MaxWidth;
    LONG		ism_MinHeight;
    LONG		ism_MaxHeight;
    LONG		ism_InfoLeftEdge;
    LONG		ism_InfoTopEdge;
    BOOL		ism_InfoOpened;
    
    STRPTR		ism_Overscan1Text;
    STRPTR		ism_Overscan2Text;
    STRPTR		ism_Overscan3Text;
    STRPTR		ism_Overscan4Text;
    STRPTR		ism_OverscanNullText;
    STRPTR		ism_AutoScrollOFFText;
    STRPTR		ism_AutoScrollONText;
    STRPTR		ism_AutoScroll0Text;
    
    STRPTR		ism_PropertyList_Title;
    STRPTR		ism_PropertyList_NotWB;
    STRPTR		ism_PropertyList_NotGenlock;
    STRPTR		ism_PropertyList_NotDraggable;
    STRPTR		ism_PropertyList_HAM;
    STRPTR		ism_PropertyList_EHB;
    STRPTR		ism_PropertyList_Interlace;
    STRPTR		ism_PropertyList_ECS;
    STRPTR		ism_PropertyList_WB;
    STRPTR		ism_PropertyList_Genlock;
    STRPTR		ism_PropertyList_Draggable;
    STRPTR		ism_PropertyList_DPFPri2;
    STRPTR		ism_PropertyList_RefreshRate;
};

</syntaxhighlight lang="c"> </syntaxhighlight>


#include <stdio.h>
#include <libraries/asl.h>
#include <proto/exec.h>
#include <proto/asl.h>

struct Library* AslBase;

int main()
{
  AslBase = OpenLibrary("asl.library", 0)

  if(AslBase != NULL)
  {
    struct FileRequester* req = AllocAslRequest(ASL_FileRequest, NULL);

    if(req != NULL)
    {
      AslRequest(req, NULL);
      printf("%s/%s\n", req->fr_Drawer, req->fr_File);
      FreeAslRequest(req);
    }

    CloseLibrary(AslBase);
  }

  return 0;
}

參考文獻

[編輯 | 編輯原始碼]
BOOL RequestFile(struct FileRequester *fileReq) (A0)
void FreeFileRequest(struct FileRequester *fileReq) (A0)
APTR AllocAslRequest(ULONG reqType, struct TagItem *tagList) (D0, A0)
BOOL AslRequest(APTR requester, struct TagItem *tagList) (A0, A1)
void FreeAslRequest(APTR requester) (A0)
void AbortAslRequest(APTR requester) (A0)
void ActivateAslRequest(APTR requester) (A0)
APTR AllocAslRequestTags( ULONG reqType, Tag tag1, ... );
VOID FreeAslRequest( APTR requester );
BOOL AslRequestTags( APTR requester, struct TagItem *tagList );
華夏公益教科書