1. wxFileDataObject fixes from Ricky Gonzales - seems to work, so demo added

to the dnd sample and documented
2. wxLogTextCtrl gets status messages too (were just eaten)
3. wxWindow::Enable() goes down recursively
4. attempts at fixing wxButton::SetBackgroundColour() - didn't work :-(


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4350 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-04 02:39:19 +00:00
parent 775a998ed0
commit 87a1e3085b
9 changed files with 151 additions and 63 deletions

View File

@@ -1,10 +1,16 @@
\section{\class{wxFileDataObject}}\label{wxfiledataobject} \section{\class{wxFileDataObject}}\label{wxfiledataobject}
wxFileDataObject is a specialization of \helpref{wxDataObject}{wxdataobject} wxFileDataObject is a specialization of \helpref{wxDataObject}{wxdataobject}
for file names. Unlike other predefined wxDataObject derivations, it only works for file names. The program works with it just as if it were a list of file
in one direction - the one of setting the data, i.e. the program can only names (absolutep aths always), but internally it uses the same format as
receive files dropped on it using it and there is no way (currently) to Explorer and other compatible programs under Windows or GNOME/KDE filemanager
initiate a drag and drop file operation. under Unix which makes it possible to receive files from them using this
class.
{\bf Warning:} Under all non-Windows platforms this class is currently
"input-only", i.e. you can receieve the files from another application, but
copying (or dragging) file(s) from a wxWindows application is not currently
supported.
\wxheading{Virtual functions to override} \wxheading{Virtual functions to override}
@@ -35,6 +41,12 @@ None.
Constructor. Constructor.
\membersection{wxFileDataObject::AddFile}\label{wxfiledataobjectaddfile}
\func{virtual void}{AddFile}{\param{const wxString\& }{file}}
{\bf MSW only:} adds a file to the file list represented by this data object.
\membersection{wxFileDataObject::GetFilenames}\label{wxfiledataobjectgetfilenames} \membersection{wxFileDataObject::GetFilenames}\label{wxfiledataobjectgetfilenames}
\constfunc{const wxArrayString\& }{GetFilenames}{\void} \constfunc{const wxArrayString\& }{GetFilenames}{\void}

View File

@@ -320,8 +320,8 @@ private:
// virtual function hiding supression // virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); } { return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& WXUNUSED(format), void *pBuf) const bool GetDataHere(const wxDataFormat& format, void *pBuf) const
{ return(wxDataObjectSimple::GetDataHere(pBuf)); } { return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf) bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); } { return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
}; };
@@ -376,8 +376,8 @@ private:
// Virtual function hiding supression // Virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); } { return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& WXUNUSED(format), void* pBuf) const bool GetDataHere(const wxDataFormat& format, void* pBuf) const
{ return(wxDataObjectSimple::GetDataHere(pBuf)); } { return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -109,6 +109,9 @@ public:
void OnSpinCtrl(wxSpinEvent& event); void OnSpinCtrl(wxSpinEvent& event);
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL
void OnEnableAll(wxCommandEvent& event);
void OnChangeColour(wxCommandEvent& event);
wxListBox *m_listbox, wxListBox *m_listbox,
*m_listboxSorted; *m_listboxSorted;
wxChoice *m_choice, wxChoice *m_choice,
@@ -148,14 +151,20 @@ public:
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
void OnSetTooltipDelay(wxCommandEvent& event); void OnSetTooltipDelay(wxCommandEvent& event);
void OnToggleTooltips(wxCommandEvent& event); void OnToggleTooltips(wxCommandEvent& event);
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
void OnEnableAll(wxCommandEvent& event);
void OnIdle( wxIdleEvent& event ); void OnIdle( wxIdleEvent& event );
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
private: private:
wxPanel *m_panel;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -180,7 +189,10 @@ enum
// tooltip menu // tooltip menu
MINIMAL_SET_TOOLTIP_DELAY = 200, MINIMAL_SET_TOOLTIP_DELAY = 200,
MINIMAL_ENABLE_TOOLTIPS MINIMAL_ENABLE_TOOLTIPS,
// panel menu
MINIMAL_ENABLE_ALL
}; };
bool MyApp::OnInit() bool MyApp::OnInit()
@@ -198,6 +210,7 @@ bool MyApp::OnInit()
wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF ); wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF );
file_menu->Append(MINIMAL_ABOUT, "&About\tF1"); file_menu->Append(MINIMAL_ABOUT, "&About\tF1");
file_menu->AppendSeparator();
file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample"); file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample");
wxMenuBar *menu_bar = new wxMenuBar; wxMenuBar *menu_bar = new wxMenuBar;
@@ -213,6 +226,11 @@ bool MyApp::OnInit()
menu_bar->Append(tooltip_menu, "&Tooltips"); menu_bar->Append(tooltip_menu, "&Tooltips");
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
wxMenu *panel_menu = new wxMenu;
panel_menu->Append(MINIMAL_ENABLE_ALL, "&Disable all\tCtrl-E",
"Enable/disable all panel controls", TRUE);
menu_bar->Append(panel_menu, "&Panel");
frame->SetMenuBar(menu_bar); frame->SetMenuBar(menu_bar);
frame->Show(TRUE); frame->Show(TRUE);
@@ -277,6 +295,8 @@ const int ID_BTNPROGRESS = 183;
const int ID_BUTTON_LABEL = 184; const int ID_BUTTON_LABEL = 184;
const int ID_SPINCTRL = 185; const int ID_SPINCTRL = 185;
const int ID_CHANGE_COLOUR = 200;
BEGIN_EVENT_TABLE(MyPanel, wxPanel) BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize) EVT_SIZE ( MyPanel::OnSize)
EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging) EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging)
@@ -326,14 +346,13 @@ EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
EVT_SPIN (ID_SPINCTRL, MyPanel::OnSpinCtrl) EVT_SPIN (ID_SPINCTRL, MyPanel::OnSpinCtrl)
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL
EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
END_EVENT_TABLE() END_EVENT_TABLE()
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
: wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ),
m_text(NULL), m_notebook(NULL) m_text(NULL), m_notebook(NULL)
{ {
// SetBackgroundColour("cadet blue");
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
// m_text->SetBackgroundColour("wheat"); // m_text->SetBackgroundColour("wheat");
@@ -435,6 +454,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
m_checkbox->SetToolTip( "Click here to disable the listbox" ); m_checkbox->SetToolTip( "Click here to disable the listbox" );
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
(void)new wxCheckBox( panel, ID_CHANGE_COLOUR, "&Toggle colour",
wxPoint(110,170) );
m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List); m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List);
panel = new wxPanel(m_notebook); panel = new wxPanel(m_notebook);
@@ -642,6 +663,30 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event )
*m_text << "Notebook selection is " << event.GetSelection() << "\n"; *m_text << "Notebook selection is " << event.GetSelection() << "\n";
} }
void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
{
static wxColour s_colOld;
// test panel colour changing and propagation to the subcontrols
if ( s_colOld.Ok() )
{
SetBackgroundColour(s_colOld);
s_colOld = wxNullColour;
m_lbSelectThis->SetBackgroundColour("blue");
}
else
{
s_colOld = GetBackgroundColour();
SetBackgroundColour("green");
m_lbSelectThis->SetBackgroundColour("red");
}
m_lbSelectThis->Refresh();
Refresh();
}
void MyPanel::OnListBox( wxCommandEvent &event ) void MyPanel::OnListBox( wxCommandEvent &event )
{ {
wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
@@ -1029,14 +1074,17 @@ MyPanel::~MyPanel()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit) EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout) EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay) EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay)
EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips) EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips)
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
EVT_SIZE(MyFrame::OnSize)
EVT_IDLE(MyFrame::OnIdle) EVT_MENU(MINIMAL_ENABLE_ALL, MyFrame::OnEnableAll)
EVT_SIZE(MyFrame::OnSize)
EVT_IDLE(MyFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h) MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
@@ -1044,7 +1092,7 @@ MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
{ {
CreateStatusBar(2); CreateStatusBar(2);
(void)new MyPanel( this, 10, 10, 300, 100 ); m_panel = new MyPanel( this, 10, 10, 300, 100 );
} }
void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
@@ -1096,6 +1144,14 @@ void MyFrame::OnToggleTooltips(wxCommandEvent& event)
} }
#endif // tooltips #endif // tooltips
void MyFrame::OnEnableAll(wxCommandEvent& WXUNUSED(event))
{
static bool s_enable = TRUE;
s_enable = !s_enable;
m_panel->Enable(s_enable);
}
void MyFrame::OnSize( wxSizeEvent& event ) void MyFrame::OnSize( wxSizeEvent& event )
{ {
wxString msg; wxString msg;

View File

@@ -320,12 +320,9 @@ void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
case wxLOG_Info: case wxLOG_Info:
if ( GetVerbose() ) if ( GetVerbose() )
case wxLOG_Message: case wxLOG_Message:
case wxLOG_Status:
default: // log unknown log levels too default: // log unknown log levels too
DoLogString(szString, t); DoLogString(szString, t);
// fall through
case wxLOG_Status:
// nothing to do
break; break;
case wxLOG_Trace: case wxLOG_Trace:

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -103,11 +103,11 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
// wxGTK does this in wxWindow, but wxMSW does not. It is // wxGTK does this in wxWindow, but wxMSW does not. It is
// also done in wxPanel if the event is propagated up. // also done in wxPanel if the event is propagated up.
wxWindow *winFocus = event.GetCurrentFocus(); wxWindow *winFocus = event.GetCurrentFocus();
// Do we know where the focus was ourselves, then? // Do we know where the focus was ourselves, then?
if (!winFocus) if (!winFocus)
winFocus = m_winLastFocused; winFocus = m_winLastFocused;
if (!winFocus) if (!winFocus)
winFocus = wxWindow::FindFocus(); winFocus = wxWindow::FindFocus();
@@ -136,23 +136,23 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
// so give them the chance to process it instead of looping inside // so give them the chance to process it instead of looping inside
// this panel (normally, the focus will go to the next/previous // this panel (normally, the focus will go to the next/previous
// item after this panel in the parent panel). // item after this panel in the parent panel).
wxWindow *focussed_child_of_parent = this; wxWindow *focussed_child_of_parent = this;
for ( wxWindow *parent = GetParent(); parent; parent = parent->GetParent() ) for ( wxWindow *parent = GetParent(); parent; parent = parent->GetParent() )
{ {
// we don't want to tab into a different dialog or frame // we don't want to tab into a different dialog or frame
if ( focussed_child_of_parent->IsTopLevel() ) if ( focussed_child_of_parent->IsTopLevel() )
break; break;
// is the parent a panel? // is the parent a panel?
wxPanel *panel = wxDynamicCast(parent, wxPanel); wxPanel *panel = wxDynamicCast(parent, wxPanel);
if (panel) if (panel)
{ {
event.SetCurrentFocus( focussed_child_of_parent ); event.SetCurrentFocus( focussed_child_of_parent );
if (parent->GetEventHandler()->ProcessEvent( event )) if (parent->GetEventHandler()->ProcessEvent( event ))
return; return;
} }
focussed_child_of_parent = parent; focussed_child_of_parent = parent;
} }
// no, we are not inside another panel so process this ourself // no, we are not inside another panel so process this ourself
@@ -166,7 +166,7 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
if ( child->AcceptsFocus() ) if ( child->AcceptsFocus() )
{ {
m_winLastFocused = child; // should be redundant, but it is not m_winLastFocused = child; // should be redundant, but it is not
child->SetFocus(); child->SetFocus();
return; return;
} }
@@ -195,51 +195,51 @@ void wxPanel::SetFocus()
wxNode *node = GetChildren().First(); wxNode *node = GetChildren().First();
while (node) while (node)
{ {
wxWindow *child = (wxWindow*) node->Data(); wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus()) if (child->AcceptsFocus())
{ {
m_winLastFocused = child; // should be redundant, but it is not m_winLastFocused = child; // should be redundant, but it is not
child->SetFocus(); child->SetFocus();
return; return;
} }
node = node->Next(); node = node->Next();
} }
m_winLastFocused = (wxWindow*) NULL; m_winLastFocused = (wxWindow*) NULL;
wxWindow::SetFocus(); wxWindow::SetFocus();
} }
void wxPanel::OnFocus(wxFocusEvent& event) void wxPanel::OnFocus(wxFocusEvent& event)
{ {
// If the panel gets the focus *by way of getting clicked on* // If the panel gets the focus *by way of getting clicked on*
// we move it to either the last window that had the focus or // we move it to either the last window that had the focus or
// the first one that can get it. // the first one that can get it.
if (m_winLastFocused) if (m_winLastFocused)
{ {
// it might happen that the window got reparented... // it might happen that the window got reparented...
if ( m_winLastFocused->GetParent() == this ) if ( m_winLastFocused->GetParent() == this )
{ {
m_winLastFocused->SetFocus(); m_winLastFocused->SetFocus();
return; return;
} }
} }
wxNode *node = GetChildren().First(); wxNode *node = GetChildren().First();
while (node) while (node)
{ {
wxWindow *child = (wxWindow*) node->Data(); wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus()) if (child->AcceptsFocus())
{ {
m_winLastFocused = child; // should be redundant, but it is not m_winLastFocused = child; // should be redundant, but it is not
child->SetFocus(); child->SetFocus();
return; return;
} }
node = node->Next(); node = node->Next();
} }
m_winLastFocused = (wxWindow*) NULL; m_winLastFocused = (wxWindow*) NULL;
event.Skip(); event.Skip();
} }

View File

@@ -226,6 +226,8 @@ bool wxApp::Initialize()
g_globalCursor = new wxCursor; g_globalCursor = new wxCursor;
// VZ: these icons are not in wx.rc anyhow (but should they?)!
#if 0
wxSTD_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_FRAME")); wxSTD_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_FRAME"));
wxSTD_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDIPARENTFRAME")); wxSTD_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDIPARENTFRAME"));
wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDICHILDFRAME")); wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDICHILDFRAME"));
@@ -233,6 +235,7 @@ bool wxApp::Initialize()
wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_FRAME")); wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_FRAME"));
wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDIPARENTFRAME")); wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDIPARENTFRAME"));
wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDICHILDFRAME")); wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDICHILDFRAME"));
#endif // 0
RegisterWindowClasses(); RegisterWindowClasses();

View File

@@ -249,9 +249,20 @@ WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
WXWPARAM wParam, WXWPARAM wParam,
WXLPARAM lParam) WXLPARAM lParam)
{ {
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); const HDC& hdc = (HDC)pDC;
return (WXHBRUSH) backgroundBrush->GetResourceHandle(); const wxColour& colBack = GetBackgroundColour();
::SetBkColor(hdc, RGB(colBack.Red(), colBack.Green(), colBack.Blue()));
const wxColour& colFor = GetForegroundColour();
::SetTextColor(hdc, RGB(colFor.Red(), colFor.Green(), colFor.Blue()));
::SetBkMode(hdc, OPAQUE);
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(colBack,
wxSOLID);
backgroundBrush->RealizeResource();
return (WXHBRUSH)backgroundBrush->GetResourceHandle();
} }
long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)

View File

@@ -260,7 +260,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
// and now it has the data // and now it has the data
wxDragResult rc = ConvertDragEffectToResult(GetDropEffect(grfKeyState)); wxDragResult rc = ConvertDragEffectToResult(GetDropEffect(grfKeyState));
m_pTarget->OnData(pt.x, pt.y, rc); rc = m_pTarget->OnData(pt.x, pt.y, rc);
if ( wxIsDragResultOk(rc) ) { if ( wxIsDragResultOk(rc) ) {
// operation succeeded // operation succeeded
*pdwEffect = ConvertDragResultToEffect(rc); *pdwEffect = ConvertDragResultToEffect(rc);

View File

@@ -372,6 +372,15 @@ bool wxWindow::Enable(bool enable)
if ( hWnd ) if ( hWnd )
::EnableWindow(hWnd, (BOOL)enable); ::EnableWindow(hWnd, (BOOL)enable);
wxWindowList::Node *node = GetChildren().GetFirst();
while ( node )
{
wxWindow *child = node->GetData();
child->Enable(enable);
node = node->GetNext();
}
return TRUE; return TRUE;
} }