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}
wxFileDataObject is a specialization of \helpref{wxDataObject}{wxdataobject}
for file names. Unlike other predefined wxDataObject derivations, it only works
in one direction - the one of setting the data, i.e. the program can only
receive files dropped on it using it and there is no way (currently) to
initiate a drag and drop file operation.
for file names. The program works with it just as if it were a list of file
names (absolutep aths always), but internally it uses the same format as
Explorer and other compatible programs under Windows or GNOME/KDE filemanager
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}
@ -35,6 +41,12 @@ None.
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}
\constfunc{const wxArrayString\& }{GetFilenames}{\void}

View File

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

View File

@ -109,6 +109,9 @@ public:
void OnSpinCtrl(wxSpinEvent& event);
#endif // wxUSE_SPINCTRL
void OnEnableAll(wxCommandEvent& event);
void OnChangeColour(wxCommandEvent& event);
wxListBox *m_listbox,
*m_listboxSorted;
wxChoice *m_choice,
@ -148,14 +151,20 @@ public:
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
#if wxUSE_TOOLTIPS
void OnSetTooltipDelay(wxCommandEvent& event);
void OnToggleTooltips(wxCommandEvent& event);
#endif // wxUSE_TOOLTIPS
void OnEnableAll(wxCommandEvent& event);
void OnIdle( wxIdleEvent& event );
void OnSize( wxSizeEvent& event );
private:
wxPanel *m_panel;
DECLARE_EVENT_TABLE()
};
@ -180,7 +189,10 @@ enum
// tooltip menu
MINIMAL_SET_TOOLTIP_DELAY = 200,
MINIMAL_ENABLE_TOOLTIPS
MINIMAL_ENABLE_TOOLTIPS,
// panel menu
MINIMAL_ENABLE_ALL
};
bool MyApp::OnInit()
@ -198,6 +210,7 @@ bool MyApp::OnInit()
wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF );
file_menu->Append(MINIMAL_ABOUT, "&About\tF1");
file_menu->AppendSeparator();
file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample");
wxMenuBar *menu_bar = new wxMenuBar;
@ -213,6 +226,11 @@ bool MyApp::OnInit()
menu_bar->Append(tooltip_menu, "&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->Show(TRUE);
@ -277,6 +295,8 @@ const int ID_BTNPROGRESS = 183;
const int ID_BUTTON_LABEL = 184;
const int ID_SPINCTRL = 185;
const int ID_CHANGE_COLOUR = 200;
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize)
EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging)
@ -326,14 +346,13 @@ EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
EVT_SPIN (ID_SPINCTRL, MyPanel::OnSpinCtrl)
#endif // wxUSE_SPINCTRL
EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
END_EVENT_TABLE()
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
: wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ),
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->SetBackgroundColour("wheat");
@ -435,6 +454,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
#if wxUSE_TOOLTIPS
m_checkbox->SetToolTip( "Click here to disable the listbox" );
#endif // wxUSE_TOOLTIPS
(void)new wxCheckBox( panel, ID_CHANGE_COLOUR, "&Toggle colour",
wxPoint(110,170) );
m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List);
panel = new wxPanel(m_notebook);
@ -642,6 +663,30 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event )
*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 )
{
wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
@ -1029,14 +1074,17 @@ MyPanel::~MyPanel()
//----------------------------------------------------------------------
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
#if wxUSE_TOOLTIPS
EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay)
EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips)
EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay)
EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips)
#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()
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);
(void)new MyPanel( this, 10, 10, 300, 100 );
m_panel = new MyPanel( this, 10, 10, 300, 100 );
}
void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
@ -1096,6 +1144,14 @@ void MyFrame::OnToggleTooltips(wxCommandEvent& event)
}
#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 )
{
wxString msg;

View File

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

View File

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

View File

@ -226,6 +226,8 @@ bool wxApp::Initialize()
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_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDIPARENTFRAME"));
wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxSTD_MDICHILDFRAME"));
@ -233,6 +235,7 @@ bool wxApp::Initialize()
wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_FRAME"));
wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDIPARENTFRAME"));
wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, wxT("wxDEFAULT_MDICHILDFRAME"));
#endif // 0
RegisterWindowClasses();

View File

@ -249,9 +249,20 @@ WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
WXWPARAM wParam,
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)

View File

@ -260,7 +260,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
// and now it has the data
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) ) {
// operation succeeded
*pdwEffect = ConvertDragResultToEffect(rc);

View File

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