Click here to Skip to main content
15,885,757 members
Articles / Containers / Virtual Machine

TOOL

Rate me:
Please Sign up or sign in to vote.
4.98/5 (52 votes)
23 Oct 200676 min read 230.2K   5.4K   147  
TOOL (Tiny Object Oriented Language) is an easily-embedded, object-oriented, C++-like-language interpreter. The purpose of this article is to introduce the TOOL interpreter and language from the perspective of a person who has a desire to include a scripting solution as part of his project.
#ifndef XML_FORM_COMBOBOX_H_INCLUDED
#define XML_FORM_COMBOBOX_H_INCLUDED
/*****************************************************************************/
/*                              HEADER FILE                                  */
/*****************************************************************************/
/*
          $Archive:   $

         $Revision:   $

      Last Checkin:
             $Date:   $
                By:
           $Author:   $

 Last Modification:
          $ModTime:   $

       Description:   This code based on a project found on the web. It has 
                      been significantly reworked and cleaned up, so may not
                      resemble the original code at all. Original author's
                      comments shown below:

                      CAdvComboBox Control
                      Version: 2,0
                      Date: September 2002
                      Author: Mathias Tunared
                      Email: Mathias@inorbit.com
                      Copyright (c) 2002. All Rights Reserved.

                      This code, in compiled form or as source code, may be 
                      redistributed unmodified PROVIDING it is not sold for 
                      profit without the authors written consent, and providing 
                      that this notice and the authors name and all copyright 
                      notices remains intact.

                      This file is provided "as is" with no expressed or implied 
                      warranty. The author accepts no liability for any damage/loss
                      of business that this product may cause.

                      TOOL And XML FORMS License
                      ==========================

                      Except where otherwise noted, all of the documentation 
                      and software included in the TOOL package is 
                      copyrighted by Michael Swartzendruber.

                      Copyright (C) 2005 Michael John Swartzendruber. 
                      All rights reserved.

                      Access to this code, whether intentional or accidental,
                      does NOT IMPLY any transfer of rights.

                      This software is provided "as-is," without any express 
                      or implied warranty. In no event shall the author be held
                      liable for any damages arising from the use of this software.

                      Permission is granted to anyone to use this software for 
                      any purpose, including commercial applications, and to 
                      alter and redistribute it, provided that the following 
                      conditions are met:

                      1. All redistributions of source code files must retain 
                         all copyright notices that are currently in place, 
                         and this list of conditions without modification.

                      2. The origin of this software must not be misrepresented;
                         you must not claim that you wrote the original software.

                      3. If you use this software in another product, an acknowledgment
                         in the product documentation would be appreciated but is
                         not required.

                      4. Modified versions in source or binary form must be plainly 
                         marked as such, and must not be misrepresented as being 
                         the original software.
*/
/*****************************************************************************/




#if _MSC_VER > 1000
#pragma once
#endif

#include "XMLFormControls.h"
#include "XMLFormComboBoxDropListBox.h"
#include "XMLFormComboBoxDropWnd.h"


#define WM_ON_DROPDOWN_BUTTON       WM_USER + 101
#define ACBS_FLAT                   0x0001
#define ACBS_STANDARD               0x0002
#define ACBS_CHECKED                0x0004
#define ACBS_AUTOAPPEND             0x0008
#define ACBS_AUTOSUGGEST            0x0010
#define XMLFORMCOMBOBOX_CLASSNAME    _T( "XMLFormComboBox" )


#pragma warning( disable : 4251 )
#pragma warning( disable : 4786 )
#pragma warning( disable : 4275 )


#include <list>
#include <map>
#include <string>

//using namespace std;


void AFXAPI DDX_XMLFORMCBIndex( CDataExchange* pDX, int nIDC, int& index );
void AFXAPI DDX_XMLFORMString( CDataExchange* pDX, int nIDC, CString& value );



class CXMLFormSuperComboBox : public CWnd, CXMLFormControl
{
public:
  CXMLFormSuperComboBox( BOOL bInst = FALSE );

  int GetDefaultVisibleItems( void );
  void SetDefaultVisibleItems( int nItems = -1 );
  virtual CFont* GetFont( void ) {return m_poFont;}
  virtual void SetFont( CFont* poFont );
  int GetMinVisibleItems( void );
  void SetMinVisibleItems( int nMinItems );
  BOOL LimitText( int nMaxChars );
  BOOL SetEditSel( int nStartChar, int nEndChar );
  DWORD GetEditSel( void );
  int FindStringExact( int nIndexStart, LPCTSTR lpszFind );
  int InsertString( int nIndex, LPCTSTR lpszString );
  int DeleteString( UINT nIndex );
  BOOL GetExtendedUI( void );
  int SetExtendedUI( BOOL bExtended = TRUE );
  BOOL GetDroppedState( void );
  void GetDroppedControlRect( LPRECT lprect );
  void ShowDropDown( BOOL bShowIt = TRUE );
  int InitStorage( int nItems, UINT nBytes );
  int SetTopIndex( int nIndex );
  int GetTopIndex( void );
  void SetItemChecked( int nIndex, BOOL bChecked );
  BOOL GetItemChecked( int nIndex );
  void SetItemDisabled( int nIndex, BOOL bDisabled );
  BOOL GetItemDisabled( int nIndex );
  void ResetContent( void );
  void* GetItemDataPtr( int nIndex );
  int SetItemDataPtr( int nIndex, void* pData );
  DWORD GetItemData( int nIndex );
  int SetItemData( int nIndex, DWORD dwItemData );
  int SetCurSel( int nSelect );
  int GetCount( void );
  int GetCurSel( void );
  void SetText( LPCTSTR lpszText );
  void GetText( CString& rString );
  int GetText( LPTSTR lpszText );
  int AddString( LPCTSTR lpszString );
  int FindString( int nStartAfter, LPCTSTR lpszString );
  int SelectString( int nStartAfter, LPCTSTR lpszString );
  void GetLBText( int nIndex, CString& rString );
  int GetLBText( int nIndex, LPTSTR lpszText );
  int GetLBTextLen( int nIndex );
  int SetItemHeight( int nIndex,  int nHeight );
  virtual ~CXMLFormSuperComboBox( void );

  CRect& GetComboRect( void ) { return m_oComboWindowRect; }
  void ModifyACBStyle( UINT nRemoveStyle, UINT nAddStyle );
  BOOL PointInWindow( CPoint ptScreenPoint );

  virtual void CreateToolTip( void );

  virtual void SetDDVHandler( P_FORM_CONTROL_DDV_TYPE pxMyDDV )
  {
    m_pxMyDDV = pxMyDDV;
  };

  virtual void SetDDXHandler( P_FORM_CONTROL_DDX_TYPE pxMyDDX )
  {
    m_pxMyDDX = pxMyDDX;
  };

  bool GetTextColor( COLORREF& rxColor );
  bool GetBackColor( COLORREF& rxColor );

  bool SetTextColor( COLORREF xColor );
  bool SetBackColor( COLORREF xColor );

  //{{AFX_VIRTUAL( CXMLFormSuperComboBox )
  public:
  virtual BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
  virtual BOOL PreTranslateMessage( MSG* pMsg );
  protected:
  virtual void PreSubclassWindow( void );
  //}}AFX_VIRTUAL

protected:
  //{{AFX_MSG( CXMLFormSuperComboBox )
  afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
  afx_msg void OnPaint( void );
  afx_msg BOOL OnEraseBkgnd( CDC* pDC );
  afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
  afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );
  afx_msg void OnSize( UINT nType, int cx, int cy );
  afx_msg void OnSetFocus( CWnd* pOldWnd );
  afx_msg void OnKillFocus( CWnd* pNewWnd );
  afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
  afx_msg void OnEnable( BOOL bEnable );
  afx_msg void OnChildActivate( void );
  afx_msg void OnMouseMove( UINT nFlags, CPoint point );
  afx_msg void OnTimer( UINT nIDEvent );
  //}}AFX_MSG

  afx_msg void OnMouseLeave( void );
  afx_msg LONG OnSelectedItem( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnDropdownButton( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnDestroyDropdownList( WPARAM wParam, LPARAM lParam );
  afx_msg void OnKillfocusEdit( void );
  afx_msg void OnSetfocusEdit( void );
  afx_msg void OnChangeEdit( void );
  afx_msg void OnUpdateEdit( void );

  // ComboBox messages
  afx_msg LONG OnAddString( WPARAM wParam, LPARAM lString );
  afx_msg LONG OnSetCurSel( WPARAM wIndex, LPARAM lParam );
  afx_msg LONG OnGetCurSel( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnSelectString( WPARAM wItemStart, LPARAM lString );
  afx_msg LONG OnGetCount( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnResetContent( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnGetLBText( WPARAM wIndex, LPARAM lString );
  afx_msg LONG OnGetLBTextLen( WPARAM wIndex, LPARAM lParam );
  afx_msg LONG OnGetTopIndex( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnSetTopIndex( WPARAM wIndex, LPARAM lParam );

  afx_msg LONG OnValidateNow( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnDropToolTip( WPARAM wParam, LPARAM lParam );
  afx_msg LONG OnShowToolTip( WPARAM wParam, LPARAM lParam );

  DECLARE_MESSAGE_MAP()

  BOOL RegisterWindowClass( void );

private:
  void CreateDropList( std::list<LIST_ITEM> &droplist );
  void SelPrevItem( void );
  void SelNextItem( void );

  int                              m_iCurrentSelection;
  CXMLFormChildEdit*               m_poTextEntryWindow;
  std::string                      m_oEditText;
  CFont*                           m_poFont;
  DWORD                            m_dwStyle;
  DWORD                            m_dwComboBoxStyle;
  CRect                            m_oComboWindowRect;
  CRect                            m_oDropDownListWindowRect;
  CXMLFormComboBoxDropWindow*      m_poDropDownListWindow;
  CRect                            m_oDropButtonRect;
  BOOL                             m_bDropListVisible;
  bool                             m_bDropRectStored;
  std::list<LIST_ITEM>             m_oItemsList;
  std::list<LIST_ITEM>::iterator   m_oItemsListIter;
  int                              m_iMouseWheelClicks; // MouseWheel...
  bool                             m_bHasFocus;
  bool                             m_bHasSentFocus;
  bool                             m_bSelItem;
  bool                             m_bFirstPaint;
  int                              m_iMinimumVisibleItems;
  bool                             m_bCodeCreate;
  BOOL                             m_bAutoAppend;
  bool                             m_bDropButtonHot;
  bool                             m_bTrackMouseLeave;
  int                              m_iDropItemShowCount; // Number of items to be shown when dropwindow first shown.

  COLORREF m_xTextColor;
  COLORREF m_xBackColor;
};



#endif



/*****************************************************************************/
/* Check-in history 
   $WorkFile:   $
    $Archive:   $

 *$Log:   $
*/
/*****************************************************************************/


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions