Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/testbed/text_test.cxx

Go to the documentation of this file.
00001 // Filename: text_test.cxx
00002 // Created by:  
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include <eventHandler.h>
00020 #include <chancfg.h>
00021 #include <textNode.h>
00022 #include <eggLoader.h>
00023 #include <notify.h>
00024 #include <pt_NamedNode.h>
00025 
00026 extern PT_NamedNode render;
00027 extern PT_NamedNode egg_root;
00028 extern EventHandler event_handler;
00029 
00030 extern int framework_main(int argc, char *argv[]);
00031 extern void (*define_keys)(EventHandler&);
00032 
00033 PT(TextNode) text_node;
00034 char *textStr;
00035 
00036 void event_p(CPT_Event) {
00037   text_node->set_text("I'm a woo woo woo!");
00038 
00039   nout << "text is " << text_node->get_width() << " by "
00040        << text_node->get_height() << "\n";
00041 }
00042 
00043 void event_s(CPT_Event) {
00044   text_node->set_wordwrap(5.0);
00045 
00046   nout << "text is " << text_node->get_width() << " by "
00047        << text_node->get_height() << "\n";
00048 }
00049 
00050 void text_keys(EventHandler& eh) {
00051   eh.add_hook("p", event_p);
00052   eh.add_hook("s", event_s);
00053 
00054   text_node = new TextNode("text_node");
00055   PT_NamedNode font = loader.load_sync("cmr12");
00056   text_node->set_font(font.p());
00057   text_node->set_wordwrap(20.0);
00058   text_node->set_card_as_margin(0.25, 0.25, 0.25, 0.25);
00059   PT(Texture) tex = new Texture;
00060   tex->set_name("genericButton.rgb");
00061   tex->set_minfilter(Texture::FT_linear);
00062   tex->set_magfilter(Texture::FT_linear);
00063   tex->read("/beta/toons/textures/smGreyButtonUp.rgb");
00064   text_node->set_card_texture( tex );
00065   text_node->set_card_border(0.1, 0.1);
00066   text_node->set_text( textStr );
00067   text_node->set_text_color( 0.0, 0.0, 0.0, 1.0 );
00068   if (text_node->has_card_texture())
00069     nout << "I've got a texture!" << "\n";
00070   else
00071     nout << "I don't have a texture..." << "\n";
00072   nout << "text is " << text_node->get_width() << " by "
00073        << text_node->get_height() << "\n";
00074 
00075   new RenderRelation(egg_root, text_node);
00076 }
00077 
00078 int main(int argc, char *argv[]) {
00079   define_keys = &text_keys;
00080         if (argc > 1)
00081                 textStr = argv[1];
00082         else
00083                 textStr = argv[0];
00084   return framework_main(argc, argv);
00085 }

Generated on Fri May 2 00:44:12 2003 for Panda by doxygen1.3