18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C++ APPLICATION PROGRAMMING INTERFACE<br />

}<br />

return 0;<br />

Step 2: Create the widgets<br />

With the toolkit initialized, you can create the single widget you are using in this<br />

application. There are two ways to create widgets:<br />

• Using a function specific to the particular widget:<br />

XmCreatePushButton()<br />

• Using a function for generic widget creation (and sometimes managing it at<br />

the same time):<br />

XtVaCreateWidget()<br />

XtVaCreateManagedWidget()<br />

Although you will see both in the C++ samples for Motif, here you will use the<br />

second method, but will not manage the widget at its creation (simply to separate<br />

that step for the purpose of this introduction).<br />

int main(int argc, char* argv[])<br />

{<br />

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

XtAppContext app_context;<br />

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

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

XmString label = XmStringCreateLocalized("Push the button.");<br />

Widget button = XtVaCreateWidget("button",<br />

xmPushButtonWidgetClass, topLevel,<br />

XmNlabelString,<br />

label,<br />

NULL);<br />

XmStringFree(label);<br />

}<br />

return 0;<br />

The parameters have the following roles:<br />

• “button”—the name of the widget in the resource database, which can be used<br />

for specifications in a resource file. If a label is not provided, it will act as the<br />

widget’s label.<br />

• xmPushButtonWidgetClass—the class of the widget to be created. For example,<br />

to create an <strong>ArcGIS</strong> control widget, you would give mwCtlWidgetClass.<br />

• topLevel—the parent of the widget, which must be a manager widget that was<br />

already created.<br />

• XmNlabelString, label, NULL—resource settings. For more information on the<br />

resources available on different widgets and how to use them, see the Motif<br />

reference at the end of this topic. Some common resources used in the C++<br />

samples for Motif are those to set the size and placement of the widget. In<br />

addition, there is a custom resource that goes with the <strong>ArcGIS</strong> controls:<br />

MwNprogID.<br />

236 • <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!