Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gripper.cpp

Go to the documentation of this file.
00001 
00002 // Name:        gripper.cpp
00003 // Purpose:     wxGripperWindow implementation.
00004 // Author:      Mark McCormack
00005 // Modified by:
00006 // Created:     23/02/04
00007 // RCS-ID:      $Id: gripper.cpp,v 1.5 2005/05/12 14:04:48 frm Exp $
00008 // Copyright:   (c) 2004 Mark McCormack
00009 // Licence:     wxWindows license
00011 
00012 #include <wx/gripper.h>
00013 #include <wx/dcclient.h>
00014 
00015 // ----------------------------------------------------------------------------
00016 // wxGripWindow implementation
00017 // ----------------------------------------------------------------------------
00018 
00019 IMPLEMENT_CLASS( wxGripWindow, wxWindow )
00020 
00021 DEFINE_EVENT_TYPE( wxEVT_GRIP_DBLCLICK )
00022 DEFINE_EVENT_TYPE( wxEVT_GRIP_LEFTDOWN )
00023 DEFINE_EVENT_TYPE( wxEVT_GRIP_LEFTUP )
00024 DEFINE_EVENT_TYPE( wxEVT_GRIP_MOTION )
00025 
00026 BEGIN_EVENT_TABLE( wxGripWindow, wxWindow )
00027     EVT_ERASE_BACKGROUND( wxGripWindow::OnErase )
00028     EVT_PAINT( wxGripWindow::OnPaint )
00029     EVT_LEFT_DCLICK( wxGripWindow::OnDoubleClick )
00030     EVT_LEFT_DOWN( wxGripWindow::OnLeftDown )
00031     EVT_LEFT_UP( wxGripWindow::OnLeftUp )
00032     EVT_MOTION( wxGripWindow::OnMotion )
00033 END_EVENT_TABLE()
00034 
00035 void wxGripWindow::Init() {
00036     // init
00037     pOwner_ = NULL;
00038 }
00039 
00040 bool wxGripWindow::Create( wxWindow * parent, wxOrientation orientation, wxGdi::eGripperStyle gripStyle ) {
00041     bool r = wxWindow::Create( parent, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN );
00042     orientation_ = orientation;
00043     gripStyle_ = gripStyle;
00044     pOwner_ = parent;
00045 
00046     return r;
00047 }
00048 
00049 void wxGripWindow::SetOrientation( wxOrientation orientation ) {
00050     orientation_ = orientation;
00051 }
00052 
00053 void wxGripWindow::SetLabel( const wxString &label ){
00054     label_ = label;
00055     if( gripStyle_ != wxGdi::wxGRIP_STYLE_HEADER ) {
00056         SetToolTip( label );
00057     }
00058 }
00059 
00060 void wxGripWindow::OnErase( wxEraseEvent& WXUNUSED(event) ) {
00061     // skip erase
00062 }
00063 
00064 void wxGripWindow::OnPaint( wxPaintEvent& WXUNUSED(event) ) {
00065     wxPaintDC dc(this);
00066     wxRect cr = GetClientRect();
00067 
00068     // NOTE: as a horizontal gripper is a vertical image, and a vertical gripper is a horizontal image
00069     wxOrientation imageOrentation = (orientation_ == wxHORIZONTAL) ? wxVERTICAL : wxHORIZONTAL;  
00070     g_gdi.DrawGripper( dc, cr, imageOrentation, gripStyle_, label_ );
00071 }
00072 
00073 void wxGripWindow::OnDoubleClick( wxMouseEvent& event ) {
00074     // create a double-click event
00075     int x = 0, y = 0;
00076     event.GetPosition( &x, &y );
00077     createMouseEvent( wxEVT_GRIP_DBLCLICK, x, y );
00078 }
00079 
00080 void wxGripWindow::OnLeftDown( wxMouseEvent& event ) {
00081     // create a left-down event
00082     int x = 0, y = 0;
00083     event.GetPosition( &x, &y );
00084     createMouseEvent( wxEVT_GRIP_LEFTDOWN, x, y );
00085 }
00086 
00087 void wxGripWindow::OnLeftUp( wxMouseEvent& event ) {
00088     // create a left-up event
00089     int x = 0, y = 0;
00090     event.GetPosition( &x, &y );
00091     createMouseEvent( wxEVT_GRIP_LEFTUP, x, y );
00092 }
00093 
00094 void wxGripWindow::OnMotion( wxMouseEvent& event ) {
00095     // create a motion event
00096     int x = 0, y = 0;
00097     event.GetPosition( &x, &y );
00098     createMouseEvent( wxEVT_GRIP_MOTION, x, y );
00099 }
00100 
00101 void wxGripWindow::createMouseEvent( int eventId, int x, int y ) {
00102     wxMouseEvent e( eventId );
00103     e.SetEventObject( this );
00104     e.m_x = x;
00105     e.m_y = y;
00106     GetParent()->GetEventHandler()->ProcessEvent( e );
00107 }

Generated on Sat May 14 14:54:39 2005 for wxDockIt by  doxygen 1.4.2