Implement wxClipboard::Flush() in wxGTK
Update the documentation and also add a call of Flush() to the sample. Closes #10515. Closes https://github.com/wxWidgets/wxWidgets/pull/1316
This commit is contained in:
committed by
Vadim Zeitlin
parent
02adddfa1a
commit
28a84486bd
@@ -53,6 +53,11 @@ public:
|
||||
// fill data with data on the clipboard (if available)
|
||||
virtual bool GetData( wxDataObject& data ) wxOVERRIDE;
|
||||
|
||||
// flushes the clipboard; that means that the data which is currently on
|
||||
// clipboard will stay available even after the application exits (possibly
|
||||
// eating memory), otherwise the clipboard will be emptied on exit
|
||||
virtual bool Flush() wxOVERRIDE;
|
||||
|
||||
// clears wxTheClipboard and the system's clipboard if possible
|
||||
virtual void Clear() wxOVERRIDE;
|
||||
|
||||
|
@@ -96,8 +96,8 @@ public:
|
||||
(possibly eating memory), otherwise the clipboard will be emptied on
|
||||
exit.
|
||||
|
||||
Currently this method is not implemented in X11-based ports, i.e.
|
||||
wxGTK, wxX11 and wxMotif and always returns @false there.
|
||||
Currently this method is implemented in MSW and GTK and always returns @false
|
||||
otherwise.
|
||||
|
||||
@return @false if the operation is unsuccessful for any reason.
|
||||
*/
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
void OnQuit(wxCommandEvent&event);
|
||||
void OnAbout(wxCommandEvent&event);
|
||||
void OnFlush(wxCommandEvent &event);
|
||||
void OnWriteClipboardContents(wxCommandEvent&event);
|
||||
void OnUpdateUI(wxUpdateUIEvent&event);
|
||||
#if USE_ASYNCHRONOUS_CLIPBOARD_REQUEST
|
||||
@@ -71,12 +72,14 @@ enum
|
||||
ID_Quit = wxID_EXIT,
|
||||
ID_About = wxID_ABOUT,
|
||||
ID_Write = 100,
|
||||
ID_Text = 101
|
||||
ID_Text = 101,
|
||||
ID_Flush = 102
|
||||
};
|
||||
|
||||
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(ID_Quit, MyFrame::OnQuit)
|
||||
EVT_MENU(ID_About, MyFrame::OnAbout)
|
||||
EVT_MENU(ID_Flush, MyFrame::OnFlush)
|
||||
EVT_BUTTON(ID_Write, MyFrame::OnWriteClipboardContents)
|
||||
EVT_UPDATE_UI(ID_Write, MyFrame::OnUpdateUI)
|
||||
#if USE_ASYNCHRONOUS_CLIPBOARD_REQUEST
|
||||
@@ -116,6 +119,7 @@ MyFrame::MyFrame(const wxString& title)
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(ID_About, "&About\tF1", "Show about dialog");
|
||||
|
||||
fileMenu->Append(ID_Flush, "Flush the clipboard" );
|
||||
fileMenu->Append(ID_Quit, "E&xit\tAlt-X", "Quit this program");
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
@@ -137,6 +141,14 @@ MyFrame::MyFrame(const wxString& title)
|
||||
panel->SetSizer( main_sizer );
|
||||
}
|
||||
|
||||
void MyFrame::OnFlush(wxCommandEvent &WXUNUSED(event))
|
||||
{
|
||||
if ( wxTheClipboard->Flush() )
|
||||
m_textctrl->SetValue( "Clipboard flushed successfully!!\n" );
|
||||
else
|
||||
m_textctrl->SetValue( "Flushing clipboard failed!!\n" );
|
||||
}
|
||||
|
||||
void MyFrame::OnWriteClipboardContents(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (wxTheClipboard->Open())
|
||||
|
@@ -593,6 +593,12 @@ void wxClipboard::Clear()
|
||||
m_formatSupported = false;
|
||||
}
|
||||
|
||||
bool wxClipboard::Flush()
|
||||
{
|
||||
gtk_clipboard_store( gtk_clipboard_get( GTKGetClipboardAtom() ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxClipboard::Open()
|
||||
{
|
||||
wxCHECK_MSG( !m_open, false, wxT("clipboard already open") );
|
||||
|
Reference in New Issue
Block a user