]>
git.saurik.com Git - wxWidgets.git/blob - demos/life/dialogs.cpp
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 #include "wx/statline.h"
21 #include "wx/spinctrl.h"
27 // --------------------------------------------------------------------------
29 // --------------------------------------------------------------------------
31 #if defined(__WXGTK__) || defined(__WXMOTIF__)
32 // logo for the about dialog
33 #include "bitmaps/life.xpm"
36 // sample configurations
37 #include "samples.inc"
39 // --------------------------------------------------------------------------
41 // --------------------------------------------------------------------------
43 // IDs for the controls and the menu commands
46 // bmp window in about dialog
49 // listbox in samples dialog
53 // --------------------------------------------------------------------------
54 // event tables and other macros for wxWindows
55 // --------------------------------------------------------------------------
58 BEGIN_EVENT_TABLE(LifeSamplesDialog
, wxDialog
)
59 EVT_LISTBOX (ID_LISTBOX
, LifeSamplesDialog::OnListBox
)
64 // ==========================================================================
66 // ==========================================================================
68 // --------------------------------------------------------------------------
70 // --------------------------------------------------------------------------
72 LifeSamplesDialog::LifeSamplesDialog(wxWindow
*parent
)
73 : wxDialog(parent
, -1,
77 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
)
81 // create and populate the list of available samples
82 m_list
= new wxListBox( this, ID_LISTBOX
,
86 wxLB_SINGLE
| wxLB_NEEDED_SB
| wxLB_HSCROLL
);
88 for (unsigned i
= 0; i
< (sizeof(g_shapes
) / sizeof(LifeShape
)); i
++)
89 m_list
->Append(g_shapes
[i
].m_name
);
92 wxStaticBox
*statbox
= new wxStaticBox( this, -1, _("Description"));
94 m_life
->SetShape(g_shapes
[0]);
95 m_canvas
= new LifeCanvas( this, m_life
, FALSE
);
96 m_text
= new wxTextCtrl( this, -1,
100 wxTE_MULTILINE
| wxTE_READONLY
);
103 wxStaticBoxSizer
*sizer1
= new wxStaticBoxSizer( statbox
, wxVERTICAL
);
104 sizer1
->Add( m_canvas
, 2, wxGROW
| wxCENTRE
| wxALL
, 5);
105 sizer1
->Add( m_text
, 1, wxGROW
| wxCENTRE
| wxALL
, 5 );
107 wxBoxSizer
*sizer2
= new wxBoxSizer( wxHORIZONTAL
);
108 sizer2
->Add( m_list
, 0, wxGROW
| wxCENTRE
| wxALL
, 5 );
109 sizer2
->Add( sizer1
, 1, wxGROW
| wxCENTRE
| wxALL
, 5 );
111 wxBoxSizer
*sizer3
= new wxBoxSizer( wxVERTICAL
);
112 sizer3
->Add( CreateTextSizer(_("Select one configuration")), 0, wxALL
, 10 );
113 sizer3
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 10 );
114 sizer3
->Add( sizer2
, 1, wxGROW
| wxCENTRE
| wxALL
, 5 );
115 sizer3
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 10 );
116 sizer3
->Add( CreateButtonSizer(wxOK
| wxCANCEL
), 0, wxCENTRE
| wxALL
, 10 );
121 sizer3
->SetSizeHints(this);
123 Centre(wxBOTH
| wxCENTRE_ON_SCREEN
);
126 LifeSamplesDialog::~LifeSamplesDialog()
131 const LifeShape
& LifeSamplesDialog::GetShape()
133 return g_shapes
[m_value
];
136 void LifeSamplesDialog::OnListBox(wxCommandEvent
& event
)
138 int sel
= event
.GetSelection();
142 m_value
= m_list
->GetSelection();
143 m_text
->SetValue(g_shapes
[ sel
].m_desc
);
144 m_life
->SetShape(g_shapes
[ sel
]);
146 // quick and dirty :-)
147 if ((g_shapes
[ sel
].m_width
> 36) ||
148 (g_shapes
[ sel
].m_height
> 22))
149 m_canvas
->SetCellSize(2);
151 m_canvas
->SetCellSize(8);
155 // --------------------------------------------------------------------------
157 // --------------------------------------------------------------------------
159 LifeAboutDialog::LifeAboutDialog(wxWindow
*parent
)
160 : wxDialog(parent
, -1,
164 wxDEFAULT_DIALOG_STYLE
| wxDIALOG_MODAL
)
167 wxBitmap bmp
= wxBITMAP(life
);
168 #if !defined(__WXGTK__) && !defined(__WXMOTIF__)
169 bmp
.SetMask(new wxMask(bmp
, *wxBLUE
));
171 wxStaticBitmap
*sbmp
= new wxStaticBitmap(this, -1, bmp
);
174 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
175 sizer
->Add( sbmp
, 0, wxCENTRE
| wxALL
, 10 );
176 sizer
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 5 );
177 sizer
->Add( CreateTextSizer(_("Life! for wxWindows, version 2.0\n\n"
178 "(c) 2000 Guillermo Rodriguez Garcia\n\n"
179 "<guille@iies.es>\n\n"
180 "Portions of the code are based in XLife\n"
181 "XLife is (c) 1989 by Jon Bennett et al.")),
182 0, wxCENTRE
| wxALL
, 20 );
183 sizer
->Add( new wxStaticLine(this, -1), 0, wxGROW
| wxLEFT
| wxRIGHT
, 5 );
184 sizer
->Add( CreateButtonSizer(wxOK
), 0, wxCENTRE
| wxALL
, 10 );
189 sizer
->SetSizeHints(this);
191 Centre(wxBOTH
| wxCENTRE_ON_SCREEN
);