Map tips
MapTipTool.h
// 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.
// 

 

// MapTipTool.h : Declaration of  MapTipTool
// 
// The MapTipTool displays text in a widget corresponding to which
// feature a user's mouse is over.  The text which is displayed is a
// field of that feature.

#ifndef __MAP_TIP_TOOL_MOTIF_SAMPLE_H_
#define __MAP_TIP_TOOL_MOTIF_SAMPLE_H_

/* C/C++ Headers */

#include <iostream>
#include <cwchar>

/* Motif Headers */

#define String         esriXString
#define Time           esriXTime
#define Cursor         esriXCursor
#define Object         esriXObject
#define ObjectClass    esriXObjectClass
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/Form.h>
#include <Xm/Protocols.h>
#include <Xm/PushB.h>
#include <Xm/FileSB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/ComboBox.h>
#include <Xm/Label.h>
#undef String
#undef Time
#undef Cursor
#undef Object
#undef ObjectClass

/* ArcObjects Headers */

// Engine
#include <ArcSDK.h>
// Controls
#include <Ao/AoControls.h>
#include <Ao/AoToolBase.h>

class MapTipTool : public CAoToolBase
{
 public:
  MapTipTool(Widget tooltipwidget);
  // ICommand
  HRESULT get_Enabled (VARIANT_BOOL * Enabled);
  HRESULT get_Checked (VARIANT_BOOL * Checked);
  HRESULT get_Name (BSTR * Name);
  HRESULT get_Caption (BSTR * Caption);
  HRESULT get_Tooltip (BSTR * Tooltip);
  HRESULT get_Message (BSTR * Message);
  HRESULT get_Bitmap(OLE_HANDLE * bitmapFile);
  HRESULT get_Category (BSTR * categoryName);
  HRESULT OnCreate (IDispatch * hook);
  HRESULT OnClick ();
  // ITool
  HRESULT get_Cursor(OLE_HANDLE * Cursor);
  HRESULT OnMouseDown (LONG Button, LONG Shift, LONG X, LONG Y);
  HRESULT OnMouseMove (LONG Button, LONG Shift, LONG X, LONG Y);
  HRESULT OnMouseUp (LONG Button, LONG Shift, LONG X, LONG Y);
  HRESULT OnDblClick ();
  HRESULT OnKeyDown (LONG keyCode, LONG Shift);
  HRESULT OnKeyUp (LONG keyCode, LONG Shift);
  HRESULT OnContextMenu (LONG X, LONG Y, VARIANT_BOOL * handled);
  HRESULT Refresh (OLE_HANDLE hDC);
  HRESULT Deactivate (VARIANT_BOOL * complete);
  
  // Additional public methods for interacting with Motif controls
  void SetLayerIndex(long ind) {m_layerIndex = ind;}
  void SetFieldIsSet(bool val) {m_fieldIsSet = val;}

 private:
  // Member variables
  IToolbarControlPtr m_ipToolbarControl;
  IMapControl3Ptr m_ipMapControl;
  IPointPtr m_ipPoint;
  long m_layerIndex;
  bool m_fieldIsSet;
  Widget m_tooltipwidget;
  OLE_HANDLE m_hCursor;
  OLE_HANDLE m_hBitmap;
  
  // Utility functions
  void SetToolTipText(char *inText);
};

#endif //__MAP_TIP_TOOL_MOTIF_SAMPLE_H_