WhipExamples/Url.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 Url()
00028 {
00029     WT_W2D_Class_Factory cf;
00030 
00031     //Define some polylines.
00032     int x=0,y=0;
00033     WT_Logical_Point vP[4];
00034     vP[0] = WT_Logical_Point(x,y);
00035     vP[1] = WT_Logical_Point(x+50,y);
00036     vP[2] = WT_Logical_Point(x,y+100);
00037     vP[3] = WT_Logical_Point(x+50,y+100);
00038     //Create the polylines.
00039     WT_Polyline *p1 = cf.Create_Polyline (2, vP, WD_True);
00040     if (p1 == NULL)
00041         return WT_Result::Out_Of_Memory_Error;
00042     WT_Polyline *p2 = cf.Create_Polyline (2, &vP[2], WD_True);
00043     if (p2 == NULL)
00044         return WT_Result::Out_Of_Memory_Error;
00045     //Create a few of hyperlinks
00046     WT_URL_Item             url1(0, "?docType=ePlot&view='Text'", "Jump to Text view");
00047     WT_URL_Item             url2(1, "?docType=ePlot&view='Images'", "Jump to Images view");
00048     WT_URL_Item             url3(2, "http://www.autodesk.com/viewers", "Autodesk Viewers Page");
00049 
00050     //Serialize line 1, with one associated hyperlinks.
00051     whip_file->desired_rendition().url().add_url_optimized(url1, *whip_file);
00052     WD_CHECK(p1->serialize (*whip_file));
00053     whip_file->desired_rendition().url().clear();
00054 
00055     //Serialize line 2, with two associated hyperlinks.
00056     whip_file->desired_rendition().url().add_url_optimized(url2, *whip_file);
00057     whip_file->desired_rendition().url().add_url_optimized(url3, *whip_file);
00058     WD_CHECK(p2->serialize (*whip_file));
00059     whip_file->desired_rendition().url().clear();
00060     
00061     cf.Destroy( p1 );
00062     cf.Destroy( p2 );
00063 
00064     return WT_Result::Success;
00065 }

Generated on Tue Jan 6 22:40:02 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5