Hildonized wxColourDialog
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50072 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1510ba2c68
commit
b6dd7ed8d7
@ -26,6 +26,10 @@
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
#include <hildon-widgets/hildon-color-selector.h>
|
||||
#endif // wxUSE_LIBHILDON
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
|
||||
|
||||
wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
|
||||
@ -38,15 +42,20 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
|
||||
if (data)
|
||||
m_data = *data;
|
||||
|
||||
m_parent = GetParentForModalDialog(parent);
|
||||
GtkWindow * const parentGTK = m_parent ? GTK_WINDOW(m_parent->m_widget)
|
||||
: NULL;
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
m_widget = hildon_color_selector_new(parentGTK);
|
||||
#else // !wxUSE_LIBHILDON
|
||||
wxString title(_("Choose colour"));
|
||||
m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
|
||||
m_parent = GetParentForModalDialog(parent);
|
||||
if ( m_parent )
|
||||
if ( parentGTK )
|
||||
{
|
||||
GtkWindow* gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(m_parent->m_widget) );
|
||||
gtk_window_set_transient_for(GTK_WINDOW(m_widget),
|
||||
gtk_parent);
|
||||
gtk_window_set_transient_for(GTK_WINDOW(m_widget), parentGTK);
|
||||
}
|
||||
|
||||
GtkColorSelection *sel =
|
||||
@ -82,14 +91,19 @@ int wxColourDialog::ShowModal()
|
||||
|
||||
void wxColourDialog::ColourDataToDialog()
|
||||
{
|
||||
const GdkColor * const
|
||||
col = m_data.GetColour().Ok() ? m_data.GetColour().GetColor()
|
||||
: NULL;
|
||||
|
||||
#if wxUSE_LIBHILDON
|
||||
HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
|
||||
hildon_color_selector_set_color(sel, wx_const_cast(GdkColor *, col));
|
||||
#else // !wxUSE_LIBHILDON
|
||||
GtkColorSelection *sel =
|
||||
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
|
||||
|
||||
if (m_data.GetColour().Ok())
|
||||
{
|
||||
gtk_color_selection_set_current_color(sel,
|
||||
m_data.GetColour().GetColor());
|
||||
}
|
||||
if ( col )
|
||||
gtk_color_selection_set_current_color(sel, col);
|
||||
|
||||
// setup the palette:
|
||||
|
||||
@ -109,16 +123,23 @@ void wxColourDialog::ColourDataToDialog()
|
||||
|
||||
GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
|
||||
g_object_set(settings, "gtk-color-palette", pal.c_str(), NULL);
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
}
|
||||
|
||||
void wxColourDialog::DialogToColourData()
|
||||
{
|
||||
#if wxUSE_LIBHILDON
|
||||
HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
|
||||
const GdkColor * const clr = hildon_color_selector_get_color(sel);
|
||||
if ( clr )
|
||||
m_data.SetColour(*clr);
|
||||
#else // !wxUSE_LIBHILDON
|
||||
GtkColorSelection *sel =
|
||||
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
|
||||
|
||||
GdkColor clr;
|
||||
gtk_color_selection_get_current_color(sel, &clr);
|
||||
m_data.SetColour(wxColour(clr));
|
||||
m_data.SetColour(clr);
|
||||
|
||||
// Extract custom palette:
|
||||
|
||||
@ -138,6 +159,7 @@ void wxColourDialog::DialogToColourData()
|
||||
}
|
||||
|
||||
g_free(pal);
|
||||
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
|
||||
}
|
||||
|
||||
#endif // wxUSE_COLOURDLG
|
||||
|
Loading…
Reference in New Issue
Block a user