some Hildon integration work: use HildonProgram (for integration with the OS), HildonWindow (which has native appearance) and more native-like menus
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49841 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
60dd3c0916
commit
e2f3bc4110
@ -18,6 +18,10 @@
|
||||
class WXDLLIMPEXP_FWD_BASE wxMutex;
|
||||
#endif
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
typedef struct _HildonProgram HildonProgram;
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxApp
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -58,6 +62,10 @@ public:
|
||||
// must return XVisualInfo pointer (it is not freed by caller)
|
||||
virtual void *GetXVisualInfo() { return NULL; }
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
// Maemo-specific method: get the main program object
|
||||
HildonProgram *GetHildonProgram() const { return m_hildonProgram; }
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
@ -80,6 +88,10 @@ private:
|
||||
#endif
|
||||
guint m_idleSourceId;
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
HildonProgram *m_hildonProgram;
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxApp)
|
||||
};
|
||||
|
||||
|
@ -852,5 +852,4 @@ wxString wxMenuBarBase::GetLabelTop(size_t pos) const
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // wxUSE_MENUS
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
#include <hildon-widgets/hildon-program.h>
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -317,6 +321,15 @@ bool wxApp::OnInitGui()
|
||||
}
|
||||
}
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
m_hildonProgram = hildon_program_get_instance();
|
||||
if ( !m_hildonProgram )
|
||||
{
|
||||
wxLogError(_("Unable to initialize Hildon program"));
|
||||
return false;
|
||||
}
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,10 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
#include <hildon-widgets/hildon-window.h>
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event tables
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -267,11 +271,15 @@ void wxFrame::DetachMenuBar()
|
||||
|
||||
if ( m_frameMenuBar )
|
||||
{
|
||||
#if wxUSE_LIBHILDON
|
||||
hildon_window_set_menu(HILDON_WINDOW(m_widget), NULL);
|
||||
#else // !wxUSE_LIBHILDON
|
||||
m_frameMenuBar->UnsetInvokingWindow( this );
|
||||
|
||||
gtk_widget_ref( m_frameMenuBar->m_widget );
|
||||
|
||||
gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
}
|
||||
|
||||
wxFrameBase::DetachMenuBar();
|
||||
@ -286,6 +294,10 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
|
||||
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
#if wxUSE_LIBHILDON
|
||||
hildon_window_set_menu(HILDON_WINDOW(m_widget),
|
||||
GTK_MENU(m_frameMenuBar->m_menubar));
|
||||
#else // !wxUSE_LIBHILDON
|
||||
m_frameMenuBar->SetInvokingWindow( this );
|
||||
|
||||
m_frameMenuBar->SetParent(this);
|
||||
@ -309,6 +321,7 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
|
||||
gtk_widget_set_size_request(menuBar->m_widget, -1, -1);
|
||||
|
||||
gtk_widget_show( m_frameMenuBar->m_widget );
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
}
|
||||
// make sure next size_allocate causes a wxSizeEvent
|
||||
m_oldClientWidth = 0;
|
||||
|
@ -174,6 +174,12 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
|
||||
m_style = style;
|
||||
m_invokingWindow = NULL;
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
// Hildon window uses a single menu instead of a menu bar, so wxMenuBar is
|
||||
// the same as menu in this case
|
||||
m_widget =
|
||||
m_menubar = gtk_menu_new();
|
||||
#else // !wxUSE_LIBHILDON
|
||||
if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
|
||||
!CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
|
||||
{
|
||||
@ -197,6 +203,7 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
|
||||
PostCreation();
|
||||
|
||||
ApplyWidgetStyle();
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
|
||||
for (size_t i = 0; i < n; ++i )
|
||||
Append(menus[i], titles[i]);
|
||||
@ -207,7 +214,6 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
|
||||
// can't pass the menu which was closed in wxMenuEvent object
|
||||
g_signal_connect (m_menubar, "deactivate",
|
||||
G_CALLBACK (gtk_menu_close_callback), this);
|
||||
|
||||
}
|
||||
|
||||
wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
|
||||
|
@ -45,6 +45,11 @@
|
||||
// XA_CARDINAL
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
#include <hildon-widgets/hildon-program.h>
|
||||
#include <hildon-widgets/hildon-window.h>
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// data
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -503,6 +508,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
// e.g. in wxTaskBarIconAreaGTK
|
||||
if (m_widget == NULL)
|
||||
{
|
||||
#if wxUSE_LIBHILDON
|
||||
// we must create HildonWindow and not a normal GtkWindow as the latter
|
||||
// doesn't look correctly in Maemo environment and it must also be
|
||||
// registered with the main program object
|
||||
m_widget = hildon_window_new();
|
||||
hildon_program_add_window(wxTheApp->GetHildonProgram(),
|
||||
HILDON_WINDOW(m_widget));
|
||||
#else // !wxUSE_LIBHILDON
|
||||
m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
|
||||
{
|
||||
@ -529,6 +542,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
style |= wxFRAME_NO_TASKBAR;
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
}
|
||||
|
||||
wxWindow *topParent = wxGetTopLevelParent(m_parent);
|
||||
@ -665,6 +679,11 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
|
||||
|
||||
wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
{
|
||||
#if wxUSE_LIBHILDON
|
||||
hildon_program_remove_window(wxTheApp->GetHildonProgram(),
|
||||
HILDON_WINDOW(m_widget));
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
if (m_grabbed)
|
||||
{
|
||||
wxFAIL_MSG(_T("Window still grabbed"));
|
||||
|
Loading…
Reference in New Issue
Block a user