PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wxWidgets-2.9.1/include/wx/osx/carbon/mimetype.h

http://gamekit.googlecode.com/
C++ Header | 118 lines | 69 code | 24 blank | 25 comment | 0 complexity | 2a2492e51c67f398defaa03b7ac43fc6 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, AGPL-3.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, MIT
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/carbon/mimetype.h
  3. // Purpose: Mac Carbon implementation for wx mime-related classes
  4. // Author: Ryan Norton
  5. // Modified by:
  6. // Created: 04/16/2005
  7. // RCS-ID: $Id$
  8. // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _MIMETYPE_IMPL_H
  12. #define _MIMETYPE_IMPL_H
  13. #include "wx/defs.h"
  14. #include "wx/mimetype.h"
  15. class wxMimeTypesManagerImpl
  16. {
  17. public :
  18. //kinda kooky but in wxMimeTypesManager::EnsureImpl it doesn't call
  19. //intialize, so we do it ourselves
  20. wxMimeTypesManagerImpl() : m_hIC(NULL) { Initialize(); }
  21. ~wxMimeTypesManagerImpl() { ClearData(); }
  22. // load all data into memory - done when it is needed for the first time
  23. void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
  24. const wxString& extraDir = wxEmptyString);
  25. // and delete the data here
  26. void ClearData();
  27. // implement containing class functions
  28. wxFileType *GetFileTypeFromExtension(const wxString& ext);
  29. wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
  30. wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
  31. size_t EnumAllFileTypes(wxArrayString& mimetypes);
  32. void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
  33. // create a new filetype association
  34. wxFileType *Associate(const wxFileTypeInfo& ftInfo);
  35. // remove association
  36. bool Unassociate(wxFileType *ft);
  37. private:
  38. wxArrayFileTypeInfo m_fallbacks;
  39. void* m_hIC;
  40. void** m_hDatabase;
  41. long m_lCount;
  42. void* pReserved1;
  43. void* pReserved2;
  44. void* pReserved3;
  45. void* pReserved4;
  46. void* pReserved5;
  47. void* pReserved6;
  48. friend class wxFileTypeImpl;
  49. };
  50. class wxFileTypeImpl
  51. {
  52. public:
  53. //kind of nutty, but mimecmn.cpp creates one with an empty new
  54. wxFileTypeImpl() : m_manager(NULL) {}
  55. ~wxFileTypeImpl() {} //for those broken compilers
  56. // implement accessor functions
  57. bool GetExtensions(wxArrayString& extensions);
  58. bool GetMimeType(wxString *mimeType) const;
  59. bool GetMimeTypes(wxArrayString& mimeTypes) const;
  60. bool GetIcon(wxIconLocation *iconLoc) const;
  61. bool GetDescription(wxString *desc) const;
  62. bool GetOpenCommand(wxString *openCmd,
  63. const wxFileType::MessageParameters&) const;
  64. bool GetPrintCommand(wxString *printCmd,
  65. const wxFileType::MessageParameters&) const;
  66. size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
  67. const wxFileType::MessageParameters& params) const;
  68. // remove the record for this file type
  69. // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
  70. bool Unassociate(wxFileType *ft)
  71. {
  72. return m_manager->Unassociate(ft);
  73. }
  74. // set an arbitrary command, ask confirmation if it already exists and
  75. // overwriteprompt is TRUE
  76. bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = true);
  77. bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
  78. private:
  79. void Init(wxMimeTypesManagerImpl *manager, long lIndex)
  80. { m_manager=(manager); m_lIndex=(lIndex); }
  81. // helper function
  82. wxString GetCommand(const wxString& verb) const;
  83. wxMimeTypesManagerImpl *m_manager;
  84. long m_lIndex;
  85. void* pReserved1;
  86. void* pReserved2;
  87. void* pReserved3;
  88. void* pReserved4;
  89. void* pReserved5;
  90. void* pReserved6;
  91. friend class wxMimeTypesManagerImpl;
  92. };
  93. #endif
  94. //_MIMETYPE_H