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.

C++ APPLICATION PROGRAMMING INTERFACE<br />

Setting the size of a control widget<br />

If you would like to set your control widget to have a specific size, you will need<br />

to do this after the widget itself is created. Do not use XmNheight and<br />

XmNwidth in the XtVaCreateWidget section. Due to internal limitations, that<br />

will cause undetermined behavior in the controls. Instead, set the size of your<br />

widget after it is created with a call to XtVaSetValues. For example, to set the<br />

above mapControl to be 200x200, add the line:<br />

XtVaSetValues(mapWidget, XmNheight, 200, XmNwidth, 200, NULL);<br />

after the call to XtVaCreateWidget.<br />

GTK PROGRAMMING<br />

Getting started with GTK programming<br />

GIMP Toolkit (GTK) widget <strong>ArcGIS</strong> controls have been provided for C++<br />

developers. To use them, you must understand some basics of GTK programming.<br />

This is not by any means a complete resource; the variety of GTK widgets and<br />

their resources, which you have available to you as a programmer, are not discussed<br />

here. However, this should give you a place to start figuring out the GTKspecific<br />

bits of the C++ API and samples.<br />

Seven steps of GTK programming<br />

When writing a GTK program, there are seven steps that need to be done.<br />

1. Initialize GTK.<br />

2. Create the widgets.<br />

3. Place the widgets.<br />

4. Implement event listening and callback functions for widgets.<br />

5. Show the widgets.<br />

6. Begin the event handling loop.<br />

7. Shut down the application.<br />

To illustrate each of these steps, you will create a simple GTK application.<br />

GTK Program: Simple PushButton<br />

This application will be a single button that displays which button on the mouse<br />

was used to click on the button widget. Start a new file that will be your program.<br />

Here that file will be called pbExample.cpp.<br />

To use GTK you will need to include the GTK header file: gtk/gtk.h. For the<br />

display of the number of the button clicked, you will need to include iostream.<br />

You will also need a main function. Set these up in your new file, so that it looks<br />

like this:<br />

#include <br />

#include <br />

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

{<br />

return 0;<br />

}<br />

Chapter 4 • <strong>Developer</strong> environments • 241

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

Saved successfully!

Ooh no, something went wrong!