[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 1013
Date : Thu May 11 21:24:15 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/appprefs.h
M /Trunk/XaraLX/Kernel/dialogop.h
M /Trunk/XaraLX/wxOil/cartprov.cpp
M /Trunk/XaraLX/wxOil/dlgmgr.cpp
M /Trunk/XaraLX/wxOil/dlgmgr.h
M /Trunk/XaraLX/wxOil/dlgtypes.h
M /Trunk/XaraLX/wxOil/stdwx.h
Make options dialog have vertical scroll with icons
Diff:
Index: Trunk/XaraLX/Kernel/appprefs.h
===================================================================
--- Trunk/XaraLX/Kernel/appprefs.h (revision 1012)
+++ Trunk/XaraLX/Kernel/appprefs.h (revision 1013)
@@ -171,6 +171,9 @@
// Functions to commit the values on the dialog box and its sections on ok
BOOL CommitDialogValues();
+ BOOL HasImages() {return FALSE;}
+ TabType GetTabType() {return TABTYPE_LIST;}
+
private:
String_256 TitleString; // title of dialog box
};
Index: Trunk/XaraLX/Kernel/dialogop.h
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.h (revision 1012)
+++ Trunk/XaraLX/Kernel/dialogop.h (revision 1013)
@@ -589,6 +589,11 @@
// just created with the standard button set
virtual BOOL LoadFrameFromResources() {return FALSE;}
+ // Override this function to provide an image list
+ virtual BOOL HasImages() {return FALSE;}
+
+ virtual TabType GetTabType() {return TABTYPE_TABS;}
+
// The DialogOP destructor destroys the instance of the DialogTabOp and all
// associated resources. If the dialog was open then it is closed.
~DialogTabOp();
Index: Trunk/XaraLX/wxOil/cartprov.cpp
===================================================================
--- Trunk/XaraLX/wxOil/cartprov.cpp (revision 1012)
+++ Trunk/XaraLX/wxOil/cartprov.cpp (revision 1013)
@@ -1135,7 +1135,7 @@
wxImage * pBitmap = NULL;
// find the name by looking up the ID as a string
- const TCHAR * tcname = CamResource::GetTextFail(r);
+ const TCHAR * tcname = NULL; /*CamResource::GetTextFail(r);*/
if (!tcname || ( (tcname[0]==_T('-')) && !tcname[1]) )
{
// default to object name
Index: Trunk/XaraLX/wxOil/dlgmgr.h
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.h (revision 1012)
+++ Trunk/XaraLX/wxOil/dlgmgr.h (revision 1013)
@@ -344,7 +344,7 @@
// Creates a DialogBarOp
static BOOL CreateBar(DialogBarOp* DlgOp);
- static wxWindow* CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage);
+ static BOOL CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage);
// Post create gets called after a dialog window has been created.
Index: Trunk/XaraLX/wxOil/dlgtypes.h
===================================================================
--- Trunk/XaraLX/wxOil/dlgtypes.h (revision 1012)
+++ Trunk/XaraLX/wxOil/dlgtypes.h (revision 1013)
@@ -267,6 +267,14 @@
DocCoord *pMousePos; // The position of the mouse at this event
};
+enum TabType
+{
+ TABTYPE_TABS,
+ TABTYPE_LIST,
+ TABTYPE_CHOICE,
+ TABTYPE_TREE,
+ TABTYPE_TOOLBAR
+};
#endif
Index: Trunk/XaraLX/wxOil/dlgmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 1012)
+++ Trunk/XaraLX/wxOil/dlgmgr.cpp (revision 1013)
@@ -228,7 +228,7 @@
If SubDlgID is non-0, then this dialog is merged with the main one during
the creation of the dialog. If it is 0, then no merging is done (the
- DialogOp::Create() function should take care of all this), and SubInstance
+ DialogOp() function should take care of all this), and SubInstance
is ignored.
If it is a tabbed dialog that is being created then we can now specify the
@@ -245,10 +245,55 @@
SeeAlso: DialogOp::Create
+********************************************************************************************/
+// First a private class definition
+// as this is missing two-stage create we have to use a static variable. Yuck.
+class wxDynamicPropertySheetDialog : public wxPropertySheetDialog
+{
+public:
+ wxDynamicPropertySheetDialog() {m_TabType=TABTYPE_TABS;}
+ ~wxDynamicPropertySheetDialog() {}
+ void SetTabType(TabType t) {m_TabType=t;}
+protected:
+ TabType m_TabType;
+ virtual wxBookCtrlBase* CreateBookCtrl()
+ {
+ int style = wxCLIP_CHILDREN | wxBC_DEFAULT;
-********************************************************************************************/
+ switch (m_TabType)
+ {
+#if wxUSE_LISTBOOK
+ case TABTYPE_LIST:
+ return new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+ break;
+#endif
+#if wxUSE_CHOICEBOOK
+ case TABTYPE_CHOICE:
+ return new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+ break;
+#endif
+#if wxUSE_TREEBOOK
+ case TABTYPE_TREE:
+ return new wxTreebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+ pClassInfo = CLASSINFO(wxTreebook);
+ break;
+#endif
+#if wxUSE_TOOLBOOK
+ case TABTYPE_TOOLBAR:
+ return new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+ break;
+#endif
+ case TABTYPE_TABS:
+ default:
+ return new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
+ break;
+ }
+ return NULL; // how did we get here?
+ }
+};
+
BOOL DialogManager::Create(DialogOp* DlgOp,
/* HINSTANCE MainInstance, */ CDlgResID MainDlgID,
/* HINSTANCE SubInstance, */ CDlgResID SubDlgID,
@@ -281,7 +326,25 @@
wxWindow* pDialogWnd = NULL;
if( DlgOp->IS_KIND_OF(DialogTabOp) && !(((DialogTabOp*)DlgOp)->LoadFrameFromResources()))
- pDialogWnd = CreateTabbedDialog( (DialogTabOp*)DlgOp, Mode, OpeningPage );
+ {
+ // ok first try and create the property sheet
+ wxDynamicPropertySheetDialog* pPropertySheet;
+
+ // error handling done later
+ pPropertySheet = new wxDynamicPropertySheetDialog();
+ if (pPropertySheet)
+ {
+ pPropertySheet->SetTabType(((DialogTabOp*)DlgOp)->GetTabType());
+ if (!pPropertySheet->Create((wxWindow *)ParentWnd, wxID_ANY, (TCHAR*)((DialogTabOp*)DlgOp)->GetName()))
+ {
+ delete pPropertySheet;
+ pPropertySheet=NULL; // error handling done below
+ }
+ else
+ pPropertySheet->CreateButtons( wxOK|wxCANCEL|wxHELP );
+ }
+ pDialogWnd=pPropertySheet;
+ }
else
{
pDialogName=CamResource::GetObjectNameFail(MainDlgID);
@@ -293,9 +356,8 @@
pDialogWnd = wxXmlResource::Get()->LoadDialog((wxWindow *)ParentWnd, pDialogName);
}
- CreateRecursor(pDialogWnd);
+ ERROR1IF(pDialogWnd == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
- ERROR1IF(pDialogWnd == NULL, FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
pDialogWnd->Hide();
CamArtProvider::Get()->EnsureChildBitmapsLoaded(pDialogWnd);
@@ -315,6 +377,21 @@
DlgOp->WindowID = (CWindowID)pDialogWnd;
pDialogWnd->PushEventHandler(DlgOp->pEvtHandler);
+ if (DlgOp->IS_KIND_OF(DialogTabOp))
+ {
+ // on balance we might be best ignoring errors here - we are really now past
+ // the point of no return, and the dialog can be closed cleanly by the user
+ // but let's try anyway
+ if (!CreateTabbedDialog( (DialogTabOp*)DlgOp, Mode, OpeningPage ))
+ {
+ // try using our own tolerant delete mechanism
+ Delete(pDialogWnd, DlgOp);
+ ERROR1(FALSE, _R(IDE_CANNOT_CREATE_DIALOG));
+ }
+ }
+
+ CreateRecursor(pDialogWnd);
+
// Register all the child controls
ControlList::Get()->RegisterWindowAndChildren(pDialogWnd, DlgOp);
@@ -6411,6 +6488,13 @@
if (pTip) Title=pTip->GetTip();
}
+ wxImageList * pImageList = pNoteBook->GetImageList();
+ if (pImageList)
+ {
+ // It has images - we should go find appropriate bitmap
+ pImageList->Add(*CamArtProvider::Get()->FindBitmap(pDialogTabOp->DlgResID));
+ }
+
pNoteBook->AddPage( pNewPage, Title );
return true;
}
@@ -7027,7 +7111,7 @@
/********************************************************************************************
-> static BOOL DialogManager::CreateTabbedDialog(DialogTabOp* DlgOp, CDlgMode Mode, INT32 OpeningPage)
+> static BOOL DialogManager::CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 5/12/94
@@ -7046,8 +7130,32 @@
********************************************************************************************/
-wxWindow* DialogManager::CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage)
+BOOL DialogManager::CreateTabbedDialog(DialogTabOp* pTabDlgOp, CDlgMode Mode, INT32 OpeningPage)
{
+ wxBookCtrlBase * pBook = GetBookControl(pTabDlgOp->WindowID);
+ if (!pBook)
+ return TRUE; // nothing to do
+
+ wxImageList * pImageList = NULL;
+ // Add images if present
+ if (pTabDlgOp->HasImages())
+ {
+ pImageList=new wxImageList;
+ if (pImageList)
+ pBook->SetImageList(pImageList);
+ }
+
+ // Before we can create the property sheet we must add pages to it.
+ // Let's ask the op do do this for us
+ if (!(pTabDlgOp->RegisterYourPagesInOrderPlease()))
+ {
+ // We failed to add pages to the dialog so we must tidy-up and fail
+ return FALSE;
+ }
+
+ // Get the dialog sized to fit
+ RelayoutDialog(pTabDlgOp);
+
// First check if the OpeningPage parameter is not equal to -1, in which case this
// specifies the active page to be opened.
// Has to be an index as otherwise we have not specified the pages yet and so cannot
@@ -7073,39 +7181,6 @@
#endif
}
- // ok first try and create the property sheet
- wxPropertySheetDialog* pPropertySheet;
- // Because wxPropertySheetDialog is derived from an MFC object we have to cope with exceptions
- try
- {
- pPropertySheet = new wxPropertySheetDialog( GetMainFrame(), wxID_ANY, (TCHAR*)pTabDlgOp->GetName()); // no doubt we shouldd o
-// pPropertySheet->Create(WS_POPUP | WS_SYSMENU | WS_BORDER | WS_DLGFRAME, 0)
- }
- catch( CMemoryException )
- {
- ERROR1(FALSE, _R(IDS_OUT_OF_MEMORY));
- }
-
- // Just to be safe
- ERROR1IF(pPropertySheet == NULL, FALSE, _R(IDS_OUT_OF_MEMORY));
-
- pPropertySheet->CreateButtons( wxOK|wxCANCEL|wxHELP );
-
- // This will be done again later, but RegisterYourPagesInOrderPlease may,
- // use it, so we do it here as well
- pTabDlgOp->WindowID = (CWindowID)pPropertySheet;
-
- // Before we can create the property sheet we must add pages to it.
- // Let's ask the op do do this for us
- if (!(pTabDlgOp->RegisterYourPagesInOrderPlease()))
- {
- // We failed to add pages to the dialog so we must tidy-up and fail
- return FALSE;
- }
-
- // Get the dialog sized to fit
- pPropertySheet->LayoutDialog();
-
// Now that the pages have been registered, check if the dialog has been opened
// before. If so force the new ActivePage to be specified rather than the old.
if (OpeningPage != -1)
@@ -7132,7 +7207,7 @@
#endif
}
- return pPropertySheet;
+ return TRUE;
}
Index: Trunk/XaraLX/wxOil/stdwx.h
===================================================================
--- Trunk/XaraLX/wxOil/stdwx.h (revision 1012)
+++ Trunk/XaraLX/wxOil/stdwx.h (revision 1013)
@@ -131,7 +131,20 @@
#include <wx/propdlg.h>
#include <wx/xrc/xh_all.h>
#include <wx/xrc/xmlres.h>
+#if wxUSE_LISTBOOK
+#include <wx/listbook.h>
+#endif
+#if wxUSE_CHOICEBOOK
+#include <wx/choicebk.h>
+#endif
+#if wxUSE_TREEBOOK
+#include <wx/treebook.h>
+#endif
+#if wxUSE_TOOLBOOK
+#include <wx/toolbook.h>
+#endif
+
// Now platform dependent stuff
// FreeBSD does not provide backtrace()
#if !defined(__WXMAC__) && !defined(__FreeBSD__)
Xara