CompareModesDialog.cs

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // $Id: CompareModesDialog.cs,v 1.6 2008/03/22 23:58:04 harald_meyer Exp $
00003 // Michael S. Muegel mike _at_ muegel dot org
00004 //
00005 // Licensed     under the Widgets license, see LICENSE.txt for details.
00006 //-----------------------------------------------------------------------------
00007 
00008 using System;
00009 using System.Drawing;
00010 using wx;
00011 
00012 namespace wx.SampleDisplay
00013 {
00014         public class CompareModesDialog : Dialog
00015         {
00016                 public CompareModesDialog( Window parent, int id, Display display )
00017                         : base( parent, id , "VideoMode Euqlity/Match Results", 
00018                         wxDefaultPosition, wxDefaultSize,
00019             wx.WindowStyles.DIALOG_DEFAULT_STYLE | wx.WindowStyles.MAXIMIZE_BOX | wx.WindowStyles.RESIZE_BORDER)
00020                 {
00021                         // Instructions
00022             wx.Html.HtmlWindow html_instr = new wx.Html.HtmlWindow(this);
00023                         // Force HTML font sizes to be same on all platforms
00024                         html_instr.SetFonts("", "", new int[] { 7, 8, 10, 12, 16, 22, 30 });
00025                         html_instr.SetPage("Testing current display's video modes for equality and \"match\" (non-zero fields are equal except for refresh, which is allowed to have a greater value).");
00026                         html_instr.SetSizeHints(-1,75);
00027 
00028                         // Test results
00029                         ListCtrl list_results = new ListCtrl( this, -1,
00030                 wxDefaultPosition, wxDefaultSize, wx.WindowStyles.LC_REPORT | wx.WindowStyles.BORDER_SUNKEN);
00031                         list_results.InsertColumn(0, "Mode1");
00032                         list_results.InsertColumn(1, "Mode2");
00033                         list_results.InsertColumn(2, "Mode1 == Mode2");
00034                         list_results.InsertColumn(3, "Mode1.Matches(Mode2)");
00035                         VideoMode[] modes = display.GetModes();
00036                         Array.Sort(modes);
00037                         int row = 0;
00038                         for (int m1 = 0; m1 < modes.Length; m1++)
00039                         {
00040                                 for (int m2 = 0; m2 < modes.Length; m2++)
00041                                 {
00042                                         // The ListCtrl API is ugly IMHO in wxLC_REPORT mode. Should
00043                                         // have seperate InsertRow() method and then use SetItem
00044                                         // for each cell vs. InsertItem() does both for the 0 column.
00045                                         list_results.InsertItem(row, modes[m1].ToString());
00046                                         list_results.SetItem(row, 1, modes[m2].ToString());
00047                                         list_results.SetItem(row, 2, (modes[m1] == modes[m2]).ToString());
00048                                         list_results.SetItem(row, 3, modes[m1].Matches(modes[m2]).ToString());
00049                                         ++row;
00050                                 }
00051                         }
00052 
00053                         // Ensure ListCtrl is as wide as it's data
00054                         int width = 0;
00055                         for (int col = 0; col <= 3; col++)
00056                         {
00057                 wx.ListCtrl.SymbolicColumnWidth sizing_mode
00058                     = (col <= 1) ? wx.ListCtrl.SymbolicColumnWidth.AUTOSIZE
00059                                  : wx.ListCtrl.SymbolicColumnWidth.AUTOSIZE_USEHEADER;
00060                                 list_results.SetColumnWidth(col, sizing_mode);
00061                                 width += list_results.GetColumnWidth(col);
00062                         }
00063                         list_results.SetSizeHints(width + 25, 400);
00064 
00065                         // OK button (built-in handler for wxID_OK will be invoked when 
00066                         // button is clicked
00067                         Button btn_ok = new Button( this, wxID_OK, "OK" );
00068 
00069                         BoxSizer sizer = new BoxSizer( Orientation.wxVERTICAL );
00070                         sizer.Add( html_instr, 0, wx.SizerFlag.wxEXPAND|wx.SizerFlag.wxALL, 5 );
00071                         sizer.Add( list_results, 1, wx.SizerFlag.wxEXPAND|wx.SizerFlag.wxALL, 5 );
00072                         sizer.Add( btn_ok, 0, wx.SizerFlag.wxALIGN_CENTER_HORIZONTAL|wx.SizerFlag.wxALL, 5 );
00073 
00074                         sizer.Fit(this);
00075                         AutoLayout = true;
00076                         SetSizer( sizer );
00077                 }
00078 
00079         }
00080  
00081 } // namespace

Manual of the wx.NET   (c) 2003-2010 the wx.NET project