\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}
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}
// 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)); }
};
// 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)); }
};
// ----------------------------------------------------------------------------
void OnSpinCtrl(wxSpinEvent& event);
#endif // wxUSE_SPINCTRL
+ void OnEnableAll(wxCommandEvent& event);
+ void OnChangeColour(wxCommandEvent& event);
+
wxListBox *m_listbox,
*m_listboxSorted;
wxChoice *m_choice,
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()
};
// tooltip menu
MINIMAL_SET_TOOLTIP_DELAY = 200,
- MINIMAL_ENABLE_TOOLTIPS
+ MINIMAL_ENABLE_TOOLTIPS,
+
+ // panel menu
+ MINIMAL_ENABLE_ALL
};
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;
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);
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)
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");
#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);
*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
//----------------------------------------------------------------------
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)
{
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) )
}
#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;
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:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// 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();
// 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
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;
}
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();
}
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"));
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();
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)
// 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);
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;
}