wxWidgets/samples/xrc/custclas.h

98 lines
4.0 KiB
C
Raw Normal View History

Applied [ 594925 ] Implement wxArtProvider and XRC together By Robert O'Connor (robertoconnor) This patch is a draft which successfully allows a wxArtProvider to serve out icons to bitmaps for XRC files. The syntax to use a wxArtProvider bitmap is: <bitmap stock_id="wxART_INFORMATION" stock_client="wxART_TOOLBAR">somefallbackicon.png</bitmap> The bitmap is optional, and will only be used as a fallback image, if the wxArtProvider returned a wxNullBitmap for some reason. The client attribute, if not specified, currently will be wxART_OTHER. Perhaps there should be a guessing heuristic of it being in a menu node to call wxART_MENU. Usage of XRC resouces and wxArtProvider together can be seen in an updated /contrib/samples/xrc demo, which is a separate patch. Search the wx-dev mailing lists for "wxArtProvider" and "XRC" for the full discussions on this feature's API design. Applied patch [ 594932 ] Extended XRC XML resources sample By Robert O'Connor (robertoconnor) This is a more comprehensive introduction to how to get up and running using XRC in your new wxWindows project. It describes both the basics (for new users) and advanced features. It consists of a demo of dialogs and frames loaded from XRC. Each dialog has a textctrl at the top of the dialog, which walks the new user through that feature. There are 8 demos: The 4 basic ones: -A non-derived dialog, as typically used for an about dialog. -A derived dialog that loads its resources from an XRC (a frequently-asked question on the mailing lists), and responds to some simple events, including the disable-another-control-via-EVT_UPDATE_UI that is another FAQ, and powerful and simple-to-use feature. -A XRC reference "Controls" dialog, using a notebook. Each tab has a single control. All XRC handled widgets can be seen at a glance, and how to use them under XRC. -An uncentered dialog, to demonstrate the easy use of <centered>1</centered> to automatically place a Dialog centered on its parent.. The 4 advanced ones: -Embedding a custom class into an XRC dialog, by using the "unknown" class. -Using wxArtProvider to use stock icons from within your your XRC resources. -Using the platform attribute to selectively show a part of XRC based on the current OS. -Runtime variable expansion (demo only. Not implemented at this time). Also: -The main frame is now demonstrated as being loaded as an XRC. - The toolbar has longhelp tag demonstrated, and are hooked up to the same events as the menu to show how XRCID() works on the same tool and menuitem XRCID. -Some custom icons for the demonstration were created, and put into the toolbar and menubar. A custom icon also for the demonstration. -The example code has been put in 1 class per file (both .cpp and a matching .xrc), to make it much less confusing for a newcomer to figure out what class is what, expecially with all the wx macros for declaration and implementation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-08-16 11:24:46 +00:00
//-----------------------------------------------------------------------------
// Name: custclas.h
// Purpose: XML resources sample: A custom class to insert into a XRC file
// Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
// RCS-ID: $Id$
// Copyright: (c) Robert O'Connor and Vaclav Slavik
// Licence: wxWindows licence
//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
// Begin single inclusion of this .h file condition
//----------------------------------------------------------------------------------------
#ifndef _CUSTCLAS_H_
#define _CUSTCLAS_H_
//----------------------------------------------------------------------------------------
// GCC interface
//----------------------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "custclas.h"
#endif
//----------------------------------------------------------------------------------------
// Headers
//----------------------------------------------------------------------------------------
#include "wx/listctrl.h"
//----------------------------------------------------------------------------------------
// Class definition: MyResizableListCtrl
//----------------------------------------------------------------------------------------
//! A custom listctrl that resizes itself and pops up a context-sensitive menu.
class MyResizableListCtrl : public wxListCtrl
{
// Very helpful wxWindows macro required for wxWindows-RTTI tracing: By using this
// you will see "Leaked one object of type myResizeableListCtrl" in the debug log,
// along with which line you if was created, but you forget to free the memory.
// NOTE: Using this REQUIRES a default constructor: that means either: giving a
// default value for all parameters in your constructor, or else having a dummy
// MyResizableListCtrl(){} constructor in addition to your regular one.
DECLARE_DYNAMIC_CLASS( MyResizableListCtrl )
public:
// Constructor.
/*
These parameters are the same as a wxWindows constructor.
\param parent The parent window.
\param id The id of the progress_listbox. Will usually be -1 unless multiple
of them on the same dialog.
\param pos The pixel position of the listctrl on its parent window
\param size The pixel size of the listctrl
\param style Style of the listbox. See wxWindows wxListBox docs for details.
\param validator Window validator. See wxWindows docs for details.
\param name Windows name (rarely used).
\param exclusion_column_caption The label of header of listctrl's exclusion
column.
*/
MyResizableListCtrl( wxWindow *parent = NULL,
wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxT("myResizableListCtrl")
);
// Destuctor.
~MyResizableListCtrl();
protected:
// A custom function for a context sensitive menu.
void ContextSensitiveMenu( wxMouseEvent& event );
// This is a wxWindows function that we are going to override with our own behaviour.
void OnSize( wxSizeEvent &event );
// A custom function. What is called in the constructor, and in an OnSize()
void SetColumnWidths();
private:
// wxWindows macro, required to be able to use Event tables in the .cpp file.
DECLARE_EVENT_TABLE()
};
//----------------------------------------------------------------------------------------
// End single inclusion of this .h file condition
//----------------------------------------------------------------------------------------
#endif //_CUSTCLAS_H_