fileinfolist.cpp

Go to the documentation of this file.
00001 // $Id: customlist.cpp 1082 2006-05-16 14:42:54Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 
00100 #include "camtypes.h"
00101 #include "camelot.h"
00102 #include "errors.h"
00103 #include "palman.h"
00104 #include "cartprov.h"
00105 
00106 #include "fileinfolist.h"
00107 
00108 
00109 
00110 /******************************************************************************
00111 Function  : CFileInfoList::CListRow::CListRow
00112 Author    : Mikhail Tatarnikov
00113 Purpose   : ListRow constructor
00114 Returns   : void
00115 Exceptions: 
00116 Parameters: [in] CFileInfoList* plstParent - list control to represent;
00117             [in] INT32          iRow       - the row to represent.
00118 Notes     : The constructor is private, only CFileInfoList can create it.
00119 ******************************************************************************/
00120 CFileInfoList::CListRow::CListRow(CFileInfoList* plstParent, INT32 iRow)
00121 {
00122     m_plstParent = plstParent;
00123     m_iRow       = iRow;
00124 }
00125 
00126 CFileInfoList::CListRow::~CListRow()
00127 {
00128 }
00129 
00130 CFileInfoList::CListRow::CListRow(const CListRow& roOtherRow)
00131 {
00132     m_plstParent = roOtherRow.m_plstParent;
00133     m_iRow       = roOtherRow.m_iRow;
00134 }
00135     
00136 const CFileInfoList::CListRow& CFileInfoList::CListRow::operator= (const CListRow& roOtherRow)
00137 {
00138     m_plstParent = roOtherRow.m_plstParent;
00139     m_iRow       = roOtherRow.m_iRow;
00140     
00141     return roOtherRow;
00142 }
00143             
00144 /******************************************************************************
00145 Function  : CFileInfoList::CListRow::SetBitmap
00146 Author    : Mikhail Tatarnikov
00147 Purpose   : Set a bitmap to the row
00148 Returns   : void
00149 Exceptions: 
00150 Parameters: [in] UINT32 uiBitmapID - a new row bitmap.
00151 Notes     : 
00152 ******************************************************************************/
00153 void CFileInfoList::CListRow::SetBitmap(UINT32 uiBitmapID)
00154 {
00155     m_plstParent->SetRowBitmap(m_iRow, uiBitmapID);
00156 }
00157 
00158 /******************************************************************************
00159 Function  : CFileInfoList::CListRow::SetText
00160 Author    : Mikhail Tatarnikov
00161 Purpose   : Set text to display
00162 Returns   : void
00163 Exceptions: 
00164 Parameters: [in] INT32      iColumn - column where the text should go;
00165             [in] String_256 strText - new text.
00166 Notes     : 
00167 ******************************************************************************/
00168 void CFileInfoList::CListRow::SetText(INT32 iColumn, String_256 strText)
00169 {
00170     m_plstParent->SetRowText(m_iRow, iColumn, strText);
00171 }
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 CFileInfoList::CFileInfoList()
00187 {
00188     m_widParentDlg = 0;
00189     m_gdgidGadget  = 0;
00190 }
00191 
00192 
00193 CFileInfoList::~CFileInfoList()
00194 {
00195 }
00196 
00197 
00198 /******************************************************************************
00199 Function  : CFileInfoList::GetListCtrl
00200 Author    : Mikhail Tatarnikov
00201 Purpose   : Helper function to retrieve the actual list control
00202 Returns   : wxListCtrl* - the list control associated with this object.
00203 Exceptions: 
00204 Parameters: None
00205 Notes     : 
00206 ******************************************************************************/
00207 wxListCtrl* CFileInfoList::GetListCtrl()
00208 {
00209     wxWindow* pwndGadget = DialogManager::GetGadget(m_widParentDlg, m_gdgidGadget);
00210     if (!pwndGadget)
00211         return NULL;
00212     
00213     if (!pwndGadget->IsKindOf(CLASSINFO(wxListCtrl)))
00214         return NULL;
00215     
00216     wxListCtrl* plstList = (wxListCtrl*)pwndGadget;
00217     
00218     return plstList;
00219 }
00220 
00221 
00222 wxImageList* CFileInfoList::GetImageList()
00223 {
00224     wxListCtrl* pListCtrl = GetListCtrl();
00225     wxImageList* pilImageList = pListCtrl->GetImageList(m_ciImageListType);
00226     
00227     return pilImageList;
00228 }
00229 
00230 
00231 
00232 
00233 /******************************************************************************
00234 Function  : CBitmapDropDown::Init
00235 Author    : Mikhail Tatarnikov
00236 Purpose   : Initialize the control
00237 Returns   : BOOL - TRUE if success, FALSE otherwise.
00238 Exceptions: 
00239 Parameters: [in] CWindowID Window - the parent window, NULL to deinitialize;
00240             [in] CGadgetID Gadget - the control ID.
00241 Notes     : 
00242 ******************************************************************************/
00243 BOOL CFileInfoList::Init(CWindowID widParentDlg, CGadgetID gdgidGadget)
00244 {
00245     // Obtain the gadget and check if it has an appropriate class (we can
00246     // be attached to a wxListCtrl only).
00247     wxWindow* pwndGadget = DialogManager::GetGadget(widParentDlg, gdgidGadget);
00248     if (pwndGadget && pwndGadget->IsKindOf(CLASSINFO(wxListCtrl)))
00249     {
00250         m_widParentDlg = widParentDlg;
00251         m_gdgidGadget  = gdgidGadget;
00252         
00253         return(TRUE);
00254     }
00255     
00256     ERROR3("CBitmapDropDown::Init failed - illegal Gadget");
00257     return(FALSE);
00258 }
00259 
00260 /******************************************************************************
00261 Function  : CFileInfoList::AddColumn
00262 Author    : Mikhail Tatarnikov
00263 Purpose   : Add a new column
00264 Returns   : void
00265 Exceptions: 
00266 Parameters: [in] String_64 strHeader - column label;
00267             [in] INT32     iWidth    - column width;
00268             [in] INT32     iFormat   - column format (see wxListCtrl::InsertColumn).
00269 Notes     : 
00270 ******************************************************************************/
00271 void CFileInfoList::AddColumn(String_64 strHeader, INT32 iWidth, INT32 iFormat)
00272 {
00273     wxListCtrl* plstList = GetListCtrl();
00274     INT32 iColNum = plstList->GetColumnCount();
00275     plstList->InsertColumn(iColNum, strHeader, iFormat, iWidth);
00276 }
00277 
00278 
00279 /******************************************************************************
00280 Function  : CFileInfoList::AddRow
00281 Author    : Mikhail Tatarnikov
00282 Purpose   : Adds a new row
00283 Returns   : CFileInfoList::CListRow - an object to represet the new created row.
00284 Exceptions: 
00285 Parameters: None
00286 Notes     : 
00287 ******************************************************************************/
00288 CFileInfoList::CListRow CFileInfoList::AddRow()
00289 {
00290     wxListCtrl* plstList = GetListCtrl();
00291     
00292     INT32 iRowsCount = plstList->GetItemCount();
00293     plstList->InsertItem(iRowsCount, _T(""));
00294     
00295     return CListRow(this, iRowsCount);
00296 }
00297     
00298 /******************************************************************************
00299 Function  : CFileInfoList::Clear
00300 Author    : Mikhail Tatarnikov
00301 Purpose   : Removes all elements from the list
00302 Returns   : void
00303 Exceptions: 
00304 Parameters: None
00305 Notes     : 
00306 ******************************************************************************/
00307 void CFileInfoList::Clear()
00308 {
00309     wxListCtrl* plstList = GetListCtrl();
00310     plstList->DeleteAllItems();
00311 
00312     
00313     plstList->AssignImageList(NULL, m_ciImageListType);
00314 }
00315 
00316 
00317 /******************************************************************************
00318 Function  : CFileInfoList::SetRowBitmap
00319 Author    : Mikhail Tatarnikov
00320 Purpose   : Set a bitmap to the row.
00321 Returns   : void
00322 Exceptions: 
00323 Parameters: [in] INT32  iRow       - row to set the bitmap to;
00324             [in] UINT32 uiBitmapID - new bitmap ID.
00325 Notes     : 
00326 ******************************************************************************/
00327 void CFileInfoList::SetRowBitmap(INT32 iRow, UINT32 uiBitmapID)
00328 {
00329     wxListCtrl* plstList = GetListCtrl();
00330     if (plstList == NULL)
00331         return;
00332     
00333     // Load the bitmap
00334     wxBitmap* pBitmap = CamArtProvider::Get()->FindBitmap(uiBitmapID, CAF_DEFAULT);
00335     if (pBitmap == NULL)
00336         return;
00337     
00338     // Obtain the control's image list and add the new bitmap into it.
00339     wxImageList* pilImageList = GetImageList();
00340     
00341     // Check if we have to create an image list ourselves.
00342     if (pilImageList == NULL)
00343     {
00344         pilImageList = new wxImageList(pBitmap->GetWidth(), pBitmap->GetHeight(), true, 0);
00345         plstList->AssignImageList(pilImageList, m_ciImageListType);
00346     }
00347     
00348     INT32 iBitmapIndex = pilImageList->Add(*pBitmap);
00349     
00350     // Finally set the item information.
00351     plstList->SetItem(iRow, 0, _T(""), iBitmapIndex);
00352 }
00353 
00354 /******************************************************************************
00355 Function  : CFileInfoList::SetRowText
00356 Author    : Mikhail Tatarnikov
00357 Purpose   : Set new text to a row
00358 Returns   : void
00359 Exceptions: 
00360 Parameters: [in] INT32      iRow    - row to set the text to;
00361             [in] INT32      iColumn - column to set the text to;
00362             [in] String_256 strText - new text.
00363 Notes     : 
00364 ******************************************************************************/
00365 void CFileInfoList::SetRowText(INT32 iRow, INT32 iColumn, String_256 strText)
00366 {
00367     wxListCtrl* plstList = GetListCtrl();
00368     plstList->SetItem(iRow, iColumn, strText);
00369 }
00370 
00371 

Generated on Sat Nov 10 03:48:27 2007 for Camelot by  doxygen 1.4.4