Not sure if this helps but here goes...
The application I'm thinking of is, not surprisingly, Visual Studio 2005. Mainly for use with re-factoring.
Here's an example:
SQL is sometimes a bit back-to-front, i.e. SELECT - what comes here in an InteiiSense list? You don't have a table etc. yet, and presenting all columns, for example, would be overkill and take a while to populate. You could do this - SELECT Orders.Id, Orders.Code FROM Orders o.
The IntelliSense list would provide tables by default, then when you type '.' you have enough information to just provide columns for that table. However Orders.Id is a bit unnatural for an SQL statement so when you type 'o' a SmartTag indicator comes up and the options include re-alias Orders to o, resulting in SELECT o.Id, o.Code FROM Orders o.
I would foresee the SmartTag being an extremely simple model (See suggested properties/methods/events below). This is how I see it working:
1) Respond to an event raised by SyntaxEditor etc. e.g. Typing or parsing
2) Determine the context of the token where the change was made
Nothing new yet - this could also be ignored and the following done based on some other logic
3) Call SmartTag.ShowIndicator with the offset of the token or wherever the appropriate context is. This would display the little yellow underline indicator.
4) When the user hovers the mouse over the indicator you raise the Popup event then show the SmartTag square (The yellow underline indicator is hidden)
5) When the user hovers the mouse over the SmartTag the tool tip is displayed and the drop down arrow added to the SmartTag. If the user moves the mouse away the drop down arrow is removed but the SmartTag remains for a few seconds then reverts to the yellow underline indicator
6) When the user clicks on the SmartTag you raise the Click event
That's it. It would then be up the developer to display the options list (this allows the developer to use their own menus - no offence but I use a different set of menu components and would like the options to be consistent with my application's style). The developer then just responds to the menus click event as they would any other menu and do whatever they want.
As far as I can tell from VS2005 there is only ever 1 SmartTag active at a time so it could be static as I've indicated. If you know differently then this would obviously need to be instance based and you may want to add a SmartTagCollection.
I hope this is simple yet does everything that is needed. While I'm sure you could improve upon this in future versions but when, how, and what, is up to you.
I've used the word 'Indicator' here, I'm not sure if there is an official term or you can think of something better.
// Text displayed in tool tip when the mouse is hovered over the SmartTag
Propery: string ToolTipText
// Is the yellow underline being shown
Property: bool IndicatorVisible
// Is the SmartTag being shown - This allows for things like 'if (SmartTag.Visible) SmartTag.Clear();'
Property: bool Visible
// This would be the screen or client location where the SmartTag would be displayed
Property: Point Location
// Shows the yellow underline indicator at the specified offset (If the indicator is already showing elsewhere then it is hidden and shown at the new offset - that assumes there can only be one SmartTag active at a time)
Method: void ShowIndicator(int offset)
// Hides the currently dispalyed indicator (if not showing does nothing)
Method: void HideIndicator()
// Shows the SmartTag at the offset previously set with ShowIndicator (if the indicator is not visible then does nothing)
Method: void Show()
// Shows the SmartTag at the specified offset (hides the indicator) - This also allows for showing the SmartTag without ever having shown the indicator (If the SmartTag is already showing elsewhere then it is hidden and shown at the new offset - that assumes there can only be one SmartTag active at a time)
Method: void Show(int offset)
// Hides the currently displayed SmartTag (if not showing does nothing) and re-displays the yellow underline indicator at the offset specifies when Show was called
Method: void Hide()
// Hides the SmartTag if visible, hides the indicator if visible (if neither showing then does nothing)
Method: void Clear();
// Occurs when the user hovers the mouse over the yellow underline indicator and the SmartTag is displayed
Event: EventHandler Popup
// Occurs when the SmartTag is clicked - This allows the developer to show the options menu or take any other action
Event: EventArgs Click