]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/ownerdrw/ownerdrw.cpp
added Bulgarian translations
[wxWidgets.git] / samples / ownerdrw / ownerdrw.cpp
index 1474b5986873c3e50a5f0c218195cc4d62f9b16b..18c3ed7c0292de3d4a3ab7218ba17031eb990140 100644 (file)
@@ -26,6 +26,7 @@
 
 #include  "wx/ownerdrw.h"
 #include  "wx/menuitem.h"
+#include  "wx/image.h"
 #include  "wx/msw/checklst.h"
 
 // Define a new application type
@@ -40,7 +41,7 @@ class OwnerDrawnFrame : public wxFrame
 {
 public:
     // ctor & dtor
-    OwnerDrawnFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
+    OwnerDrawnFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h);
     ~OwnerDrawnFrame();
 
     // notifications
@@ -83,8 +84,9 @@ IMPLEMENT_APP(OwnerDrawnApp);
 // init our app: create windows
 bool OwnerDrawnApp::OnInit(void)
 {
+    wxInitAllImageHandlers();
     OwnerDrawnFrame *pFrame
-        = new OwnerDrawnFrame(NULL, "wxWindows Ownerdraw Sample",
+        = new OwnerDrawnFrame(NULL, _T("wxWindows Ownerdraw Sample"),
                               50, 50, 450, 340);
 
     SetTopWindow(pFrame);
@@ -108,82 +110,84 @@ void OwnerDrawnFrame::InitMenu()
            fontBmp(14, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE);
 
     // sorry for my artistic skills...
-    wxBitmap bmpBell("bell"), bmpSound("sound"), bmpNoSound("nosound");
+    wxBitmap bmpBell(_T("bell"));
+    wxBitmap bmpSound(_T("sound.png"), wxBITMAP_TYPE_PNG);
+    wxBitmap bmpNoSound(_T("nosound.png"), wxBITMAP_TYPE_PNG);
 
     // construct submenu
-    pItem = new wxMenuItem(sub_menu, Menu_Sub1, "Submenu &first", "large");
+    pItem = new wxMenuItem(sub_menu, Menu_Sub1, _T("Submenu &first"), _T("large"));
 
     pItem->SetFont(fontLarge);
     sub_menu->Append(pItem);
 
-    pItem = new wxMenuItem(sub_menu, Menu_Sub2, "Submenu &second", "italic",
+    pItem = new wxMenuItem(sub_menu, Menu_Sub2, _T("Submenu &second"), _T("italic"),
                            wxITEM_CHECK);
     pItem->SetFont(fontItalic);
     sub_menu->Append(pItem);
 
-    pItem = new wxMenuItem(sub_menu, Menu_Sub3, "Submenu &third", "underlined",
+    pItem = new wxMenuItem(sub_menu, Menu_Sub3, _T("Submenu &third"), _T("underlined"),
                            wxITEM_CHECK);
     pItem->SetFont(fontUlined);
     sub_menu->Append(pItem);
 
     // construct menu
-    pItem = new wxMenuItem(file_menu, Menu_Test1, "&Uncheckable", "red item");
+    pItem = new wxMenuItem(file_menu, Menu_Test1, _T("&Uncheckable"), _T("red item"));
     pItem->SetFont(*wxITALIC_FONT);
     pItem->SetTextColour(wxColor(255, 0, 0));
     pItem->SetMarginWidth(23);
     file_menu->Append(pItem);
 
-    pItem = new wxMenuItem(file_menu, Menu_Test2, "&Checkable",
-                           "checkable item", wxITEM_CHECK);
+    pItem = new wxMenuItem(file_menu, Menu_Test2, _T("&Checkable"),
+                           _T("checkable item"), wxITEM_CHECK);
     pItem->SetFont(*wxSMALL_FONT);
     file_menu->Append(pItem);
     file_menu->Check(Menu_Test2, TRUE);
 
-    pItem = new wxMenuItem(file_menu, Menu_Test3, "&Disabled", "disabled item");
+    pItem = new wxMenuItem(file_menu, Menu_Test3, _T("&Disabled"), _T("disabled item"));
     pItem->SetFont(*wxNORMAL_FONT);
     file_menu->Append(pItem);
     file_menu->Enable(Menu_Test3, FALSE);
 
     file_menu->AppendSeparator();
 
-    pItem = new wxMenuItem(file_menu, Menu_Bitmap, "&Bell",
-                           "check/uncheck me!", wxITEM_CHECK);
+    pItem = new wxMenuItem(file_menu, Menu_Bitmap, _T("&Bell"),
+                           _T("check/uncheck me!"), wxITEM_CHECK);
     pItem->SetFont(fontBmp);
     pItem->SetBitmaps(bmpBell);
     file_menu->Append(pItem);
 
-    pItem = new wxMenuItem(file_menu, Menu_Bitmap2, "So&und",
-                           "icon changes!", wxITEM_CHECK);
+    pItem = new wxMenuItem(file_menu, Menu_Bitmap2, _T("So&und"),
+                           _T("icon changes!"), wxITEM_CHECK);
     pItem->SetFont(fontBmp);
     pItem->SetBitmaps(bmpSound, bmpNoSound);
     file_menu->Append(pItem);
 
     file_menu->AppendSeparator();
 
-    pItem = new wxMenuItem(file_menu, Menu_Submenu, "&Sub menu", "",
+    pItem = new wxMenuItem(file_menu, Menu_Submenu, _T("&Sub menu"), _T(""),
                            wxITEM_CHECK, sub_menu);
     pItem->SetFont(*wxSWISS_FONT);
     file_menu->Append(pItem);
 
     file_menu->AppendSeparator();
-    pItem = new wxMenuItem(file_menu, Menu_Quit, "&Quit", "Normal item",
+    pItem = new wxMenuItem(file_menu, Menu_Quit, _T("&Quit"), _T("Normal item"),
                            wxITEM_NORMAL);
     pItem->SetFont(*wxNORMAL_FONT);
     file_menu->Append(pItem);
 
     wxMenuBar *menu_bar = new wxMenuBar;
 
-    menu_bar->Append(file_menu, "&File");
+    menu_bar->Append(file_menu, _T("&File"));
     SetMenuBar(menu_bar);
 }
 
 // main frame constructor
-OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, char *title,
+OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, wxChar *title,
                                  int x, int y, int w, int h)
          : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
 {
     // set the icon
-    SetIcon(wxIcon("mondrian"));
+    SetIcon(wxIcon(_T("mondrian")));
 
     // create the menu
     InitMenu();
@@ -192,16 +196,16 @@ OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, char *title,
     const int widths[] = { -1, 60 };
     CreateStatusBar(2);
     SetStatusWidths(2, widths);
-    SetStatusText("no selection", 0);
+    SetStatusText(_T("no selection"), 0);
 
     // make a panel with some controls
     wxPanel *pPanel = new wxPanel(this, -1, wxPoint(0, 0), 
                                   wxSize(400, 200), wxTAB_TRAVERSAL);
 
     // check list box
-    static const char* aszChoices[] = { "Hello", "world", "and"
-                                      "goodbye", "cruel", "world",
-                                      "-------", "owner-drawn", "listbox" };
+    static const wxChar* aszChoices[] = { _T("Hello"), _T("world"), _T("and")
+                                          _T("goodbye"), _T("cruel"), _T("world"),
+                                          _T("-------"), _T("owner-drawn"), _T("listbox") };
 
     wxString *astrChoices = new wxString[WXSIZEOF(aszChoices)];
     unsigned int ui;
@@ -228,9 +232,9 @@ OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, char *title,
     m_pListBox->Check(2);
 
     // normal (but owner-drawn) listbox
-    static const char* aszColors[] = { "Red", "Blue", "Pink",
-                                       "Green", "Yellow"
-                                       "Black", "Violet"  };
+    static const wxChar* aszColors[] = { _T("Red"), _T("Blue"), _T("Pink"),
+                                         _T("Green"), _T("Yellow")
+                                         _T("Black"), _T("Violet")  };
     struct { unsigned int r, g, b; } aColors[] =
         {
             {255,0,0}, {0,0,255}, {255,128,192},
@@ -288,8 +292,8 @@ void OwnerDrawnFrame::OnQuit(wxCommandEvent& event)
 void OwnerDrawnFrame::OnAbout(wxCommandEvent& event)
 {
     wxMessageDialog dialog(this,
-                           "Demo of owner-drawn controls\n",
-                           "About wxOwnerDrawn", wxYES_NO | wxCANCEL);
+                           _T("Demo of owner-drawn controls\n"),
+                           _T("About wxOwnerDrawn"), wxYES_NO | wxCANCEL);
     dialog.ShowModal();
 }
 
@@ -297,16 +301,16 @@ void OwnerDrawnFrame::OnListboxSelect(wxCommandEvent& event)
 {
     wxString strSelection;
     unsigned int nSel = event.GetSelection();
-    strSelection.sprintf(wxT("item %d selected (%schecked)"), nSel,
-                         m_pListBox->IsChecked(nSel) ? wxT("") : wxT("not "));
+    strSelection.Printf(wxT("item %d selected (%schecked)"), nSel,
+                        m_pListBox->IsChecked(nSel) ? wxT("") : wxT("not "));
     SetStatusText(strSelection);
 }
 
 void OwnerDrawnFrame::OnListboxDblClick(wxCommandEvent& event)
 {
     wxString strSelection;
-    strSelection.sprintf(wxT("item %d double clicked"),
-                         m_pListBox->GetSelection());
+    strSelection.Printf(wxT("item %d double clicked"),
+                        m_pListBox->GetSelection());
     wxMessageDialog dialog(this, strSelection);
     dialog.ShowModal();
 }
@@ -315,7 +319,7 @@ void OwnerDrawnFrame::OnCheckboxToggle(wxCommandEvent& event)
 {
     wxString strSelection;
     unsigned int nItem = event.GetInt();
-    strSelection.sprintf(wxT("item %d was %schecked"), nItem,
-                         m_pListBox->IsChecked(nItem) ? wxT("") : wxT("un"));
+    strSelection.Printf(wxT("item %d was %schecked"), nItem,
+                        m_pListBox->IsChecked(nItem) ? wxT("") : wxT("un"));
     SetStatusText(strSelection);
 }