18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH C++ AND CONTROL WIDGETS<br />

6. To increase code readability, use a helper function FormSetup. You will need to<br />

pass in an XtAppContext, which will be set in that function, as well as the<br />

parameters passed into main.<br />

a. First, place a definition of this file in MapViewer.h. You will also need to<br />

inform the compiler where to find the Resize function, which you will be<br />

using in FormSetup().<br />

#include <br />

For the equivalent GTK setup, see<br />

form_setup in the provided MapViewer.cpp<br />

file in the GTK zip file. You will notice that the<br />

GTK function names differ slightly from the<br />

Motif ones. This is to maintain the programming<br />

styles associated with each.<br />

void FormSetup(int argc, char* argv[], XtAppContext* app_context);<br />

extern "C" void XtResizeWidget(Widget, _XtDimension,<br />

_XtDimension, _XtDimension);<br />

#endif // __ENGINE_CONTROL_MOTIF_EXAMPLE__<br />

b. After initialization in MapViewer.cpp, call FormSetup, which you will write<br />

in the following steps.<br />

::AoInitialize(NULL);<br />

{<br />

…<br />

}<br />

XtAppContext app_context;<br />

FormSetup(argc, argv, &app_context);<br />

7. In MapViewer.cpp, after the main function, begin writing FormSetup by setting<br />

the language procedure for your application.<br />

void FormSetup(int argc, char* argv[], XtAppContext* app_context)<br />

{<br />

XtSetLanguageProc(NULL,NULL,NULL);<br />

}<br />

8. Continuing in FormSetup, create the Motif form for the MapViewer.<br />

a. Initialize the Motif toolkit and create your top-level application Motif<br />

widget.<br />

XtSetLanguageProc(NULL,NULL,NULL);<br />

// Initialize the Motif toolkit and create the parent widget<br />

Widget topLevel = XtVaAppInitialize(app_context, "XApplication", NULL,<br />

0, &argc, argv, NULL, NULL);<br />

XtVaSetValues(topLevel, XmNtitle, "MapViewer", NULL);<br />

b. Set the application’s initial size to 800 x 640, using the resize function that<br />

you placed in MapViewer.h earlier.<br />

XtVaSetValues(topLevel, XmNtitle, "MapViewer", NULL);<br />

// Set the application size by resizing the created widget<br />

XtResizeWidget(topLevel, 800, 640, 1);<br />

c. Create the main application window after the resize. Create the main form<br />

and attach it to the main window so that it fills the window. The main form<br />

widget will be the parent widget for each of the ESRI <strong>Engine</strong> Control<br />

widgets.<br />

362 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!