1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #pragma implementation "minifram.h" 
  14 #include "wx/minifram.h" 
  15 #include "wx/dcscreen.h" 
  17 //----------------------------------------------------------------------------- 
  19 //----------------------------------------------------------------------------- 
  21 static void gtk_button_clicked_callback( GtkWidget 
*WXUNUSED(widget
), wxMiniFrame 
*mf 
) 
  26 //----------------------------------------------------------------------------- 
  28 //----------------------------------------------------------------------------- 
  30 BEGIN_EVENT_TABLE(wxMiniFrame
,wxFrame
) 
  31     EVT_PAINT(wxMiniFrame::OnPaint
) 
  32     EVT_MOUSE_EVENTS(wxMiniFrame::OnMouse
) 
  35 IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame
,wxFrame
) 
  37 bool wxMiniFrame::Create( wxWindow 
*parent
, wxWindowID id
, const wxString 
&title
, 
  38       const wxPoint 
&pos
, const wxSize 
&size
, 
  39       long style
, const wxString 
&name 
) 
  41     style 
= style 
| wxSIMPLE_BORDER
; 
  51     wxFrame::Create( parent
, id
, title
, pos
, size
, style
, name 
); 
  53     GtkWidget 
*close_button 
= gtk_button_new_with_label( "x" ); 
  55     gtk_myfixed_put( GTK_MYFIXED(m_wxwindow
), close_button
, 4, 4 ); 
  56     gtk_widget_set_usize( close_button
, 12, 11 ); 
  58     gtk_widget_show( close_button 
); 
  60     gtk_signal_connect( GTK_OBJECT(close_button
), "clicked", 
  61       GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this ); 
  66 void wxMiniFrame::OnPaint( wxPaintEvent 
&WXUNUSED(event
) ) 
  68     if (m_miniTitle 
== 0) return; 
  69     if (m_title
.IsEmpty()) return; 
  73     dc
.SetBrush( *wxTRANSPARENT_BRUSH 
); 
  74     dc
.DrawRectangle( 0, 0, m_width
, m_height 
); 
  76     dc
.SetPen( *wxWHITE_PEN 
); 
  77     dc
.DrawLine( 1, 1, m_width
-2, 1 ); 
  78     dc
.DrawLine( 1, 1, 1, m_height
-2 ); 
  80     dc
.SetPen( *wxMEDIUM_GREY_PEN 
); 
  81     dc
.DrawLine( 1, m_height
-1, m_width
-2, m_height
-1 ); 
  82     dc
.DrawLine( m_width
-1, 1, m_width
-1, m_height
-2 ); 
  84     dc
.SetBrush( *wxBLUE_BRUSH 
); 
  85     dc
.SetPen( *wxTRANSPARENT_PEN 
); 
  86     dc
.DrawRectangle( m_miniEdge
, m_miniEdge
, m_width 
- 2*m_miniEdge
, m_miniTitle 
); 
  88     dc
.SetTextForeground( *wxWHITE 
); 
  89     dc
.SetFont( *wxSMALL_FONT 
); 
  90     dc
.DrawText( m_title
, 14 + m_miniEdge
, 1 + m_miniEdge 
); 
  93 void wxMiniFrame::DrawFrame( int x
, int y 
) 
  97     gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y 
); 
 102     dc
.SetLogicalFunction( wxXOR 
); 
 104     dc
.DrawRectangle( x
, y
, m_width
, m_height 
); 
 107 void wxMiniFrame::OnMouse( wxMouseEvent 
&event 
) 
 109     int x 
= event
.GetX(); 
 110     int y 
= event
.GetY(); 
 112     if (event
.LeftDown()) 
 124     if (event
.Dragging() && m_isDragging
) 
 126         DrawFrame( m_oldX
, m_oldY 
); 
 127         m_oldX 
= x 
- m_diffX
; 
 128         m_oldY 
= y 
- m_diffY
; 
 129         DrawFrame( m_oldX
, m_oldY 
); 
 133     if (event
.LeftUp() && m_isDragging
) 
 135        m_isDragging 
= FALSE
; 
 136        DrawFrame( m_oldX
, m_oldY 
); 
 141        gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y 
); 
 142        x 
+= org_x 
- m_diffX
; 
 143        y 
+= org_y 
- m_diffY
; 
 146        gtk_widget_set_uposition( m_widget
, x
, y 
);