зеркало из https://github.com/mozilla/gecko-dev.git
Fix for 2986.
Radio buttons and checkbuttons on form not rendering. The problem was that the parent widget was rendering on top of them, because they are windowless. The fix is to wrap the radio/check buttons in an event box to give them a window. Not the most effecient solution, but will do for now until the devil is exorcised from the event system.
This commit is contained in:
Родитель
11456f2556
Коммит
4953a3a830
|
@ -34,6 +34,7 @@ nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton()
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
mLabel = nsnull;
|
||||
mCheckButton = nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -52,8 +53,15 @@ nsCheckButton::~nsCheckButton()
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_check_button_new();
|
||||
gtk_widget_set_name(mWidget, "nsCheckButton");
|
||||
mWidget = gtk_event_box_new();
|
||||
mCheckButton = gtk_check_button_new();
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(mWidget), mCheckButton);
|
||||
|
||||
gtk_widget_show(mCheckButton);
|
||||
|
||||
gtk_widget_set_name(mCheckButton, "nsCheckButton");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -87,7 +95,7 @@ nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::SetState(const PRBool aState)
|
||||
{
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mWidget), aState);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckButton), aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -98,7 +106,7 @@ NS_METHOD nsCheckButton::SetState(const PRBool aState)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsCheckButton::GetState(PRBool& aState)
|
||||
{
|
||||
gint state = GTK_TOGGLE_BUTTON(mWidget)->active;
|
||||
gint state = GTK_TOGGLE_BUTTON(mCheckButton)->active;
|
||||
aState = state;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -116,7 +124,7 @@ NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
|
|||
} else {
|
||||
mLabel = gtk_label_new(label);
|
||||
gtk_misc_set_alignment (GTK_MISC (mLabel), 0.0, 0.5);
|
||||
gtk_container_add(GTK_CONTAINER(mWidget), mLabel);
|
||||
gtk_container_add(GTK_CONTAINER(mCheckButton), mLabel);
|
||||
gtk_widget_show(mLabel);
|
||||
}
|
||||
NS_FREE_STR_BUF(label);
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
protected:
|
||||
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
||||
GtkWidget *mLabel;
|
||||
GtkWidget *mCheckButton;
|
||||
};
|
||||
|
||||
#endif // nsCheckButton_h__
|
||||
|
|
|
@ -38,6 +38,7 @@ nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton()
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
mLabel = nsnull;
|
||||
mRadioButton = nsnull;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,8 +82,14 @@ nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_radio_button_new(nsnull);
|
||||
gtk_widget_set_name(mWidget, "nsRadioButton");
|
||||
mWidget = gtk_event_box_new();
|
||||
mRadioButton = gtk_radio_button_new(nsnull);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(mWidget), mRadioButton);
|
||||
|
||||
gtk_widget_show(mRadioButton);
|
||||
|
||||
gtk_widget_set_name(mRadioButton, "nsRadioButton");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -94,7 +101,7 @@ NS_METHOD nsRadioButton::CreateNative(GtkWidget *parentWindow)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::SetState(const PRBool aState)
|
||||
{
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mWidget), aState);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mRadioButton), aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -104,7 +111,7 @@ NS_METHOD nsRadioButton::SetState(const PRBool aState)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::GetState(PRBool& aState)
|
||||
{
|
||||
int state = GTK_TOGGLE_BUTTON(mWidget)->active;
|
||||
int state = GTK_TOGGLE_BUTTON(mRadioButton)->active;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -122,7 +129,7 @@ NS_METHOD nsRadioButton::SetLabel(const nsString& aText)
|
|||
} else {
|
||||
mLabel = gtk_label_new(label);
|
||||
gtk_misc_set_alignment (GTK_MISC (mLabel), 0.0, 0.5);
|
||||
gtk_container_add(GTK_CONTAINER(mWidget), mLabel);
|
||||
gtk_container_add(GTK_CONTAINER(mRadioButton), mLabel);
|
||||
gtk_widget_show(mLabel); /* XXX */
|
||||
}
|
||||
NS_FREE_STR_BUF(label);
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
protected:
|
||||
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
||||
GtkWidget *mLabel;
|
||||
GtkWidget *mRadioButton;
|
||||
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче