var alinks_link; var trackImage = new Image(); function alinks_click(link) { var keyphrase = link.innerHTML; trackImage.src = 'http://www.thecredence.com/wp-content/plugins/alinks/classes/aLinksAjax.php?log=' + keyphrase; pause(1000); return true; } function pause(numberMillis) { var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true) { now = new Date(); if (now.getTime() > exitTime) return; } }
You seem to be using a version of Internet Explorer. Вы, по-видимому, используя версию Internet Explorer. For a safer browsing experience, please consider Для безопасного поиска, просьба рассмотреть and и

If you're new here, you may want to subscribe to our RSS feed as well as to our NewsLetter (on Top Right hand menu) to get highly informative articles weekly...and NO, we never spam! Если вы новичок на сайте, Вы можете подписаться на наш канал, а также наши с новостями (по началу Правое меню), чтобы получить весьма информативным статей неделю ... и НЕТ, мы никогда не спам!

wxWidgets is an open source cross-platform C++ programming toolkit that includes many features. wxWidgets является открытым исходным кросс-платформенной C + + инструментарий программирования, которая включает многие черты. It is most often used for developing applications with a GUI, but also provides features for networking, file access, and more. Она чаще всего используется для разработки приложений с графическим интерфейсом, но также обеспечивает функции для создания сетей доступа к файлу, и многое другое. With versions available for Windows, Linux, Mac, and even some embedded devices, cross platform programming becomes much easier. В версии для Windows, Linux, Mac, и даже некоторые встраиваемых устройств, кросс-платформенный программирования становится гораздо проще.

I am myself very new to wxWidgets but still have penned down a Beginners Tutorial on wxWidgets - Я сам очень новый для wxWidgets, но еще написал вниз начинающих Учебник по wxWidgets -

During this tutorial, a very simple text editor will be constructed that can load and save text files. За этот урок, очень простой текстовый редактор, будут построены, что может загружать и сохранять текстовые файлы. The tutorial will focus on the application object, the main window, and the event table. Урок будет посвящен применению объекта главного окна, и это событие таблице.

The Application Применение
All wxWidgets applications are derived from wxApp , and simply need to override a single member, wxApp::OnInit , and create a window. Все wxWidgets заявок, полученных от wxApp и просто необходимо изменить один член, wxApp:: OnInit, а также создавать окна. As long as the window is open, the application is as well. Пока окно открыто, заявки, а также. The following code illustrates the code needed. Следующий код иллюстрирует код необходимо.

  1.  
  2. #include “wx/wx.h”class MyApplication : public wxApp # включить "wx / wx.h" классе MyApplication: государственное wxApp
  3. { (
  4. public : общественности:
  5. bool OnInit ( ) ;</code> bool OnInit (); </ код>
  6.  
  7. } ;bool MyApplication:: OnInit ( ) { ); bool MyApplication:: OnInit () (
  8.  
  9. // TODO: Show window / / TODO: Показать окно
  10.  
  11. return false ; вернуться ложь;
  12.  
  13. } IMPLEMENT_APP ( MyApplication ) ; ) IMPLEMENT_APP (MyApplication);
  14.  

The first line includes most of the header files needed for a wxWidgets application. Первая строка включает большинство заголовочные файлы, необходимые для wxWidgets применения. Then a new class is derived from wxApp called MyApplication, and the MyApplication::OnInit() function is created. Затем новый класс взята из wxApp называется MyApplication и MyApplication:: OnInit () функция создана. Finally, IMPLEMENT_APP(MyApplication), is needed to cause the application to run. Наконец, IMPLEMENT_APP (MyApplication), необходимо вызвать заявку на размещение. This macro expands to the correct code for any given platform to actually start the application. Этот макрос расширяется в правильный код для любой платформы действительно начала применения.

The Frame in wxWidgets Frame в wxWidgets
After creating the application, the window frame needs to be created and controls need to be created on it. После создания приложения, окна, рамы должна быть создана и контроля необходимо создать его. The frame object is derived from wxFrame and, as shown below, includes several functions and the text control. Рамки объекта взята из wxFrame и, как показано ниже, включает в себя несколько функций, и текст контроль.

  1.  
  2. class MyFrame : public wxFrame класс MyFrame: государственное wxFrame
  3. { (
  4. public : MyFrame ( ) ; void OnNew ( wxCommandEvent&amp; evt ) ; общественности: MyFrame (); недействительным OnNew (wxCommandEvent и evt);
  5.  
  6. void OnOpen ( wxCommandEvent&amp; evt ) ; недействительным OnOpen (wxCommandEvent и evt);
  7.  
  8. void OnSave ( wxCommandEvent&amp; evt ) ;private: недействительным OnSave (wxCommandEvent и evt); частные:
  9.  
  10. void CreateWidgets ( ) ; недействительным CreateWidgets ();
  11.  
  12. wxTextCtrl* m_text; wxTextCtrl * m_text;
  13. } ; );
  14.  
  15. MyFrame:: MyFrame ( ) : MyFrame:: MyFrame ():
  16.  
  17. wxFrame ( NULL , wxID_ANY, wxT ( "Sample Program" ) ) wxFrame (NULL, wxID_ANY, wxT ( "Пример программы"))
  18. { (
  19. CreateWidgets ( ) ; CreateWidgets ();
  20. } )
  21.  
  22. void MyFrame:: OnNew ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnNew (wxCommandEvent и WXUNUSED (evt))
  23. { (
  24. m_text-&gt;Clear ( ) ; m_text -> Очистить ();
  25. } )
  26.  
  27. void MyFrame:: OnOpen ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnOpen (wxCommandEvent и WXUNUSED (evt))
  28. { (
  29. wxString file = :: wxFileSelector ( wxT ( "Open file" ) ) ; файл = wxString:: wxFileSelector (wxT ( "Открыть файл"));
  30. if ( file . IsEmpty ( ) == false ) если (файл. IsEmpty () == ложные)
  31. m_text-&gt;LoadFile ( file ) ; m_text -> LoadFile (файла);
  32. } )
  33.  
  34. void MyFrame:: OnSave ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnSave (wxCommandEvent и WXUNUSED (evt))
  35. { (
  36. wxString file = :: wxFileSelector ( wxT ( "Save file" ) ) ; файл = wxString:: wxFileSelector (wxT ( "Сохранить файл"));
  37. if ( file . IsEmpty ( ) == false ) если (файл. IsEmpty () == ложные)
  38. m_text-&gt;SaveFile ( file ) ; m_text -> SaveFile (файла);
  39. } )
  40. void MyFrame:: CreateWidgets ( ) недействительным MyFrame:: CreateWidgets ()
  41. { (
  42. // Create a text control / / Создать текст контроль
  43. m_text = new wxTextCtrl ( this , wxID_ANY, wxEmptyString, m_text = новый wxTextCtrl (это, wxID_ANY, wxEmptyString,
  44. wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB | wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB |
  45. wxTE_PROCESS_ENTER | wxTE_MULTILINE ) ; wxTE_PROCESS_ENTER | wxTE_MULTILINE);
  46. // Create file menu / / Создать файл меню
  47.  
  48. wxMenu* fileMenu = new wxMenu ( ) ; wxMenu * fileMenu = новый wxMenu ();
  49. fileMenu-&gt;Append ( wxID_NEW, wxT ( "New File" ) ) ; fileMenu -> добавить (wxID_NEW, wxT ( "New File"));
  50. fileMenu-&gt;Append ( wxID_OPEN, wxT ( "Open File" ) ) ; fileMenu -> добавить (wxID_OPEN, wxT ( "Открыть файл"));
  51. fileMenu-&gt;Append ( wxID_SAVE, wxT ( "Save File" ) ) ; fileMenu -> добавить (wxID_SAVE, wxT ( "Сохранить Файл"));
  52. // Create menu bar / / Создание меню
  53. wxMenuBar* menuBar = new wxMenuBar ( ) ; wxMenuBar * menuBar = новый wxMenuBar ();
  54. menuBar-&gt;Append ( fileMenu, wxT ( "File" ) ) ; menuBar -> добавить (fileMenu, wxT ( "Файл"));
  55. // Set menu / / Установить меню
  56. SetMenuBar ( menuBar ) ; SetMenuBar (menuBar);
  57. } )

All of that code creates the window. Все, что код создает окно. The constructor MyFrame::MyFrame calls the parent constructor wxFrame::wxFrame to create the frame and give it a name, and then it calls CreateWidgets, to create the contents of the frame. Конструктор MyFrame:: MyFrame призывает родителей конструктор wxFrame:: wxFrame создать рамки и придать ему фамилию, а затем звонки CreateWidgets, создать содержание кадра. The MyFrame::CreateWidgets function creates a text control and a menu bar. MyFrame:: CreateWidgets функция создает текст и меню. In addition, function MyFrame::OnNew , MyFrame::OnOpen , and MyFrame::OnSave are implemented to clear, open, or save the text to a file. Кроме того, функция MyFrame:: OnNew, MyFrame:: OnOpen и MyFrame:: OnSave осуществляются очистить, открыть или сохранить текст в файл. Also notice that text constants are enclosed in wxT(...). Также заметить, что текст константы, заключенные в wxT (...). Since wxWidgets can compile in Unicode as well, wrapping text constants like this ensure that they are declare correctly. С wxWidgets можно собрать в Unicode, а также, обертывания текст константы так чтобы они заявляют правильно.

The event Table in wxWidgets Таблица событие в wxWidgets
The event table is used to route events from controls, menus, and anything else to the correct functions to handle the events. Случае таблица используется для маршрута от контроля событий, меню, и все прочее, что для правильного функций для обработки событий. Without them, this application would not be able to load or save the text. Без них, это приложение не сможет загрузить или сохранить текст. The following changes are needed to implement the event table. Следующие изменения, необходимые для осуществления этого мероприятия таблице.

  1.  
  2. class MyFrame : public wxFrame класс MyFrame: государственное wxFrame
  3.  
  4. { (
  5.  
  6. ...
  7.  
  8. ... DECLARE_EVENT_TABLE ( ) ; ... DECLARE_EVENT_TABLE ();
  9.  
  10. } ; );
  11.  
  12. BEGIN_EVENT_TABLE ( MyFrame, wxFrame ) BEGIN_EVENT_TABLE (MyFrame, wxFrame)
  13.  
  14. EVT_MENU ( wxID_NEW, MyFrame:: OnNew ) EVT_MENU (wxID_NEW, MyFrame:: OnNew)
  15.  
  16. EVT_MENU ( wxID_OPEN, MyFrame:: OnOpen ) EVT_MENU (wxID_OPEN, MyFrame:: OnOpen)
  17.  
  18. EVT_MENU ( wxID_SAVE, MyFrame:: OnSave ) EVT_MENU (wxID_SAVE, MyFrame:: OnSave)
  19.  
  20. END_EVENT_TABLE ( ) END_EVENT_TABLE ()

First, the event table for the frame is declared. Во-первых, в случае таблицы кадр объявляется. Then the table is created, and the event ids wxID_NEW, wxID_OPEN, and wxID_SAVE are used to call the functions MyFrame::OnNew, MyFrame::OnOpen, and MyFrame::OnSave. Затем создается таблица, и это событие идентификаторы wxID_NEW, wxID_OPEN и wxID_SAVE используются для вызова функций MyFrame:: OnNew, MyFrame:: OnOpen и MyFrame:: OnSave. The events generated by the menus will get processed by the correct functions. Событий от меню получите обрабатываются правильно функций.

Showing the frame Демонстрация фреймов
Now that the frame is complete, a small change is needed to the application. Теперь, когда кадр полностью, незначительные изменения необходимы для применения. It needs to create the window frame, show it, and set it as the application top window. Необходимо создать окно рамки, показать его, и поставили его в верхней части окна приложения.

  1.  
  2. bool MyApplication:: OnInit ( ) bool MyApplication:: OnInit ()
  3.  
  4. { (
  5.  
  6. // Create and show the frame / / Создать и показать кадр
  7.  
  8. MyFrame* frame = new MyFrame ( ) ; MyFrame * новый кадр = MyFrame ();
  9.  
  10. frame-&gt;Show ( ) ; SetTopWindow ( frame ) ; рамы -> Show (); SetTopWindow (рамы);
  11.  
  12. return true ; вернуться верно;
  13.  
  14. } )

The complete code Полный код

  1.  
  2. #include "wx/wx.h"// Main window frame # включить "wx / wx.h" / / Главное окно кадра
  3. class MyFrame : public wxFrame класс MyFrame: государственное wxFrame
  4. { (
  5. public : общественности:
  6. MyFrame ( ) ; MyFrame ();
  7.  
  8. void OnNew ( wxCommandEvent&amp; evt ) ; недействительным OnNew (wxCommandEvent и evt);
  9.  
  10. void OnOpen ( wxCommandEvent&amp; evt ) ; недействительным OnOpen (wxCommandEvent и evt);
  11.  
  12. void OnSave ( wxCommandEvent&amp; evt ) ; недействительным OnSave (wxCommandEvent и evt);
  13.  
  14. private : частные:
  15. void CreateWidgets ( ) ; недействительным CreateWidgets ();
  16.  
  17. wxTextCtrl* m_text; wxTextCtrl * m_text;
  18.  
  19. DECLARE_EVENT_TABLE ( ) ; DECLARE_EVENT_TABLE ();
  20. } ; );
  21.  
  22. MyFrame:: MyFrame ( ) : MyFrame:: MyFrame ():
  23. wxFrame ( NULL , wxID_ANY, wxT ( "Sample Program" ) ) wxFrame (NULL, wxID_ANY, wxT ( "Пример программы"))
  24. { (
  25. CreateWidgets ( ) ; CreateWidgets ();
  26. } )
  27.  
  28. void MyFrame:: OnNew ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnNew (wxCommandEvent и WXUNUSED (evt))
  29. { (
  30.  
  31. m_text-&gt;Clear ( ) ; m_text -> Очистить ();
  32. } )
  33.  
  34. void MyFrame:: OnOpen ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnOpen (wxCommandEvent и WXUNUSED (evt))
  35. { (
  36.  
  37. wxString file = :: wxFileSelector ( wxT ( "Open file" ) ) ; файл = wxString:: wxFileSelector (wxT ( "Открыть файл"));
  38.  
  39. if ( file . IsEmpty ( ) == false ) если (файл. IsEmpty () == ложные)
  40.  
  41. m_text-&gt;LoadFile ( file ) ; m_text -> LoadFile (файла);
  42. } )
  43.  
  44. void MyFrame:: OnSave ( wxCommandEvent&amp; WXUNUSED ( evt ) ) недействительным MyFrame:: OnSave (wxCommandEvent и WXUNUSED (evt))
  45. { (
  46. wxString file = :: wxFileSelector ( wxT ( "Save file" ) ) ; файл = wxString:: wxFileSelector (wxT ( "Сохранить файл"));
  47.  
  48. if ( file . IsEmpty ( ) == false ) если (файл. IsEmpty () == ложные)
  49.  
  50. m_text-&gt;SaveFile ( file ) ; m_text -> SaveFile (файла);
  51.  
  52. } )
  53.  
  54. void MyFrame:: CreateWidgets ( ) недействительным MyFrame:: CreateWidgets ()
  55. { (
  56. // Create a text control / / Создать текст контроль
  57.  
  58. m_text = new wxTextCtrl ( this , ID_TEXTCTRL, wxEmptyString, m_text = новый wxTextCtrl (это, ID_TEXTCTRL, wxEmptyString,
  59.  
  60. wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB | wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_TAB |
  61.  
  62. wxTE_PROCESS_ENTER | wxTE_MULTILINE ) ; wxTE_PROCESS_ENTER | wxTE_MULTILINE);
  63.  
  64. // Create file menu / / Создать файл меню
  65.  
  66. wxMenu* fileMenu = new wxMenu ( ) ; wxMenu * fileMenu = новый wxMenu ();
  67.  
  68. fileMenu-&gt;Append ( wxID_NEW, wxT ( "New File" ) ) ; fileMenu -> добавить (wxID_NEW, wxT ( "New File"));
  69.  
  70. fileMenu-&gt;Append ( wxID_OPEN, wxT ( "Open File" ) ) ; fileMenu -> добавить (wxID_OPEN, wxT ( "Открыть файл"));
  71.  
  72. fileMenu-&gt;Append ( wxID_SAVE, wxT ( "Save File" ) ) ; fileMenu -> добавить (wxID_SAVE, wxT ( "Сохранить Файл"));
  73.  
  74. // Create menu bar / / Создание меню
  75.  
  76. wxMenuBar* menuBar = new wxMenuBar ( ) ; wxMenuBar * menuBar = новый wxMenuBar ();
  77.  
  78. menuBar-&gt;Append ( fileMenu, wxT ( "File" ) ) ; menuBar -> добавить (fileMenu, wxT ( "Файл"));
  79.  
  80. // Set menu / / Установить меню
  81.  
  82. SetMenuBar ( menuBar ) ; SetMenuBar (menuBar);
  83.  
  84. } )
  85.  
  86. // Event table to route menu events to functions / / Событие таблицу маршрутов меню событий функции
  87.  
  88. BEGIN_EVENT_TABLE ( MyFrame, wxFrame ) BEGIN_EVENT_TABLE (MyFrame, wxFrame)
  89.  
  90. EVT_MENU ( wxID_NEW, MyFrame:: OnNew ) EVT_MENU (wxID_NEW, MyFrame:: OnNew)
  91.  
  92. EVT_MENU ( wxID_OPEN, MyFrame:: OnOpen ) EVT_MENU (wxID_OPEN, MyFrame:: OnOpen)
  93.  
  94. EVT_MENU ( wxID_SAVE, MyFrame:: OnSave ) EVT_MENU (wxID_SAVE, MyFrame:: OnSave)
  95.  
  96. END_EVENT_TABLE ( ) END_EVENT_TABLE ()
  97.  
  98. // Application / / Применение
  99.  
  100. class MyApplication : public wxApp классе MyApplication: государственное