home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
monitors
/
rsys
/
source.lha
/
src
/
RSysInit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-09
|
13KB
|
391 lines
/*
***************************************************************************
*
* Datei:
* RSysInit.c
*
* Inhalt:
* void RefreshRastPort(struct Window *wind, struct Gadget **gads, int *gadnum, int cnt);
* long SetupScreen(void);
* void CloseDownScreen(void);
* int OpenSysWindow(void);
*
* Bemerkungen:
* Initialisierung des Hauptfensters von RSys.
*
* Erstellungsdatum:
* 07-Jul-93 Rolf Böhme
*
* Änderungen:
* 07-Jul-93 Rolf Böhme Erstellung
*
***************************************************************************
*/
#include "RSysDebug.h"
#include "RSysFunc.h"
/*
* FillGadget() löscht den Hintergrund eines Boolean-Gadgets
*/
static void
FillGadget( struct Window *wind, struct Gadget *gad )
{
BYTE GadType = (BYTE)gad->GadgetType;
UWORD pos = RemoveGadget(wind,gad);
if(GadType == GTYP_STRGADGET)
EraseRect( wind->RPort,(long)gad->LeftEdge - 2,
(long)gad->TopEdge - 1,
(long)(gad->LeftEdge + gad->Width + 1),
(long)(gad->TopEdge + gad->Height) );
else
EraseRect( wind->RPort,(long)gad->LeftEdge,
(long)gad->TopEdge,
(long)(gad->LeftEdge + gad->Width - 1),
(long)(gad->TopEdge + gad->Height - 1) );
AddGadget(wind,gad,(ULONG)pos);
return;
}
/*
* RefreshRastPort() malt das Hintergrundmuster und erneuert
* die Gadgets und deren Hintergrund
*/
void
RefreshRastPort(struct Window *wind, struct Gadget **gads,
int *gadnum, int cnt)
{
struct RastPort *RP = wind->RPort;
struct Gadget *gad;
extern int bpc, bgc;
extern long bpp;
register int i;
if((bgc || bpc) && NOT(wind->Flags & WFLG_ZOOMED))
{
SetAfPt(RP,(USHORT *)&bpp,1L);
SetAPen(RP,bpc);
SetBPen(RP,bgc);
SetDrMd(RP,JAM2);
/*
MyEasyRequest(SysWnd, (UBYTE *)"huhu",(UBYTE *)"Ok",
(UBYTE *)"OffX: %ld\nScr->WBorRight: %ld",
OffX, Scr->WBorRight);
*/
RectFill(RP,(long)OffX,(long)OffY,
(long)wind->Width - Scr->WBorRight /* - OffX + 3*/,
(long)wind->Height - Scr->WBorBottom + 1 );
SetAfPt(RP,NULL,NULL);
for(i = 0; i < cnt; i++)
FillGadget( wind,gads[gadnum[i]] );
for(gad = gads[0]; gad; gad = gad->NextGadget)
if(gad->GadgetText)
{
int pixlen = IntuiTextLength(gad->GadgetText);
int x = gad->LeftEdge + gad->GadgetText->LeftEdge - 3,
y = gad->TopEdge + gad->GadgetText->TopEdge - 2,
w = pixlen + 6,
h = gad->GadgetText->ITextFont->ta_YSize + 4;
EraseRect( wind->RPort,(long)x, (long)y, (long)(x + w - 1), (long)(y + h - 1));
DrawBevelBox( wind->RPort, x, y, w, h,
GTBB_Recessed, TRUE,
GT_VisualInfo, VisualInfo,
TAG_DONE );
}
RefreshGadgets(wind->FirstGadget, wind,NULL);
RefreshWindowFrame(wind);
}
GT_RefreshWindow( wind, NULL );
return;
}
/*
* SetupScreen() ermittelt eine Zeiger auf den vordersten
* Screen. Ist der vorderste Screen kein PublicScreen,
* wird der WorkBench-Screen als Default-Screen genommen.
*/
long
SetupScreen(void)
{
extern struct Screen *lastpubscreen;
DPOS;
(void)FindFrontPubScr(lastpubscreen);
if (NOT(Scr = LockPubScreen(namebuffer)))
{
strcpy((char *)namebuffer,"Workbench");
if (NOT(Scr = LockPubScreen(namebuffer)))
return (1L);
}
ComputeFont(Scr,(UWORD) 0, (UWORD) 0);
if (NOT(VisualInfo = GetVisualInfo(Scr, TAG_DONE)))
return (2L);
lastpubscreen = Scr;
return (NULL);
}
/*
* CloseDownScreen() gibt den Screen frei, auf den ein
* RSys-Window geöffnet wurde.
*/
void
CloseDownScreen(void)
{
DPOS;
if (VisualInfo)
{
FreeVisualInfo(VisualInfo);
VisualInfo = NULL;
}
if (Scr)
{
UnlockPubScreen(NULL, Scr);
Scr = NULL;
}
return;
}
static UWORD SysGTypes[] = {
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
LISTVIEW_KIND,
TEXT_KIND,
TEXT_KIND
};
static struct NewGadget SysNGad[] = {
5,117,93,12, (UBYTE *)"_Tasks",NULL,GD_TasksGad,PLACETEXT_IN,NULL,NULL,
101,117,93,12,(UBYTE *)"_Libraries",NULL,GD_LibrariesGad,PLACETEXT_IN,NULL,NULL,
197,117,93,12,(UBYTE *)"_Memory",NULL,GD_MemoryGad,PLACETEXT_IN,NULL,NULL,
293,117,93,12,(UBYTE *)"_Ports",NULL,GD_PortsGad,PLACETEXT_IN,NULL,NULL,
5,131,93,12, (UBYTE *)"_Volumes",NULL,GD_VolumesGad,PLACETEXT_IN,NULL,NULL,
101,131,93,12,(UBYTE *)"_Assigns",NULL,GD_AssignsGad,PLACETEXT_IN,NULL,NULL,
197,131,93,12,(UBYTE *)"_Fonts",NULL,GD_FontsGad,PLACETEXT_IN,NULL,NULL,
293,131,93,12,(UBYTE *)"_Ressources",NULL,GD_ResourcesGad,PLACETEXT_IN,NULL,NULL,
5,145,93,12, (UBYTE *)"_Interrupts",NULL,GD_InterruptsGad,PLACETEXT_IN,NULL,NULL,
101,145,93,12,(UBYTE *)"_Windows",NULL,GD_WindowsGad,PLACETEXT_IN,NULL,NULL,
197,145,93,12,(UBYTE *)"_Screens",NULL,GD_ScreensGad,PLACETEXT_IN,NULL,NULL,
293,145,93,12,(UBYTE *)"_HandlerInp",NULL,GD_HandlerInpGad,PLACETEXT_IN,NULL,NULL,
5,159,93,12, (UBYTE *)"S_ystem",NULL,GD_SystemGad,PLACETEXT_IN,NULL,NULL,
101,159,93,12,(UBYTE *)"Har_dware",NULL,GD_HardwareGad,PLACETEXT_IN,NULL,NULL,
197,159,93,12,(UBYTE *)"Save List",NULL,GD_SaveListGad,PLACETEXT_IN,NULL,NULL,
293,159,93,12,(UBYTE *)"_Jump",NULL,GD_JumpGad,PLACETEXT_IN,NULL,NULL,
5,16,381,85, (UBYTE *)NULL,NULL,GD_ListeLV,0,NULL,NULL,
5,2,381,12, (UBYTE *)NULL,NULL,GD_TextHeader,0,NULL,NULL,
5,102,381,13, (UBYTE *)NULL,NULL,GD_InfoMsgGad,0,NULL,NULL
};
extern struct List ListeLVList;
static ULONG *SysGTags[] = {
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(TAG_DONE),
(ULONG *)(GT_Underscore), (ULONG *)'_', (ULONG *)(TAG_DONE),
(ULONG *)(GTLV_Labels), (ULONG *)&ListeLVList, (ULONG *)(TAG_DONE),
(ULONG *)(GTTX_Text), (ULONG *)NULL,(ULONG *)(GTTX_Border), (ULONG *)TRUE, (ULONG *)(TAG_DONE),
(ULONG *)(GTTX_Text), (ULONG *)NULL,(ULONG *)(GTTX_Border), (ULONG *)TRUE,(ULONG *)(TAG_DONE)
};
#define Sys_CNT 19
/*
* OpenSysWindow() öffnet das Hauptfenster von RSys
*/
int
OpenSysWindow(void)
{
struct NewGadget ng;
struct Gadget *g;
UWORD wleft = SysLeft,
wtop = SysTop,
ww,
wh;
UWORD lc, tc;
extern int winddetail,windblock,menudetail;
DPOS;
ComputeFont(Scr,SysWidth, SysHeight);
ww = compute((UWORD) 0, FontX, (int)SysWidth);
wh = compute((UWORD) 0, FontY, (int)SysHeight);
if ((wleft + ww + OffX + Scr->WBorRight) > Scr->Width)
wleft = Scr->Width - ww;
if ((wtop + wh + OffY + Scr->WBorBottom) > Scr->Height)
wtop = Scr->Height - wh;
ww = compute((UWORD) (OffX + Scr->WBorRight), FontX, (int)SysWidth);
wh = compute((UWORD) (OffY + Scr->WBorBottom), FontY, (int)SysHeight);
CenterWindow(Scr, &wtop, &wleft, ww, wh);
if (NOT(g = CreateContext(&SysGList)))
return (1L);
SysGTags[50] = (ULONG *)&EntryAttr[LastID].ea_header[0];
for( lc = 0, tc = 0; lc < Sys_CNT; lc++ ) {
CopyMem(&SysNGad[ lc ], &ng, sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
SysGadgets[ lc ] = g = CreateGadgetA((ULONG)SysGTypes[ lc ], g, &ng, ( struct TagItem * )&SysGTags[ tc ] );
while( SysGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
#define FFLAG 62
SysNewMenu[FFLAG].nm_Flags = (Flags.fastmode ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE)) ;
SysNewMenu[FFLAG+1].nm_Flags = (Flags.sortmode ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE)) ;
SysNewMenu[FFLAG+2].nm_Flags = (Flags.workingbar ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE)) ;
SysNewMenu[FFLAG+3].nm_Flags = (Flags.autofront ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE)) ;
SysNewMenu[FFLAG+4].nm_Flags = (Flags.mousewindow ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE)) ;
SysNewMenu[FFLAG+5].nm_Flags = (Flags.sysfont ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE));
SysNewMenu[FFLAG+7].nm_Flags = (Flags.speakmode ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE));
SysNewMenu[FFLAG+9].nm_Flags = (Flags.saveasking ? (CHECKIT | CHECKED | MENUTOGGLE) :
(CHECKIT | MENUTOGGLE));
if (NOT(SysMenus = CreateMenus(SysNewMenu, GTMN_FrontPen, menudetail, TAG_DONE)))
return (3L);
LayoutMenus(SysMenus, VisualInfo, TAG_DONE);
SysZoom[0] = 300;
SysZoom[1] = 0;
SysZoom[2] = compute((UWORD) (OffX + Scr->WBorRight), FontX, 158);
SysZoom[3] = OffY;
if (NOT(SysWnd = OpenWindowTags(NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww,
WA_Height, wh,
WA_DetailPen, winddetail,
WA_BlockPen, windblock,
WA_IDCMP, BUTTONIDCMP |
LISTVIEWIDCMP |
IDCMP_MOUSEBUTTONS |
IDCMP_MOUSEMOVE |
IDCMP_CLOSEWINDOW |
IDCMP_ACTIVEWINDOW |
IDCMP_INACTIVEWINDOW |
IDCMP_RAWKEY |
IDCMP_VANILLAKEY |
IDCMP_CHANGEWINDOW |
IDCMP_DISKREMOVED |
IDCMP_DISKINSERTED |
IDCMP_MENUPICK,
WA_Flags, WFLG_DRAGBAR |
WFLG_DEPTHGADGET |
WFLG_CLOSEGADGET |
WFLG_SMART_REFRESH |
WFLG_NOCAREREFRESH,
WA_Gadgets, SysGList,
WA_PubScreenName, (LONG) namebuffer,
WA_PubScreenFallBack, TRUE,
WA_PubScreen, Scr,
WA_Title, SysWdt,
WA_Zoom, SysZoom,
/* WA_Dummy + 0x30, 1L,*/
TAG_DONE)))
return (4L);
SysZoom[0] = SysWnd->LeftEdge;
SysZoom[1] = SysWnd->TopEdge;
SysZoom[2] = SysWnd->Width;
SysZoom[3] = SysWnd->Height;
SetMenuStrip(SysWnd, SysMenus);
if(NOT(Flags.wb_start))
OffMenu(SysWnd, 0);
RefreshMainWindowPattern();
if(Flags.autofront)
{
WindowToFront(SysWnd);
ActivateWindow(SysWnd);
}
return (NULL);
}