///////////////////////////////////////////////////////////////////////////// // Name: floatwindow.cpp // tag: a window showing the last trick. // Author: David Roundy // Modified by: // Copyright: (c) 2002 David Roundy // Licence: GPL /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes . #include #ifndef WX_PRECOMP #include #endif #include "floatwindow.h" #include "debug.h" BEGIN_EVENT_TABLE(FloatWindow, wxMiniFrame) EVT_ACTIVATE(FloatWindow::OnActivate) EVT_CLOSE(FloatWindow::OnCloseWindow) EVT_MOVE(FloatWindow::OnMove) END_EVENT_TABLE() FloatWindow::FloatWindow(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint &relpos, const wxSize& size, long style, const wxString& name) : wxMiniFrame() { wxPoint my_starting_position = parent->GetPosition() + relpos; if (relpos == wxPoint(-1,-1)) my_starting_position = wxDefaultPosition; m_allow_move = true; wxMiniFrame::Create(parent, id, title, my_starting_position, size, style, name); } FloatWindow::~FloatWindow() { } void FloatWindow::OnMove(const wxMoveEvent& event) { if (!m_allow_move) { Move(GetParent()->GetPosition() + GetRelativePosition()); m_allow_move = true; return; } wxPoint temp = event.GetPosition() - GetParent()->GetPosition() - GetRelativePosition(); if (abs(temp.x) < 800 && abs(temp.y) < 600) { // Refuse to accept a huge move (which at least under fvwm2 may simply // indicate the user switching desktops). UpdateRelPos(event); } } // The following is a trick to get around a spurious move event that is // generated under wxGTK 2.3.2. void FloatWindow::DisallowOneMove() { m_allow_move = false; } void FloatWindow::OnActivate(wxActivateEvent& event) { //MoveToPosition(); } void FloatWindow::MoveToPosition() { //Move(GetParent()->GetPosition() + GetRelativePosition()); } void FloatWindow::ParentMoved() { Move(GetRelativePosition() + GetParent()->GetPosition()); Raise(); } void FloatWindow::OnCloseWindow(wxCloseEvent& event) { //SetRelativePosition(GetPosition() - GetParent()->GetPosition()); event.Veto(); this->Show(false); } void FloatWindow::UpdateRelPos(const wxEvent& event) { SetRelativePosition(GetPosition() - GetParent()->GetPosition()); }