跳转到内容

Aros/开发人员/文档/库/Intuition

来自 Wikibooks,开放世界中的开放书籍
Aros wiki 书籍的导航栏
Aros 用户
Aros 用户文档
Aros 用户常见问题解答
Aros 用户应用程序
Aros 用户 DOS Shell
Aros/用户/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 支持
Motorola 68k Amiga 支持
Linux 和 FreeBSD 支持
Windows Mingw 和 MacOSX 支持
Android 支持
Arm Raspberry Pi 支持
PPC Power Architecture
其他
Aros 公共许可证
  • V34 = Amiga OS1.3
  • V36 = Amiga OS2.x
  • V37 = Amiga OS3.0
  • V40 = Amiga OS3.1 AROS 开始兼容级别
  • V44 = Amiga OS3.5 OS3.9
  • V45 = Amiga OS4

典型的应用程序或游戏将涉及...

  • 设置任何库、屏幕、窗口。
  • 设置任何需要的基于直觉的小部件、菜单和请求器或 Zune(基于 mui)小部件、菜单和请求器
  • Wait() 等待来自 Intuition/Zune 关于用户活动或其他事件的消息。
  • 从消息中复制所需数据,并通过回复告诉 Intuition/Zune 你已经收到它。查看数据并采取相应的行动。例如(按键盘上的键,移动鼠标,点击小部件,选择菜单项,时间流逝,插入磁盘,移除磁盘,以及窗口重新排列)。
  • 重复,直到用户想要退出。(然后关闭窗口、屏幕和库)

大多数情况下,你不需要设置屏幕,因为你经常会使用已经使用的公共屏幕(漫游者、Scalos 或其他 WB 替代品),因此你可以跳过在该屏幕上打开窗口。

AROS(像之前的 Amigas 一样)支持称为屏幕的概念,每个屏幕都可以设置特定的分辨率和颜色深度,受使用的显示器驱动程序或 CRT 或 LCD 显示器限制。

  1. 自己的公共屏幕,主应用程序可以在其中“托管”具有相同屏幕规格等的附加模块,如果需要。
  2. 默认的共享公共屏幕(通常称为漫游者、Scalos 或 Workbook)表示多个应用程序驻留在同一个屏幕上,这可以节省内存。
  3. 最后一种选择是自定义屏幕,为每个应用程序创建一个新的显示,例如,如果你想要特定的分辨率和颜色深度。打开任何新的屏幕都会使用内存。

使用 OpenScreenTags() 打开屏幕

[编辑 | 编辑源代码]

下面是已经设置在 AROS 中的公共结构,它是一个模板,可以在编程中快速使用。

struct Screen {
    struct Screen *NextScreen;		/* linked list of screens */
    struct Window *FirstWindow;		/* linked list Screen's Windows */
    WORD LeftEdge, TopEdge;		/* parameters of the screen */
    WORD Width, Height;			/* parameters of the screen */
    WORD MouseY, MouseX;		/* position relative to upper-left */
    UWORD Flags;			/* see definitions below */
    UBYTE *Title;			/* null-terminated Title text */
    UBYTE *DefaultTitle;		/* for Windows without ScreenTitle */

    /* Bar sizes for this Screen and all Window's in this Screen */
    BYTE BarHeight, BarVBorder, BarHBorder, MenuVBorder, MenuHBorder;
    BYTE WBorTop, WBorLeft, WBorRight, WBorBottom;
    struct TextAttr *Font;		/* this screen's default font	   */

    /* the display data structures for this Screen */
    struct ViewPort ViewPort;		/* underlying graphics struct for each screen (&my_screen->ViewPort) */
    struct RastPort RastPort;		/* allow direct rendering into the screen (not useful) &my_screen->RastPort) */
    struct BitMap BitMap;		/* Screen->RastPort.BitMap in place of &Screen->BitMap whenever possible */
    struct Layer_Info LayerInfo;	/* each screen gets a LayerInfo    */

    /* Only system gadgets may be attached to a screen. The standard system Screen Gadgets automatically  */
    struct Gadget *FirstGadget;
    UBYTE DetailPen, BlockPen;		/* for bar/border/gadget rendering */

    /* the following variable(s) are maintained by Intuition to support the DisplayBeep() color flashing technique */
    UWORD SaveColor0;

    /* This layer is for the Screen and Menu bars */
    struct Layer *BarLayer;
    UBYTE *ExtData;
    UBYTE *UserData;                    /* general-purpose pointer to User data extension */
};

每一行都会添加并存储一些关于正在使用的屏幕的信息。Screen 结构内的每个附加结构都是 AROS 内已经存在的预定义数据存储的“块”。许多 AROS 依赖于结构在更新的结构中使用,以帮助和加快开发。

每个屏幕都有一个 ViewPort 结构(屏幕由图形库表示),每个屏幕都有一个 drawinfo(高级)和一个 RastPort 结构(图形库用来在该屏幕上绘图的低级句柄)。View 是整个显示,包括所有可见的屏幕,通过 ViewAddress() 访问。

标签是参数名称后跟逗号,然后是值。例如,要指定屏幕的 DefaultTitle,可以使用 SA_Title 后跟逗号,然后是引号内的标题,还有许多其他标签可以用来定义屏幕的位,稍后将列出。最后一个标签项始终应该是 TAG_DONE。

屏幕的标题栏,而不是窗口的标题栏,是在窗口前面绘制的。如果将窗口从默认的 0,0 位置移动,使用 WA_Top 和/或 WA_Left(SA_ShowTitle 为 FALSE 当然),在全屏模式下,只需忽略这些标签,而不要将它们设置为 0。

// Opens a PubScreen. The name can be given as argument. 
// Default name is "MYPUBSCREEN".

#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/exec.h>

#include <stdlib.h>
#include <stdio.h>

struct Screen *myscreen;
struct Window *mywindow;
BYTE signalnum;

void clean_exit(STRPTR txt)
{
    if (mywindow) CloseWindow(mywindow);
    if (myscreen) CloseScreen(myscreen);
    FreeSignal(signalnum);

    if (txt)
    {
        PutStr(txt);
        exit(RETURN_FAIL);
    }
    exit(RETURN_OK);
}

int main(int argc, char **argv)
{
    BOOL done = FALSE;
    BOOL closewindow = FALSE;
    ULONG signals, winsig, pubsig;
    struct IntuiMessage *message;
    char *name;

    if (argc == 2)
    {
        name = argv[1];
    }
    else
    {
        name = "MYPUBSCREEN";
    }

    if ((signalnum = AllocSignal(-1)) == -1)
    {
        clean_exit("Can't allocate signal\n");
    }

    if
    (
        (
            myscreen = OpenScreenTags
            (
                NULL,
                SA_PubName, name,
                SA_PubSig, signalnum,
                SA_LikeWorkbench, TRUE,
                SA_Title, name,
                TAG_DONE
            )
        ) == NULL
    )
    {
        clean_exit("Can't open screen\n");
    }

    if
    (
        (
            mywindow = OpenWindowTags
            (
                NULL,
                WA_Left, 30,
                WA_Top, 30,
                WA_Width, 250,
                WA_Height, 100,
                WA_DragBar, TRUE,
                WA_DepthGadget, TRUE,
                WA_CloseGadget, TRUE,
                WA_Activate, TRUE,
                WA_Title, "Close me to close the screen",
                WA_IDCMP, IDCMP_CLOSEWINDOW,
                WA_PubScreen, myscreen,
                TAG_DONE
            )
        ) == NULL
    )
    {
        clean_exit("Can't open window\n");
    }

    if ((PubScreenStatus(myscreen, 0) & 1) == 0)
    {
        clean_exit("Can't make screen public");
    }

    winsig = 1L << mywindow->UserPort->mp_SigBit;
    pubsig = 1L << signalnum;

    while (!done)
    {
        signals = Wait(winsig | pubsig);

        if (mywindow && (signals & winsig))
        {
            while (NULL != (message = (struct IntuiMessage *)GetMsg(mywindow->UserPort)))
            {
                if (message->Class == IDCMP_CLOSEWINDOW)
                {
                    closewindow = TRUE;
                }
                ReplyMsg((struct Message *)message);
            }
        }
        if (signals & pubsig)
        {
            if (PubScreenStatus(myscreen, PSNF_PRIVATE) & 1)
            {
                done = TRUE;
            }
            else
            {
                PutStr("Failed to make screen private\n");
            }
        }

        if (closewindow)
        {
            if (mywindow) CloseWindow(mywindow);
            winsig = 0;
            mywindow = NULL;
            closewindow = FALSE;
        }
    }

    clean_exit(NULL);
    return 0;
}
#include <proto/intuition.h>
#include <proto/dos.h>
#include <intuition/screens.h>
 
int main() {
 
/* makes a copy of the Screen struct(ure) and calls that copy myScreen, changes are made to this copy */ 
  struct Screen *myScreen; 
/* you can call the copy 'myScreen' any name you like, as long as you use it throughout the program consistently */ 
 
  /* describe how 'myScreen' looks like by using tags SA_? */ 
  myScreen = OpenScreenTags(NULL,
  SA_Left, 0, SA_Top, 0, SA_Width, 640, SA_Height, 480,
  SA_Depth, 8, SA_Title, "My New Screen",
  SA_Type, PUBLICSCREEN,
  SA_SysFont, 1,
  TAG_DONE);
 
  Delay(500);
 
/* check if screen open, returns TRUE for success and FALSE for failure, if so, use CloseScreen() command to close */
  if (myScreen) CloseScreen(myScreen);
}
#include <proto/intuition.h>
#include <proto/dos.h>
#include <intuition/screens.h>
#include <proto/graphics.h>

int main (void)

{
struct Screen *scr;
struct Window *win;
struct RastPort *rp;

if (scr = OpenScreenTags (NULL,SA_LikeWorkbench,TRUE,TAG_END))  /* open RTG screen */
{
Delay (50); /* one second */
if (win = OpenWindowTags (NULL,
WA_CustomScreen,scr,
WA_Left,100,WA_Top,100,
WA_Width,200,WA_Height,100,
TAG_END))
{
rp = win->RPort;
Move (rp,20,40);
Text (rp,"Beep !",6); /* you won't see DisplayBeep on a RTG screen */
Delay (50); /* one second */
CloseWindow (win);
}
Delay (100); /* two seconds */
CloseScreen (scr);
}

return (0);
}

打开或锁定公共屏幕

[编辑 | 编辑源代码]

如果你不希望使用自定义屏幕,那么可以使用现有的公共屏幕,例如漫游者。屏幕可以随时关闭,所以为了防止这种情况,应用程序运行时应该锁定公共屏幕。你可以使用 LockPubScreen 函数来实现这一点。

myScreen = LockPubScreen(name)

其中 name 是要锁定的公共屏幕的名称。如果未提供名称(NULL),则它将使用工作台公共屏幕。完成对公共屏幕的操作后,你可以解锁它。

UnlockPubScreen(NULL, myScreen);
#include <proto/intuition.h>
#include <intuition/screens.h>
#include <proto/dos.h>
#include <stdio.h>

int main(void) {

  struct Screen *myScreen;

  if (myScreen = LockPubScreen(NULL)) {
       printf("Public Screen locked.\n");
       Delay(100);
       UnlockPubScreen(NULL, myScreen);
       printf("Public Screen unlocked.\n");
  }
  return 0;
}
       if ((scr->screen = LockPubScreen(PROGNAME)))
       {
       scr->screentype = PUBLICSCREEN;
       success = TRUE;
       scr->modeID = GetVPModeID(&scr->screen->ViewPort);
       }
       else
       {
       if (id != INVALID_ID)
           {
           UWORD empty = 0xffff;

           if ((scr->screen = OpenScreenTags(NULL,
                SA_Width, width,
                SA_Height, height
                SA_Depth, depth,
                SA_DisplayID, id, 
                SA_Type, PUBLICSCREEN,
                SA_AutoScroll, TRUE,
                SA_Title, (IPTR)PROGNAME,
                SA_PubName, (IPTR)PROGNAME,
                SA_ShowTitle, FALSE,
                SA_LikeWorkbench, TRUE,
                SA_FullPalette, TRUE,
                SA_SharePens, TRUE,
                SA_Pens, (IPTR)&empty,
                TAG_DONE)))
           {
           PubScreenStatus(scr->screen, 0);
           scr->screentype = CUSTOMSCREEN;
           scr->modeID = id;
           success = TRUE;
           }
      }
}

if (defscreen)
    {
    UnlockPubScreen(NULL, defscreen);
    }
}

//else
		
if (!success)
    {
    if (!success)
        {
        if (mvs->scropenmode == SCROPENMODE_PUBLIC)
            {
            if ((scr->screen = LockPubScreen(mvs->pubscreen)))
                {
                ScreenToFront(scr->screen);
                success = TRUE;
                }
            }
        }

        if (!success)
            {
            success = !!(scr->screen = LockPubScreen(NULL));		
            }

        if (success)
            {
            scr->screentype = PUBLICSCREEN;
            scr->modeID = GetVPModeID(&scr->screen->ViewPort);
            }
      }

屏幕参考

[编辑 | 编辑源代码]

屏幕标签

[编辑 | 编辑源代码]
SA_Left - Default is 0
SA_Top - Default is 0
SA_Width - Default depends on display 
SA_Height - Default depends on display 
SA_Depth - Select depth of screen. This specifies how many colors the screen can display. Default 1

SA_DetailPen - Pen number for details. Default is 0 (obsolete)
SA_BlockPen - Pen number for block fills. Default is 1 (obsolete)

SA_Title (STRPTR) - Default NULL
SA_Font (struct TextAttr *) - user's preferred monospace font. Default NULL 
SA_BitMap (struct BitMap *) - Provide a bitmap 
SA_ShowTitle (BOOL) - Default TRUE

SA_Behind (BOOL) - Screen will be created behind other open screens. Default is FALSE

SA_Quiet (BOOL) - Intuition does not draw any system gadgets and screen title. Defaults is FALSE

SA_Type - PUBLICSCREEN or CUSTOMSCREEN

SA_DisplayID - 32-bit display mode ID

SA_Overscan - Set an overscan mode. Possible values OSCAN_TEXT (default) - OSCAN_STANDARD - OSCAN_MAX - OSCAN_VIDEO 
SA_DClip (struct Rectangle *) - Define a DisplayClip region - see SA_Overscan above

SA_AutoScroll (BOOL) - Screens can be larger than the DisplayClip region. Set this tag TRUE if automatic scrolling

SA_PubName (STRPTR)  - Make this screen a public screen with the given name. Screen is opened in "private" mode 
SA_PubTask (struct Task *) - Task to be signalled, when last visitor window of a public screen is closed 
SA_PubSig (UBYTE) - Signal number used to notify a task when the last visitor window of a public screen is closed

SA_Colors (struct ColorSpec *) - Screen's initial color palette. Array must be terminated with ColorIndex = -1

SA_FullPalette (BOOL) - Intuition maintains a set of 32 preference colors. Default is FALSE

SA_ErrorCode (ULONG *) - OSERR_NOMONITOR, OSERR_NOCHIPS, OSERR_NOMEM, OSERR_NOCHIPMEM, OSERR_PUBNOTUNIQUE, OSERR_UNKNOWNMODE, OSERR_TOODEEP, OSERR_ATTACHFAIL

SA_SysFont - Select screen font type. overwrites SA_Font. 0=Fixed-width font, 1=Font set by font prefs

SA_Parent (struct Screen *) - Attach the screen to the given parent screen 
SA_FrontChild (struct Screen *) - Attach given child screen to this screen  
SA_BackChild (struct Screen *) - Attach given child screen to this screen

SA_BackFill (struct Hook *) - Backfill hook (see layers library)

SA_Draggable (BOOL) - Make screen movable. Default is TRUE

SA_Exclusive (BOOL) - False (default) but if TRUE screen must not share the display with other screens

SA_Pens (UWORD *) - Define the pen array for struct DrawInfo. This enables the 3D look - terminates with 0 
SA_SharePens (BOOL) - if FALSE (default) obtains the pens of a public screen with PENF_EXCLUSIVE. if TRUE pens are not set

SA_Colors32 (ULONG *) - Data is sent to graphics.library/LoadRGB32(). Overwrites values which were set by SA_Colors

SA_Interleaved (BOOL) - Request interleaved bitmap. It this fails a non-interleaved bitmap will be allocated

SA_VideoControl (struct TagItem *) - Taglist which will be  passed to VideoControl() after the screen is open 
    SA_ColorMapEntries =  Number of entries of the ColorMap. Default 1<<depth, but not less than 32

SA_LikeWorkbench (BOOL) - Inherit depth, colors, pen-array, screen mode, etc. from the WB replacement screen

SA_MinimizeISG (BOOL) - Minimize the Inter-Screen Gap 

下面是另一个已经设置在 AROS 中的公共结构,它是一个模板,可以在编程中快速使用。

struct Window
{
   struct Window *NextWindow;                   /* for the linked list to next Window */
   WORD LeftEdge, TopEdge, Width, Height;       /* window dimensions */
   WORD MouseY, MouseX;                         /* relative top top-left corner */
   WORD MinWidth, MinHeight;                    /* minimum sizes */
   UWORD MaxWidth, MaxHeight;                   /* maximum sizes */
   ULONG Flags;
   struct Menu *MenuStrip;                      /* first in a list of menu headers */
   UBYTE *Title;                                /* title text for the Window */
   struct Requester *FirstRequest, *DMRequest;  /* first in linked list of active reqs - the double-menu Requester */
   WORD ReqCount;                               /* number of Requesters blocking this Window */ 
   struct Screen *WScreen;                      /* this Window's Screen */

   /* Each window has one RastPort but within each RastPort a BitMap pointer. */
   struct RastPort *RPort;
   BYTE BorderLeft, BorderTop, BorderRight, BorderBottom;
   struct RastPort *BorderRPort;
   struct Gadget *FirstGadget;

   /* these are for opening/closing the windows */
   struct Window *Parent, *Descendant;

   /* sprite data information for your own Pointer set these AFTER you Open the Window by calling SetPointer() */
   UWORD *Pointer;
   BYTE PtrHeight, PtrWidth;
   BYTE XOffset, YOffset;

   /* the IDCMP Flags and User's and Intuition's Message Ports */
   ULONG IDCMPFlagS;
   struct MsgPort *UserPort, *WindowPort;
   struct IntuiMessage *MessageKey;
   UBYTE DetailPen, BlockPen;

   /* the CheckMark is a pointer to the imagery that will be used when rendering MenuItems of this Window checkmarked - if this is equal to NULL, you'll get the default imagery */
   struct Image *CheckMark;

   /* if non-null, Screen title when Window is active */
   UBYTE *ScreenTitle;

   WORD GZZMouseX, GZZMouseY, GZZWidth, GZZHeight;
    ; general-purpose pointer to User data extension
   UBYTE *ExtData;
   BYTE *UserData;

   struct Layer *WLayer;               /* stash of Window.RPort->Layer */
   struct TextFont *IFont;
   ULONG MoreFlags;
};

设置好屏幕后,你可以在该屏幕上创建任意数量的窗口。

打开窗口与打开屏幕非常相似,OpenWindowTags() 以及窗口标签...

屏幕标签以 SA_ 开头,窗口标签以 WA_ 开头,而 WA_IDCMP 和 WA_Flags 则有进一步的子标签。列表将在后面给出...

因此,当我执行 window->Width / rport->TxWidth 时,列数最终会大于可见区域,因此文本会超出屏幕,高度也是如此。有没有办法获取窗口大小减去附加的小部件/工具的大小?对于非无边框窗口(即普通窗口),可用宽度为 w->Width - w->BorderLeft - w->BorderRight,高度为 w->Height - w->BorderTop - w->BorderBottom。

对于 GimmeZeroZero 窗口,使用 w->GZZWidth 和 w->GZZHeight 代替 w->Width 和 w->Height。GZZWidth 和 GZZHeight 也为非 GZZ 窗口维护。您无需自己计算它们。

要能够调整窗口大小,您需要设置 WA_MinWidth、WA_MinHeight、WA_MaxWidth 和 WA_MaxHeight,因为它们都默认设置为 WA_Width 或 WA_Height。

窗口示例

[编辑 | 编辑源代码]

对于 AROS,您应该省略所有常见的 #?Base(GfxBase、IntuitionBase、DOSBase 等)声明以及它们对应的“OpenLibrary() & CloseLibrary()”调用,因为 AROS GCC 编译器会在看到引用时自动为您打开和关闭它们。大多数核心库会由编译器自动打开。

这仅供背景知识。打开库时,它将返回指向库结构或该库的特定基础结构的指针,否则将返回 NULL 值。转换旧的 Commodore 示例可能是了解 Amiga 程序与 AROS 程序差异的好方法。注意,由于 OpenLibrary、CloseLibrary 和 #?base 的问题,这些旧示例需要编辑... 过去,要关闭库,请使用 CloseLibrary() 函数并提供在 OpenLibrary() 中返回的指向库或基础结构的指针。通常的做法是在尝试关闭库之前测试它是否已打开。

请参阅 AROS 网站示例、Aros/Developer/Docs/Examples/SimpleWindowIntuition 和 这里

#include <proto/exec.h>
#include <exec/libraries.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <intuition/intuition.h>

int main(int argc, char *argv[])
{
    int error = RETURN_OK;

    /* makes a copy of the Window struct(ure) and calls that copy win, changes are made to this copy */ 
    struct Window *win;

    /* describe the copy window 'win' looks like by using tags WA_?, this is separate from the struct stuff above */ 
    win = OpenWindowTags
    (
        NULL, WA_Width, 200, WA_Height, 100,
        WA_Title, "Hello World!", TAG_DONE
    );
    if( win )
            {
                /* Now wait for two seconds, so we can look at our nice window.
                */
                Delay(100);

                /* We close our window again. */
                CloseWindow(win);
            }

    return error;
}

窗口参考

[编辑 | 编辑源代码]
struct TagItem + OpenWindowTagList()  Open a window. Not used much see below...
OpenWindowTags()  Alternate calling sequence for OpenWindowTagList(). 
CloseWindow()  Close a window.

BeginRefresh()  Turn on optimized window refresh mode. 
EndRefresh()  Turn off optimized window refresh mode. 
RefreshWindowFrame()  Redraw the borders and border gadgets of an open window.

ActivateWindow()  Make an open window active. 
SizeWindow()  Change the size of an open window. 
MoveWindow()  Change the position of an open window.

ChangeWindowBox()  Change the size and position of an open window.  
WindowLimits()  Change the minimum and maximum sizes of an open window. 
WindowToBack()  Move a window behind all other windows. 
WindowToFront()  Move a window in front of all other windows. 
MoveWindowInFrontOf()  Move a window in front of another window.

ZipWindow()  Change the size of window to its alternate size.  
SetWindowTitles()  Change the window titles for the window and the screen. 
SetPointer()  Set up a custom pointer to display whenever the window is active. 
ClearPointer()  Restore the mouse pointer to its default imagery. 

窗口标签

[编辑 | 编辑源代码]
 
WA_Left      - Left edge of the window
WA_Top       - Top edge of the window
WA_Width     - Width of the window
WA_Height    - Height of the window
WA_DetailPen - Pen number for window details (obsolete)
WA_BlockPen  - Pen number for filled blocks (obsolete)
WA_IDCMP     - Define what events should send messages to your task
    IDCMP_CLOSEWINDOW - Check if the Window Close button has been pressed. If so, then close down program 
    IDCMP_GADGETUP - Check to see if a Gadget has been pressed AND released 
    IDCMP_GADGETDOWN - Check to see if a Gadget has been pressed (but not released yet) - Not often used 
    IDCMP_MENUPICK - Check to see if a menu item has been selected 
    IDCMP_ACTIVEWINDOW - Check to see if Window has been activated (clicked on title bar) 
    IDCMP_MOUSEMOVE - Check if mouse moves (useful to keep track of x,y position) 
    IDCMP_NEWSIZE - Check to see if window has been resized

    IDCMP_VANILLAKEY - Check to see if a key on keyboard has been pressed 
    IDCMP_RAWKEY - 
    IDCMP_NEWPREFS - 
    IDCMP_DISKINSERTED - Check to see if a floppy disk has been inserted, probably ready for saving 
    IDCMP_DISKREMOVED - message type is broadcast to all IDCMP that have this flag set, not just active win 
    IDCMP_INTUITICKS - 
    IDCMP_IDCMPUPDATE - 
    IDCMP_CHANGEWINDOW - 
    IDCMP_LONELYMESSAGE - system use only

WA_Flags - 
    WFLG_SIZEGADGET, WFLG_DRAGBAR, WFLG_DEPTHGADGET, WFLG_CLOSEGADGET 
    WFLG_BORDERLESS, WFLG_ACTIVATE, WFLG_NEWLOOKMENUS

WA_Gadgets (struct Gadget *) - Pointer to a linked list of gadgets (WB 2.0 only)

WA_Title (STRPTR) - Window title string

WA_CustomScreen (struct Screen *) - Open window on the given screen

WA_MinWidth
WA_MinHeight
WA_MaxWidth
WA_MaxHeight

WA_SizeGadget (BOOL)  - Make window resizeable
WA_DragBar (BOOL)     - Make window dragable
WA_DepthGadget (BOOL) - Add a depth gadget
WA_CloseGadget (BOOL) - Add a close gadget

WA_Backdrop (BOOL) - Create a window which is placed behind other windows

WA_ReportMouse (BOOL) - Store mouse position in struct Window

WA_NoCareRefresh (BOOL) - Use this if you don't want to be responsible for calling BeginRefresh()/EndRefresh()

WA_Borderless (BOOL) - Create borderless window

WA_Activate (BOOL) - Make this window the active one, i.e. it receives the input from mouse and keyboard

WA_RMBTrap (BOOL) - Set to TRUE if you want to get button events events for the right mouse button

WA_SimpleRefresh (BOOL) - Enable simplerefresh mode. Only specify if TRUE

WA_SmartRefresh (BOOL) - Enable smartrefresh mode. Only specify if TRUE

WA_SuperBitMap (struct BitMap *) - Create window with superbitmap refreshing, 0 to keep the current size as limit

WA_SizeBRight (BOOL)    - Place size gadget in right window border 
WA_SizeBBottom (BOOL)   - Place size gadget in bottom window border

WA_GimmeZeroZero (BOOL) - Create a GimmeZeroZero window

WA_NewLookMenus (BOOL) - Use DrawInfo colors for rendering the menu bar

WA_ScreenTitle (STRPTR) - Screen title which is shown when window is active

WA_AutoAdjust (BOOL) - usually TRUE make the window to fit on the screen, wrt WA_MinWidth and WA_MinHeight

WA_InnerWidth
WA_InnerHeight - Dimensions of the interior region of the window - this restricts border gadgets 
    GACT_LEFTBORDER gadgets can't be GFLG_RELWIDTH if WA_InnerWidth is used 
    GACT_RIGHTBORDER gadgets must be GFLG_RELRIGHT if WA_InnerWidth is used 
    GACT_TOPBORDER gadgets can't be GFLG_RELHEIGHT if WA_InnerHeight is used 
    GACT_BOTTOMBORDER gadgets must be GFLG_RELBOTTOM if WA_InnerHeight is used

WA_PubScreen (struct Screen *) - Open the window on the public screen - NULL being WB replacement
WA_PubScreenName (STRPTR) - Open the window on the public screen (name) 
WA_PubScreenFallBack (BOOL) - if TRUE fallback to default public screen if other public screen is not available

WA_Zoom (WORD *) - 4 WORDs set Left Top Width Height of the other zoom position - also adds zoom gadget

WA_MouseQueue - Limits the number of possible mousemove messages. Can be changed with SetMouseQueue()

WA_RptQueue - Limits the number of possible repeated IDCMP_RAWKEY, IDCMP_VANILLAKEY and IDCMP_IDCMPUPDATE messages

WA_BackFill (struct Hook *) - Function to be called for backfilling

WA_MenuHelp (BOOL) - Enables menuhelp. Pressing the help key during menu handling sends IDCMP_MENUHELP messages.

WA_NotifyDepth (BOOL) - If TRUE send IDCMP_CHANGEWINDOW events when window is depth arranged. Code field=CWCODE_DEPTH

WA_Checkmark (struct Image *) - Image to use as a checkmark in menus 
WA_AmigaKey (struct Image *) - Image to use as the Amiga-key symbol in menus

WA_Pointer (APTR) - The pointer to associate with the window. Use NULL for the Preferences default pointer 
WA_BusyPointer (BOOL) - Enable the Preferences busy-pointer. Default is FALSE
WA_PointerDelay (BOOL) - Set this to TRUE to delay change of the pointer image - prevents flickering

WA_HelpGroup (ULONG) - Get IDCMP_GADGETHELP messages from the active window and all other windows 
WA_HelpGroupWindow (struct Window *) - Similar for WA_HelpGroup. Use the helpgroup of another window

WA_TabletMessages (BOOL) - Request extended tablet data - Default is FALSE

WA_ToolBox (BOOL) - Make this window a toolbox window

WA_Parent (struct Window *) - Make the window a child of the given window.

WA_Visible (BOOL) - Make window visible Default is TRUE

WA_Shape (struct Region *) - 
WA_ShapeHook (struct Hook *) - 

事件处理

[编辑 | 编辑源代码]

窗口可以接收发往它的事件。通常的做法是让应用程序请求 Intuition 发送消息,这些消息基于 Intuition 已处理的输入事件。这些消息称为 IntuiMessages,是标准的 Amiga Exec 消息,并且发送到一个名为 Intuition Direct Communications Message Port(IDCMP)的端口。每个窗口都可能与它关联一个 IDCMP。虽然 AmigaOS(TM) 从 Intuition 事件开始,但 AROS 也为向后兼容性目的纳入了这些事件,但建议使用 Zune,请参阅这里 Zune

a) Wait for signal from the current Active Window 
b) If a signal has been sent, get the Message data structure 
c) Reply to the message, so that message is removed from the queue and is being dealt with. 
d) Determine the message class (or gadget or event) occurred by comparing class value with IDCMP flags
e) Do some user processing with that event.

Intuition 事件

输入 = 硬件设备 -> HIDD 或 .device -> 事件处理程序 -> IDCMP 或控制台 -> 应用程序

输出 = 应用程序 -> 控制台或 Intuition -> 图形库 -> 显示器

应用程序将通过任何 Intuition 事件收到发往它的消息。这些消息(IntuiMessages)是标准的 Exec 消息,并且发送到一个名为 IDCMP 的端口。每个窗口都可能/将与它关联一个 IDCMP(Window->UserPort)。键不会在窗口中自动工作。您必须通过 WA_IDCMP 标签进行设置。

struct IntuiMessage
      {
      struct Message ExecMessage;
      ULONG Class;
      UWORD Code;
      UWORD Qualifier;
      APTR IAddress;
      WORD MouseX, MouseY;
      ULONG Seconds, Micros;
      struct Window *IDCMPWindow;
      struct IntuiMessage *SpecialLink;
      };
  • IDCMP_VANILLAKEY - 事件提供简单的 ASCII 文本和标准控制键,如空格键、回车键和退格键
  • IDCMP_RAWKEY - 返回所有按键代码,包括按键按下和松开,包括功能键(是指键盘、移动、工具(关闭/调整大小)和其他许多东西)
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>

int main (void)

{
/* set up variables to be used in this function */
struct Window *win;
struct IntuiMessage *mess;
BOOL cont;
BOOL lbutton;
BOOL rbutton;
long old_x;
long old_y;
long x;
long y;

win = OpenWindowTags (NULL,
		WA_Left,112,
		WA_Top,84,
		WA_Width,800,
		WA_Height,600,
		WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_RMBTRAP | WFLG_REPORTMOUSE | WFLG_ACTIVATE | WFLG_GIMMEZEROZERO | WFLG_NOCAREREFRESH,
		WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE,
		WA_MinWidth,80,WA_MinHeight,40,
		WA_MaxWidth,-1,WA_MaxHeight,-1,
		TAG_END);

/* if (win==NULL)  { */
if (!win)
	{
	Printf ("cannot open window\n");
	return (RETURN_FAIL);
	}

rbutton = FALSE;
lbutton = FALSE;
x = win->MouseX;
y = win->MouseY;
old_x = x;
old_y = y;

cont = TRUE;
do	{
	if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
		cont = FALSE;

	while (mess = (struct IntuiMessage *) GetMsg (win->UserPort))
		{
		switch (mess->Class)
			{
		case IDCMP_MOUSEMOVE:
			x = mess->MouseX - win->BorderLeft;;
			y = mess->MouseY - win->BorderTop;
			break;
		case IDCMP_MOUSEBUTTONS:
			switch (mess->Code)
				{
			case SELECTDOWN:
				lbutton = TRUE;
				break;
			case SELECTUP:
				lbutton = FALSE;
				break;
			case MENUDOWN:
				rbutton = TRUE;
				break;
			case MENUUP:
				rbutton = FALSE;
				break;
				}
			break;
		case IDCMP_VANILLAKEY:
			if (mess->Code == 0x1b) /* Esc */
				cont = FALSE;
			break;
		case IDCMP_CLOSEWINDOW:
			cont = FALSE;
			break;
			}
		ReplyMsg ((struct Message *)mess);
		}

	if (x != old_x || y != old_y)
		{
		if (rbutton && lbutton)
			{
			SetAPen (win->RPort,3);
			Move (win->RPort,old_x,old_y);
			Draw (win->RPort,x,y);
			}
		else if (rbutton)
			{
			SetAPen (win->RPort,2);
			Move (win->RPort,old_x,old_y);
			Draw (win->RPort,x,y);
			}
		else if (lbutton)
			{
			SetAPen (win->RPort,1);
			Move (win->RPort,old_x,old_y);
			Draw (win->RPort,x,y);
			}
		old_x = x;
		old_y = y;
		}
	}
while (cont);

CloseWindow (win);

return (RETURN_OK);
}
在这里了解有关按键代码的更多信息 https://wikibooks.cn/wiki/Aros/Developer/Docs/Libraries/Keymap
  /* loop for each frame */
  while (loop) {

    /* check for input */
    while ((msg = (struct IntuiMessage *)GetMsg (w->UserPort)) != NULL) {

       /* After we have successfully collected the message we can read */
       /* it, and save any important values which we maybe want to check later */
       class = msg->Class;  /* IDCMP flag */ 
       code = msg->Code;

      /* After we have read it we reply as fast as possible: */
      /* REMEMBER! Do never try to read a message after you have replied! */
      /* (Some other process has maybe changed it.) */
      ReplyMsg ((struct Message *)msg);

      switch (class) {
        case IDCMP_VANILLAKEY:

          switch (code) {
            case 0x03: /* CTRL/C */
            case 0x1b: /* ESC */
            case 'q':  /* q */
            case 'Q':  /* Q */
              break;
            default:
              break;
          }
          break;
        case IDCMP_RAWKEY:
          switch (code) {
            case 0x11: /* W */
              break;
            case 0x20: /* A */
              break;
            case 0x21: /* S */
              break;
            case 0x22: /* D */
              break;

            case 0x50: /* F1 */
              break;
            case 0x51: /* F2 */
              break;
            case 0x52: /* F3 */
              break;
            case 0x53: /* F4 */
              break;
            case 0x54: /* F5 */
              break;
            case 0x55: /* F6 */
              break;
            case 0x56: /* F7 */
              break;
            case 0x57: /* F8 */
              break;
            case 0x58: /* F9 */
              break;
            case 0x59: /* F10 */
              break;
            default:
              break;
          }
          break;
        case IDCMP_MOUSEBUTTONS:
          if (code == MENUDOWN)
            loop = FALSE;
          break;
        default:
          break;
      }
    }

INTUITICKS

[编辑 | 编辑源代码]

基本上,创建了一个 IDCMP 循环来检查用户输入和/或计时器事件。然后您可能设置了一个计时器设备调用,该调用将为您提供这些事件。您必须使用 IDCMP_INTUITICKS(“滴答”每秒大约十次)更新您的窗口内容。这些滴答事件应作为唤醒调用使用,而不是作为计时器使用。

case IDCMP_GADGETUP:
  gadget_down_happened=FALSE;
  break;
case IDCMP_GADGETDOWN:
  gadget_down_happened=TRUE;
  break;
case IDCMP_INTUITICKS:
  if(gadget_down_happened) {
    update_window_contents();
  }
  break;
        case IDCMP_INTUITICKS:
            /*
             *  If the user is NOT holding the LMB down, then we'll
             *  report this event back to the program in order not to confuse
             *  the select box drawing routines.
             */
            if( !(imsg->Qualifier & IEQUALIFIER_LEFTBUTTON))
                method = GID_DW_INTUITICKS;
            break;

当然,您可能只想在每 3 个 Intuition 滴答中更新一次内容,例如,并且仅在比例工具已更改时更新。

数位板

[编辑 | 编辑源代码]

Intuition 中定义的旧式和新式数位板事件

系统对数位板的支持始于 WB 2.x。当时,数位板驱动程序应该将信息作为事件发送到输入设备,例如 (X,Y) 范围和坐标以及压力。这种方法现在被称为旧式数位板事件。

从 WB3.0 开始,定义了一种新型数位板事件来支持更多数位板功能,例如接近度、倾斜度等。这种方法被称为新式数位板事件。

所有 IntuiMessages 现在都略微扩展了。ExtIntuiMessage 结构有一个用于数位板数据的额外字段,该字段通常为 NULL。如果系统中安装了发送 IESUBCLASS_NEWTABLET 事件的数位板驱动程序,则设置了 WA_TabletMessages 属性的窗口将发现 eim_TabletData 指向 TabletData 结构。应用程序必须首先检查该字段是否非 NULL;对于某些类型的消息(包括来自数位板以外的其他来源生成的鼠标活动(即键盘等效项或鼠标本身)),它将为 NULL。

    struct IntuiMessage
        {
        struct Message ExecMessage;
        ULONG Class;
        UWORD Code;
        UWORD Qualifier;
        APTR IAddress;
        WORD MouseX, MouseY;
        ULONG Seconds, Micros;
        struct Window *IDCMPWindow;
        struct IntuiMessage *SpecialLink;
        };
struct ExtIntuiMessage
{
    struct IntuiMessage eim_IntuiMessage;
    struct TabletData *eim_TabletData;
};

WA_TabletMessages - (BOOL)设置为 TRUE 以请求为您的窗口扩展 IntuiMessages。如果数位板驱动程序正在生成 IESUBCLASS_NEWTABLET 输入事件,您将能够使用大多数 IntuiMessages 接收扩展的数位板信息。请参阅 ExtIntuiMessage 结构的 eim_TabletData 字段。默认为 FALSE。(V39)

#define WA_TabletMessages   TRUE 

(WA_Dummy + 0x37)是一个布尔值。设置为 TRUE 以请求将数位板信息包含在发送到您的窗口的 IntuiMessages 中。要求某些东西(即数位板驱动程序)将 IESUBCLASS_NEWTABLET InputEvents 提供给系统。要获得指向 TabletData 的指针,请检查 ExtIntuiMessage->eim_TabletData 字段。

struct TabletData
{
    UWORD td_XFraction;
    UWORD td_YFraction;
    ULONG td_TabletX;
    ULONG td_TabletY;
    ULONG td_RangeX;
    ULONG td_RangeY;

    struct TagItem * td_TagList; /* see below */
};

/* Tags */
#define TABLETA_Dummy	    (TAG_USER + 0x3A000)
#define TABLETA_TabletZ     (TABLETA_Dummy + 0x01)
#define TABLETA_RangeZ	    (TABLETA_Dummy + 0x02)
#define TABLETA_AngleX	    (TABLETA_Dummy + 0x03)
#define TABLETA_AngleY	    (TABLETA_Dummy + 0x04)
#define TABLETA_AngleZ	    (TABLETA_Dummy + 0x05)
#define TABLETA_Pressure    (TABLETA_Dummy + 0x06)
#define TABLETA_ButtonBits  (TABLETA_Dummy + 0x07)
#define TABLETA_InProximity (TABLETA_Dummy + 0x08)
#define TABLETA_ResolutionX (TABLETA_Dummy + 0x09)
#define TABLETA_ResolutionY (TABLETA_Dummy + 0x0a)

struct TabletHookData
{
    struct Screen * thd_Screen;
    ULONG	    thd_Width;
    ULONG	    thd_Height;
    LONG	    thd_ScreenChanged;
};

Intuition 支持 IECLASS_NEWPOINTERPOS 事件的 IESUBCLASS_NEWTABLET 子类。此类事件的 ie_EventAddress 指向 TabletData 结构

TabletData 结构包含某些元素,包括一个标签列表。标签列表可用于特殊的数位板参数。数位板驱动程序应该只包含数位板支持的标签项。应用程序可以监听它感兴趣的任何标签项。注意:应用程序必须将 WA_TabletMessages 属性设置为 TRUE 以在其 IntuiMessages 中接收此扩展信息。

这里给出的定义必须遵守。请仔细注意归一化和符号的解释。

TABLETA_TabletZ:数位板在 Z 方向上的当前值。此无符号值通常应该使用数位板的自然单位。您还应该提供 TABLETA_RangeZ。

TABLETA_RangeZ:数位板在 Z 方向上的最大值。通常与 TABLETA_TabletZ 一起指定,这允许应用程序在其范围内缩放实际 Z 值。

TABLETA_AngleX:围绕 X 轴的旋转或倾斜角度。此数字应归一化为填充有符号长整数。正值表示从 +X 方向看向原点时围绕 X 轴的顺时针旋转。

TABLETA_AngleY:围绕 Y 轴的旋转或倾斜角度。此数字应归一化为填充有符号长整数。正值表示从 +Y 方向看向原点时围绕 Y 轴的顺时针旋转。

TABLETA_AngleZ:围绕 Z 轴的旋转或倾斜角度。此数字应归一化为填充有符号长整数。正值表示从 +Z 方向看向原点时围绕 Z 轴的顺时针旋转。

注意:支持倾斜的触控笔应使用 TABLETA_AngleX 和 TABLETA_AngleY 属性。将触控笔倾斜使笔尖指向 X 轴增大或减小的方向实际上是绕 Y 轴旋转。因此,如果触控笔笔尖指向正 X 轴,则该倾斜表示为负 TABLETA_AngleY。同样,如果触控笔笔尖指向正 Y 轴,则该倾斜表示为正 TABLETA_AngleX。

TABLETA_Pressure:触控笔的压力读数。压力应规范化为填充有符号的长整型。典型设备不会产生负压力,但不能排除这种可能性。预计压力阈值将在平板电脑供应商提供的偏好程序中设置,以被视为导致按钮单击。当压力超过该阈值时,平板电脑驱动程序将发送 IECODE_LBUTTON 类型的事件。

TABLETA_ButtonBits:ti_Data 是一个长整型,其位应被解释为平板电脑前 32 个按钮的状态。

TABLETA_InProximity:ti_Data 是一个布尔值。对于支持邻近度的平板电脑,当触控笔不在邻近度内时,它们应该发送 TABLETA_InProximity,FALSE} 标签项。可以用作鼠标空白商品,它以此为键来空白鼠标。当此标签不存在时,假设触控笔在邻近度内。

TABLETA_ResolutionX:ti_Data 是一个无符号长整型,表示以每英寸点数为单位的 X 轴分辨率。

TABLETA_ResolutionY:ti_Data 是一个无符号长整型,表示以每英寸点数为单位的 Y 轴分辨率。

IntuiText

[编辑 | 编辑源代码]
struct IntuiText
{
UBYTE FrontPen, BackPen;    /* the pen numbers for the rendering */
UBYTE DrawMode;             /* the mode for rendering the text */
WORD LeftEdge;              /* relative start location for the text */
WORD TopEdge;               /* relative start location for the text */
struct TextAttr *ITextFont; /* if NULL, you accept the default */
UBYTE *IText;               /* pointer to null-terminated text */
struct IntuiText *NextText; /* pointer to another IntuiText to render */
};
dri_Pens[TEXTPEN];
	    myBACKGROUNDPEN  = drawinfo->dri_Pens[BACKGROUNDPEN];

	    /* create a TextAttr that matches the specified font. */
	    myTextAttr.ta_Name	= drawinfo->dri_Font->tf_Message.mn_Node.ln_Name;
	    myTextAttr.ta_YSize = drawinfo->dri_Font->tf_YSize;
	    myTextAttr.ta_Style = drawinfo->dri_Font->tf_Style;
	    myTextAttr.ta_Flags = drawinfo->dri_Font->tf_Flags;

	    /* open a simple window on the workbench screen for displaying a text string.  
              An application would probably never use such a window, but it is useful for demonstrating graphics...
	    */

	    if ((win = OpenWindowTags(NULL,
				WA_PubScreen,	 (IPTR)screen,
				WA_RMBTrap,	 TRUE,
				WA_IDCMP,	 IDCMP_RAWKEY,
				TAG_END)))

		{
		myIText.FrontPen    = myTEXTPEN;
		myIText.BackPen     = myBACKGROUNDPEN;
		myIText.DrawMode    = JAM2;
		myIText.LeftEdge    = MYTEXT_LEFT;
		myIText.TopEdge     = MYTEXT_TOP;
		myIText.ITextFont   = &myTextAttr;
		myIText.IText	    = "Hello, World.  ;-)";
		myIText.NextText    = NULL;

		/* Draw the text string at 10,10 */
		PrintIText(win->RPort,&myIText,10,10);

		/* Wait for keypress */
		Wait (1L << win->UserPort->mp_SigBit);

		CloseWindow(win);
		}
	    FreeScreenDrawInfo(screen,drawinfo);
	    }
	UnlockPubScreen(NULL,screen);
	}
    return 0;
}

图形用户界面系统

[编辑 | 编辑源代码]

尽管 AmigaOS(TM) 最初是基于直觉的菜单、小工具、请求器和事件。

Amiga 引入了许多替代方案,如 GadTools、BOOPSI、ASL、BGui、ReqTools、ClassAct 和 MUI。AROS 选择了 MUI 重写(Zune)作为默认图形用户界面工具集,例如 Zune(MUI)菜单。

本页的其余部分包含信息(仅限基于直觉的内容),仅供向后兼容使用。

定义菜单

[编辑 | 编辑源代码]

如果你想定义自己的菜单,我认为 intuition.library 也可以满足你的需求,尽管菜单最好留到后面再处理,因为我认为它们过于复杂且容易出错。

对于菜单栏中的每个主菜单标题(即顶部选项),你为每个标题声明一个 Menu 结构。对于菜单中的每个项目或子项目,你为每个项目声明一个 MenuItem 结构。你应该使用比 Menu 更多的 MenuItem。基于文本的菜单需要一个额外的 IntuiText 结构,用于每个菜单和(子)项目。(它们出现最多)。图像菜单需要图像结构。

要使用菜单,你需要使用 Menu 和 MenuItem 结构,然后将它们附加到窗口。请注意,IntuiTexts 和 Image 结构应该在调用它们的 MenuItem 结构之前定义。

struct Menu
{
struct Menu *NextMenu;      /* same level */
WORD LeftEdge, TopEdge;     /* position of the select box */
WORD Width, Height;         /* dimensions of the select box */
UWORD Flags;                /* flag definitions*/
BYTE *MenuName;             /* text for this Menu Header */
struct MenuItem *FirstItem; /* pointer to first in chain */
};
struct MenuItem
{
struct MenuItem *NextItem;   /* pointer to next in chained list */
WORD LeftEdge, TopEdge;      /* position of the select box */
WORD Width, Height;          /* dimensions of the select box */
UWORD Flags;                 /* see the defines below */
LONG MutualExclude;          /* set bits mean this item excludes that */
IPTR ItemFill;               /* points to Image, IntuiText, or NULL */
IPTR SelectFill;             /* points to Image, IntuiText, or NULL */
BYTE Command;                /* only if appliprog sets the COMMSEQ flag */
struct MenuItem *SubItem;    /* if non-zero, points to MenuItem for submenu */
UWORD NextSelect;            /* Menu no of next selected item when drag-selecting items */
};
struct Image
{
WORD LeftEdge;              /* starting offset relative to some origin */
WORD TopEdge;               /* starting offsets relative to some origin */
WORD Width;                 /* pixel size (though data is word-aligned) */
WORD Height;
WORD Depth;                 /* >= 0, for images you create */
UWORD *ImageData;           /* pointer to the actual word-aligned bits */
UBYTE PlanePick, PlaneOnOff;
struct Image *NextImage;
};

向窗口添加和删除菜单

[编辑 | 编辑源代码]

要向窗口添加或删除菜单,你需要使用以下命令

BOOL SetMenuStrip( struct Window *window, struct Menu *menu )

void ClearMenuStrip( struct Window *window )

在定义并打开窗口后使用 SetMenuStrip 命令,并提供窗口地址和链接列表中最后一个 Menu 结构的地址。在关闭窗口之前,你必须首先使用 ClearMenuStrip 命令从屏幕上删除菜单,然后再关闭窗口。将菜单附加到窗口而不是屏幕,可以使你的程序具有灵活性,这样如果你打开了多个窗口,你就可以自定义菜单以适应相应的窗口,例如,在绘画软件或视频程序中,你可以拥有具有自己菜单的较小窗口。

启用和禁用菜单项

[编辑 | 编辑源代码]

可以启用或禁用菜单项,当你不想让用户访问某个菜单功能时。可以使用 OnMenu 和 OffMenu 函数来实现

void OffMenu( struct Window *window, unsigned long menuNumber)

void OnMenu( struct Window *window, unsigned long menuNumber )

只需提供要启用或禁用的项目的菜单编号。如果你更改了菜单项的 CHECKED 或 ITEMENABLED 值,那么你可以使用 ResetMenuStrip 命令刷新菜单,该命令与使用 SetMenuStrip 命令类似,但速度更快。

[编辑 | 编辑源代码]

请求器

[编辑 | 编辑源代码]

AROS 支持几种类型的请求器:原始系统(直觉)和 ASL、ReqTools 和 MUI(推荐)。直觉的 AutoRequest() 和 Request() 函数现在已弃用。

文件请求器不会返回完整路径吗?需要额外的步骤。

EasyRequest

[编辑 | 编辑源代码]

EasyRequest() 提供了一种简单的方法来创建一个请求器,允许用户从有限数量的选择中选择一个。

LONG EasyRequest( struct Window *window, struct EasyStruct *easyStruct, ULONG *idcmpPtr, APTR argl, ... );

LONG EasyRequestArgst struct Window *window, struct EasyStruct *easyStruct, ULONG *idcmpPtr, APTR ergs );

struct EasyStruct
{
       ULONG es_StructSize;
       ULONG es_Flags;
       UBYTE *es_Title;
       UBYTE *es_TextFormat;
       UBYTE *es_GadgetFormat;
};

请求器示例

[编辑 | 编辑源代码]

也可以看看 这里

int amiga_filereq(char *buffer, int len, ...) 
{ 
va_list args; 
LONG result;

  if (FileReq == 0) 
  { 
    if ((FileReq = AllocAslRequestTags(ASL_FileRequest, 
      ASLFR_SleepWindow,1, 
      ASLFR_RejectIcons,1,TAG_DONE)) == 0) 
    { 
      return 0; 
    } 
  }

  va_start(args,len); 
  result = AslRequest(FileReq,(struct TagItem *)args); 
  va_end(args);

  if (result) 
  { 
    strncpy(buffer,FileReq->fr_Drawer,len); 
    AddPart(buffer,FileReq->fr_File,len); 
    return 1; 
  } 
  return 0; 
}
/*  Chaos:                  The Chess HAppening Organisation System     V5.3
    Copyright (C)   1993    Jochen Wiedmann

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    $RCSfile: ProjectAmi.c,v $
    $Revision: 3.4 $
    $Date: 1994/11/19 19:32:01 $

    This file contains the system dependent functions that support the
    Project menu.

    Computer:   Amiga 1200                  Compiler:   Dice 2.07.54 (3.0)

    Author:     Jochen Wiedmann
		Am Eisteich 9
	  72555 Metzingen
		Tel. 07123 / 14881
		Internet: [email protected]
*/

#ifndef CHAOS_H
#include "chaos.h"
#endif

#ifdef AMIGA
#include <libraries/asl.h>
#include <libraries/gadtools.h>
#include <libraries/dos.h>
#include <proto/asl.h>
#include <proto/icon.h>
#endif  /*  AMIGA   */

/*
    FileRequest() creates a file requester which reads a file name.

    Inputs: defaultfile a pointer to a string containing the default name
	    title       a pointer to a string containing the requester's
			title. This may be NULL, in which case
			MSG_CDAT_SELECTION is assumed.
	    ending      a pointer to a string containing the default ending.
			This may be NULL, in which case "#?.cdat" is assumed.
			Note, that this MUST be something like "#?.xxx" on
			the Amiga!
	    savemode    TRUE, if non-existing files may be selected.

    Result: Full path name of the file, that was selected or NULL, if the
	    user cancelled.
*/
char *FileRequest(char *defaultfile, char *title, char *ending, int savemode)

#ifdef AMIGA
{ struct FileRequester *requester;
  char pattern[20];
  char *result = NULL;
  char *filename, *pathname, *endptr;
  BPTR dir;
  static char FileRequestName[TRNFILENAME_LEN+1];
  static char PathName[TRNFILENAME_LEN+1];
  struct Window *window;

  /*
      Bring up default settings, if needed.
  */
  if (title == NULL)
  { title = (char *) MSG_CDAT_SELECTION;
  }
  if (ending == NULL)
  { ending = "#?.cdat";
  }

  /*
      Get Intuition window pointer from MUI window, allocate Filerequester
      and parse the ending for wildcards.
  */
  get(MainWnd, MUIA_Window_Window, &window);
  if ((requester = (struct FileRequester *)
		   MUI_AllocAslRequest(ASL_FileRequest, NULL))  ==  NULL)
  { MemError();
    return(NULL);
  }
  ParsePatternNoCase((UBYTE *) ending, (UBYTE *) pattern, sizeof(pattern));

  /*
      Get default file- and drawername.
  */
  if (defaultfile  &&  *defaultfile != '\0')
  { strcpy(FileRequestName, defaultfile);
  }
  else
  { if (TrnFileName != '\0')
    { strcpy(FileRequestName, TrnFileName);
    }
    else
    { sprintf(FileRequestName, savemode ? "chaos.%d.cdat" : "", NumRounds);
    }
  }
  filename = (char *) FilePart((STRPTR) FileRequestName);
  strcpy(PathName, FileRequestName);
  *(pathname = (char *) PathPart((STRPTR) PathName)) = '\0';

  /*
      Make the drawername absolute.
  */
  dir = Lock((STRPTR) PathName, SHARED_LOCK);
  NameFromLock(dir, (STRPTR) PathName, sizeof(PathName));
  UnLock(dir);

  /*
     Ensure, that the default filename has the right ending.
  */
  if (ending != NULL  &&  (endptr = strrchr(filename, '.')) != NULL)
  { strcpy(endptr, ending+2);
  }

  /*
      Bring up the requester
  */
#ifdef V39_INCLUDES
  if (MUI_AslRequestTags(requester,
			 ASLFR_Window, window,
			 ASLFR_PrivateIDCMP, TRUE,
			 ASLFR_SleepWindow, TRUE,
			 ASLFR_TitleText, title,
			 ASLFR_InitialFile, filename,
			 ASLFR_InitialDrawer, PathName,
			 ASLFR_InitialPattern, ending,
			 ASLFR_DoSaveMode, savemode,
			 ASLFR_RejectIcons, TRUE,
			 ASLFR_AcceptPattern, pattern,
			 TAG_DONE)  !=  FALSE   &&
      requester->fr_File != NULL  &&  requester->fr_File != '\0')
  { strcpy(FileRequestName, (char *) requester->fr_Drawer);
    AddPart((STRPTR) FileRequestName, requester->fr_File,
	    sizeof(FileRequestName));
    result = FileRequestName;
  }
#else
  if (MUI_AslRequestTags(requester,
			 ASL_Window, window,
			 ASL_Hail, title
			 ASL_File, filename,
			 ASL_Dir, PathName,
			 TAG_DONE)  ==  FALSE   &&
      requester->rf_File != NULL  &&  requester->rf_File != '\0')
  { strcpy(FileRequestName, (char *) requester->rf_Dir);
    AddPart((STRPTR) FileRequestName, (STRPTR) requester->rf_File,
	    sizeof(FileRequestName));
    result = FileRequestName;
  }
#endif
  MUI_FreeAslRequest((APTR) requester);
  return (result);
}
#endif  /*  AMIGA   */

/*
    CreateIcon() puts an icon to a recently saved file.

    Inputs: name of the file just created; must not be NULL
*/
void CreateIcon(char *name)

#ifdef AMIGA
{ extern int MakeIcons;

  /*
      Does the user want to have an icon?
  */
  if (MakeIcons)
  { /*
	Yes, get a diskobject
    */
    struct DiskObject *dobj;
    char *olddeftool;
    int len = strlen(IconName);

    /*
	Icon.library doesn't like a trailing ".info" when calling
	GetDiskObject().
    */
    if (len >= 5  &&
	Stricmp((STRPTR) IconName+len-5, (STRPTR) ".info") == 0)
    { IconName[len-5] = '\0';
    }

    if ((dobj = GetDiskObject((STRPTR) IconName))  !=  NULL  ||
	(dobj = GetDiskObject((STRPTR) "s:Chaos_Project"))  !=  NULL  ||
	(dobj = GetDefDiskObject(WBPROJECT))  !=  NULL)
    { /*
	  Put the right settings into the diskobject and save it.
      */
      dobj->do_Type = WBPROJECT;
      olddeftool = dobj->do_DefaultTool;
      dobj->do_DefaultTool = ProgName;
      dobj->do_CurrentX = dobj->do_CurrentY = NO_ICON_POSITION;
      if (dobj->do_StackSize < 20000)
      { dobj->do_StackSize = 20000;
      }
      PutDiskObject((STRPTR) name, dobj);
      dobj->do_DefaultTool = olddeftool;
      FreeDiskObject(dobj);
    }
  }
}
#else   /*  !AMIGA  */
{   /*
	There is nothing to be done on other systems.
    */
}
#endif  /*  !AMIGA  */

/*
    AskSave brings up a requester asking the user, if he wants to save
    first.
*/
int AskSave(void)

#ifdef AMIGA
{
  switch (MUI_RequestA(App, MainWnd, 0,
		       (char *) MSG_ATTENTION,
		       (char *) MSG_YES_NO_CANCEL,
		       (char *) MSG_CHANGES_MADE, NULL))
  { case 2:
      return(TRUE);
    case 1:
      return(SaveTournament(NULL));
  }
  return(FALSE);
}
#endif  /*  AMIGA   */

/*
    The TerminateTrnWnd() function closes the tournament input window.
*/
#ifdef AMIGA
static APTR TrnWnd = NULL; /*  Tournament window                   */
static APTR TrnOkGad;      /*  Ok gadget (tournament window)       */
static APTR TrnCancelGad;  /*  Cancel gadget (tournament window)   */
static APTR TrnNameGad;    /*  Tournament name gadget              */
static APTR WinnerPointsGad; /* Winner points gadget               */
static APTR DrawPointsGad;   /* Draw points gadget                 */

void TerminateTrnWnd(void)

{ if (TrnWnd)
  { set(TrnWnd, MUIA_Window_Open, FALSE);
    DoMethod(App, OM_REMMEMBER, TrnWnd);
    MUI_DisposeObject(TrnWnd);
    TrnWnd = NULL;
  }
}
#endif  /*  AMIGA   */

/*
    The InitTrnWnd() function brings up a window, that allows to input
    tournament data.

    Inputs: name    pointer to a buffer, that can hold the tournament name
	    winnerpoints    current number of points for winning a game
	    drawpoints      current number of points for a draw

    Results: TRUE, if successful, FALSE otherwise
*/
#ifdef AMIGA
#define ID_TrnWnd_Cancel    201
#define ID_TrnWnd_Ok        202
int InitTrnWnd(char *buffer, int winnerpoints, int drawpoints)

{ ULONG open;
  int OK_SC = *MSG_OK_SC;
  int Cancel_SC = *MSG_CANCEL_SC;

  /*
      Open the window and check for success.
  */
  TrnWnd = WindowObject,
	    MUIA_Window_ID, MAKE_ID('T','R','N','I'),
	    MUIA_Window_Title, MSG_TOURNAMENT_INPUT_TITLE,
	    MUIA_Window_Width, MUIV_Window_Width_MinMax(40),
	    WindowContents, VGroup,
		Child, HGroup,
		    Child, Label2(MSG_TOURNAMENT_NAME_OUTPUT),
		    Child, TrnNameGad = StringObject,
			StringFrame,
			MUIA_String_MaxLen, TRNNAME_LEN+1,
			MUIA_String_Contents, buffer,
		    End,
		End,
		Child, VSpace(0),
		Child, HGroup,
		    Child, VGroup,
			Child, Label2(MSG_WINNERPOINTS),
			Child, Label2(MSG_DRAWPOINTS),
		    End,
		    Child, VGroup,
			Child, WinnerPointsGad = StringObject,
			    StringFrame,
			    MUIA_String_MaxLen, 3,
			    MUIA_String_Accept, "0123456789 ",
			    MUIA_String_Integer, winnerpoints,
			End,
			Child, DrawPointsGad = StringObject,
			    StringFrame,
			    MUIA_String_MaxLen, 3,
			    MUIA_String_Accept, "0123456789 ",
			    MUIA_String_Integer, drawpoints,
			End,
		    End,
		    Child, HSpace(0),
		End,
		Child, VSpace(0),
		Child, HGroup,
		    MUIA_Group_SameSize, TRUE,
		    Child, TrnOkGad = KeyButton(MSG_OK, OK_SC),
		    Child, HSpace(0),
		    Child, TrnCancelGad = KeyButton(MSG_CANCEL_INPUT, Cancel_SC),
		End,
	    End,
	End;
  if (!TrnWnd)
  { return(FALSE);
  }
  DoMethod(App, OM_ADDMEMBER, TrnWnd);
  DoMethod(TrnWnd, MUIM_Window_SetCycleChain, TrnNameGad, TrnOkGad,
	   TrnCancelGad, NULL);
  set(TrnWnd, MUIA_Window_ActiveObject, TrnNameGad);

  /*
      Setting up the notification events for the tournament input window:
      CloseWindow, Ok- and Cancel Gadget
  */
  DoMethod(TrnWnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
	   MUIM_Application_ReturnID, ID_TrnWnd_Cancel);
  DoMethod(TrnWnd, MUIM_Notify, MUIA_Window_InputEvent, "ctrl return",
	   App, 2, MUIM_Application_ReturnID, ID_TrnWnd_Ok);
  DoMethod(TrnOkGad, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
	   MUIM_Application_ReturnID, ID_TrnWnd_Ok);
  DoMethod(TrnCancelGad, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
	   MUIM_Application_ReturnID, ID_TrnWnd_Cancel);
  DoMethod(TrnWnd, MUIM_Window_SetCycleChain,
	   TrnNameGad, WinnerPointsGad, DrawPointsGad, TrnOkGad, TrnCancelGad,
	   NULL);
  DoMethod(TrnNameGad, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
	   TrnWnd, 3, MUIM_Set, MUIA_Window_ActiveObject, WinnerPointsGad);
  DoMethod(WinnerPointsGad, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
	   TrnWnd, 3, MUIM_Set, MUIA_Window_ActiveObject, DrawPointsGad);
  DoMethod(DrawPointsGad, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
	   TrnWnd, 3, MUIM_Set, MUIA_Window_ActiveObject, TrnNameGad);

  set(TrnWnd, MUIA_Window_Open, TRUE);
  get(TrnWnd, MUIA_Window_Open, &open);
  if (!open)
  { MUIError((char *) ERRMSG_CANNOT_OPEN_WINDOW);
    TerminateTrnWnd();
    return(FALSE);
  }
  set(TrnWnd, MUIA_Window_ActiveObject, TrnNameGad);

  set(MainWnd, MUIA_Window_Open, FALSE);
  return(TRUE);
}
#endif  /*  AMIGA   */

/*
    The ProcessTrnWnd() function waits for user actions concerning
    the tournament input window.

    Inputs: buffer  pointer to a string, that holds the users input.
		    (Not needed on the Amiga.)
	    winnerpoints    pointer to an int where to store the
			    number of points for winning a game
			    game
	    drawpoints      pointer to an int where to store the
			    number of points for a draw

    Results:    0   Indicates, that the user has cancelled.
		1   Indicates, that this has to be called again.
		-1  Terminating via Ok-Gadget, okay
*/
int ProcessTrnWnd(char *buffer, int *winnerpoints, int *drawpoints)

#ifdef AMIGA
{ ULONG Signal;
  char *name;

  /*
      Check for user actions
  */
  switch (DoMethod(App, MUIM_Application_Input, &Signal))
  { case MUIV_Application_ReturnID_Quit:
      if (TestSaved())
      { exit(0);
      }
      break;
    case ID_TrnWnd_Cancel:
      return(0);
    case ID_TrnWnd_Ok:
      /*
	  Get the final state of the tournament name gadget.
      */
      if (buffer)
      { get(TrnNameGad, MUIA_String_Contents, &name);
	strcpy (buffer, name);
	get(WinnerPointsGad, MUIA_String_Integer, winnerpoints);
	get(DrawPointsGad, MUIA_String_Integer, drawpoints);
      }
      return(-1);
  }
  if (Signal)
  { Wait(Signal);
  }
  return(1);
}
#endif

它非常易于使用,只需要一个要附加的窗口、一个结构、一个指向 IDCMP 标志列表的指针以及可选参数。

struct Requester
{
    struct Requester *OlderRequest;
    WORD LeftEdge, TopEdge;
    WORD Width, Height;
    WORD RelLeft, RelTop;
    struct Gadget *ReqGadget;
    struct Border *ReqBorder;
    struct IntuiText *ReqText;
    UWORD Flags;
       POINTREL
       PREDRAWN
       NOISYREQ
       USEREQIMAGE
       NOREQBACKFILL
       REQOFFWINDOW (the following are library called) 
       REQACTIVE
       SYSREQUEST
    UBYTE Backfill;
    struct Layer *ReqLayer;
    UBYTE ReqPad1[32];
    struct BitMap *ImageBMap;
    struct Window *RWindow;
    struct Image *ReqImage;
    UBYTE ReqPad2[32];
};

请求器参考

[编辑 | 编辑源代码]

BuildSysRequest(Window)

FreeSysRequest (Window)

AutoRequest( Window, BodyText, PosText, NegText, PosFlags, NegFlags, Width, Height)

小工具

[编辑 | 编辑源代码]

每个小工具(用于窗口或请求器)都会创建一个独立的 Gadget 结构

struct Gadget {
    struct Gadget *NextGadget;
    WORD   LeftEdge, TopEdge;
    WORD   Width, Height;
    UWORD  Flags;
    UWORD  Activation;
    UWORD  GadgetType;
        GTYP_BOOLGADGET - Boolean gadget type.
        GTYP_STRGADGET  - String gadget type.  For an integer gadget, also set the GACT_LONGINT flag. 
        GTYP_PROPGADGET - Proportional gadget type.
        GTYP_CUSTOMGADGET - Normally not set by the application.  Used by custom BOOPSI gadget types.

        GTYP_GZZGADGET - If the gadget is placed in a GimmeZeroZero window, will place the gadget in the border layer. 
        GTYP_REQGADGET - Set this bit if this gadget is placed in a requester.
    APTR   GadgetRender;
    APTR   SelectRender;
    struct IntuiText *GadgetText;
    IPTR   MutualExclude;      /* changed from LONG used by BOOPSI gadgets to store dispatcher address */
    APTR   SpecialInfo;
    UWORD  GadgetID;
    APTR   UserData;
};

突出显示标志

GFLG_GADGHNONE - GFLG_GADGHCOMP - GFLG_GADGHBOX - GFLG_GADGHIMAGE -

除了突出显示标志之外,还可以将这些其他值设置在 Gadget 结构的 Flags 字段中。

GFLG_GADGIMAGE - GFLG_RELBOTTOM - GFLG_RELRIGHT - GFLG_RELWIDTH - GFLG_RELHEIGHT - GFLG_SELECTED - GFLG_DISABLED - GFLG_STRINGEXTEND - GFLG_TABCYCLE -

小工具激活标志 - 可以设置在 Gadget 结构的 Activation 字段中。

GACT_TOGGLESELECT GACT_IMMEDIATE GACT_RELVERIFY GACT_ENDGADGET GACT_FOLLOWMOUSE

边框标志

GACT_RIGHTBORDER GACT_LEFTBORDER GACT_TOPBORDER GACT_BOTTOMBORDER

以下标志仅适用于字符串小工具

GACT_STRINGCENTER GACT_STRINGRIGHT GACT_STRINGLEFT GACT_LONGINT GACT_ALTKEYMAP GACT_BOOLEXTEND GACT_STRINGEXTEND


如果你使用老式 struct Gadget,你需要适当地计算和设置 PropInfo 结构的 BODY 和 POT 字段。

阅读更多 gadtools.library

字符串

[编辑 | 编辑源代码]

字符串小工具需要它们自己的特殊结构,称为 StringInfo 结构。对于字符串小工具,将 Gadget 结构中的 GadgetType 字段设置为 GTYP_STRGADGET。将 SpecialInfo 字段设置为指向 StringInfo 结构的实例,该实例必须由应用程序初始化。

struct StringInfo
    {
    UBYTE *Buffer;
    UBYTE *UndoBuffer;
    WORD BufferPos;
    WORD MaxChars;
    WORD DispPos;
    WORD UndoPos;
    WORD NumChars;
    WORD DispCount;
    WORD CLeft, CTop;
    struct StringExtend *Extension;
    LONG LongInt;
    struct KeyMap *AltKeyMap;
    };

自定义

[编辑 | 编辑源代码]

自定义字符串编辑

struct SGWork 
        {
        struct Gadget       *Gadget;
        struct StringInfo   *StringInfo;
        UBYTE               *WorkBuffer;
        UBYTE               *PrevBuffer;
        ULONG               Modes;
        struct InputEvent   *IEvent;
        UWORD               Code;
        WORD                BufferPos;
        WORD                NumChars;
        ULONG               Actions;
        LONG                LongInt;
        struct GadgetInfo   *GadgetInfo;
        UWORD               EditOp;
        };
  EditOp          Action Taken by Global Hook
  ------          ---------------------------
  EO_NOOP         Did nothing.
  EO_DELBACKWARD  Deleted some chars (possibly 0).
  EO_DELFORWARD   Deleted some characters under and in front of the cursor.
  EO_MOVECURSOR   Moved the cursor.
  EO_ENTER        Enter or Return key, terminate.
  EO_RESET        Current Intuition-style undo.
  EO_REPLACECHAR  Replaced one character and (maybe) advanced cursor.
  EO_INSERTCHAR   Inserted one character into string or added one at end.
  EO_BADFORMAT    Didn't like the text data, e.g., alpha characters in a GACT_LONGINT type.
  EO_BIGCHANGE    Complete or major change to the text, e.g. new string.
  EO_UNDO         Some other style of undo.
  EO_CLEAR        Clear the string.
  EO_SPECIAL      An operation that doesn't fit into the categories here.

These are the actions to be taken by Intuition after the hook returns.

  Actions Flag    Purpose
  ------------    -------
  SGA_USE         If set, use contents of SGWork.
  SGA_END         Terminate gadget, Code field is sent to application in IDCMP_GADGETUP event code field.
  SGA_BEEP        Beep (i.e., flash) the screen.
  SGA_REUSE       Reuse the input event.  Only valid with SGA_END.
  SGA_REDISPLAY   Gadget visuals have changed, update on screen.
  SGA_NEXTACTIVE  Make next possible gadget active 
  SGA_PREVACTIVE  Make previous possible gadget active

struct PropInfo
{
    UWORD Flags;
      PROPBORDERLESS - 
      AUTOKNOB - 
      FREEHORIZ and FREEVERT
      PROPNEWLOOK
      KNOBHIT
    UWORD HorizPot;
    UWORD VertPot;
    UWORD HorizBody;
    UWORD VertBody;
    UWORD Cwidth;
    UWORD Cheight;
    UWORD HPotRes, VPotRes;
    UWORD LeftBorder;
    UWORD TopBorder;
};

在 Gadget 结构中,将 GadgetType 字段设置为 GTYP_PROPGADGET,并将 PropInfo 结构的地址放在 SpecialInfo 字段中。

要更改小工具显示后的标志以及 pot 和 body 变量,程序可以调用 NewModifyProp()。

void NewModifyProp(struct Gadget *gadget, struct Window *window, struct Requester *requester,

        unsigned long flags, unsigned long horizPot, unsigned long vertPot,
        unsigned long horizBody, unsigned long vertBody, long numGad );

BOOPSI 非常适合 GUI 内容和运行时类加载/方法分派。它是用 C 编写的,考虑到这种系统语言的限制,设计人员做得非常出色。但是,如果我们从 Amiga 开始就拥有良好的 C++ 支持,当然 BOOPSI 会用它编写。

问题是,BOOPSI 很适合事件驱动代码(例如 GUI),其中用户交互是决定速度的因素。但是,方法分派机制和数据访问方法比 C++ 虚拟函数调用慢得多(由于它们的工作原理),更不用说非虚拟或静态成员函数了。

你不会想在所有 OOP 需要中都依赖 BOOPSI。想象一下在时间关键循环中使用的函数调用的速度损失。哎哟:-)

如果你使用 BOOPSI 滚动条,你可以设置 Total、Visible 和 Top 属性。你还可以让它在用户移动滚动条时向你发送消息。Intuition 自带自己的 BOOPSI 滚动条类 - propgclass。它更好地集成在窗口边框内。

BOOPSI

BOOPSIClasses

似乎还存在将 SA_PubSig 信号发送到 SA_PubTask 的问题。如果调用 UnlockPubScreen 并且这是最后一个锁定,则 SA_PubTask 会收到信号。这与屏幕上的窗口数量无关。

因此,这可能会发生

- Open Pubscreen
- Lock Pubscreen
- Open window on Pubscreen
- UnlockPubscreen
- SA_PubSig is sent!!
- ....
- Close Window

正如你所见中,似乎不需要锁定 pubscreen 才能在其上打开窗口,至少,如果你拥有它的话。

LockPubScreen()  Find Workbench or any other public screen; prevent it from closing while a window is  opened or its attributes copied. 
UnlockPubScreen()  Release the lock allowing the screen to later be closed. 
 struct Screen *LockPubScreen( UBYTE * )
     VOID        UnlockPubScreen( UBYTE * , struct Screen *)

SetDefaultPubScreen()  Establishes a given public screen as the default. 
GetDefaultPubScreen()  Copies the name of the default screen to a user supplied buffer for use by the screen manager utility 
(the name is not needed by normal applications, use LockPubScreen(NULL) instead).

PubScreenStatus()  Converts a screen to private or public status. 
SetPubScreenModes()  Controls the public screen global mode bits. 
 
WBenchToBack()  Move the Workbench screen behind all other screens. 
WBenchToFront()  Move the Workbench screen in front of all other screens.

OpenWorkBench()  Open the Workbench screen.  If the screen is already open, this call has no effect. 
This call will re-awaken the Workbench application if it was active when CloseWorkBench() was called.

CloseWorkBench()  Attempt to reclaim memory used for the Workbench screen.  
If successful, this call closes the screen and puts the Workbench application to sleep. 
This call fails if any application has windows open or locks on the Workbench screen.

LockPubScreenList()  Lock the public screen list maintained by intuition so that it may be quickly copied. 
UnlockPubScreenList()  Release the lock on the public screen list. 
NextPubScreen()  Find the next screen in the public screen list. 

仅限 shell 的应用程序

[编辑 | 编辑源代码]

在 AROS 上,你的正常入口点是 main(int argc, char **argv)。

如果 argc == 0,则 argv 实际上指向 struct WBStartup。

如果 argc > 0,则程序是从 CLI 启动的。

但是,从 CLI 运行的程序 *必须* 对每个 Forbid() 调用 Permit(),因为最终的 'rts' 返回到 shell,而不是终止进程。

尽可能使用信号量。仅当没有其他选择时,才应使用 Forbid()/Permit()。信号量对于访问内存池、可能被其他线程修改的列表等非常有用。

一些程序使用启动新进程并清除 cli_Module 以从运行它们的 shell 中分离的技术。至少对于 FileX(参见 contrib/aminet/disk/moni/filex/main.c),这似乎不再起作用。FileX 仅在使用 SYNC 参数禁用此行为时才起作用。

标准启动代码或 shell 是否支持这种分离?也许 seglist 无论 cli_Module 中放置的值如何都会被卸载。

如果 cli_Module 已被程序清除,是否可以将库在退出时保持打开状态?它们是否可以在分离的进程退出时关闭?实际上不行,因为它不会修复更常见的“拆分段列表”分离方式。

这与 FileX 的做法有什么不同?:-| 我认为 SegmentSplit() 函数名称的相似性具有误导性。是的,FileX 不会做任何段拆分技巧(也许它最初做过了?),它只是清除了 cli_Module。“标准”段列表拆分是拥有 2 个(或更多)段,第一个段中的代码从单链表中删除后续段 -> 只有第一个段被 dos 释放。

当原始进程存在时,aroscbase 被设置为 NULL(猜想它也被释放了)。当然,分离的进程仍在使用它.. 哎哟。我猜想 FileX 没有使用 detach.o?它应该这样做以避免此类问题。

这意味着要包含 aros/detach.h,并且不要链接到标准启动模块,而是链接到 detach.o,正如 Fabio 刚刚所说的。这是在 mmakefile.src 中通过 detach=yes 断言完成的。你甚至可以使用 Detach() 函数选择分离发生的位置。

AmigaOS libnix 仅为 libc I/O 打开自己的控制台。它不会将默认的 dos.library 流重新分配到它。换句话说:当程序从 CLI 启动时,libc I/O(printf()、write()、stdin、stdout 等)将被定向到 dos.library 默认流。当程序从 Workbench 启动时,libc 为自己的 I/O 打开自己的窗口,但不会触及 dos.library 流。因此,当从 WB 启动时,printf() 会将字符串发送到 __stdiowin,但是 Printf() 会将它发送到 NIL:。

#include <proto/exec.h> 
#include <proto/dos.h>
 
int __stack = 0x500000; /* 5 MiB */ 
 
int real_main (int argc, char *argv[]); 
 
int main (int argc, char *argv[])
{ 
    struct Task *mytask = FindTask(NULL); 
    ULONG stacksize = mytask->tc_SPUpper - mytask->tc_SPLower; 
    int rc = 1;
    int i;

    Printf("stack desired: %lu current %lun", __stack, stacksize); 
    Printf("SPUpper %lu SPLower %lu SPReg %lun", mytask->tc_SPUpper, mytask->tc_SPLower, mytask->tc_SPReg);

    Printf("argc %d argv %pn", argc, argv);
 
    for (i = 0; i < argc; i++)
        Printf("argv[%d] = %sn", i, argv[i]);

    if (stacksize >= __stack)
    { 
        Printf("no stack adjustment is necessaryn"); 
        rc = real_main(argc, argv); 
    } 
    else
    { 
        struct StackSwapArgs swapargs;
        struct StackSwapStruct stack;
        
        swapargs.Args[0] = argc;
        swapargs.Args[1] = (IPTR) argv;
        
        Printf("stack was too small, stackswappingn"); 
        
        if (stack.stk_Lower = AllocVec(__stack, MEMF_PUBLIC))
        {
            stack.stk_Upper = stack.stk_Lower + __stack;
            stack.stk_Pointer = stack.stk_Upper;
            
            rc = NewStackSwap(&stack, real_main, &swapargs);
            
            FreeVec(stack.stk_Lower);
        }
        else
        {
            Printf("Couldn't allocate %d bytes for stack.n", __stack);
        }
    }
 
    return rc; 
} 
 
int real_main (int argc, char *argv[])
{ 
    int i;
    struct Task *mytask = FindTask(NULL); 
    ULONG stacksize = mytask->tc_SPUpper - mytask->tc_SPLower;

    Printf("New stack size: %lun", stacksize);
    Printf("SPUpper %lu SPLower %lu SPReg %lun", mytask->tc_SPUpper, mytask->tc_SPLower, mytask->tc_SPReg);
    Printf("argc %d argv %pn", argc, argv);
 
    for (i = 0; i < argc; i++)
        Printf("argv[%d] = %sn", i, argv[i]);
        
    return RETURN_OK; 
}

漫游者

[编辑 | 编辑源代码]

OpenWorkbenchObjectA

start:
wbmsg = NULL;

task = FindTask(NULL)

if (task->pr_CLI == 0 )
{
WaitPort(&task->pr_MsgPort);
wbmsg = GetMsg(&task->pr_MsgPort);
}

; your code here

if ( wbmsg != NULL )
{
Forbid();
ReplyMsg(wbmsg);
}
return return_code;

最后的 Forbid() 保证 Workbench 在程序仍在执行时没有机会 UnLoadSeg() 程序的 seglist。

如果没有 Forbid(),ReplyMsg() 将导致任务调度,Workbench 会有机会运行。Workbench 会 UnLoadSeg() seglist,最后几条指令将在未分配的内存上执行。这会导致崩溃。

不需要最后的 Permit(),因为进程最终会 RemTask(NULL) 自身(默认的任务 EndPC),并且这会完全删除进程。

{
struct WBStartup *wbmsg;
BPTR win;

if (argc != 0)
	{
	Printf ("This program cannot be run in DOS mode :-)\n");
	return (RETURN_ERROR);
	}

wbmsg = (struct WBStartup *)argv;

if (win = Open ("con:0/0/640/400/WB Icon/CLOSE/WAIT",MODE_NEWFILE))
	{
	char buffer[256];
	long i;

	NameFromLock (wbmsg->sm_ArgList->wa_Lock,buffer,256);
	AddPart (buffer,wbmsg->sm_ArgList->wa_Name,256);
	FPrintf (win,"Program name: <%s>\n",buffer);

	for (i = 1; i < wbmsg->sm_NumArgs; i++)
		{
		NameFromLock (wbmsg->sm_ArgList[i].wa_Lock,buffer,256);
		AddPart (buffer,wbmsg->sm_ArgList[i].wa_Name,256);
		FPrintf (win,"Argument #%ld: <%s>\n",i,buffer);
		}

	Close (win);
	}

return (RETURN_OK);
}

使用屏幕

[编辑 | 编辑源代码]

使用 intuition.library/StartScreenNotifyTagList(),以便在不需要关闭/重新打开屏幕的情况下允许更改屏幕首选项。

你可以使用一些其他函数来操作屏幕。

void DisplayBeep(struct Screen *)
This function will flash the specified screen, for example, to indicate an error.
e.g. DisplayBeep(myScreen);

void MoveScreen(struct Screen *, WORD dx, WORD dy)
This function will move the current screen to the specified pixel co-ordinates. 
This is similar to dragging the screen bar to a new location.
e.g. MoveScreen(myScreen, 0, 100); /* Move screen down to y co-ord 100 */

void ScreenToBack(struct Screen *)
void ScreenToFront(struct Screen *)
If you have multiple screens open, then you can switch between screens 
using these functions. ScreenToFront will make a screen the visible screen.
e.g. ScreenToFront(myScreen);

void MakeScreen(struct Screen *)
e.g. MakeScreen(myScreen);

void ShowTitle(struct Screen *, BOOL)
Specifies whether to show the screen's title bar or not.
e.g. ShowTitle(myScreen, FALSE);

有关更多命令,请参阅Intuition 参考文档。

GetScreenDrawInfo()  Get the DrawInfo information for an open screen. 
FreeScreenDrawInfo()  Free the DrawInfo information for a screen.

MakeScreen()  Low level screen handling--rebuild Copper list. 
RethinkDisplay()  Low level screen handling--incorporate Copper list changes. 
RemakeDisplay()  MakeScreen() for all screens, then RethinkDisplay().

ScreenNotify()  Private function

回填钩子

[编辑 | 编辑源代码]

请参阅此线程

AROS_UFH3(void ,sbackfillfunc,
AROS_UFHA(struct Hook *,hook,a0),
AROS_UFHA(struct RastPort *,frp,a2),
AROS_UFHA(struct BackfillMsg *,bfm,a1))
{    
    AROS_USERFUNC_INIT

    struct RastPort rp;

    CopyMem(frp, &rp, sizeof(struct RastPort));
    rp.Layer = NULL;

    FillPixelArray(    &rp, 
                    bfm->rect.MinX, 
                    bfm->rect.MinY,
                    bfm->rect.MaxX - bfm->rect.MinX + 1, 
                    bfm->rect.MaxY - bfm->rect.MinY + 1, 
                    0x00000000);

    AROS_USERFUNC_EXIT
}
struct Hook sbackfillhook;

以下是打开屏幕的调用

sbackfillhook.h_Entry = (HOOKFUNC) sbackfillfunc;
        info->screen = OpenScreenTags(    NULL,
                                        SA_Width, target_width,
                                        SA_Height, target_height,
                                        SA_Depth, target_depth,
                                        SA_Quiet, TRUE,
                                        SA_ShowTitle, FALSE,
                                        SA_Type, CUSTOMSCREEN,
                                        SA_DisplayID, dispid,
                                        SA_BackFill, (ULONG) &sbackfillhook,           
                                        TAG_DONE);

SA_BackFill, (ULONG) &sbackfillhook,

请不要在代码中使用 ULONG 来存储/强制转换指针。在适当的情况下使用 APTR/IPTR。

如果你发布的代码是完整的代码,那么它不起作用的原因可能是你填充 sbackfillhook 的方式。在 Demos/scrbackfill 中,钩子是这样填充的

static void InitBackfillHook(void)
{
backfillhook.h_Entry = HookEntry;
backfillhook.h_SubEntry = (HOOKFUNC)MyBackfillFunc;
}

HookEntry 在 clib/alib_protos.h 中定义,MyBackfillFunc 是

static void MyBackfillFunc(struct Hook *hook,struct RastPort *rp, struct LayerHookMsg *msg);

或者直接查看 Demos/scrbackfill.c。

struct DrawInfo
{
    UWORD	dri_Version;	/* will be  DRI_VERSION			*/
    UWORD	dri_NumPens;	/* guaranteed to be >= 9		*/
    UWORD	*dri_Pens;	/* pointer to pen array			*/

    struct TextFont	*dri_Font;	/* screen default font		*/
    UWORD	dri_Depth;	/* (initial) depth of screen bitmap	*/

    struct {	  /* from DisplayInfo database for initial display mode	*/
	UWORD	X;
	UWORD	Y;
    }		dri_Resolution;

    ULONG	dri_Flags;		/* defined below		*/
/* New for V39: dri_CheckMark, dri_AmigaKey. */
    struct Image	*dri_CheckMark;	/* pointer to scaled checkmark image
					 * Will be NULL if DRI_VERSION < 2
					 */
    struct Image	*dri_AmigaKey;	/* pointer to scaled Amiga-key image
					 * Will be NULL if DRI_VERSION < 2
					 */
    ULONG	dri_Reserved[5];	/* avoid recompilation ;^)	*/
};

#define DRIF_NEWLOOK	0x00000001L	/* specified SA_Pens, full treatment */

/* rendering pen number indexes into DrawInfo.dri_Pens[]	*/
#define DETAILPEN	 (0x0000)	/* compatible Intuition rendering pens	*/
#define BLOCKPEN	 (0x0001)	/* compatible Intuition rendering pens	*/
#define TEXTPEN		 (0x0002)	/* text on background			*/
#define SHINEPEN	 (0x0003)	/* bright edge on 3D objects		*/
#define SHADOWPEN	 (0x0004)	/* dark edge on 3D objects		*/
#define FILLPEN		 (0x0005)	/* active-window/selected-gadget fill	*/
#define FILLTEXTPEN	 (0x0006)	/* text over FILLPEN			*/
#define BACKGROUNDPEN	 (0x0007)	/* may not always be color 0		*/
#define HIGHLIGHTTEXTPEN (0x0008)	/* special color text, on background	*/
/* New for V39, only present if DRI_VERSION >= 2: */
#define BARDETAILPEN	 (0x0009)	/* text/detail in screen-bar/menus */
#define BARBLOCKPEN	 (0x000A)	/* screen-bar/menus fill */
#define BARTRIMPEN	 (0x000B)	/* trim under screen-bar */

#define NUMDRIPENS	 (0x000C)

/* New for V39:  It is sometimes useful to specify that a pen value
 * is to be the complement of color zero to three.  The "magic" numbers
 * serve that purpose:
 */
#define PEN_C3		0xFEFC		/* Complement of color 3 */
#define PEN_C2		0xFEFD		/* Complement of color 2 */
#define PEN_C1		0xFEFE		/* Complement of color 1 */
#define PEN_C0		0xFEFF		/* Complement of color 0 */

窗口其他

[编辑 | 编辑源代码]

要隐藏窗口(并使其重新出现!),请使用 ChangeWindowShape()。仍然不知道如何使用 WA_Visible=FALSE 打开的窗口再次可见;)

如果我们收到 MENUVERIFY 消息,我们会查看相应的打开窗口。如果在鼠标点击时它已清除 WFLG_RMBTRAP,我们会显示相应的 AROS intuition 菜单。

繁忙指针,我已经尝试添加 ..

SetWindowPointer( win, WA_BusyPointer, TRUE, WA_PointerDelay, TRUE, TAG_DONE );

 SetWindowPointer( win, TAG_DONE );

因为我只得到默认指针,而不是应用程序使用 SetWindowPointer() 或 SetPointer() 函数设置的当前指针。

有没有办法获得当前的指针位图?你始终可以在运行时修补必要的函数,以便你的例程会使用必要的信息被调用,然后执行你需要的操作(以及调用原始函数以实际设置可见指针)。

  • 拦截调用,
  • 复制位图以便我可以将其用于自己的目的
  • 将调用转发到原始函数

深入研究似乎不是 SetWindowPointerA 而是 ChangeExtSpriteA 需要修补。当为窗口设置新的指针时使用 SetWindowPointer,因此当窗口处于活动状态时将使用此指针。但是,每次指针发生变化时都会调用 ChangeExtSprite,即当活动窗口发生变化时也会调用。

有没有办法获得当前指针变化的通知?应用程序可以通过调用 SetWindowPointer() 随时更改指针图像,例如显示繁忙指针。这些更改不会反映在文件更改中,也不会触发 DOS 通知。

UWORD AddGadget(struct Window *window, struct Gadget *gadget, ULONG position) (A0, A1, D0)
BOOL ClearDMRequest(struct Window *window) (A0)
void ClearMenuStrip(struct Window *window) (A0)
void ClearPointer(struct Window *window) (A0)
BOOL CloseScreen(struct Screen *screen) (A0)
void CloseWindow(struct Window *window) (A0)
LONG CloseWorkBench() ()
void CurrentTime(ULONG *seconds, ULONG *micros) (A0, A1)
BOOL DisplayAlert(ULONG alertnumber, UBYTE *string, UWORD height) (D0, A0, D1)
void DisplayBeep(struct Screen *screen) (A0)
BOOL DoubleClick(ULONG sSeconds, ULONG sMicros, ULONG cSeconds, ULONG cMicros) (D0, D1, D2, D3)
void DrawBorder(struct RastPort *rp, struct Border *border, LONG leftOffset, LONG topOffset) (A0, A1, D0, D1)
void DrawImage(struct RastPort *rp, struct Image *image, LONG leftOffset, LONG topOffset) (A0, A1, D0, D1)
void EndRequest(struct Requester *requester, struct Window *window) (A0, A1)

struct Preferences *GetDefPrefs(struct Preferences *prefbuffer, WORD size) (A0, D0)
struct Preferences *GetPrefs(struct Preferences *prefbuffer, WORD size) (A0, D0)
void InitRequester(struct Requester *requester) (A0)
struct MenuItem *ItemAddress(struct Menu *menustrip, UWORD menunumber) (A0, D0)
BOOL ModifyIDCMP(struct Window *window, ULONG flags) (A0, D0)
void ModifyProp(struct Gadget *gadget, struct Window *window, struct Requester *requester, ULONG flags, ULONG horizPot, ULONG vertPot, ULONG horizBody, ULONG vertBody) (A0, A1, A2, D0, D1, D2, D3, D4)
void MoveScreen(struct Screen *screen, LONG dx, LONG dy) (A0, D0, D1)
void MoveWindow(struct Window *window, LONG dx, LONG dy) (A0, D0, D1)
void OffGadget(struct Gadget *gadget, struct Window *window, struct Requester *requester) (A0, A1, A2)
void OffMenu(struct Window *window, UWORD menunumber) (A0, D0)
void OnGadget(struct Gadget *gadget, struct Window *window, struct Requester *requester) (A0, A1, A2)
void OnMenu(struct Window *window, UWORD menunumber) (A0, D0)

struct Screen *OpenScreen(struct NewScreen *newScreen) (A0)
struct Window *OpenWindow(struct NewWindow *newWindow) (A0)
IPTR OpenWorkBench() ()
void PrintIText(struct RastPort *rp, struct IntuiText *iText, LONG leftOffset, LONG topOffset) (A0, A1, D0, D1)
void RefreshGadgets(struct Gadget *gadgets, struct Window *window, struct Requester *requester) (A0, A1, A2)
UWORD RemoveGadget(struct Window *window, struct Gadget *gadget) (A0, A1)
void ReportMouse(LONG flag, struct Window *window) (D0, A0)
BOOL Request(struct Requester *requester, struct Window *window) (A0, A1)
void ScreenToBack(struct Screen *screen) (A0)
void ScreenToFront(struct Screen *screen) (A0)
BOOL SetDMRequest(struct Window *window, struct Requester *dmrequest) (A0, A1)
BOOL SetMenuStrip(struct Window *window, struct Menu *menu) (A0, A1)
void SetPointer(struct Window *window, UWORD *pointer, LONG height, LONG width, LONG xOffset, LONG yOffset) (A0, A1, D0, D1, D2, D3)
void SetWindowTitles(struct Window *window, CONST_STRPTR windowTitle, CONST_STRPTR screenTitle) (A0, A1, A2)
void ShowTitle(struct Screen *screen, BOOL ShowIt) (A0, D0)
void SizeWindow(struct Window *window, LONG dx, LONG dy) (A0, D0, D1)

struct View *ViewAddress() ()
struct ViewPort *ViewPortAddress(struct Window *Window) (A0)

void WindowToBack(struct Window *window) (A0)
void WindowToFront(struct Window *window) (A0)
BOOL WindowLimits(struct Window *window, WORD MinWidth, WORD MinHeight, UWORD MaxWidth, UWORD MaxHeight) (A0, D0, D1, D2, D3)
struct Preferences *SetPrefs(struct Preferences *prefbuffer, LONG size, BOOL inform) (A0, D0, D1)
LONG IntuiTextLength(struct IntuiText *iText) (A0)
BOOL WBenchToBack() ()
BOOL WBenchToFront() ()
BOOL AutoRequest(struct Window *window, struct IntuiText *body, struct IntuiText *posText, struct IntuiText *negText, ULONG pFlag, ULONG nFlag, ULONG width, ULONG height) (A0, A1, A2, A3, D0, D1, D2, D3)
void BeginRefresh(struct Window *window) (A0)
struct Window *BuildSysRequest(struct Window *window, struct IntuiText *bodytext, struct IntuiText *postext, struct IntuiText *negtext, ULONG IDCMPFlags, WORD width, WORD height) (A0, A1, A2, A3, D0, D2, D3)
void EndRefresh(struct Window *window, BOOL complete) (A0, D0)
void FreeSysRequest(struct Window *window) (A0)
LONG MakeScreen(struct Screen *screen) (A0)
LONG RemakeDisplay() ()
LONG RethinkDisplay() ()

APTR AllocRemember(struct Remember **rememberKey, ULONG size, ULONG flags) (A0, D0, D1)
void AlohaWorkbench(struct MsgPort *wbmsgport) (A0)
void FreeRemember(struct Remember **rememberKey, LONG reallyForget) (A0, D0)
ULONG LockIBase(ULONG What) (D0)
void UnlockIBase(ULONG ibLock) (A0)
LONG GetScreenData(APTR buffer, ULONG size, ULONG type, struct Screen *screen) (A0, D0, D1, A1)
void RefreshGList(struct Gadget *gadgets, struct Window *window, struct Requester *requester, LONG numGad) (A0, A1, A2, D0)
UWORD AddGList(struct Window *window, struct Gadget *gadget, ULONG position, LONG numGad, struct Requester *requester) (A0, A1, D0, D1, A2)
UWORD RemoveGList(struct Window *remPtr, struct Gadget *gadget, LONG numGad) (A0, A1, D0)

void ActivateWindow(struct Window *window) (A0)
void RefreshWindowFrame(struct Window *window) (A0)
BOOL ActivateGadget(struct Gadget *gadget, struct Window *window, struct Requester *requester) (A0, A1, A2)
void NewModifyProp(struct Gadget *gadget, struct Window *window, struct Requester *requester, ULONG flags, ULONG horizPot, ULONG vertPot, ULONG horizBody, ULONG vertBody, LONG numGad) (A0, A1, A2, D0, D1, D2, D3, D4, D5)
LONG QueryOverscan(ULONG displayid, struct Rectangle *rect, WORD oscantype) (A0, A1, D0)
void MoveWindowInFrontOf(struct Window *window, struct Window *behindwindow) (A0, A1)
void ChangeWindowBox(struct Window *window, LONG left, LONG top, LONG width, LONG height) (A0, D0, D1, D2, D3)
struct Hook *SetEditHook(struct Hook *hook) (A0)
LONG SetMouseQueue(struct Window *window, UWORD queuelength) (A0, D0)
void ZipWindow(struct Window *window) (A0)
struct Screen *LockPubScreen(CONST_STRPTR name) (A0)
void UnlockPubScreen(UBYTE *name, struct Screen *screen) (A0, A1)
struct List *LockPubScreenList() ()
void UnlockPubScreenList() ()
UBYTE *NextPubScreen(struct Screen *screen, UBYTE *namebuff) (A0, A1)
void SetDefaultPubScreen(UBYTE *name) (A0)
UWORD SetPubScreenModes(UWORD modes) (D0)
UWORD PubScreenStatus(struct Screen *Scr, UWORD StatusFlags) (A0, D0)
struct RastPort *ObtainGIRPort(struct GadgetInfo *gInfo) (A0)
void ReleaseGIRPort(struct RastPort *rp) (A0)
void GadgetMouse(struct Gadget *gadget, struct GadgetInfo *ginfo, WORD *mousepoint) (A0, A1, A2)
ULONG SetIPrefs(APTR data, ULONG length, ULONG type) (A0, D0, D1)
struct Screen *GetDefaultPubScreen(UBYTE *nameBuffer) (A0)

LONG EasyRequestArgs(struct Window *window, struct EasyStruct *easyStruct, ULONG *IDCMP_ptr, APTR argList) (A0, A1, A2, A3)
struct Window *BuildEasyRequestArgs(struct Window *RefWindow, struct EasyStruct *easyStruct, ULONG IDCMP, APTR Args) (A0, A1, D0, A3)
LONG SysReqHandler(struct Window *window, ULONG *IDCMPFlagsPtr, BOOL WaitInput) (A0, A1, D0)
struct Window *OpenWindowTagList(struct NewWindow *newWindow, struct TagItem *tagList) (A0, A1)
struct Screen *OpenScreenTagList(struct NewScreen *newScreen, struct TagItem *tagList) (A0, A1)
void DrawImageState(struct RastPort *rp, struct Image *image, LONG leftOffset, LONG topOffset, ULONG state, struct DrawInfo *drawInfo) (A0, A1, D0, D1, D2, A2)
BOOL PointInImage(ULONG point, struct Image *image) (D0, A0)
void EraseImage(struct RastPort *rp, struct Image *image, LONG leftOffset, LONG topOffset) (A0, A1, D0, D1)
APTR NewObjectA(struct IClass *classPtr, UBYTE *classID, struct TagItem *tagList) (A0, A1, A2)
void DisposeObject(APTR object) (A0)
IPTR SetAttrsA(APTR object, struct TagItem *tagList) (A0, A1)
ULONG GetAttr(ULONG attrID, Object *object, IPTR *storagePtr) (D0, A0, A1)
IPTR SetGadgetAttrsA(struct Gadget *gadget, struct Window *window, struct Requester *requester, struct TagItem *tagList) (A0, A1, A2, A3)
APTR NextObject(APTR objectPtrPtr) (A0)
struct IClass *FindClass(ClassID classID) (A0)
struct IClass *MakeClass(ClassID classID, ClassID superClassID, struct IClass *superClassPtr, ULONG instanceSize, ULONG flags) (A0, A1, A2, D0, D1)
void AddClass(struct IClass *classPtr) (A0)
struct DrawInfo *GetScreenDrawInfo(struct Screen *screen) (A0)
void FreeScreenDrawInfo(struct Screen *screen, struct DrawInfo *drawInfo) (A0, A1)
BOOL ResetMenuStrip(struct Window *window, struct Menu *menu) (A0, A1)
void RemoveClass(struct IClass *classPtr) (A0)
BOOL FreeClass(struct IClass *iclass) (A0)

struct ScreenBuffer *AllocScreenBuffer(struct Screen *screen, struct BitMap *bitmap, ULONG flags) (A0, A1, D0)
void FreeScreenBuffer(struct Screen *screen, struct ScreenBuffer *screenbuffer) (A0, A1)
ULONG ChangeScreenBuffer(struct Screen *screen, struct ScreenBuffer *screenbuffer) (A0, A1)
void ScreenDepth(struct Screen *screen, ULONG flags, APTR reserved) (A0, D0, A1)
void ScreenPosition(struct Screen *screen, ULONG flags, LONG x1, LONG y1, LONG x2, LONG y2) (A0, D0, D1, D2, D3, D4)
void ScrollWindowRaster(struct Window *win, WORD dx, WORD dy, WORD xmin, WORD ymin, WORD xmax, WORD ymax) (A1, D0, D1, D2, D3, D4, D5)
void LendMenus(struct Window *fromwindow, struct Window *towindow) (A0, A1)
IPTR DoGadgetMethodA(struct Gadget *gad, struct Window *win, struct Requester *req, Msg msg) (A0, A1, A2, A3)
void SetWindowPointerA(struct Window *window, struct TagItem *taglist) (A0, A1)
BOOL TimedDisplayAlert(ULONG alertnumber, UBYTE *string, UWORD height, ULONG time) (D0, A0, D1, A1)
void HelpControl(struct Window *window, ULONG flags) (A0, D0)
LONG IsWindowVisible(struct Window *window) (A0)
void ShowWindow(struct Window *window) (A0)
void HideWindow(struct Window *window) (A0)

struct Region *ChangeWindowShape(struct Window *window, struct Region *newshape, struct Hook *callback) (A0, A1, A2)
void SetDefaultScreenFont(struct TextFont *textfont) (A0)
IPTR DoNotify(Class *cl, Object *o, struct ICData *ic, struct opUpdate *msg) (A0, A1, A2, A3)
void FreeICData(struct ICData *icdata) (A0)

struct IntuiMessage *AllocIntuiMessage(struct Window *window) (A0)
void FreeIntuiMessage(struct IntuiMessage *imsg) (A0)
void SendIntuiMessage(struct Window *window, struct IntuiMessage *imsg) (A0, A1)
void ChangeDecoration(ULONG ID, struct NewDecorator *decor) (D0, A0)
void WindowAction(struct Window *window, ULONG action, struct TagItem *tags) (A0, D0, A1)

void ScrollWindowRasterNoFill(struct Window *win, WORD dx, WORD dy, WORD xmin, WORD ymin, WORD xmax, WORD ymax) (A1, D0, D1, D2, D3, D4, D5)
ULONG SetPointerBounds(struct Screen *screen, struct Rectangle *rect, ULONG reserved, struct TagItem *tags) (A0, A1, D0, A2)
IPTR StartScreenNotifyTagList(struct TagItem *tags) (A0)
BOOL EndScreenNotify(IPTR notify) (A0)
Object **GetMonitorList(struct TagItem *tags) (A1)
void FreeMonitorList(Object **list) (A1)
华夏公益教科书