home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- //
- // Copyright (c) 2002, Colin Granville
- //
- // All rights reserved.
- //
- // Redistribution and use in source and binary forms, with or
- // without modification, are permitted provided that the following
- // conditions are met:
- //
- // * Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- //
- // * Redistributions in binary form must reproduce the above
- // copyright notice, this list of conditions and the following
- // disclaimer in the documentation and/or other materials
- // provided with the distribution.
- //
- // * The name Colin Granville may not be used to endorse or promote
- // products derived from this software without specific prior
- // written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- // OF THE POSSIBILITY OF SUCH DAMAGE.
- //
- //--------------------------------------------------------------------------
-
- #include "GuiDrawFileText.h"
- #include "iostream.h"
- #include <limits.h>
-
- GuiDrawFileText::GuiDrawFileText(GuiDrawFile& d)
- : drawfile(d)
- {
- ob.typeId=OBJECT_ID;
- }
-
- //***************************************************************
-
- GuiDrawFileText::~GuiDrawFileText()
- {
- }
-
- //***************************************************************
-
- void GuiDrawFileText::start()
- {
- ob.size=drawfile.startObject(sizeof(GuiDrawFileGraphicsObject) + sizeof(GuiDrawFileTextState));
- }
-
- //***************************************************************
-
- void GuiDrawFileText::end(const GuiDrawFileTextState& state, int handle)
- {
- static struct {int a[5];GuiBBox bounds;} fscb = {0,0, 0,0, -1, {0,0,0,0}};
- put('\0');
-
- int i;
- for (i=drawfile.getSize();i & 3;i++) put('\0');
-
- if (drawfile.hasFailed()) return;
-
-
- _swix(Font_ScanString,_INR(0,6), handle,
- drawfile.getPtr(ob.size+sizeof(GuiDrawFileGraphicsObject) +
- sizeof(GuiDrawFileTextState)),
- (1<<5) | (1<<6) | (1<<8) | (1<<18),
- INT_MIN,INT_MIN,&fscb,&state.transform);
-
- //should be 16/25 but 21/32 is faster and it needs a bit extra anyway
- ob.bounds.xmin=fscb.bounds.xmin*21/32+state.x-4*256;
- ob.bounds.xmax=fscb.bounds.xmax*21/32+state.x;
- ob.bounds.ymin=fscb.bounds.ymin*21/32+state.y-4*256;
- ob.bounds.ymax=fscb.bounds.ymax*21/32+state.y;
- int offset=ob.size;
- ob.size=i-offset;
- *(GuiDrawFileGraphicsObject*)drawfile.getPtr(offset)=ob;
- *(GuiDrawFileTextState*)drawfile.getPtr(offset+sizeof(GuiDrawFileGraphicsObject))=state;
- drawfile.addBBox(ob.bounds);
- drawfile.endObject();
- }
-
- //***************************************************************
-
- void GuiDrawFileText::put(const char* s)
- {
- for (;*s;s++) put(*s);
- }
-