]> git.saurik.com Git - wxWidgets.git/blobdiff - user/wxLayout/wxLayout.cpp
Listctrl updates
[wxWidgets.git] / user / wxLayout / wxLayout.cpp
index e9b644ff091ffd1d4f3dd423c6c37b65d4cc9fa9..8cbf257bbd550bcba144eca910881b38f8cd6cdc 100644 (file)
@@ -33,7 +33,7 @@ IMPLEMENT_APP(MyApp)
    enum ids{ ID_EDIT = 1, ID_ADD_SAMPLE, ID_CLEAR, ID_PRINT,
              ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
              ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
-             ID_DPRINT,
+             ID_DPRINT, ID_WRAP, ID_NOWRAP,
              ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT, ID_TEST };
 
 
@@ -54,29 +54,20 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
    END_EVENT_TABLE()
 
 
-
-
-
-
 int orientation = wxPORTRAIT;
 
-
-
-
-
-   
-   MyFrame::MyFrame(void) :
+MyFrame::MyFrame(void) :
       wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) )
 {
    CreateStatusBar( 1 );
   
    SetStatusText( "wxLayout by Karsten Ballüder." );
 
-   wxMenu *file_menu = new wxMenu( "Menu 1" );
+   wxMenu *file_menu = new wxMenu;
    file_menu->Append( ID_CLEAR, "Clear");
    file_menu->Append( ID_ADD_SAMPLE, "Example");
-   file_menu->Append( ID_EDIT, "Edit");
-   file_menu->Append( ID_WXLAYOUT_DEBUG, "Debug");
+//   file_menu->Append( ID_EDIT, "Edit");
+//   file_menu->Append( ID_WXLAYOUT_DEBUG, "Debug");
 
   file_menu->Append(ID_PRINT, "&Print...", "Print");
   file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties");
@@ -90,21 +81,27 @@ int orientation = wxPORTRAIT;
   file_menu->Append(ID_PREVIEW_PS, "Print Preview PostScript", "Preview (PostScript)");
 #endif
   file_menu->AppendSeparator();
+  file_menu->Append(ID_WRAP, "Wrap mode", "Activate wrapping at pixel 200.");
+  file_menu->Append(ID_NOWRAP, "No-wrap mode", "Deactivate wrapping.");
 
-   file_menu->Append( ID_DPRINT, "Direct Print");
+  file_menu->AppendSeparator();
+//   file_menu->Append( ID_DPRINT, "Direct Print");
    file_menu->Append( ID_TEXT, "Export Text");
    file_menu->Append( ID_HTML, "Export HTML");
-   file_menu->Append( ID_TEST, "Test");
+//   file_menu->Append( ID_TEST, "Test");
    file_menu->Append( ID_QUIT, "Exit");
   
    wxMenuBar *menu_bar = new wxMenuBar();
    menu_bar->Append(file_menu, "File" );
+
+#ifndef __WXMSW__
    menu_bar->Show( TRUE );
+#endif // MSW
   
    SetMenuBar( menu_bar );
 
    m_lwin = new wxLayoutWindow(this);
-   m_lwin->SetEventId(ID_CLICK);
+   m_lwin->SetMouseTracking(true);
    m_lwin->GetLayoutList().SetEditable(true);
    m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
    m_lwin->SetFocus();
@@ -113,13 +110,15 @@ int orientation = wxPORTRAIT;
 void
 MyFrame::AddSampleText(wxLayoutList &llist)
 {
+   llist.SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
    llist.Insert("--");
    llist.LineBreak();
 
+   llist.SetFont(wxROMAN);
    llist.Insert("The quick brown fox jumps over the lazy dog.");
    llist.LineBreak();
    llist.Insert("Hello ");
-   llist.Insert(new wxLayoutObjectIcon(new wxIcon(Micon_xpm,-1,-1)));
+   llist.Insert(new wxLayoutObjectIcon(new wxICON(Micon)));
    llist.LineBreak();
    llist.SetFontWeight(wxBOLD);
    llist.Insert("World! ");
@@ -203,7 +202,7 @@ MyFrame::Clear(void)
 void MyFrame::Edit(void)
 {
    wxLayoutList & llist = m_lwin->GetLayoutList();
-   m_lwin->SetEventId(ID_CLICK);
+   //m_lwin->SetEventId(ID_CLICK);
   
    llist.MoveCursor(0);
    llist.MoveCursor(5);
@@ -226,6 +225,11 @@ void MyFrame::OnCommand( wxCommandEvent &event )
    case ID_PRINT:
       m_lwin->Print();
       break;
+   case ID_NOWRAP:
+   case ID_WRAP:
+      m_lwin->GetLayoutList().SetWrapMargin(
+         event.GetId() == ID_NOWRAP ? -1 : 40);
+      break;
    case ID_DPRINT:
    {
       wxLayoutList llist;
@@ -254,15 +258,6 @@ void MyFrame::OnCommand( wxCommandEvent &event )
    case ID_CLICK:
       cerr << "Received click event." << endl;
       break;
-   case ID_TEST:
-   {
-      Clear();
-      m_lwin->GetLayoutList().LineBreak();
-      m_lwin->GetLayoutList().Insert("abc");
-      m_lwin->GetLayoutList().LineBreak();
-      m_lwin->GetLayoutList().Insert("def");
-      break;
-   }
    case ID_HTML:
    {
       wxLayoutExportObject *export;
@@ -306,9 +301,11 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
       wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
 #endif
       wxPrinter printer;
-      wxLayoutPrintout printout( m_lwin->GetLayoutList(),"My printout");
-      if (!printer.Print(this, &printout, TRUE))
-        wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK);
+      wxLayoutPrintout printout( m_lwin->GetLayoutList(),"Printout from wxLayout");
+      if (! printer.Print(this, &printout, TRUE))
+         wxMessageBox(
+            "There was a problem printing.\nPerhaps your current printer is not set correctly?",
+            "Printing", wxOK);  
 }
 
 void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
@@ -331,7 +328,9 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
       printData.SetOrientation(orientation);
 
       // Pass two printout objects: for preview, and possible printing.
-      wxPrintPreview *preview = new wxPrintPreview(new wxLayoutPrintout( m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
+      wxPrintPreview *preview = new wxPrintPreview(new
+                                                   wxLayoutPrintout(
+                                                      m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);  
       if (!preview->Ok())
       {
         delete preview;
@@ -443,7 +442,7 @@ bool MyApp::OnInit(void)
 {
    wxFrame *frame = new MyFrame();
    frame->Show( TRUE );
-   wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
+//   wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
    return TRUE;
 };