标签:des style blog ar io color os sp for
1 //HelloWorld2.cpp 2 3 /* 4 Copyright 2000-2004 The VCF Project. 5 Please see License.txt in the top level directory 6 where you installed the VCF. 7 */ 8 9 10 /** 11 *This builds on our work in the first example, HelloWorld 12 *This will demonstrate customizing the VCF::Application class 13 *and positioning the window where we want it 14 */ 15 16 /** 17 *standard headers here 18 */ 19 #include "vcf/ApplicationKit/ApplicationKit.h" 20 21 22 using namespace VCF; 23 24 /** 25 *This is our application derived class that 26 *we are going to customize. 27 *We override one method: the initRunningApplication() method, 28 *which surprisingly enough, is called to initialize the running 29 *application. 30 *In this method we can execute whatever appropriate start up code is 31 *neccessary for our application, including createing the main 32 *window like we‘ll do below. 33 */ 34 class HelloWorld2Application : public Application { 35 public: 36 37 HelloWorld2Application( int argc, char** argv ): Application(argc, argv) { 38 39 } 40 41 virtual bool initRunningApplication(){ 42 /** 43 *call the super classes initRunningApplication() 44 *and store off the result. 45 *If anything goes wrong here that will prevent our app 46 *from starting, we should return false, to attempt 47 *to gracefully allow the application to shut down 48 */ 49 bool result = Application::initRunningApplication(); 50 51 /** 52 *Create the window as before 53 */ 54 Window* mainWindow = new Window(); 55 56 /** 57 *set the main window, again as we did in the first 58 *HelloWorld example 59 */ 60 setMainWindow( mainWindow ); 61 62 /** 63 *set the bounds for the main window. 64 *First create a VCF::Rect object on the stack 65 *passing in the desired left, top, right, and 66 *bottom coordinates. Our coordinates are screen 67 *coordinates, since this is the main window and 68 *it does not have a parent. As usual, the coordinates 69 *origin is in the top left corner of the screen 70 * 71 *In our case we will pass in 100.0, 100.0 for the left 72 *and top coordinates, and 500.0, and 500.0 for the 73 *right and bottom, thus giving us a window with a 74 *width and height of 400.0 and 400.0 respectively. 75 */ 76 Rect mainWindowBounds( 100.0, 100.0, 500.0, 500.0 ); 77 78 /** 79 *pass in a pointer to the rect to the window 80 *via the setBounds() call 81 */ 82 mainWindow->setBounds( &mainWindowBounds ); 83 84 /** 85 set caption 86 */ 87 mainWindow->setCaption( "Hello World 2" ); 88 89 /** 90 *Show the main window 91 */ 92 mainWindow->show(); 93 94 return result; 95 } 96 97 }; 98 99 100 /** 101 *the applications one and only main function 102 */ 103 int main(int argc, char *argv[]) 104 { 105 /** 106 *here we create an instance of our application class on the heap 107 */ 108 Application* app = new HelloWorld2Application( argc, argv ); 109 110 /** 111 *call the appMain() method 112 */ 113 Application::main(); 114 115 return 0; 116 } 117 118 119 /** 120 $Id: HelloWorld2.cpp 2647 2006-04-28 16:42:38Z kdmix $ 121 */
标签:des style blog ar io color os sp for
原文地址:http://www.cnblogs.com/elitiwin/p/4171057.html