Difference between revisions of "WxWidgets"

From LinuxMCE
Jump to: navigation, search
(Original Document)
(Undo revision 28685 by AHagerty93 (talk) spam)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<table width="100%"> <tr><td bgcolor="#FFCFCF">This page was written by Pluto and imported with their permission when LinuxMCE branched off in February, 2007.  In general any information should apply to LinuxMCE. However, this page should be edited to reflect changes to LinuxMCE and remove old references to Pluto.</td></tr> </table>== wxWidgets integration with Pluto ==
+
{| align="right"
 +
  | __TOC__
 +
  |}
 +
[[Category: Programmer's Guide]]
 +
 
 +
== What is wxWidgets? ==
 +
From their website:
 +
An open source C++ GUI framework to make cross-platform programming child's play. Well, almost.
 +
 
 +
 
 +
== wxWidgets integration with LinuxMCE ==
  
 
wxWidgets must be compiled with:
 
wxWidgets must be compiled with:
--with-gtk=2 --enable-monolithic --with-sdl --with-opengl
+
--with-gtk=2 --enable-monolithic --with-sdl --with-opengl
  
 
For debug builds, add
 
For debug builds, add
--enable-debug
+
--enable-debug
  
 
sdl: needed by Orbiter
 
sdl: needed by Orbiter
opengl: needed by Orbiter in the future
+
opengl: needed by Orbiter
  
Required debian-pluto packages
 
*Release executables: libwxgtk2.6-0
 
*Debug executables, linked with debug version of the wx library: libwxgtk2.6-dbg
 
  
 
== wxWidgets integration with Orbiter ==
 
== wxWidgets integration with Orbiter ==
Line 19: Line 26:
  
 
A new directory, Orbiter/wxAppMain, was created, which contains only wx-related files
 
A new directory, Orbiter/wxAppMain, was created, which contains only wx-related files
 +
All *.cpp and *.h files added in this directory are automatically used by the Makefile in Orbiter
 +
 +
Read the following wiki link "[[Integrating custom controls in Orbiter]]",
 +
which will explain how to use the wx dialogs, and how to control them.
 +
 +
== Creating a new wxWidgets dialog to be used in Orbiter ==
 +
 +
example: wxSecurityWizard will be the class name
 +
 +
It should be derived from class wxDialog_Base.
 +
 +
    class wxSecurityWizard : public wxDialog_Base
 +
    {
 +
    .......
 +
    }
 +
 +
wxDialog_Base and other classes already implemented will handle the wx-actions and the Orbiter-tasks.
 +
 +
    In "dialog_types.h", E_Dialog_SecurityWizard constant should be added
 +
 +
    In "CallBackData.h", a new class should be created, with the data that will be used by the new dialog
  
Note that only important changes are written to this file, for the full changes, look at the code, as it may change in time.
+
if wxSecurityWizard will be used as a popup:
 +
    class SecurityWizardCallBackData : public PopupCallBackData
 +
    {...}
  
wxDialog_RoomWizard :
+
if wxSecurityWizard will be used as a normal dialog:
*is a Rooms-Wizard dialog
+
    class SecurityWizardCallBackData : public PositionCallBackData
*changed in Orbiter/: Orbiter.cpp, Main.cpp, Main.h (added), Makefile
+
    {...}
*changed in Orbiter/Linux/: OSDScreenHandler.h OSDScreenHandler.cpp
+
  
In Makefile :
+
-- Generic methods from wxDialog_Base that can/should be overrided --
*added WX_* variables
+
*added to sources section wxAppMain/*
+
  
In Linux/OSDScreenHandler.* :
+
    // load data from external object, called after create
*redefine the following method to register the callbacks: SCREEN_RoomsWizard
+
    // by default calls Gui_Refresh
*added callbacks: RoomsWizardCreate, RoomsWizardDelete, RoomsWizardRefresh
+
    virtual bool Gui_DataLoad(CallBackData *pCallBackData);
 +
   
 +
    // save data to external object
 +
    // not called by default
 +
    virtual bool Gui_DataSave(CallBackData *pCallBackData);
 +
    // this should be used when the data from the dialog
 +
    // needs to be transfered to Orbiter
 +
   
 +
    // GUI refresh related code should be implemented here
 +
    // by default set full-screen or update position
 +
    virtual bool Gui_Refresh(CallBackData *pCallBackData);
  
== wxDialog with thread support ==
+
-- Other methods from wxDialog_Base --
  
( will be updated when the Orbiter-Wx interface will be ready )
+
This function should always be called if the position comes from Orbiter,
 +
from a PositionCallBackData derived class.
  
 +
    void Update_Position_FullScreen(const int x, const int y, const int width, const int height, bool bShowFullScreen);
 +
    // if bShowFullScreen is true, the dialog is created full-screen
 +
    // otherwise, his position is changed
 +
    // if the dialog is already in the desired state, then wx functions for full-screen, or SetSize will not be called
  
 
== Original Document ==
 
== Original Document ==
 
http://svn.plutohome.com/pluto/trunk/src/Orbiter/wxAppMain/WX_PLUTO.txt
 
http://svn.plutohome.com/pluto/trunk/src/Orbiter/wxAppMain/WX_PLUTO.txt

Latest revision as of 14:53, 27 September 2011

What is wxWidgets?

From their website: An open source C++ GUI framework to make cross-platform programming child's play. Well, almost.


wxWidgets integration with LinuxMCE

wxWidgets must be compiled with: --with-gtk=2 --enable-monolithic --with-sdl --with-opengl

For debug builds, add --enable-debug

sdl: needed by Orbiter opengl: needed by Orbiter


wxWidgets integration with Orbiter

Now, only Linux port of Orbiter uses wxWidgets

A new directory, Orbiter/wxAppMain, was created, which contains only wx-related files All *.cpp and *.h files added in this directory are automatically used by the Makefile in Orbiter

Read the following wiki link "Integrating custom controls in Orbiter", which will explain how to use the wx dialogs, and how to control them.

Creating a new wxWidgets dialog to be used in Orbiter

example: wxSecurityWizard will be the class name

It should be derived from class wxDialog_Base.

   class wxSecurityWizard : public wxDialog_Base
   {
   .......
   }

wxDialog_Base and other classes already implemented will handle the wx-actions and the Orbiter-tasks.

   In "dialog_types.h", E_Dialog_SecurityWizard constant should be added
   In "CallBackData.h", a new class should be created, with the data that will be used by the new dialog

if wxSecurityWizard will be used as a popup:

   class SecurityWizardCallBackData : public PopupCallBackData
   {...}

if wxSecurityWizard will be used as a normal dialog:

   class SecurityWizardCallBackData : public PositionCallBackData
   {...}

-- Generic methods from wxDialog_Base that can/should be overrided --

   // load data from external object, called after create
   // by default calls Gui_Refresh
   virtual bool Gui_DataLoad(CallBackData *pCallBackData);
   
   // save data to external object
   // not called by default
   virtual bool Gui_DataSave(CallBackData *pCallBackData);
   // this should be used when the data from the dialog
   // needs to be transfered to Orbiter
   
   // GUI refresh related code should be implemented here
   // by default set full-screen or update position
   virtual bool Gui_Refresh(CallBackData *pCallBackData);

-- Other methods from wxDialog_Base --

This function should always be called if the position comes from Orbiter, from a PositionCallBackData derived class.

   void Update_Position_FullScreen(const int x, const int y, const int width, const int height, bool bShowFullScreen);
   // if bShowFullScreen is true, the dialog is created full-screen
   // otherwise, his position is changed
   // if the dialog is already in the desired state, then wx functions for full-screen, or SetSize will not be called

Original Document

http://svn.plutohome.com/pluto/trunk/src/Orbiter/wxAppMain/WX_PLUTO.txt