WhipExamples/Text.cpp

00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #include "whiptk/whip_toolkit.h"
00023 #include "whiptk/w2d_class_factory.h"
00024 
00025 extern WT_File *whip_file; //Assume this has been opened for writing elsewhere.
00026 
00027 WT_Result Text()
00028 {
00029     WT_W2D_Class_Factory cf;
00030 
00031     int x=0, y=0;
00032 
00033     //Define scoring positions.
00034     WT_Unsigned_Integer16 score_pos[6] = { 0, 1, 2, 3, 4, 5};
00035     //Define a bounding box.
00036     WT_Logical_Point bounds[4];
00037     bounds[0].m_x = x;
00038     bounds[0].m_y = y-200;
00039     bounds[1].m_x = x+1190;
00040     bounds[1].m_y = y-200;
00041     bounds[2].m_x = x+1190;
00042     bounds[2].m_y = y;
00043     bounds[3].m_x = x;
00044     bounds[3].m_y = y;
00045 
00046     //Create text with overscoring, underscoring, and a bounding box
00047     WT_Text *text = cf.Create_Text( WT_Logical_Point(x, y-200), WT_String("Text 1"), bounds, 6, score_pos, 6, score_pos);
00048     if (text == NULL)
00049         return WT_Result::Out_Of_Memory_Error;
00050     //Serialize it.
00051     WD_CHECK(text->serialize(*whip_file));
00052     cf.Destroy( text );
00053 
00054     //Create simple text using current rendition settings.
00055     text = cf.Create_Text(WT_Logical_Point(x, y-500), WT_String("Text 2"));
00056     if (text == NULL)
00057         return WT_Result::Out_Of_Memory_Error;
00058     
00059     //Serialize it.
00060     WD_CHECK(text->serialize(*whip_file));
00061     cf.Destroy(text);
00062 
00063     return WT_Result::Success;
00064 }

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5