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: custclass.cpp
|
|
|
|
// 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
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// GCC implementation
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "custclas.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-05-25 11:20:37 +00:00
|
|
|
// Standard wxWidgets headers
|
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
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For all others, include the necessary headers (this file is usually all you
|
2004-05-25 11:20:37 +00:00
|
|
|
// need because it includes almost all "standard" wxWidgets headers)
|
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
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Header of this .cpp file
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "custclas.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Internal constants
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Popup menu (PU) item control IDs. In this example, they aren't hooked up
|
|
|
|
// to any functions. Normally you would use these IDs in your event table, so
|
|
|
|
// that if one of these menu items is clicked, then a certain function is
|
|
|
|
// called.
|
|
|
|
enum {
|
|
|
|
PU_ADD_RECORD = wxID_HIGHEST + 1,
|
|
|
|
PU_EDIT_RECORD,
|
|
|
|
PU_DELETE_RECORD
|
|
|
|
};
|
|
|
|
|
|
|
|
// Columns of the listctrl (the leftmost one starts at 0, and so on).
|
|
|
|
// Allows easier code maintenance if want to add/rearrangement of listctrl's
|
|
|
|
// columns.
|
|
|
|
enum {
|
|
|
|
RECORD_COLUMN = 0,
|
|
|
|
ACTION_COLUMN,
|
|
|
|
PRIORITY_COLUMN
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-05-25 11:20:37 +00:00
|
|
|
// wxWidgets macro: implement dynamic class
|
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
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( MyResizableListCtrl, wxListCtrl )
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Event table: connect the events to the handler functions to process them
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
|
|
|
|
// Something to do when right mouse down
|
|
|
|
EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
|
|
|
|
// Something to do when resized
|
|
|
|
EVT_SIZE( MyResizableListCtrl::OnSize )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Public methods
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Constructor, including setting the dialog's m_configuration_section member
|
|
|
|
// to the incoming configuration_section string.
|
|
|
|
MyResizableListCtrl::MyResizableListCtrl( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
long style, const wxValidator& validator,
|
|
|
|
const wxString& name )
|
|
|
|
: wxListCtrl( parent, id, pos, size, style, validator, name )
|
|
|
|
{
|
|
|
|
|
|
|
|
// This listctrl needs to insert its columns in the constructor, since
|
|
|
|
// as soon as the listctrl is built, it is resized and grafted onto an
|
|
|
|
// "unknown" XRC placeholder. This induces an OnSize() event, calling the
|
|
|
|
// overrriden OnSize function for this class, which needs to have 3
|
|
|
|
// columns to resize (else an assert on WXGTK debug build).
|
|
|
|
InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140);
|
|
|
|
InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70);
|
|
|
|
InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MyResizableListCtrl::~MyResizableListCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
// Make an instance of a menu.
|
|
|
|
wxMenu a_menu;
|
|
|
|
|
|
|
|
a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
|
|
|
|
a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) );
|
|
|
|
a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) );
|
|
|
|
|
|
|
|
// If no listctrl rows selected, then disable the menu items that
|
|
|
|
// require selection
|
|
|
|
if ( GetSelectedItemCount() == 0 ) {
|
|
|
|
a_menu.Enable( PU_EDIT_RECORD, FALSE );
|
|
|
|
a_menu.Enable( PU_DELETE_RECORD, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the popup menu (wxWindow::PopupMenu ), at the x,y position
|
|
|
|
// of the click event
|
|
|
|
PopupMenu( &a_menu, event.GetPosition() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyResizableListCtrl::OnSize( wxSizeEvent &event )
|
|
|
|
{
|
|
|
|
// Call our custom width setting function.
|
|
|
|
SetColumnWidths();
|
|
|
|
// REQURED event.Skip() call to allow this event to propagate
|
|
|
|
// upwards so others can do what they need to do in response to
|
|
|
|
// this size event.
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyResizableListCtrl::SetColumnWidths()
|
|
|
|
{
|
|
|
|
// Get width of entire listctrl
|
|
|
|
int leftmostColumnWidth = GetSize().x;
|
|
|
|
|
|
|
|
// Subtract width of other columns, scrollbar, and some padding
|
|
|
|
leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN );
|
|
|
|
leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN );
|
|
|
|
leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
|
|
|
|
leftmostColumnWidth -= 5;
|
|
|
|
|
|
|
|
// Set the column width to the new value.
|
|
|
|
SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
|
|
|
|
|
|
|
|
// This is just a debug message in case you want to watch the
|
|
|
|
// events scroll by as you resize.
|
2002-12-04 14:11:26 +00:00
|
|
|
wxLogDebug( wxT("Successfully set column widths") );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|