1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        src/gtk/statline.cpp
3 // Purpose:
4 // Author:      Robert Roebling
5 // Copyright:   (c) 1998 Robert Roebling
6 // Licence:     wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8 
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11 
12 #include "wx/statline.h"
13 
14 #if wxUSE_STATLINE
15 
16 #include "wx/gtk/private/wrapgtk.h"
17 
18 //-----------------------------------------------------------------------------
19 // wxStaticLine
20 //-----------------------------------------------------------------------------
21 
wxStaticLine()22 wxStaticLine::wxStaticLine()
23 {
24 }
25 
wxStaticLine(wxWindow * parent,wxWindowID id,const wxPoint & pos,const wxSize & size,long style,const wxString & name)26 wxStaticLine::wxStaticLine( wxWindow *parent, wxWindowID id,
27                             const wxPoint &pos, const wxSize &size,
28                             long style, const wxString &name )
29 {
30     Create( parent, id, pos, size, style, name );
31 }
32 
Create(wxWindow * parent,wxWindowID id,const wxPoint & pos,const wxSize & size,long style,const wxString & name)33 bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
34                            const wxPoint &pos, const wxSize &size,
35                            long style, const wxString &name )
36 {
37     if (!PreCreation( parent, pos, size ) ||
38         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
39     {
40         wxFAIL_MSG( wxT("wxStaticLine creation failed") );
41         return FALSE;
42     }
43 
44     const bool isVertical = IsVertical();
45     m_widget = gtk_separator_new(GtkOrientation(isVertical));
46     g_object_ref(m_widget);
47     if (isVertical)
48     {
49         if (size.x == -1)
50         {
51             wxSize new_size( size );
52             new_size.x = 4;
53             SetSize( new_size );
54         }
55     }
56     else
57     {
58         if (size.y == -1)
59         {
60             wxSize new_size( size );
61             new_size.y = 4;
62             SetSize( new_size );
63         }
64     }
65 
66     m_parent->DoAddChild( this );
67 
68     PostCreation(size);
69 
70     return TRUE;
71 }
72 
73 // static
74 wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant WXUNUSED (variant))75 wxStaticLine::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
76 {
77     return GetDefaultAttributesFromGTKWidget(gtk_separator_new(GTK_ORIENTATION_VERTICAL));
78 }
79 
80 #endif
81