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.

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

Customizing the ToolbarControl<br />

In addition to adding Controls commands to the ToolbarControl programmatically,<br />

you can also add them at runtime by customizing the ToolbarControl using the Customize<br />

dialog box. To do this, you will place the ToolbarControl in customize mode<br />

and display the Customize dialog box.<br />

1. You will place a toggle button next to the ToolbarControl to turn the toolbar<br />

customization mode on and off. To follow Motif standards, you will create a new<br />

panel for the top of the screen, and it will hold both the ToolbarControl and the<br />

toggle button.<br />

a. First, include Xm/ToggleB.h in MapViewer.h.<br />

Note that only tools and commands that are<br />

registered on the system as COM components<br />

can be added to the toolbar using the Customize<br />

dialog box. Custom C++ commands and<br />

tools, such as the one built in the previous step,<br />

do not appear in the Customize dialog box, as<br />

they are not registered as COM components in<br />

the system registry.<br />

The GTK toggle button’s setup is shown in the<br />

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

#include <br />

#include <br />

#undef String<br />

b. In MapViewer.cpp, add declarations for the toggle button widget. Also declare<br />

the ICustomizeDialog interface pointer.<br />

IEnvelopePtr g_ipCurrentExtent;<br />

ICustomizeDialogPtr g_ipCustomizeDialog;<br />

AddDateTool* g_dateTool;<br />

Widget g_customizeToggle;<br />

c. In FormSetup, create the toggle button (after mainForm is created) that will allow<br />

you to customize the toolbar as well as its panel. Update the widget attachments<br />

to reflect the new panel, replacing the location of the ToolbarControl.<br />

// Create a sub-form to place ToolbarControl and customizeToggle on<br />

Widget topFormPanel = XtVaCreateWidget("topformpanel",<br />

xmFormWidgetClass, mainForm,<br />

XmNtopAttachment, XmATTACH_FORM,<br />

XmNrightAttachment, XmATTACH_FORM,<br />

XmNleftAttachment, XmATTACH_FORM,<br />

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

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

Saved successfully!

Ooh no, something went wrong!