home *** CD-ROM | disk | FTP | other *** search
-
- #include "parms.h" /* added for proper prototyping -- EDB */
- #include "GraphicObject.h"
- #include "GraphicObjectClass.h"
- #include "TitleBox.h"
- #include <stdlib.h>
- #include <string.h>
- #include "minmax.h"
- #include <graphics/gfxmacros.h>
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #include "amigamem.h"
-
- Point TitleBox_Location( TitleBox *self )
- {
- return self->Location;
- }
-
-
- Point TitleBox_SetLocation( TitleBox *self,
- PIXELS LeftEdge,
- PIXELS TopEdge )
- {
- self->Location.x = LeftEdge;
- self->Location.y = TopEdge;
- return self->Location;
- }
-
- Point TitleBox_Size( TitleBox *self )
- {
- return self->Size;
- }
-
- Point TitleBox_AskSize( TitleBox *self,
- PIXELS Width,
- PIXELS Height )
- {
- Point size;
-
- size.x = MAX( Width, 6 );
- size.y = MAX( Height, 6 );
- return size;
- }
-
-
- Point TitleBox_SetSize( TitleBox *self,
- PIXELS Width,
- PIXELS Height )
- {
- Point size;
-
- size = AskSize( (GraphicObject *)self, Width, Height );
- self->Size.x = size.x;
- self->Size.y = size.y;
-
- pcg_Init3DBox( &self->BoxBorder, 0,0, size.x, size.y,
- self->Pens.BrightPen, self->Pens.DarkPen, NULL );
-
- AlignText( &self->ptext, size );
- return size;
- }
-
- USHORT TitleBox_DitherPattern[] = { 0x5555, 0xAAAA };
-
-
-
- void TitleBox_Render( TitleBox *self,
- RastPort *RPort )
- {
- PIXELS xmin, xmax, ymin, ymax;
-
- xmin = self->Location.x;
- xmax = xmin + self->Size.x - 1;
- ymin = self->Location.y;
- ymax = ymin + self->Size.y - 1;
-
- SetAfPt( RPort, TitleBox_DitherPattern, 1 );
- SetAPen( RPort, self->Pens.BackPen );
- SetBPen( RPort, self->Pens.DarkPen );
- SetDrMd( RPort, JAM2 );
- RectFill( RPort, xmin, ymin, xmax, ymax );
- SetAfPt( RPort, NULL, 0 );
-
-
- DrawBorder( RPort, &self->BoxBorder.TopLeft, xmin, ymin );
-
- SetDrMd( RPort, JAM1 );
- SetAPen( RPort, self->Pens.BrightPen );
-
- PrintIText( RPort, (struct IntuiText *)&self->ptext, xmin, ymin );
- }
-
- char *TitleBox_Title( TitleBox *self )
- {
- return (char *)self->ptext.IText;
- }
-
- BOOL TitleBox_SetTitle( TitleBox *self, char *title )
- {
- Afree(self->ptext.IText);
- self->ptext.IText = Astrdup(title);
- AlignText( &self->ptext, Size( (GraphicObject *)self ) );
-
- return TRUE;
- }
-
- AlignInfo *TitleBox_TextAlignment( TitleBox *self )
- {
- return( &(self->ptext.alignment) );
- }
-
- BOOL TitleBox_SetTextAlignment( TitleBox *self,
- UBYTE Flags,
- BYTE Xpad,
- BYTE Ypad )
- {
- self->ptext.alignment.Flags = Flags;
- self->ptext.alignment.Xpad = Xpad;
- self->ptext.alignment.Ypad = Ypad;
- AlignText( &self->ptext, Size( (GraphicObject *)self ) );
- return TRUE;
- }
-
-
-
-
-
- BOOL TitleBox_elaborated = FALSE;
-
- struct GraphicObjectClass TitleBox_Class;
-
-
- void TitleBoxClass_Init( struct GraphicObjectClass *class )
- {
- GraphicObjectClass_Init( class );
- class->isa = GraphicObjectClass();
- class->ClassName = "TitleBox";
- class->CleanUp = NULL;
- class->Location = (Point(*)(GraphicObject *))TitleBox_Location;
- class->SetLocation = (Point(*)(GraphicObject *, PIXELS, PIXELS))TitleBox_SetLocation;
- class->Size = (Point(*)(GraphicObject *))TitleBox_Size;
- class->AskSize = (Point(*)(GraphicObject *, PIXELS, PIXELS))TitleBox_AskSize;
- class->SetSize = (Point(*)(GraphicObject *, PIXELS,PIXELS))TitleBox_SetSize;
- class->SizeFlags = GraphicObject_SizeFlagsAll;
- class->Render = (void(*)(GraphicObject *, RastPort *))TitleBox_Render;
- class->SetTitle = (BOOL(*)(GraphicObject *, char *))TitleBox_SetTitle;
- class->Title = (char*(*)(GraphicObject *))TitleBox_Title;
- class->TextAlignment = (AlignInfo*(*)(GraphicObject *))TitleBox_TextAlignment;
- class->SetTextAlignment = (BOOL(*)(GraphicObject *,UBYTE, BYTE, BYTE))TitleBox_SetTextAlignment;
-
- }
-
-
- struct GraphicObjectClass *TitleBoxClass( void )
- {
- if( ! TitleBox_elaborated )
- {
- TitleBoxClass_Init( &TitleBox_Class );
- TitleBox_elaborated = TRUE;
- }
-
- return &TitleBox_Class;
- }
-
- void TitleBox_Init( TitleBox *self,
- PIXELS LeftEdge,
- PIXELS TopEdge,
- PIXELS Width,
- PIXELS Height,
- pcg_3DPens Pens,
- char *Label )
- {
- GraphicObject_Init( (GraphicObject *)self );
-
- self->isa = TitleBoxClass();
- self->Pens = Pens;
-
- self->ptext.FrontPen = Pens.BrightPen;
- self->ptext.BackPen = Pens.BackPen;
- self->ptext.DrawMode = JAM1;
- self->ptext.ITextFont = &pcg_Topaz80;
- self->ptext.IText = NULL;
- self->ptext.NextText = NULL;
-
- self->ptext.alignment.Flags = tx_XCENTER | tx_YCENTER | tx_INSIDE;
- self->ptext.alignment.Xpad = STD_XPAD;
- self->ptext.alignment.Ypad = STD_YPAD;
-
- SetLocation( (GraphicObject *)self, LeftEdge, TopEdge );
- SetSize( (GraphicObject *)self, Width, Height );
- SetTitle( (GraphicObject *)self, Label );
- }
-