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"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 static void gtk_button_clicked_callback( GtkWidget
*WXUNUSED(widget
), wxMiniFrame
*mf
)
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 BEGIN_EVENT_TABLE(wxMiniFrame
,wxFrame
)
35 EVT_PAINT(wxMiniFrame::OnPaint
)
36 EVT_MOUSE_EVENTS(wxMiniFrame::OnMouse
)
39 IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame
,wxFrame
)
41 bool wxMiniFrame::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
42 const wxPoint
&pos
, const wxSize
&size
,
43 long style
, const wxString
&name
)
45 style
= style
| wxSIMPLE_BORDER
;
55 wxFrame::Create( parent
, id
, title
, pos
, size
, style
, name
);
57 GtkWidget
*close_button
= gtk_button_new_with_label( "x" );
59 gtk_myfixed_put( GTK_MYFIXED(m_wxwindow
), close_button
, 4, 4 );
60 gtk_widget_set_usize( close_button
, 12, 11 );
62 gtk_widget_show( close_button
);
64 gtk_signal_connect( GTK_OBJECT(close_button
), "clicked",
65 GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this );
70 void wxMiniFrame::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
72 if (m_miniTitle
== 0) return;
73 if (m_title
.IsEmpty()) return;
77 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
78 dc
.DrawRectangle( 0, 0, m_width
, m_height
);
80 dc
.SetPen( *wxWHITE_PEN
);
81 dc
.DrawLine( 1, 1, m_width
-2, 1 );
82 dc
.DrawLine( 1, 1, 1, m_height
-2 );
84 dc
.SetPen( *wxMEDIUM_GREY_PEN
);
85 dc
.DrawLine( 1, m_height
-1, m_width
-2, m_height
-1 );
86 dc
.DrawLine( m_width
-1, 1, m_width
-1, m_height
-2 );
88 dc
.SetBrush( *wxBLUE_BRUSH
);
89 dc
.SetPen( *wxTRANSPARENT_PEN
);
90 dc
.DrawRectangle( m_miniEdge
, m_miniEdge
, m_width
- 2*m_miniEdge
, m_miniTitle
);
92 dc
.SetTextForeground( *wxWHITE
);
93 dc
.SetFont( *wxSMALL_FONT
);
94 dc
.DrawText( m_title
, 14 + m_miniEdge
, 1 + m_miniEdge
);
97 void wxMiniFrame::DrawFrame( int x
, int y
)
101 gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y
);
106 dc
.SetLogicalFunction( wxXOR
);
108 dc
.DrawRectangle( x
, y
, m_width
, m_height
);
111 void wxMiniFrame::OnMouse( wxMouseEvent
&event
)
113 int x
= event
.GetX();
114 int y
= event
.GetY();
116 if (event
.LeftDown())
128 if (event
.Dragging() && m_isDragging
)
130 DrawFrame( m_oldX
, m_oldY
);
131 m_oldX
= x
- m_diffX
;
132 m_oldY
= y
- m_diffY
;
133 DrawFrame( m_oldX
, m_oldY
);
137 if (event
.LeftUp() && m_isDragging
)
139 m_isDragging
= FALSE
;
140 DrawFrame( m_oldX
, m_oldY
);
145 gdk_window_get_origin( m_wxwindow
->window
, &org_x
, &org_y
);
146 x
+= org_x
- m_diffX
;
147 y
+= org_y
- m_diffY
;
150 gtk_widget_set_uposition( m_widget
, x
, y
);