]>
git.saurik.com Git - wxWidgets.git/blob - demos/life/dialogs.cpp
635aa75da1bea83d5f1ac29a0aedaf7a4c9b0b56
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Life! dialogs
4 // Author: Guillermo Rodriguez Garcia, <guille@iies.es>
8 // Copyright: (c) 2000, Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ==========================================================================
13 // headers, declarations, constants
14 // ==========================================================================
17 #pragma implementation "dialogs.h"
20 // For compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
31 #include "wx/statline.h"
32 #include "wx/minifram.h"
39 // --------------------------------------------------------------------------
41 // --------------------------------------------------------------------------
43 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
44 // logo for the about dialog
45 #include "bitmaps/life.xpm"
48 // sample configurations
49 #include "samples.inc"
51 // --------------------------------------------------------------------------
53 // --------------------------------------------------------------------------
55 // IDs for the controls and the menu commands
58 // listbox in samples dialog
62 // --------------------------------------------------------------------------
63 // event tables and other macros for wxWindows
64 // --------------------------------------------------------------------------
67 BEGIN_EVENT_TABLE(LifeSamplesDialog
, wxDialog
)
68 EVT_LISTBOX (ID_LISTBOX
, LifeSamplesDialog::OnListBox
)
72 // ==========================================================================
74 // ==========================================================================
76 // --------------------------------------------------------------------------
78 // --------------------------------------------------------------------------
80 LifeSamplesDialog::LifeSamplesDialog(wxWindow
*parent
)
81 : wxDialog(parent
, -1,
85 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
)
89 // create and populate the list of available samples
90 m_list
= new wxListBox( this, ID_LISTBOX
,
94 wxLB_SINGLE
| wxLB_NEEDED_SB
| wxLB_HSCROLL
);
96 for (unsigned i
= 0; i
< (sizeof(g_patterns
) / sizeof(LifePattern
)); i
++)
97 m_list
->Append(g_patterns
[i
].m_name
);
100 wxStaticBox
*statbox
= new wxStaticBox( this, -1, _("Description"));
102 m_life
->SetPattern(g_patterns
[0]);
103 m_canvas
= new LifeCanvas( this, m_life
, FALSE
);
104 m_text
= new wxTextCtrl( this, -1,
105 g_patterns
[0].m_description
,
108 wxTE_MULTILINE
| wxTE_READONLY
);
111 wxStaticBoxSizer
*sizer1
= new wxStaticBoxSizer( statbox
, wxVERTICAL
);
112 sizer1
->Add( m_canvas
, 2, wxGROW
| wxALL
, 5);
113 sizer1
->Add( m_text
, 1, wxGROW
| wxALL
, 5 );
115 wxBoxSizer
*sizer2
= new wxBoxSizer( wxHORIZONTAL
);
116 sizer2
->Add( m_list
, 0, wxGROW
| wxALL
, 5 );
117 sizer2
->Add( sizer1
, 1, wxGROW
| wxALL
, 5 );
119 wxBoxSizer
*sizer3
= new wxBoxSizer( wxVERTICAL
);
120 sizer3
->Add( CreateTextSizer(_("Select one configuration")), 0, wxALL
, 10 );
121 sizer3
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 10 );
122 sizer3
->Add( sizer2
, 1, wxGROW
| wxALL
, 5 );
123 sizer3
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 10 );
124 sizer3
->Add( CreateButtonSizer(wxOK
| wxCANCEL
), 0, wxCENTRE
| wxALL
, 10 );
129 sizer3
->SetSizeHints(this);
131 Centre(wxBOTH
| wxCENTRE_ON_SCREEN
);
134 LifeSamplesDialog::~LifeSamplesDialog()
139 const LifePattern
& LifeSamplesDialog::GetPattern()
141 return g_patterns
[m_value
];
144 void LifeSamplesDialog::OnListBox(wxCommandEvent
& event
)
146 int sel
= event
.GetSelection();
150 m_value
= m_list
->GetSelection();
151 m_text
->SetValue(g_patterns
[ sel
].m_description
);
152 m_life
->SetPattern(g_patterns
[ sel
]);
154 // these values shouldn't be hardcoded...
155 if ((size_t)sel
< (sizeof(g_patterns
) / sizeof(LifePattern
)) - 3)
156 m_canvas
->SetCellSize(8);
158 m_canvas
->SetCellSize(2);
162 // --------------------------------------------------------------------------
164 // --------------------------------------------------------------------------
166 LifeAboutDialog::LifeAboutDialog(wxWindow
*parent
)
167 : wxDialog(parent
, -1,
171 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
)
174 wxBitmap bmp
= wxBITMAP(life
);
175 #if !defined(__WXGTK__) && !defined(__WXMOTIF__) && !defined(__WXMAC__)
176 bmp
.SetMask(new wxMask(bmp
, *wxBLUE
));
178 wxStaticBitmap
*sbmp
= new wxStaticBitmap(this, -1, bmp
);
181 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
182 sizer
->Add( sbmp
, 0, wxCENTRE
| wxALL
, 10 );
183 sizer
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 5 );
184 sizer
->Add( CreateTextSizer(_("Life! version 2.2 for wxWindows\n\n"
185 "(c) 2000 Guillermo Rodriguez Garcia\n\n"
186 "<guille@iies.es>\n\n"
187 "Portions of the code are based in XLife;\n"
188 "XLife is (c) 1989 by Jon Bennett et al.")),
189 0, wxCENTRE
| wxALL
, 20 );
190 sizer
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 5 );
191 sizer
->Add( CreateButtonSizer(wxOK
), 0, wxCENTRE
| wxALL
, 10 );
196 sizer
->SetSizeHints(this);
198 Centre(wxBOTH
| wxCENTRE_ON_SCREEN
);