home *** CD-ROM | disk | FTP | other *** search
- #include <classes/Graphics/Text.h>
-
- #pragma -
- #include <pragma/diskfont_lib.h>
- #include <pragma/graphics_lib.h>
- #pragma +
-
- TextFontC::TextFontC()
- : opened()
- {
- textfont = NULL;
- }
-
- TextFontC::TextFontC(const TextFontC &s)
- : opened()
- {
- textfont = s.textfont;
- // Falls ein Font geöffnet war...
- if (!s.opened.only())
- {
- // kopiere und referenziere diesen.
- opened = s.opened;
- opened.reference()
- };
- // Ansonsten wird der schon angelegte Referenzenzähler benutzt.
- }
-
- TextFontC::~TextFontC()
- {
- close();
- }
-
- TextFontC &TextFontC::operator = (const TextFontC &s)
- {
- if (this != &s)
- {
- close();
- textfont = s.textfont;
- // Falls kein Font geöffnet war...
- if (s.opened.only())
- {
- // lege eine neue Instanz für den Referenzenzähler an...
- opened = ShareManualC()
- }
- else {
- // ansonsten kopiere und referenziere den alten.
- opened = s.opened;
- opened.reference()
- };
- };
- return *this;
- }
-
- BOOL TextFontC::open(const TextAttrC &t)
- {
- if (opened.only())
- {
- if (textfont = OpenFont((struct TextAttr *) &t))
- {
- opened.reference();
- return TRUE;
- };
- if (textfont = OpenDiskFont((struct TextAttr *) &t))
- {
- opened.reference();
- return TRUE;
- };
- };
- return FALSE;
- }
-
- VOID TextFontC::close()
- {
- if (textfont)
- {
- opened.dereference();
- if (opened.only())
- {
- CloseFont(textfont);
- textfont = NULL;
- };
- };
- }
-
- // *************************************************************
-
- TextAttrC::TextAttrC(STRPTR name, UWORD YSize,
- UBYTE Style, UBYTE Flags, struct TagItem *tagitems)
- : tags(tagitems),
- fontname(name)
- {
- tta_Name = (STRPTR) fontname;
- tta_YSize = YSize;
- tta_Style = Style;
- tta_Flags = Flags|FSF_TAGGED;
- tta_Tags = tags.tags();
- }
-
- TextAttrC::TextAttrC(STRPTR name, UWORD YSize,
- UBYTE Style, UBYTE Flags, Tag tag1type, ...)
- : tags((struct TagItem *) &tag1type),
- fontname(name)
- {
- tta_Name = (STRPTR) fontname;
- tta_YSize = YSize;
- tta_Style = Style;
- tta_Flags = Flags|FSF_TAGGED;
- tta_Tags = tags.tags();
- }
-
- TextAttrC::TextAttrC(const struct TextAttr &t)
- : tags(NULL),
- fontname(t.ta_Name)
- {
- tta_Name = (STRPTR) fontname;
- tta_YSize = t.ta_YSize;
- tta_Style = t.ta_Style;
- tta_Flags = t.ta_Flags|FSF_TAGGED;
- tta_Tags = NULL;
- }
-
- TextAttrC::TextAttrC(const TextAttrC &t)
- : tags(t.tags),
- fontname(t.fontname)
- {
- tta_Name = (STRPTR) fontname;
- tta_YSize = t.tta_YSize;
- tta_Style = t.tta_Style;
- tta_Flags = t.tta_Flags;
- tta_Tags = tags.tags();
- }
-
- TextAttrC &TextAttrC::operator= (const TextAttrC &s)
- {
- if (this != &s)
- {
- fontname = s.fontname;
- tta_Name = (STRPTR) fontname;
- tta_YSize = s.tta_YSize;
- tta_Style = s.tta_Style;
- tta_Flags = s.tta_Flags;
- tags = s.tags;
- tta_Tags = tags.tags();
- };
- return *this;
- }
-
- /*
- TextAttrC &TextAttrC::operator= (const struct TextAttr &t)
- {
- fontname = t.ta_Name;
- tta_Name = (STRPTR) fontname;
- tta_YSize = t.ta_YSize;
- tta_Style = t.ta_Style;
- tta_Flags = t.ta_Flags|FSF_TAGGED;
- tags = TagItemC(NULL);
- tta_Tags = NULL;
- return *this;
- }
- */
-
- TextAttrC &TextAttrC::assign(const TextAttrC &s)
- {
- return *this;
- }
-
- // *************************************************************
-
-
- LTextAttrC::LTextAttrC(STRPTR name, UWORD YSize,
- UBYTE Style, UBYTE Flags, struct TagItem *tagitems)
- : TextAttrC(name,YSize,Style,Flags,tagitems),
- fontlock()
- {
- if (!fontlock.open(*this))
- throw FontX();
- }
-
- LTextAttrC::LTextAttrC(STRPTR name, UWORD YSize,
- UBYTE Style, UBYTE Flags, Tag tag1type, ...)
- : TextAttrC(name,YSize,Style,Flags,(struct TagItem *) &tag1type),
- fontlock()
- {
- if (!fontlock.open(*this))
- throw FontX();
- }
-
- LTextAttrC::LTextAttrC(const struct TextAttr &s)
- : TextAttrC(s),
- fontlock()
- {
- if (!fontlock.open(*this))
- throw FontX();
- }
-
- LTextAttrC::LTextAttrC(const LTextAttrC &s)
- : TextAttrC(s),
- fontlock(s.fontlock)
- {
- }
-
- LTextAttrC <extAttrC::operator= (const LTextAttrC &s)
- {
- if (this != &s)
- {
- TextAttrC::operator= (s);
- fontlock = s.fontlock;
- };
- return *this;
- }
-
- /*
- LTextAttrC <extAttrC::operator= (const struct TextAttr &s)
- {
- fontlock.close();
- TextAttrC::operator= (s);
- if (!fontlock.open(*this))
- throw FontX();
- return *this;
- }
- */
-
- // *************************************************************
-
- FTextAttrC::FTextAttrC(STRPTR Name, UWORD YSize,
- UBYTE Style, UBYTE StyleMask,
- UBYTE Flags, UBYTE FlagsMask,
- struct TagItem *tagitems)
- : TextAttrC(Name,YSize,Style,Flags,tagitems)
- {
- named = Name != NULL;
- sized = YSize != NULL;
- styleMask = StyleMask;
- flagsMask = FlagsMask;
- }
-
- FTextAttrC::FTextAttrC(STRPTR Name, UWORD YSize,
- UBYTE Style, UBYTE StyleMask, UBYTE Flags, UBYTE FlagsMask,
- Tag tag1type, ...)
- : TextAttrC(Name,YSize,Style,Flags,(struct TagItem *) &tag1type)
- {
- named = Name != NULL;
- sized = YSize != NULL;
- styleMask = StyleMask;
- flagsMask = FlagsMask;
- }
-
- TextAttrC &FTextAttrC::assign(const TextAttrC &s)
- {
- if ((TextAttrC *) this != &s)
- {
- if (!named)
- {
- fontname = s.tta_Name;
- tta_Name = (STRPTR) fontname;
- };
- if (!sized)
- tta_YSize = s.tta_YSize;
- tta_Style = (tta_Style & styleMask) | (s.tta_Style & ~styleMask);
- tta_Flags = (tta_Flags & flagsMask) | (s.tta_Flags & ~flagsMask);
- };
- return (TextAttrC &) *this;
- }
-
- // *************************************************************
-
- FLTextAttrC::FLTextAttrC(STRPTR Name, UWORD YSize,
- UBYTE Style, UBYTE StyleMask,
- UBYTE Flags, UBYTE FlagsMask,
- struct TagItem *tagitems)
- : FTextAttrC(Name,YSize,Style,StyleMask,Flags,FlagsMask,tagitems),
- fontlock()
- {
- }
-
- FLTextAttrC::FLTextAttrC(STRPTR Name, UWORD YSize,
- UBYTE Style, UBYTE StyleMask, UBYTE Flags, UBYTE FlagsMask,
- Tag tag1type, ...)
- : FTextAttrC(Name,YSize,Style,StyleMask,Flags,FlagsMask,
- (struct TagItem *) &tag1type),
- fontlock()
- {
- }
-
- TextAttrC &FLTextAttrC::assign(const TextAttrC &s)
- {
- if ((TextAttrC *) this != &s)
- {
- fontlock.close();
- FTextAttrC::assign(s);
- if (!fontlock.open(*this))
- throw FontX();
- };
- return (TextAttrC &) *this;
- }
-