core/vgui/impl/mfc/vgui_mfc_dialog_extensions_impl.h
Go to the documentation of this file.
00001 // This is core/vgui/impl/mfc/vgui_mfc_dialog_extensions_impl.h
00002 #ifndef vgui_mfc_dialog_extensions_impl_h_
00003 #define vgui_mfc_dialog_extensions_impl_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Gamze Tunali, LEMS, Brown University
00010 // \date   16 Nov 2007
00011 // \brief  MFC implementation of vgui_dialog_extensions
00012 //
00013 // \verbatim
00014 //  Modifications
00015 // \endverbatim
00016 
00017 class CFont;
00018 
00019 #include <vgui/internals/vgui_dialog_extensions_impl.h>
00020 #include "StdAfx.h"
00021 #undef MAX_ITEMS // also defined in vgui_mfc_dialog_impl.h
00022 #define MAX_ITEMS 255
00023 // MFC documentation says that our IDs should be in the range 0x8000-0xDFF
00024 #undef ID_BROWSE_FILES // also defined in vgui_mfc_dialog_impl.h
00025 #define ID_BROWSE_FILES 0x8000  // Assume that there won't be more than 100 browser buttons
00026 #undef ID_CHOOSE_COLOUR // also defined in vgui_mfc_dialog_impl.h
00027 #define ID_CHOOSE_COLOUR 0x8100 // Assume that there won't be more than 100 color chooser buttons
00028 #define ID_BROWSE_DIRS 0x8200   // Assume that there won't be more than 100 browser buttons
00029 #undef ID_EDIT // also defined in vgui_mfc_dialog_impl.h
00030 #define ID_EDIT 0x8300
00031 #undef ID_COMBOBOX // also defined in vgui_mfc_dialog_impl.h
00032 #define ID_COMBOBOX 0x8400
00033 
00034 //: The MFC implementation of vgui_extensions_dialog_impl.
00035 //
00036 //  Creates a dialog box in MFC.
00037 //  Based on vgui_gtk_dialog_impl.
00038 class vgui_mfc_dialog_extensions_impl : public CWnd,public vgui_dialog_extensions_impl
00039 {
00040  public:
00041   vgui_mfc_dialog_extensions_impl(const char* name);
00042   ~vgui_mfc_dialog_extensions_impl();
00043 
00044   void* choice_field_widget(const char*, const vcl_vector<vcl_string>&, int&);
00045   void* inline_tableau_widget(const vgui_tableau_sptr tab, unsigned width, unsigned height);
00046   //: Sets the modality of the dialog box.
00047   // True makes the dialog modal (i.e. the dialog 'grabs' all events), this is
00048   // the default.  False makes the dialog non-modal. WARNING: It is dangerous to
00049   // make a dialog that changes data nonmodal, only messages should be nonmodal.
00050   // NOTE: currently a no-op
00051   void modal(bool ) {}
00052   //: Display the dialog box.
00053   bool ask();
00054 
00055  protected:
00056   LOGFONT m_logfont;
00057   //: Called by MFC when the user clicks the OK button.
00058   virtual void OnOk();
00059   //: Called by MFC when the user clicks the cancel button.
00060   virtual void OnCancel();
00061   //: Called by MFC when the user clicks the (file) browse button.
00062   virtual void OnBrowse(UINT uID);
00063   //: Called by MFC when the user clicks the (directory) browse button.
00064   virtual void OnBrowseDir(UINT uID);
00065   //: Called by MFC when the user clicks the colour chooser button.
00066   virtual void OnChooseColour(UINT uID);
00067   //: Called by MFC when the application is about to terminate.
00068   afx_msg void OnClose();
00069  private:
00070   int nResult;
00071   //: File browser counter.
00072   int count_fbsr;
00073   //: Directory browser counter
00074   int count_dbsr;
00075   //: Colour chooser counter.
00076   int count_csr;
00077   bool ok_clicked;
00078   //: Array of MFC file browser objects.
00079   CWnd *fbsrs[100];
00080   //: Array of MFC directory browser objects.
00081   CWnd *dbsrs[100];
00082   //: Array of MFC colour chooser objects.
00083   CWnd *csrs[100];
00084   //: MFC dialog box object.
00085   CWnd *dialog_box;
00086   vcl_vector<CWnd *> wlist;
00087   //: List of created MFC objects (so we can delete them).
00088   vcl_vector<CWnd *> awlist;
00089   DECLARE_MESSAGE_MAP()
00090   //: Type font.
00091   CFont* font;
00092 };
00093 
00094 #endif // vgui_mfc_dialog_extensions_impl_h_