]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/artmac.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/mac/carbon/artmac.cpp 
   3 // Purpose:     wxArtProvider instance with native Mac stock icons 
   7 // Copyright:   (c) wxWindows team 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 // --------------------------------------------------------------------------- 
  13 // --------------------------------------------------------------------------- 
  15 // For compilers that support precompilation, includes "wx.h". 
  16 #include "wx/wxprec.h" 
  18 #if defined(__BORLANDC__) 
  26 #include "wx/artprov.h" 
  29 // ---------------------------------------------------------------------------- 
  31 // ---------------------------------------------------------------------------- 
  33 class wxMacArtProvider 
: public wxArtProvider
 
  36     virtual wxBitmap 
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
, 
  38     virtual wxIconBundle 
CreateIconBundle(const wxArtID
& id
, 
  39                                           const wxArtClient
& client
); 
  42 /* static */ void wxArtProvider::InitNativeProvider() 
  44     wxArtProvider::Push(new wxMacArtProvider
); 
  47 // ---------------------------------------------------------------------------- 
  49 // ---------------------------------------------------------------------------- 
  51 #define CREATE_STD_ICON(iconId, xpmRc) \ 
  53         wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \ 
  57 // Macro used in CreateBitmap to get wxICON_FOO icons: 
  58 #define ART_MSGBOX(artId, iconId, xpmRc) \ 
  61         CREATE_STD_ICON(#iconId, xpmRc) \ 
  64 static wxIconBundle 
wxMacArtProvider_CreateIconBundle(const wxArtID
& id
) 
  66     ART_MSGBOX(wxART_ERROR
,       wxICON_ERROR
,       error
) 
  67     ART_MSGBOX(wxART_INFORMATION
, wxICON_INFORMATION
, info
) 
  68     ART_MSGBOX(wxART_WARNING
,     wxICON_WARNING
,     warning
) 
  69     ART_MSGBOX(wxART_QUESTION
,    wxICON_QUESTION
,    question
) 
  71     ART_MSGBOX(wxART_FOLDER
,      wxICON_FOLDER
,      folder
) 
  72     ART_MSGBOX(wxART_FOLDER_OPEN
, wxICON_FOLDER_OPEN
, folder_open
) 
  73     ART_MSGBOX(wxART_NORMAL_FILE
, wxICON_NORMAL_FILE
, deffile
) 
  75     return wxNullIconBundle
; 
  78 // ---------------------------------------------------------------------------- 
  80 // ---------------------------------------------------------------------------- 
  82 wxIconBundle 
wxMacArtProvider::CreateIconBundle(const wxArtID
& id
, const wxArtClient
& client
) 
  84     // On the Mac folders in lists are always drawn closed, so if an open 
  85     // folder icon is asked for we will ask for a closed one in its place 
  86     if ( client 
== wxART_LIST 
&& id 
== wxART_FOLDER_OPEN 
) 
  87         return wxMacArtProvider_CreateIconBundle(wxART_FOLDER
); 
  89     return wxMacArtProvider_CreateIconBundle(id
); 
  92 // ---------------------------------------------------------------------------- 
  94 // ---------------------------------------------------------------------------- 
  96 wxBitmap 
wxMacArtProvider::CreateBitmap(const wxArtID
& id
, 
  97                                         const wxArtClient
& client
, 
  98                                         const wxSize
& reqSize
) 
 100     wxIconBundle 
ic(CreateIconBundle(id
, client
)); 
 103         wxIcon 
theIcon(ic
.GetIcon(reqSize
)); 
 104         return wxBitmap(theIcon
);