1 SCREENS 1.1 INTRODUCTION The screen is the foundation of Intuition's display. It determines how many colours you can use, what kind of colours, what resolution etc. Every window, gadget, icon, drawing is connected to a screen. Moving that screen, and you are also moving the objects on it. You may have several screens running at the same time, and you may combine different screens (with their own individual resolutions, colours, etc) on the same display. 1.2 DIFFERENT TYPEN.&J`)H)HLLNu !LeRBHl:NTPO)@fNTHl N:XO)@f/,NHN8XOHxN(.N,.N*XONuN4NNNNNNparZl~fx`RMY WINDOW2dintuition.library(r@,rP$/,y"/N:,_Nu_Delay /,y"oNb,_Nu/,y"o / N,_Nu_OpenLibrary_CloseLibrary /,y oN,_Nu/,y oN4,_Nu_OpenWindow_CloseWindow !LeRBHl:NTPO)@fNTHl N:XO)@f/,NHN8XOHxN(.N,.N*XONuN4NNNNNNparZl~fx`RMY WINDOW2dintuition.library(rD */ }ll now try to open the window: */ my_window = (struct Window *) OpenWindow( &my_new_window ); /* The "(struct Window *)" is not necessary but it tells the compiler */ /* that the function OpenWindow() returns a pointer to a Window */ /* structure. (See chapter 0 INTRODUCTION for more information about */ /* "casting".) */ /* Have we opened the window succesfully? */ if(my_window == NULL) { /* re: */ struct Window *my_window; /* Declare and initialize your NewWindow structure: */ struct NewWindow my_new_window= { 50, /* LeftEdge x position of the window. */ 25, /* TopEdge y positio of the window. */ 150, /* Width 150 pixels wide. */ 100, /* Height 100 lines high. */ 0, /* DetailPen Text should be drawn with colour reg. 0 */ 1, /* BlockPen Blocks should be drawn with colour reg. 1 */ NULL, /* IDCMPFlags No IDCMP flags. */ SMART_REFRESH, /* Flags Intuition should refresh the window. */ NULL, /* FirstGadget No Custom Gadgets. */ NULL, /* CheckMark Use Intuition's default CheckMark (v). */ "MY WINDOW", /* Title Title of the window. */ NULL, /* Screen Connected to the Workbench Screen. */ NULL, /* BitMap No Custom BitMap. */ 0, /* MinWidth We do not need to care about these */ 0, /* MinHeight since we havent supplied the window with */ 0, /* MaxWidth a Sizing Gadget. */ 0, /* MaxHeight */ WBENCHSCREEN /* Type Connected to the Workbench Screen. */ }; main() { /* Open the Intuition Library: */ IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 0 ); if( IntuitionBase == NULL ) exit(); /* Could NOT open the Intuition Library! */ /* We will now try to open the window: */ my_window = (struct Window *) OpenWindow( &my_new_window ); /* The "(struct Window *)" is not necessary but it tells the compiler */ /* that the function OpenWindow() returns a pointer to a Window */ /* structure. (See chapter 0 INTRODUCTION for more information about */ /* "casting".) */ /* Have we opened the window succesfully? */ if(my_window == NULL) { /* Could NOT open the Window! */ /* Close the Intuition Library since we have opened it: */ CloseLibrary( IntuitionBase ); exit(); } /* We have opened the window, and everything seems to be OK. */ /* Wait for 30 seconds: */ Delay( 50 * 30); /* We should always close the windows we have opened before we leave: */ CloseWindow( my_window ); /* Close the Intuition Library since we have opened it: */ CloseLibrary( IntuitionBase ); /* THE ENH0./&o,/ /NXXO$@ fp`6*gHxB/NO // /*NXO *Jgp` L NupaNUH!2&o, Jlr g r gr fR`Jgh ,JRJAR$Hp"f&R$Jg p"gR`Jf HxNhXO`B`$Jgr gr g r gR`Jf`B`rJJf l`AR)HNJJf|A$C""""2"l i$Hx(/(HlNZO A"$<,lN)@)@r)A)@)A倓,x+@N m"@#h~+@`*,lN)@N)@A"$<N)@~ @ @Jgp` <.B @)@p)@ @)@p)@ @)@A)H/,N/,JN2BNLLN]Nucon:10/10/320/80/*Npa.lNHyNpaNUH0&o $o$./( JJfS, KJfS "K+Ic,  J`Sd mB0h L N]NuH./,/*/ /N`XO&@ fp`///+NO (Jgp` LNupaH./G g4+f(+g +,Jg//+/+N~O &S`/NXOLNuH7./&o ,/$JgNB"$ &,lN*pfN|)@p)@ LNupaH?./,/ */$JgNB S"$&,lN(pfN|)@p)@  g gJf ` І`"tv,lNLNu/./JgN:",lNp.NuNU/JfCp,xN)@p l(C`Sdp l(B5A)HHx(Hxp//Hlr/Hl/NHxN<,mN]Nu** Stack Overflow **EXITintuition.libraryNUH32~ l(pOo. C`SdB5x,xN&@JgL +$@,*8Jf,+Jg4"A$v ,lN GR  "A$&,lNp`NJfCp,xN)@A)HHHx.N6.N4O4NuN4NNNN(NNNp@?c?z;?c???x00@~?^Zzz2P,BANG!,4P,intuition.library((p\4  LT/,y"/N:,_Nu_Delay /,y"oNb,_Nu/,y"o / N,_Nu_OpenLibrary_CloseLibrary/,y oN,_Nu/,y oN4,_NuH0,yLLNL@ Nu._SetPointer(_OpenWindow_CloseWindow?c?z;?c???x00s. */ NULL, /* CheckMark Use Intuition's default CheckMark (v). */ "Zzz", /* Title Title of the window. */ NULL, /* Screen Connected to the Workbench Screen. */ NULL, /* BitMap No Custom BitMap. */ 80, /* MinWidth We will not allow the window to become */ 30, /* MinHeight smaller than 80 x 30, and not bigger */ 300, /* MaxWidth than 300 x 200. */ 200, /* MaxHeight */ WBENCHSCREEN /* Type Connected to the Workbench Screen. */ }; /* Declare a pointer to the second Window structure: */ struct Window *my_window2; /* Declare and initialize your second NewWindow structure: */ struct NewWindow my_new_window2= { 300, /* LeftEdge x position of the window. */ 25, /* TopEdge y positio of the window. */ 200, /* Width 200 pixels wide. */ 150, /* Height 150 lines high. */ 0, struct IntuitionBase *IntuitionBase; /* Declare a pointer to the first Window structure: */ struct Window *my_window1; /* Declare and initialize your first NewWindow structure: */ struct NewWindow my_new_window1= { 50, /* LeftEdge x position of the window. */ 25, /* TopEdge y positio of the window. */ 200, /* Width 200 pixels wide. */ 150, /* Height 150 lines high. */ 0, /* DetailPen Text should be drawn with colour reg. 0 */ 1, /* BlockPen Blocks should be drawn with colour reg. 1 */ NULL, /* IDCMPFlags No IDCMP flags. */ SMART_REFRESH| /* Flags Intuition should refresh the window. */ WINDOWCLOSE| /* Close Gadget. */ WINDOWDRAG| /* Drag gadget. */ WINDOWDEPTH| /* Depth arrange Gadgets. */ WINDOWSIZING, /* Sizing Gadget. */ NULL, /* FirstGadget No Custom Gadget: my_screen = OpenScreen( &my_new_screen ); my_screen has been declared as: struct Screen *my_screen; my_new_screen has been declared as: struct NewScreen my_new_screen; and has been initialized with your requirements. OpenScreen() will return a pointer to a Screen structure, else NULL if it could not open the screen (for example, not enough memory). Remember to check what OpenScreen() returned! if( my_screen==NULL ) { /* PANIC! Could not open the screen */ } 1.7 SCREEN STRUCTURE Once you have opened the screen you will receive a pointer to a Screen structure which look like this: struct Screen { struct Screen *NextScreen; /* Pointer to the next */ /* screen, or NULL. */ struct Window *FirstWindow; /* Pointer to the first */ /* Window on this screen. */ SHORT LeftEdge, TopEdge; /* Position of the screen. */ SHORT Width, Height; /* Size of the screen. */ SHORT MouseY, MouseX; /* Mouse position relative */ /* to the top left corner */ /* of the screen. */ USHORT Flags; /* The selected flags. */ UBYTE *Title; /* The screen's Current title. */ UBYTE *DefaultTitle; /* The screen's Default title. */ BYTE BarHeight, BarVBorder, BarHBorder, MenuVBorder, MenuHBorder; BYTE WBorTop, WBorLeft, WBorRight, WBorBottom; struct TextAttr *Font; /* The screens default font. */ struct ViewPort ViewPort; /* The screen's ViewPort etc: */ struct RastPort RastPort; struct BitMap BitMap; struct Layer_Info LayerInfo; struct Gadget *FirstGadget; UBYTE DetailPen, BlockPen; USHORT SaveColor0; struct Layer *BarLayer; UBYTE *ExtData; UBYTE *UserData; }; You will probably not use this structure a lot, but some variables/structures can be useful later on. When you are, for example, using the function SetRGB4(). More about this later. 1.8 FUNCTIONS Here are some common functions which will effect screens: OpenScreen() This function will open a Custom Screen with your requirements. Synopsis: my_screen = OpenScreen( my_new_screen ); my_screen: (struct Screen *) Pointer to a Screen structure. It will point to your newly opened screen or be equal to NULL if the screen could not be opened. my_new_screen: (struct NewScreen *) Pointer to a NewScreen structure which contains your preferences. CloseScreen() This function will close a Custom Screen which you have previously opened. Synopsis: CloseScreen( my_screen ); my_screen: (struct Screen *) Pointer to an already opened screen. All windows (See chapter 2 WINDOWS for more information) on your Screen MUST have been closed before you may close the screen. If you close a window after the screen has been closed, the system will crash. (Not recommended.) If there does not exist any more screens when you close yours, Intuition will automatically reopen the Workbench Screen. MoveScreen() This function will move the screen. For the moment you may only move it vertically. Synopsis: MoveScreen( my_screen, delta_x, delta_y ); my_screen: (struct Screen *) Pointer to the screen which you want to move. delta_x: (long) Number of pixels which the screen should move horizontally. For the moment you may not move a screen horizontally, set it therefore to 0. delta_y: (long) Number of lines which the screen should move vertically. ScreenToBack() This will move the screen behind all other screens. Synopsis: ScreenToBack( my_screen ); my_screen: (struct Screen *) Pointer to the screen which you want to move. ScreenToFront() This will move the screen in front of all other screens. Synopsis: ScreenToFront( my_screen ); my_screen: (struct Screen *) Pointer to the screen which you want to move. ShowTitle() This function will make the screen's Title appear above or behind any Backdrop Windows (See chapter 2 WINDOWS for more information about Backdrop Windows). (The screen's title appear always behind normal windows.) Synopsis: ShowTitle( my_screen, show_it ); my_screen: (struct Screen *) Pointer to the screen. show_it: (long) A boolean value which can be: TRUE: The title will be in front of any Backdrop Windows, but behind any other windows. FALSE: The Title will be behind any windows. OpenWorkBench() This function will try to open the Workbench Screen if there exist enough memory. Synopsis: result = OpenWorkBench(); result: (long) A boolean value which tell us if the Workbench Screen has been (or already was) opened (TRUE), or not (FALSE). CloseWorkBench() This function will try to close the Workbench Screen if possible. If any other programs is using the Workbench Screen, the function can not close it. Closing the Workbench will free some memory, and can therefore be used if your program needs more memory. (Remember to reopen the Workbench Screen when your program terminates.) Synopsis: result = CloseWorkBench(); result: (long) A boolean value which tell us if the Workbench screen has been (or already was) closed (TRUE), or not (FALSE). WBenchToBack() This will move the Workbench Screen behind all other screens. Synopsis: result = WBenchToBack(); result: (long) A boolean value which is TRUE if the Workbench screen was open, or FALSE it it was not. WBenchToFront() This will move the Workbench Screen in front of all other screens. Synopsis: result = WBenchToFront(); result: (long) A boolean value which is TRUE if the Workbench screen was open, or FALSE it it was not. SetRGB4() This function allows you to change your screen's colours. Each colour may be picked out of a 4096 colour palette. (16 levels of red, 16 levels of green and 16 levels of blue; 16*16*16 = 4096.) IMPORTANT! Before you may use this function you must have opened the Graphics Library. (All other functions are in the Intuition Library.) (See chapter 0 INTRODUCTION for more information.) Synopsis: SetRGB4( viewport, register, red, green, blue ); viewport: (struct ViewPort *) Pointer to a ViewPort which colour registers we are going to change. We can find the screen's ViewPort in the Screen structure. (If my_screen is a pointer to a Screen structure, this will get us a pointer to that screen's ViewPort: &my_screen->ViewPort) register: (long) The colour register you want to change. The screen's Depth decides how many colour registers the screen have: Depth Colour Registers ----------------------- 1 0 - 1 2 0 - 3 3 0 - 7 4 0 - 15 5 0 - 31 6 0 - 63 red: Amount of red. (0 - 15) green: Amount of green. (0 - 15 ) blue: Amount of blue. (0 - 15 ) Eg: SetRGB4( &my_screen->ViewPort, 2, 15, 15, 0 ); will change colour register 2 to be light yellow. (Red and green together will be yellow.) 1.9 EXAMPLES We have now talked about different screens, Workbench Screen and your own Custom Screens. We have looked at how you can change the Custom Screen's display mode, resolution, depth etc, and we have described some important functions. It is now time for us to have some examples to clear up any confusions. All Examples, both the programs as well as the source codes, are in the same directory as this document. Example1 This program will open a low-resolution, non-Interlaced, eight colour Custom Screen. It will display it for 30 seconds, and then close it. Example2 Same as Example1 except that the screen will be a high- resolution, Interlaced, 4 colour Custom Screen. Example3 Same as Example1 except that we will use the TOPAZ_SIXTY Italic style as default font. (See chapter 3 GRAPHICS for more information about text styles.) Example4 This program will open two screens, one (low-resolution 32 colours) at the top of the display, and one (high-resolution 16 colours) a bit down. Example5 Same as Example4 except that after 10 seconds the low- resolution screen will move down 75 lines. After another 10 seconds it will be put in front of all other screens. 10 seconds later it will move down another 75 lines. The program will wait 10 seconds before the screens are closed and the program exits. Example6 This program will open a low-resolution, non-Interlaced, 4 colour Custom Screen. It will after 5 seconds start to change the screens colours, and will after a while close the screen and exit.