Globe, TOC, and toolbar
GlobeTocToolbar.cpp
// Copyright 2010 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 

  
#include <stdio.h>
#include <qapplication.h>
#include <qvbox.h>
#include <qsplitter.h>

#include <ArcSDK.h>
#include <AxCtl/qt3axctl.h>
#include <Ao/AoControls.h>

void add_toolbar_items(IToolbarControl* pToolbar);

int main(int argc, char **argv)
{
  // Initialize the Engine
  ::AoInitialize(NULL);
  {
    IAoInitializePtr ipInit(CLSID_AoInitialize);
    esriLicenseStatus status;
    ipInit->Initialize(esriLicenseProductCodeEngine, &status);
    if (status != esriLicenseCheckedOut)
    {
      printf("Invalid Licensing.\n");
      AoExit(0);
    }
  }
  
  QApplication qapp(argc, argv);

  QVBox vbox(NULL);
  vbox.resize(500 , 400);

  QAxCtl tlb(AoPROGID_ToolbarControl, &vbox, "Toolbar Control");
  tlb.setMinimumHeight(30);
  tlb.setMaximumHeight(30);

  QSplitter split(&vbox);
  
  QAxCtl toc(AoPROGID_TOCControl, &split, "TOC Control");
  QAxCtl glb(AoPROGID_GlobeControl, &split, "Globe Control");
  
  qapp.setMainWidget(&vbox);

  vbox.show();

  {
    IToolbarControlPtr ipToolbar;
    IGlobeControlPtr   ipGlobe;
    ITOCControlPtr     ipToc;
    HRESULT hr;

    hr = tlb.getInterface((IUnknown **)&ipToolbar);
    hr = toc.getInterface((IUnknown **)&ipToc);
    hr = glb.getInterface((IUnknown **)&ipGlobe);

    if (ipToolbar != 0) 
      ipToolbar->SetBuddyControl(ipGlobe);
    if (ipToc != 0) 
      ipToc->SetBuddyControl(ipGlobe);
  
    add_toolbar_items(ipToolbar);
  }
  
  qapp.exec();  

  // Uninitialize the engine
  {
    IAoInitializePtr ipInit(CLSID_AoInitialize);
    ipInit->Shutdown();
  }
  ::AoUninitialize();

  AoExit(0);
  return 0;
}

void add_toolbar_items(IToolbarControl* pToolbar)
{
  CComVariant varTool;
  long itemIndex;

  if (!pToolbar) 
    return;

  varTool = L"esriGlobeCore.ControlsGlobeOpenDocCommand";
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeZoomInOutTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_TRUE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeFixedZoomInCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeFixedZoomOutCommand";
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobePanTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeFullExtentCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeNavigateTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeRotateForwardCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeRotateBackCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeRotateClockwiseCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeRotateCounterClockwiseCommand";
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSpinClockwiseCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSpinCounterClockwiseCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSpinFasterCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSpinSlowerCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSpinStopCommand"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeTargetCenterTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeTargetZoomTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeWalkTool"; 
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriGlobeCore.ControlsGlobeSelectFeaturesTool";
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
  varTool = L"esriControlCommands.ControlsSelectTool";
  pToolbar->AddItem(varTool, 0, -1, VARIANT_FALSE, 0,
                     esriCommandStyleIconOnly, &itemIndex);
}