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 />

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

Widget mainWindow = XtVaCreateWidget("mainwindow",<br />

xmMainWindowWidgetClass, topLevel,<br />

NULL);<br />

Widget mainForm = XtVaCreateWidget("mainform",<br />

xmFormWidgetClass, mainWindow,<br />

XmNtopAttachment, XmATTACH_WIDGET,<br />

XmNtopWidget, mainWindow,<br />

XmNbottomAttachment, XmATTACH_WIDGET,<br />

XmNbottomWidget, mainWindow,<br />

XmNleftAttachment, XmATTACH_WIDGET,<br />

XmNleftWidget, mainWindow,<br />

XmNrightAttachment, XmATTACH_WIDGET,<br />

XmNrightWidget, mainWindow,<br />

XmNfractionBase, 100,<br />

NULL);<br />

d. Manage the child widgets.<br />

Widget mainForm = XtVaCreateWidget(…);<br />

// Manage the non-parent widgets<br />

XtManageChild(mainWindow);<br />

XtManageChild(mainForm);<br />

e. Listen for window manager events to exit the application on command. To<br />

set this up, you will use a callback on the entire application that will respond<br />

to window manager protocols. When the window manager’s close<br />

message is received, the CloseAppCallback function is executed. Here just<br />

listen—you will implement the callback function in Step 9.<br />

XtManageChild(mainForm);<br />

GTK deals with closing differently, as shown in<br />

form_setup of GTK’s MapViewer.cpp.<br />

// Handle the "close" window manager message<br />

Atom wm_delete_window = XmInternAtom(XtDisplay(topLevel),<br />

"WM_DELETE_WINDOW", FALSE);<br />

XmAddWMProtocolCallback(topLevel,<br />

wm_delete_window, CloseAppCallback,<br />

NULL);<br />

f. With all the application widgets created and managed and all the callbacks<br />

registered, the application can start running. Realizing the top-level widget<br />

recursively creates the actual windows for all the application widgets. The<br />

call to the function is made at the end of your FormSetup function.<br />

void FormSetup(…)<br />

{<br />

…<br />

XmAddWMProtocolCallback(topLevel,<br />

wm_delete_window, CloseAppCallback,<br />

NULL);<br />

Chapter 6 • <strong>Developer</strong> scenarios • 363

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

Saved successfully!

Ooh no, something went wrong!