[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 1052
Date : Mon May 15 15:19:16 BST 2006
Changed paths:
M /Trunk/XaraLX/tools/textinfo.cpp
M /Trunk/XaraLX/wxOil/Makefile.am
M /Trunk/XaraLX/wxOil/coldrop.cpp
M /Trunk/XaraLX/wxOil/coldrop.h
M /Trunk/XaraLX/wxOil/dlgevt.cpp
M /Trunk/XaraLX/wxOil/dlgmgr.cpp
M /Trunk/XaraLX/wxOil/dropdown.cpp
M /Trunk/XaraLX/wxOil/dropdown.h
M /Trunk/XaraLX/wxOil/fontdrop.cpp
M /Trunk/XaraLX/wxOil/fontdrop.h
M /Trunk/XaraLX/wxOil/xrc/IDB_ATM_SYMBOL.png
A /Trunk/XaraLX/wxOil/xrc/IDB_FREETYPE_SYMBOL.png
M /Trunk/XaraLX/wxOil/xrc/IDB_TTF_SYMBOL.png
First attempt at font dropdown
Diff:
Index: Trunk/XaraLX/tools/textinfo.cpp
===================================================================
--- Trunk/XaraLX/tools/textinfo.cpp (revision 1051)
+++ Trunk/XaraLX/tools/textinfo.cpp (revision 1052)
@@ -182,10 +182,7 @@
CommonAttrSet TextInfoBarOp::CommonAttrsToFindSet; // A set which will contain all attribute types
// that we need to find common attributes for
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
FontDropDown *TextInfoBarOp::NameDropDown = NULL; // Font name drop-down list support for the font list and
-#endif
String_64 TextInfoBarData::FontName;
FontClass TextInfoBarData::FontType;
@@ -339,16 +336,12 @@
// DeleteFontCache();
pTextInfoBar= NULL;
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
// Delete our drop-down font list
if (NameDropDown != NULL)
{
delete NameDropDown;
NameDropDown = NULL;
}
-#endif
-
}
@@ -713,13 +706,10 @@
if(!pTextInfoBar->HasWindow())
return ;
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
// Font Name
NameDropDown->SetTopFontName(&InfoData.FontName, InfoData.FontType, FALSE);
FontDropItem Dummy(InfoData.FontName, InfoData.FontType);
NameDropDown->SetSelection(&Dummy);
-#endif
// Kerning
pTextInfoBar->SetLongGadgetValue(_R(IDC_KERN_EDIT_X),InfoData.HorizontalKern,0,-1);
@@ -923,13 +913,10 @@
if (result == SelRange ::ATTR_MANY)
{
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
String_64 Multiple(_R(IDS_TEXTTOOL_MULTIPLE));
NameDropDown->SetTopFontName(&Multiple, FC_UNDEFINED, TRUE);
ForceUpdate = TRUE;
InfoData.FontName = _R(IDS_TEXTINFO_MULTIPLE); // "Multiple" just to invalidate this field
-#endif
}
else
{
@@ -986,15 +973,13 @@
else
ItalicChanged = FALSE;
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
NameDropDown->SetTopFontName(&FontName, InfoData.FontType, Deselect);
if(!Deselect)
{
FontDropItem Dummy(InfoData.FontName, InfoData.FontType);
NameDropDown->SetSelection(&Dummy);
}
-#endif
+
ForceUpdate = !ThisData->IsValid();
}
}
@@ -1657,12 +1642,9 @@
if (Cache)
FONTMANAGER->CacheNamedFont(Name, Type);
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
NameDropDown->SetTopFontName(Name, Type, FALSE);
FontDropItem Dummy(*Name, Type);
NameDropDown->SetSelection(&Dummy);
-#endif
return TRUE;
}
@@ -1969,8 +1951,6 @@
if (pFontChange!=NULL)
pFontChange->DoAffectFontChange();
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
// Update the text info bar font drop list (if it's there)
if(NameDropDown != NULL)
{
@@ -1979,7 +1959,6 @@
FontDropItem Dummy(InfoData.FontName, InfoData.FontType);
NameDropDown->SetSelection(&Dummy);
}
-#endif
// Update the actual combobox if the texttool is active
if(pTextInfoBar!= NULL &&pTextInfoBar->HasWindow())
@@ -2527,8 +2506,6 @@
{
if(Msg->DlgMsg == DIM_SELECTION_CHANGED_COMMIT)
{
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
// Handle selections in the font name menu.
INT32 SelIndex = GetSelectedValueIndex(_R(IDC_FONT_COMBO));
@@ -2550,7 +2527,6 @@
}
}
}
-#endif
}
}
}
@@ -2728,8 +2704,6 @@
// current info bar public for callbacks argh..
pTextInfoBar = this;
-PORTNOTE("text", "Removed custom dropdown");
-#ifndef EXCLUDE_FROM_XARALX
// Only enum the fonts if it's the first time - should respond to font change messages now !
if (NameDropDown == NULL)
{
@@ -2741,7 +2715,6 @@
NameDropDown->Init((CWindowID)WindowID, _R(IDC_FONT_COMBO));
NameDropDown->FillInFontList();
}
-#endif
pTextInfoBar->SetComboListLength(_R(IDC_FONT_COMBO));
UpdateGadgets();
Index: Trunk/XaraLX/wxOil/dlgevt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgevt.cpp (revision 1051)
+++ Trunk/XaraLX/wxOil/dlgevt.cpp (revision 1052)
@@ -105,6 +105,7 @@
#include "camframe.h"
#include "dialogop.h"
#include "ctrllist.h"
+#include "dropdown.h"
const TCHAR * DialogEventHandler::DefaultString = _T("[Event Name Not Found]
EventNumberToName * DialogEventHandler::pHash = NULL;
@@ -467,6 +468,7 @@
// called anyway
if (pwxWindow)
{
+ DropDown::KillDropDownsByWindow(pwxWindow);
ControlList::Get()->RemoveWindowAndChildren(pwxWindow);
}
Index: Trunk/XaraLX/wxOil/Makefile.am
===================================================================
--- Trunk/XaraLX/wxOil/Makefile.am (revision 1051)
+++ Trunk/XaraLX/wxOil/Makefile.am (revision 1052)
@@ -43,7 +43,7 @@
drawctl.cpp filedlgs.cpp fileutil.cpp ktimer.cpp camplatform.cpp \
outptdib.cpp outptpng.cpp outptgif.cpp gpalopt.cpp bmpfiltr.cpp giffiltr.cpp \
fontbase.cpp ftfonts.cpp textfuns.cpp dragbmp.cpp xpoilflt.cpp xmlutils.cpp \
- camprocess.cpp dropdown.cpp coldrop.cpp \
+ camprocess.cpp dropdown.cpp coldrop.cpp fontdrop.cpp \
binreloc.c \
resources.cpp
Index: Trunk/XaraLX/wxOil/coldrop.cpp
===================================================================
--- Trunk/XaraLX/wxOil/coldrop.cpp (revision 1051)
+++ Trunk/XaraLX/wxOil/coldrop.cpp (revision 1052)
@@ -749,17 +749,7 @@
Purpose: Draws the icon for an item
- Notes: Called by HandleDrawItemInternal when this object has been identified as the
- owner of the control to be redrawn, if HasIcon returned TRUE
- This method MUST be overridden by derived classes to provide redraw of their
- ColourDropDown list items. The base class does nothing.
-
- On entry, the DC is ready for you to draw into, including having the camelot
- palette selected in etc.
-
- SeeAlso: ColourDropDown::DrawIcon; ColourDropDown::DrawText
-
********************************************************************************************/
BOOL ColourDropDown::DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags)
@@ -829,14 +819,15 @@
/********************************************************************************************
-> virtual wxString ColourDropDown::GetText(void * ItemData)
+> virtual wxString ColourDropDown::GetText(void * ItemData, INT32 Item)
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
Date: 13/9/95
Inputs: ItemData - Your item data
+ Item - the number of the item
- Returns: TRUE if redraw went well
+ Returns: The text for the item
Purpose: Draws the text for an item
@@ -854,15 +845,16 @@
********************************************************************************************/
-wxString ColourDropDown::GetText(void * ItemData)
+wxString ColourDropDown::GetText(void * ItemData, INT32 Item)
{
ERROR3IF(ItemData == NULL, "NULL Itemdata in ColourDropDown::DrawText");
// Determine if it's a colour or a special item, and find the text to draw
TCHAR * TextToDraw = NULL;
- CCObject *Item = (CCObject *) ItemData;
- if (Item->IsKindOf(CC_RUNTIME_CLASS(IndexedColour)))
+ CCObject *pItem = (CCObject *) ItemData;
+
+ if (pItem->IsKindOf(CC_RUNTIME_CLASS(IndexedColour)))
TextToDraw = ( (TCHAR *) (*((IndexedColour *)ItemData)->GetName()) );
else
TextToDraw = ( (TCHAR *) ((SpecialEntry *)ItemData)->ItemText );
Index: Trunk/XaraLX/wxOil/dropdown.h
===================================================================
--- Trunk/XaraLX/wxOil/dropdown.h (revision 1051)
+++ Trunk/XaraLX/wxOil/dropdown.h (revision 1052)
@@ -121,11 +121,13 @@
virtual BOOL Init(CWindowID ParentWindow, CGadgetID ParentControl);
+ static void DropDown::KillDropDownsByWindow(CWindowID Window);
+
protected:
static List CurrentDropDowns; // A list of all currently active dropdowns
+ virtual void KillList() {} // allow reclaiming of memory on death
-
// --- Winoily section
protected: // Methods that must be overridden by derived classes
@@ -139,7 +141,7 @@
// Handles redraw of the text for an item. Default draws the text
// returned by GetText. You this probably do not need to override this
- virtual wxString GetText(void * ItemData) {return wxEmptyString;}
+ virtual wxString GetText(void * ItemData, INT32 Item) {return wxEmptyString;}
// By default returns a dummy string
Index: Trunk/XaraLX/wxOil/coldrop.h
===================================================================
--- Trunk/XaraLX/wxOil/coldrop.h (revision 1051)
+++ Trunk/XaraLX/wxOil/coldrop.h (revision 1052)
@@ -187,7 +187,7 @@
virtual BOOL DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags);
// Handles redraw of the icon, if any. Default is nothing gets drawn
- virtual wxString GetText(void * ItemData);
+ virtual wxString GetText(void * ItemData, INT32 Item);
// Gets the text
protected:
Index: Trunk/XaraLX/wxOil/xrc/IDB_ATM_SYMBOL.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: Trunk/XaraLX/wxOil/xrc/IDB_TTF_SYMBOL.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: Trunk/XaraLX/wxOil/xrc/IDB_FREETYPE_SYMBOL.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: Trunk/XaraLX/wxOil/xrc/IDB_FREETYPE_SYMBOL.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: Trunk/XaraLX/wxOil/dlgmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 1051)
+++ Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 1052)
@@ -130,7 +130,7 @@
#include "camframe.h"
//#include "palman.h"
#include "stack.h"
-//#include "dropdown.h" // Colour/Font dropdown combo box support
+#include "dropdown.h" // Colour/Font dropdown combo box support
#include "unicdman.h"
#include "appprefs.h"
#include "helpuser.h"
@@ -1617,6 +1617,9 @@
// Delete all ControlInfo records
List* ControlInfoList = GetControlList( (wxWindow *)WindowID );
+ // Kill of Dropdowns
+ DropDown::KillDropDownsByWindow(WindowID);
+
// Remove new-form control list
ControlList::Get()->RemoveWindowAndChildren((wxWindow *)WindowID);
Index: Trunk/XaraLX/wxOil/dropdown.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dropdown.cpp (revision 1051)
+++ Trunk/XaraLX/wxOil/dropdown.cpp (revision 1052)
@@ -212,11 +212,8 @@
if (Initialised)
{
// Do any deinit here
- Initialised=FALSE;
+ Init(NULL, 0);
}
-
- if (ParentDlg != NULL)
- CurrentDropDowns.RemoveItem(this);
}
/********************************************************************************************
@@ -245,7 +242,7 @@
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
Date: 29/8/95
- Inputs: Window - The Window in which your dropdown list gadget resides
+ Inputs: Window - The Window in which your dropdown list gadget resides or NULL to denitialise
Gadget - The GadgetID of the deropdown list gadget
Returns: TRUE if it succeeded in connecting itself to your gadget
@@ -257,30 +254,77 @@
BOOL DropDown::Init(CWindowID Window, CGadgetID Gadget)
{
- wxWindow * pGadget = DialogManager::GetGadget(Window, Gadget);
- if (pGadget && pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
+ if (Window)
{
- if (!Initialised) // Only ever add myself to the list once
+ wxWindow * pGadget = DialogManager::GetGadget(Window, Gadget);
+ if (pGadget && pGadget->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)))
{
- m_pPopup = new wxCamVListBoxComboPopup(this);
- ERROR2IF(!m_pPopup, FALSE, "Could not get new list popup");
- ((wxOwnerDrawnComboBox *)pGadget)->SetPopupControl(m_pPopup);
- CurrentDropDowns.AddHead(this);
+ if (!Initialised) // Only ever add myself to the list once
+ {
+ m_pPopup = new wxCamVListBoxComboPopup(this);
+ ERROR2IF(!m_pPopup, FALSE, "Could not get new list popup");
+ ((wxOwnerDrawnComboBox *)pGadget)->SetPopupControl(m_pPopup);
+ CurrentDropDowns.AddHead(this);
+ }
+
+ ParentDlg = Window;
+ ParentGadget = Gadget;
+
+ Initialised = TRUE;
+ return(TRUE);
}
+ ERROR3("DropDown::Init failed - illegal Gadget");
+ return(FALSE);
+ }
+ else
+ {
+ // release all memory
+ KillList();
+ ClearList();
+ ParentDlg=NULL;
+ ParentGadget=0;
+ Initialised=FALSE;
+ CurrentDropDowns.RemoveItem(this);
+ return TRUE;
+ }
+}
- ParentDlg = Window;
- ParentGadget = Gadget;
+/********************************************************************************************
- Initialised = TRUE;
- return(TRUE);
+> static void DropDown::KillDropDownsByWindow(CWindowID Window)
+
+ Author: Alex Bligh <alex@xxxxxxxxxxx>
+ Date: 15/05/2005
+
+ Purpose: Kills all the dropdowns associated with a particular window
+ This is called when that window is dying. We can't delete the dropdowns
+ but we can deinit them so they won't cause anyone eny hassle.
+
+********************************************************************************************/
+
+void DropDown::KillDropDownsByWindow(CWindowID Window)
+{
+ // First kill any associated with this window
+ DropDown *Ptr = (DropDown *) CurrentDropDowns.GetHead();
+ while (Ptr != NULL)
+ {
+ DropDown * Next = (DropDown *) CurrentDropDowns.GetNext(Ptr); // as we may remove this item from the list
+ if (Ptr->Initialised && (Ptr->ParentDlg==Window))
+ Ptr->Init(NULL, 0);
+ Ptr = Next;
}
- ERROR3("DropDown::Init failed - illegal Gadget");
- return(FALSE);
+ // Now process children if any
+ wxWindowList::Node * pNode = Window->GetChildren().GetFirst();
+ while (pNode)
+ {
+ KillDropDownsByWindow(pNode->GetData());
+ pNode = pNode->GetNext();
+ }
+ return;
}
-
/********************************************************************************************
> void DropDown::ClearList(void)
@@ -353,7 +397,7 @@
INT32 n=pGadget->Append(wxEmptyString); // put in an empty string first
m_pPopup->SetItemClientData(n, ItemData, wxClientData_Void);
if (ItemData)
- pGadget->SetString(n, GetText(ItemData));
+ pGadget->SetString(n, GetText(ItemData, n));
}
@@ -658,7 +702,7 @@
else
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
- wxString Text = GetText(ItemData);
+ wxString Text = GetText(ItemData, item);
wxCoord w, h;
dc.GetTextExtent(Text, &w, &h);
wxSize size(w,dc.GetCharHeight());
Index: Trunk/XaraLX/wxOil/fontdrop.h
===================================================================
--- Trunk/XaraLX/wxOil/fontdrop.h (revision 1051)
+++ Trunk/XaraLX/wxOil/fontdrop.h (revision 1052)
@@ -101,7 +101,7 @@
#ifndef INC_FONTDROP
#define INC_FONTDROP
-//#include "dropdown.h"
+#include "dropdown.h"
#include "fontbase.h"
class Document;
@@ -165,7 +165,6 @@
********************************************************************************************/
-#ifndef EXCLUDE_FROM_XARALX
class FontDropDown : public DropDown
{
friend class DialogManager;
@@ -204,23 +203,19 @@
// Overriding methods
protected:
- // Returns TRUE if the item has an icon.
- virtual BOOL HasIcon(DWORD ItemData);
+ virtual BOOL HasIcon(void * ItemData);
+ // Returns TRUE if the item has an icon. Default is no icon
- // Handles redraw of the icon, if any.
- virtual BOOL DrawIcon(DWORD ItemData, HDC hDC, RECT *IconRect, BOOL Disabled);
+ virtual BOOL DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags);
+ // Handles redraw of the icon, if any. Default is nothing gets drawn
- // Handles redraw of the text for an item.
- virtual BOOL DrawText(DWORD ItemData, HDC hDC, RECT *TextRect);
+ virtual wxString GetText(void * ItemData, INT32 Item);
+ // By default returns a dummy string
- // Handles redrawing the top item, which may be a special case...
- virtual BOOL HandleDrawItemInternal(HWND hDlg, UINT32 wParam, INT32 lParam);
-
-
// Member variables
public:
// this is required because enumerating fonts uses a callback function...
- static DWORD CurrentFontDropDown;
+ static void * CurrentFontDropDown;
// List of font items
List Fonts;
@@ -230,10 +225,8 @@
protected:
// True if the item above the list (-1) is being redrawn...
- BOOL RedrawingTopItem;
};
-#endif
/********************************************************************************************
@@ -247,7 +240,6 @@
document rather than the fonts avalaible in the system.
********************************************************************************************/
-#ifndef EXCLUDE_FROM_XARALX
class DocumentFontDropDown : public FontDropDown
{
@@ -264,6 +256,5 @@
BOOL FillInFontList(Document * WorkDoc);
};
-#endif
#endif
Index: Trunk/XaraLX/wxOil/fontdrop.cpp
===================================================================
--- Trunk/XaraLX/wxOil/fontdrop.cpp (revision 1051)
+++ Trunk/XaraLX/wxOil/fontdrop.cpp (revision 1052)
@@ -123,6 +123,7 @@
//#include "mario.h" // _R(IDS_NO_FONTSINDOC)
#include "fontlist.h"
#include "fontman.h" // Fontmanager
+#include "cartprov.h"
//#include "will2.h" // _R(IDS_K_FINFODLG_DASH)
class Document;
@@ -143,7 +144,7 @@
//-----------------------------------------------------------------------------------------
// Enumerating fonts uses a callback function, which in turn needs to access the original FontDropDown caller...
-DWORD FontDropDown::CurrentFontDropDown = 0;
+void * FontDropDown::CurrentFontDropDown = 0;
/********************************************************************************************
@@ -158,7 +159,7 @@
FontDropItem::FontDropItem()
{
- FontName = "";
+ FontName = _T("");
Type = FC_UNDEFINED;
}
@@ -209,7 +210,7 @@
ERROR3IF(((FontDropDown *)FontDropDown::CurrentFontDropDown) == NULL, "CurrentFontDropDown is NULL in NewFont");
if(((FontDropDown *)FontDropDown::CurrentFontDropDown) != NULL)
return ((FontDropDown *)FontDropDown::CurrentFontDropDown)
- -> AddFontToList((TCHAR *)lpelf->elfLogFont.lfFaceName, Type);
+ -> AddFontToList((TCHAR *)lpelf->elfLogFont.FaceName, Type);
return FALSE;
}
@@ -247,7 +248,7 @@
FontDropDown::~FontDropDown()
{
- KillList();
+
}
@@ -336,7 +337,7 @@
return TRUE;
}
- if(((FontDropItem *)TheItem)->FontName > FontName)
+ if( ((FontDropItem *)TheItem)->FontName > String_64(FontName))
{
Fonts.InsertBefore(TheItem, Item);
return TRUE;
@@ -352,7 +353,7 @@
return TRUE;
}
- if(((FontDropItem *)TheNextItem)->FontName > FontName)
+ if(((FontDropItem *)TheNextItem)->FontName > String_64(FontName))
{
Fonts.InsertBefore(TheNextItem, Item);
return TRUE;
@@ -391,7 +392,7 @@
ClearList(); // Delete combobox contents
// Setup the static class pointer variable so we can add things to this dropdown...
- CurrentFontDropDown = (DWORD)this;
+ CurrentFontDropDown = (void *)this;
if(Fonts.GetCount() == 0)
{
@@ -435,7 +436,7 @@
while (Item != NULL)
{
// Add the font in the list to the combo box
- AddItem((DWORD) Item);
+ AddItem((void *) Item);
// Try the next item
Item = Fonts.GetNext(Item);
@@ -515,7 +516,7 @@
{
FontDropItem *Fred = (FontDropItem *) GetItemData(SelectionIndex);
- if ((INT32)Fred == -1)
+ if (Fred==&TheTopItem)
return(NULL);
return Fred;
@@ -524,7 +525,7 @@
/********************************************************************************************
-> virtual BOOL FontDropDown::HasIcon(DWORD ItemData)
+> virtual BOOL FontDropDown::HasIcon(void * ItemData)
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
Date: 13/9/95
@@ -547,7 +548,7 @@
********************************************************************************************/
-BOOL FontDropDown::HasIcon(DWORD ItemData)
+BOOL FontDropDown::HasIcon(void * ItemData)
{
// All our items have a space for a truetype icon to their left
return(TRUE);
@@ -557,8 +558,8 @@
/********************************************************************************************
-> virtual BOOL FontDropDown::DrawIcon(DWORD ItemData, HDC hDC, RECT *IconRect,
- BOOL Disabled)
+> virtual BOOL FontDropDown::DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect,
+ BOOL Disabled, INT32 flags)
Author: Richard_Millican (Xara Group Ltd) <camelotdev@xxxxxxxx>
Date: 4/10/95
@@ -585,200 +586,80 @@
********************************************************************************************/
-BOOL FontDropDown::DrawIcon(DWORD ItemData, HDC hDC, RECT *IconRect, BOOL Disabled)
+BOOL FontDropDown::DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags)
{
- BOOL ReturnOK = TRUE;
+ ResourceID BitmapID = 0;
+ FontClass Type;
- // 0 denotes no bmp at all...
- INT32 BitmapID = 0;
+ if ((ItemData==&TheTopItem) || !ItemData)
+ Type = TheTopItem.Type;
+ else
+ Type = ((FontDropItem *)ItemData)->Type;
- // If the item is disabled, so just put a light grey splodge in the place of the colour
- if (!Disabled)
+ switch(Type)
{
- FontClass Type;
+ case FC_TRUETYPE:
+ BitmapID = _R(IDB_TTF_SYMBOL);
+ break;
- if(RedrawingTopItem || ItemData == 0)
- Type = TheTopItem.Type;
- else
- Type = ((FontDropItem *)ItemData)->Type;
+ case FC_ATM:
+ BitmapID = _R(IDB_ATM_SYMBOL);
+ break;
- switch(Type)
- {
- case FC_TRUETYPE:
- BitmapID = _R(IDB_TTF_SYMBOL);
- break;
+ case FC_FREETYPE:
+ BitmapID = _R(IDB_FREETYPE_SYMBOL);
+ break;
- case FC_ATM:
- BitmapID = _R(IDB_ATM_SYMBOL);
- break;
-
- default:
- BitmapID = 0;
- break;
- }
+ default:
+ BitmapID = 0;
+ break;
}
if(BitmapID == 0)
return FALSE;
- HBITMAP hBmp;
-
- // Load bmp
- hBmp = ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(BitmapID));
-
- if (hBmp == 0)
- {
- TRACEUSER( "Richard", _T("Bitmap failed to Load in FontDropDown::DrawIcon
"));
+ wxBitmap * pBitmap = CamArtProvider::Get()->FindBitmap(BitmapID, (CamArtFlags)(CAF_DEFAULT|(Disabled?CAF_GREYED:0)));
+ if (!pBitmap)
return FALSE;
- }
-
- // Make a Bitmap Object
- CBitmap Bitmap;
- BOOL ok = Bitmap.Attach(hBmp);
- if (!ok)
- {
- TRACEUSER( "Richard", _T("CBitmap failed to create in FontDropDown::DrawIcon
"));
- return FALSE;
- }
+ dc.DrawBitmap(*pBitmap, IconRect.GetLeft(), IconRect.GetTop(), TRUE);
- CDC MemDC;
- // Create a Memory DC based on the screen
- if(!MemDC.CreateCompatibleDC(0))
- {
- ERROR3("FontDropDown::DrawIcon Couldn't get a CDC");
- return FALSE;
- }
-
- // And select the Bitmap into it
- CBitmap* OldBmp = MemDC.SelectObject(&Bitmap);
-
- if (OldBmp == NULL)
- {
- ERROR3("FontDropDown::DrawIcon Couldn't select bmp into cdc");
- ReturnOK = FALSE;
- }
- else
- {
- // Plot the bitmap onto this render region
- ::BitBlt( hDC,
- IconRect->left, IconRect->top,
- IconRect->right - IconRect->left, IconRect->bottom - IconRect->top, //Width, Height,
- MemDC.m_hDC,
- 0,0,
- SRCCOPY
- );
-
- // Unselect our bitmap and delete it
- MemDC.SelectObject(OldBmp);
-
- ok = Bitmap.DeleteObject();
- if (!ok)
- ERROR3("FontDropDown::DrawIcon Couldn't delete object");
- }
-
- return ReturnOK;
+ return TRUE;
}
/********************************************************************************************
-> virtual BOOL FontDropDown::DrawText(DWORD ItemData, HDC hDC, RECT *TextRect)
+> virtual wxString FontDropDown::GetText(void * ItemData, INT32 Item)
Author: Richard_Millican (Xara Group Ltd) <camelotdev@xxxxxxxx>
Date: 3/10/95
Inputs: ItemData - Your item data
- HDC - the DC to draw into
- TextRect - points at a rectangle in which the text should be rendered
- Returns: TRUE if redraw went well
+ Returns: The text
- Purpose: Draws the text for an item
-
- Notes: Called by HandleDrawItemInternal when this object has been identified as the
- owner of the control to be redrawn, if HasIcon returned TRUE
-
- This method MUST be overridden by derived classes to provide redraw of their
- FontDropDown list items. The base class draws nothing.
-
- Note that on entry, the text FG/BG colours have been set up appropriately
- for the state of the item (shaded, selected, etc)
- Basically, all you have to do is find the text and do a DrawText call.
-
- SeeAlso: FontDropDown::DrawIcon; FontDropDown::DrawText
-
********************************************************************************************/
-BOOL FontDropDown::DrawText(DWORD ItemData, HDC hDC, RECT *TextRect)
+wxString FontDropDown::GetText(void * ItemData, INT32 Item)
{
- ERROR3IF(ItemData == NULL || TextRect == NULL, "NULL Itemdata/TextRect in FontDropDown::DrawText");
+ ERROR3IF(ItemData == NULL, "NULL Itemdata in FontDropDown::DrawText");
- String_64 TextToDisplay("");
+ String_64 TextToDisplay(_T(""));
- if(RedrawingTopItem || ItemData == 1 || ItemData == 0 || ItemData == -1)
+ if (!ItemData || Item<0 || (ItemData==&TheTopItem))
TextToDisplay = TheTopItem.FontName;
else
TextToDisplay = (((FontDropItem *)ItemData)->FontName);
// and draw the text...
- ::DrawText(hDC, (TCHAR *)TextToDisplay, -1, TextRect, DT_LEFT | DT_VCENTER);
-
- return(TRUE);
+ return(wxString((TCHAR *)TextToDisplay));
}
-/********************************************************************************************
-> virtual BOOL FontDropDown::HandleDrawItemInternal(HWND hDlg, UINT32 wParam, INT32 lParam)
- Author: Richard_Millican (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Date: 4/10/95
-
- Inputs: hDlg - The HWND of the control which needs redrawing
- wParam, lParam - As for the WM_DRAWITEM message
-
- Returns: TRUE if it handled (claimed) the message
- FALSE if it did not handle the message
-
- Purpose: Overrides default redraw handler to provide special support for the '-1' item,
- which is not necessarily in the list...
-
- SeeAlso: DropDown::HasIcon; DropDown::DrawIcon; DropDown::DrawText
-
-********************************************************************************************/
-
-BOOL FontDropDown::HandleDrawItemInternal(HWND hDlg, UINT32 wParam, INT32 lParam)
-{
- // We need to know in our drawtext functions if we're redrawing the -1 item or not...
- // Note that when this is TRUE, we cannot use the itemID and itemData fields...
- RedrawingTopItem = FALSE;
-
- DRAWITEMSTRUCT *pInfo = (DRAWITEMSTRUCT *)lParam;
- if (pInfo == NULL)
- return(FALSE);
-
- if (CCamApp::DisableSys) // Inside an error handler
- return(FALSE);
-
- // Check for the special item
- if (lParam == -1 || (INT32)pInfo->itemID == -1 || (INT32)pInfo->itemData == -1)
- {
- pInfo->itemID = 0;
- pInfo->itemData = 1;
- RedrawingTopItem = TRUE;
- }
-
- BOOL ok = DropDown::HandleDrawItemInternal(hDlg, wParam, lParam);
-
- RedrawingTopItem = FALSE;
-
- return ok;
-}
-
-
-
/********************************************************************************************
> BOOL FontDropDown::SetTopFontName(StringBase* StrValue, FontClass Type, BOOL Deselect = TRUE)
@@ -882,7 +763,7 @@
//ClearList(); // Delete combobox contents
// Setup the static class pointer variable so we can add things to this dropdown...
- CurrentFontDropDown = (DWORD)this;
+ CurrentFontDropDown = (void *)this;
//if(Fonts.GetCount() == 0)
//{
@@ -924,14 +805,14 @@
// check the style
INT32 Style = FontItem->GetFontStyle();
if(Style & 1)
- Name += " -Bold";
+ Name += _T(" -Bold");
if(Style & 2)
- Name += " -Italic";
+ Name += _T(" -Italic");
if(Handle > 0)
{
if (FONTMANAGER->IsFontReplaced(Handle))
- Name += " *";
+ Name += _T(" *");
}
FontClass Type = FontItem->GetFontClass();
@@ -960,7 +841,7 @@
while (Item != NULL)
{
// Add the font in the list to the combo box
- AddItem((DWORD) Item);
+ AddItem((void *) Item);
// Try the next item
Item = Fonts.GetNext(Item);
Xara