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"
18 #include "wx/gtk/win_gtk.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 static void gtk_button_clicked_callback( GtkWidget
*WXUNUSED(widget
), wxMiniFrame
*mf
)
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 BEGIN_EVENT_TABLE(wxMiniFrame
,wxFrame
)
34 EVT_PAINT(wxMiniFrame::OnPaint
)
35 EVT_MOUSE_EVENTS(wxMiniFrame::OnMouse
)
38 IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame
,wxFrame
)
40 bool wxMiniFrame::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
41 const wxPoint
&pos
, const wxSize
&size
,
42 long style
, const wxString
&name
)
44 style
= style
| wxSIMPLE_BORDER
;
54 wxFrame::Create( parent
, id
, title
, pos
, size
, style
, name
);
56 GtkWidget
*close_button
= gtk_button_new_with_label( "x" );
58 gtk_myfixed_put( GTK_MYFIXED(m_wxwindow
), close_button
, 4, 4 );
59 gtk_widget_set_usize( close_button
, 12, 11 );
61 gtk_widget_show( close_button
);
63 gtk_signal_connect( GTK_OBJECT(close_button
), "clicked",
64 GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this );
69 void wxMiniFrame::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
71 if (m_miniTitle
== 0) return;
72 if (m_title
.IsEmpty()) return;
76 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
77 dc
.DrawRectangle( 0, 0, m_width
, m_height
);
79 dc
.SetPen( *wxWHITE_PEN
);
80 dc
.DrawLine( 1, 1, m_width
-2, 1 );
81 dc
.DrawLine( 1, 1, 1, m_height
-2 );
83 dc
.SetPen( *wxMEDIUM_GREY_PEN
);
84 dc
.DrawLine( 1, m_height
-1, m_width
-2, m_height
-1 );
85 dc
.DrawLine( m_width
-1, 1, m_width
-1, m_height
-2 );
87 dc
.SetBrush( *wxBLUE_BRUSH
);
88 dc
.SetPen( *wxTRANSPARENT_PEN
);
89 dc
.DrawRectangle( m_miniEdge
, m_miniEdge
, m_width
- 2*m_miniEdge
, m_miniTitle
);
91 dc
.SetTextForeground( *wxWHITE
);
92 dc
.SetFont( *wxSMALL_FONT
);
93 dc
.DrawText( m_title
, 14 + m_miniEdge
, 1 + m_miniEdge
);
96 void wxMiniFrame::DrawFrame( int x
, int y
)
100 gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y
);
105 dc
.SetLogicalFunction( wxXOR
);
107 dc
.DrawRectangle( x
, y
, m_width
, m_height
);
110 void wxMiniFrame::OnMouse( wxMouseEvent
&event
)
112 int x
= event
.GetX();
113 int y
= event
.GetY();
115 if (event
.LeftDown())
127 if (event
.Dragging() && m_isDragging
)
129 DrawFrame( m_oldX
, m_oldY
);
130 m_oldX
= x
- m_diffX
;
131 m_oldY
= y
- m_diffY
;
132 DrawFrame( m_oldX
, m_oldY
);
136 if (event
.LeftUp() && m_isDragging
)
138 m_isDragging
= FALSE
;
139 DrawFrame( m_oldX
, m_oldY
);
144 gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y
);
145 x
+= org_x
- m_diffX
;
146 y
+= org_y
- m_diffY
;
149 gtk_widget_set_uposition( m_widget
, x
, y
);