GTK ArcGIS control programming


The Engine C++ SDK also provides a set of GTK widgets that may be used to embed the ArcGIS controls in a GTK application.

Header files

For an ArcGIS GTK control application, you will need to include Ao/GtkControls.h in addition to your ArcGIS Engine and GTK includes (ArcSDK.h and gtk/gtk.h, respectively).

Control types and their details

Control
ProgID
Interface type
GlobeControl
AoPROGID_GlobeControl
IGlobeControl
MapControl
AoPROGID_MapControl
IMapControl3
PageLayoutControl
AoPROGID_PageLayoutControl
IPageLayoutControl
ReaderControl
AoPROGID_ReaderControl
IARControl
SceneControl
AoPROGID_SceneControl
ISceneControl
TOCControl
AoPROGID_TOCControl
ITOCControl
ToolbarControl
AoPROGID_ToolbarControl
IToolbarControl

API functions and arguments

  • For each ArcGIS Engine Control interface, there is a smart pointed defined for you. Instead of IMapControl3* you can use IMapControl3Ptr.
  • gtk_axctl_new is used to create the GTK ArcGIS Control Widget.

    GtkWidget *gtk_axctl_new(ControlDataPtr cd);
  • gtk_axctl_get_interface is used to get the control's interface pointer.

    HRESULT gtk_axctl_get_interface(GtkWidget *axctl, IUnknown **ppUnk);
  • gtk_axctl_initialize_message_queue is used to enable MainWin message delivery before starting the main GTK loop with gtk_main.

    void gtk_axctl_initialize_message_queue();
  • gtk_axctl_set_cursor is used to set a custom cursor for the GTK control widget.

    HRESULT gtk_axctl_set_cursor(HCURSOR cur);

Control widget creation example

The following example demonstrates creating and placing a map control that fills the entire GTK form window (defined outside this code snippet) and retrieves a smart pointer for the control.
[GTK C++]
          // ArcObjects Headers
          // Engine
          #include <ArcSDK.h>
// Controls#include <Ao/AoGtkControls.h>
int main(int argc, char *argv[])
{
  // some previous code goes here

  GtkWidget *mapWidget;
  IMapControl3Ptr ipMapControl;
  mapWidget = gtk_axctl_new(AoPROGID_MapControl);
  gtk_axctl_get_interface(mapWidget, (IUnknown **) &ipMapControl);
  gtk_widget_set_size_request(mapWidget,  - 1,  - 1);
  gtk_container_add(GTK_CONTAINER(window), mapWidget);

  // more code here
}