]> git.saurik.com Git - wxWidgets.git/blobdiff - user/wxLayout/wxLayout.cpp
First part of fixes to make this work under MSW.
[wxWidgets.git] / user / wxLayout / wxLayout.cpp
index 4d8d9baf90b32017722f30c0e7ba55ccab473a46..41431fbe242d151396e170af84713a13693b565a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Program: wxLayout
- * 
+ *
  * Author: Karsten Ballüder
  *
  * Copyright: (C) 1998, Karsten Ballüder <Ballueder@usa.net>
@@ -36,7 +36,7 @@ IMPLEMENT_APP(MyApp)
    enum ids{ ID_ADD_SAMPLE = 1, 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_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY,
+             ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT, ID_FIND,
              ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
              ID_TEST, ID_LONG_TEST };
 
@@ -61,12 +61,12 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
 MyFrame::MyFrame(void) :
    wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) )
 {
-   CreateStatusBar( 1 );
-  
+   CreateStatusBar( 2 );
+
    SetStatusText( "wxLayout by Karsten Ballüder." );
 
    wxMenuBar *menu_bar = new wxMenuBar();
-   
+
    wxMenu *file_menu = new wxMenu;
    file_menu->Append(ID_PRINT, "&Print...", "Print");
    file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties");
@@ -94,16 +94,19 @@ MyFrame::MyFrame(void) :
    edit_menu->Append(ID_NOWRAP, "No-wrap mode", "Deactivate wrapping.");
    edit_menu->AppendSeparator();
    edit_menu->Append(ID_COPY, "Copy", "Copy text to clipboard.");
+   edit_menu->Append(ID_CUT, "Cut", "Cut text to clipboard.");
    edit_menu->Append(ID_PASTE,"Paste", "Paste text from clipboard.");
+   edit_menu->Append(ID_FIND, "Find", "Find text.");
    menu_bar->Append(edit_menu, "Edit" );
 
 #ifndef __WXMSW__
    menu_bar->Show( TRUE );
 #endif // MSW
-  
+
    SetMenuBar( menu_bar );
 
    m_lwin = new wxLayoutWindow(this);
+   m_lwin->SetStatusBar(GetStatusBar(), 0, 1);
    m_lwin->SetMouseTracking(true);
    m_lwin->SetEditable(true);
    m_lwin->SetWrapMargin(40);
@@ -114,6 +117,13 @@ MyFrame::MyFrame(void) :
 void
 MyFrame::AddSampleText(wxLayoutList *llist)
 {
+   llist->Clear(wxSWISS,16,wxNORMAL,wxNORMAL, false);
+   llist->SetFont(-1,-1,-1,-1,-1,"blue");
+   llist->Insert("blue");
+   llist->SetFont(-1,-1,-1,-1,-1,"black");
+   llist->Insert("The quick brown fox jumps over the lazy dog.");
+   llist->LineBreak();
+
    llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
    llist->Insert("--");
    llist->LineBreak();
@@ -128,7 +138,6 @@ MyFrame::AddSampleText(wxLayoutList *llist)
    llist->SetFontWeight(wxNORMAL);
    llist->Insert("The quick brown fox jumps...");
    llist->LineBreak();
-
    llist->Insert("over the lazy dog.");
    llist->SetFont(-1,-1,-1,-1,true);
    llist->Insert("underlined");
@@ -141,7 +150,7 @@ MyFrame::AddSampleText(wxLayoutList *llist)
    llist->Insert("italics ");
    llist->SetFont(-1,-1,wxNORMAL);
    llist->LineBreak();
-   
+
    llist->Insert("and ");
    llist->SetFont(-1,-1,wxSLANT);
    llist->Insert("slanted");
@@ -210,7 +219,7 @@ void MyFrame::OnCommand( wxCommandEvent &event )
       wxPrinter printer;
       wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
       if (! printer.Print(this, &printout, TRUE))
-         wxMessageBox(                           
+         wxMessageBox(
             _("There was a problem with printing the message:\n"
               "perhaps your current printer is not set up correctly?"),
             _("Printing"), wxOK);
@@ -231,9 +240,19 @@ void MyFrame::OnCommand( wxCommandEvent &event )
       break;
    case ID_PASTE:
       m_lwin->Paste();
+      m_lwin->Refresh(FALSE);
       break;
    case ID_COPY:
       m_lwin->Copy();
+      m_lwin->Refresh(FALSE);
+      break;
+   case ID_CUT:
+      m_lwin->Cut();
+      m_lwin->Refresh(FALSE);
+      break;
+   case ID_FIND:
+      m_lwin->Find("void");
+      m_lwin->Refresh(FALSE);
       break;
    case ID_HTML:
    {
@@ -296,7 +315,7 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
    if (! printer.Print(this, &printout, TRUE))
       wxMessageBox(
          "There was a problem printing.\nPerhaps your current printer is not set correctly?",
-         "Printing", wxOK);  
+         "Printing", wxOK);
 }
 
 void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
@@ -322,14 +341,14 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
    // Pass two printout objects: for preview, and possible printing.
    wxPrintPreview *preview = new wxPrintPreview(new
                                                 wxLayoutPrintout(
-                                                   m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);  
+                                                   m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
    if (!preview->Ok())
    {
       delete preview;
       wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
       return;
    }
-      
+
    wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
    frame->Centre(wxBOTH);
    frame->Initialize();
@@ -412,7 +431,7 @@ void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
 // MyApp
 //-----------------------------------------------------------------------------
 
-MyApp::MyApp(void) : 
+MyApp::MyApp(void) :
    wxApp( )
 {
 };