Fix gtklayout child sizing problems, add gtk_widget_set_name to all of the
widgets for a bunch of debugging into that is being printf'd. Fixed most all of nsListBox so that it works correctly. We now have widgets working! yippie! I almost have gfx working too... heehee :-) git-svn-id: svn://10.0.0.236/trunk@14595 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -153,14 +153,14 @@ gtk_layout_put (GtkLayout *layout,
|
||||
child->window = NULL;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
child->requisition.width = 0;
|
||||
child->requisition.height = 0;
|
||||
child->widget->requisition.width = 0;
|
||||
child->widget->requisition.height = 0;
|
||||
|
||||
layout->children = g_list_append (layout->children, child);
|
||||
|
||||
gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
|
||||
|
||||
gtk_widget_size_request (child->widget, &child->requisition);
|
||||
gtk_widget_size_request (child->widget, &child->widget->requisition);
|
||||
|
||||
if (GTK_WIDGET_REALIZED (layout) &&
|
||||
!GTK_WIDGET_REALIZED (child_widget))
|
||||
@@ -468,7 +468,7 @@ gtk_layout_size_request (GtkWidget *widget,
|
||||
while (tmp_list)
|
||||
{
|
||||
GtkLayoutChild *child = tmp_list->data;
|
||||
gtk_widget_size_request (child->widget, &child->requisition);
|
||||
gtk_widget_size_request (child->widget, &child->widget->requisition);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
@@ -628,8 +628,8 @@ gtk_layout_position_child (GtkLayout *layout,
|
||||
GtkAllocation allocation;
|
||||
allocation.x = x;
|
||||
allocation.y = y;
|
||||
allocation.width = child->requisition.width;
|
||||
allocation.height = child->requisition.height;
|
||||
allocation.width = child->widget->requisition.width;
|
||||
allocation.height = child->widget->requisition.height;
|
||||
|
||||
gtk_widget_size_allocate (child->widget, &allocation);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,6 @@ struct _GtkLayoutChild {
|
||||
GdkWindow *window; /* For NO_WINDOW widgets */
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
GtkRequisition requisition;
|
||||
};
|
||||
|
||||
struct _GtkLayout {
|
||||
|
||||
@@ -49,6 +49,7 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv)
|
||||
gtk_init (argc, &argv);
|
||||
|
||||
gtk_rc_init();
|
||||
|
||||
// Windows and Mac don't create anything here, so why should we?
|
||||
// mTopLevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
/* we should probibly set even handlers here */
|
||||
|
||||
@@ -46,7 +46,7 @@ nsButton::nsButton() : nsWidget() , nsIButton()
|
||||
NS_METHOD nsButton::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_button_new_with_label("");
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsButton");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ nsCheckButton::~nsCheckButton()
|
||||
NS_METHOD nsCheckButton::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_check_button_new();
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsCheckButton");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ nsresult nsComboBox::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
NS_METHOD nsComboBox::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_combo_new();
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsComboBox");
|
||||
gtk_combo_set_value_in_list(GTK_COMBO(mWidget), TRUE, TRUE);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -48,6 +48,7 @@ nsDialog::nsDialog() : nsWidget(), nsIDialog()
|
||||
NS_METHOD nsDialog::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mShell = gtk_dialog_new();
|
||||
gtk_widget_set_name(mShell, "nsDialog");
|
||||
gtk_widget_show(mShell);
|
||||
mWidget = gtk_layout_new(FALSE, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(mShell)->vbox), mWidget);
|
||||
|
||||
@@ -53,7 +53,7 @@ NS_METHOD nsLabel::CreateNative(GtkWidget *parentWindow)
|
||||
unsigned char alignment = GetNativeAlignment();
|
||||
|
||||
mWidget = gtk_label_new("");
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsLabel");
|
||||
gtk_misc_set_alignment(GTK_MISC(mWidget), 0.0, alignment);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -104,14 +104,14 @@ NS_METHOD nsListBox::SetMultipleSelection(PRBool aMultipleSelections)
|
||||
|
||||
NS_METHOD nsListBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
{
|
||||
NS_ALLOC_STR_BUF(text, aItem, 256);
|
||||
NS_ALLOC_STR_BUF(textc, aItem, 256);
|
||||
// str = XmStringCreateLocalized(val);
|
||||
gchar *text[2];
|
||||
text[0] = textc;
|
||||
gtk_clist_insert(GTK_CLIST(mCList), (int)aPosition, text);
|
||||
gtk_clist_set_row_data(GTK_CLIST(mCList), (int)aPosition, aItem);
|
||||
|
||||
gtk_clist_insert(GTK_CLIST(mCList), (int)aPosition+1, NULL);
|
||||
gtk_clist_set_text(GTK_CLIST(mCList), (int)aPosition+1, 0, text);
|
||||
gtk_clist_set_row_data(GTK_CLIST(mCList), (int)aPosition+1, aItem);
|
||||
|
||||
NS_FREE_STR_BUF(text);
|
||||
NS_FREE_STR_BUF(textc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ NS_METHOD nsListBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::FindItem(nsString &aItem, PRInt32 aStartPos)
|
||||
{
|
||||
int index = gtk_clist_find_row_from_data(GTK_CLIST(mCList), aItem)-1;
|
||||
int index = gtk_clist_find_row_from_data(GTK_CLIST(mCList), aItem);
|
||||
|
||||
if (index < aStartPos) {
|
||||
index = -1;
|
||||
@@ -149,7 +149,7 @@ PRInt32 nsListBox::GetItemCount()
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
gtk_clist_remove(GTK_CLIST(mCList), aPosition+1);
|
||||
gtk_clist_remove(GTK_CLIST(mCList), aPosition);
|
||||
/*
|
||||
int count = 0;
|
||||
XtVaGetValues(mCList, XmNitemCount, &count, nsnull);
|
||||
@@ -251,7 +251,7 @@ PRInt32 nsListBox::GetSelectedIndex()
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
gtk_clist_select_row(GTK_CLIST(mCList), aPosition+1, 0);
|
||||
gtk_clist_select_row(GTK_CLIST(mCList), aPosition, 0);
|
||||
/*
|
||||
int count = 0;
|
||||
XtVaGetValues(mCList, XmNitemCount, &count, nsnull);
|
||||
@@ -335,14 +335,16 @@ NS_METHOD nsListBox::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
// to handle scrolling
|
||||
mWidget = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_set_name(mWidget, "nsListBox");
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mWidget),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_ALWAYS);
|
||||
|
||||
mCList = gtk_clist_new(1);
|
||||
mCList = ::gtk_clist_new(1);
|
||||
gtk_clist_column_titles_hide(GTK_CLIST(mCList));
|
||||
// Default (it may be changed)
|
||||
gtk_clist_set_selection_mode(GTK_CLIST(mCList), GTK_SELECTION_BROWSE);
|
||||
gtk_widget_show(mCList);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (mWidget), mCList);
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
NS_METHOD nsRadioButton::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_radio_button_new(NULL);
|
||||
gtk_widget_set_name(mWidget, "nsRadioButton");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ NS_METHOD nsScrollbar::CreateNative(GtkWidget *parentWindow)
|
||||
} else {
|
||||
mWidget = gtk_vscrollbar_new(GTK_ADJUSTMENT(mAdjustment));
|
||||
}
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsScrollbar");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ nsTextAreaWidget::~nsTextAreaWidget()
|
||||
NS_METHOD nsTextAreaWidget::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_text_new(FALSE, FALSE);
|
||||
|
||||
gtk_widget_set_name(mWidget, "nsTextAreaWidget");
|
||||
gtk_editable_set_editable(GTK_EDITABLE(mWidget), mMakeReadOnly?PR_FALSE:PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
@@ -66,11 +66,9 @@ NS_METHOD nsTextAreaWidget::CreateNative(GtkWidget *parentWindow)
|
||||
|
||||
nsresult nsTextAreaWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
static NS_DEFINE_IID(kITextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
|
||||
|
||||
if (aIID.Equals(kITextAreaWidgetIID)) {
|
||||
nsITextAreaWidget* textArea = this;
|
||||
*aInstancePtr = (void*) (textArea);
|
||||
|
||||
@@ -61,8 +61,9 @@ nsTextWidget::~nsTextWidget()
|
||||
NS_METHOD nsTextWidget::CreateNative(GtkWidget *parentWindow)
|
||||
{
|
||||
mWidget = gtk_entry_new();
|
||||
gtk_widget_set_name(mWidget, "nsTextWidget");
|
||||
gtk_editable_set_editable(GTK_EDITABLE(mWidget), mMakeReadOnly?PR_FALSE:PR_TRUE);
|
||||
|
||||
gtk_widget_show(mWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "nsRepository.h"
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
|
||||
nsWidget::nsWidget()
|
||||
{
|
||||
// XXX Shouldn't this be done in nsBaseWidget?
|
||||
@@ -86,6 +87,7 @@ nsIWidget *nsWidget::GetParent(void)
|
||||
|
||||
NS_METHOD nsWidget::Show(PRBool bState)
|
||||
{
|
||||
g_print("nsWidget::Show(%6d) - %s %p\n", bState, mWidget->name, this);
|
||||
if (bState) {
|
||||
if (mWidget) {
|
||||
gtk_widget_show(mWidget);
|
||||
@@ -123,9 +125,7 @@ NS_METHOD nsWidget::IsVisible(PRBool &aState)
|
||||
|
||||
NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY)
|
||||
{
|
||||
#if DBG
|
||||
fprintf(stderr,"nsWidget::Move called (%d,%d)\n", aX, aY);
|
||||
#endif
|
||||
g_print("nsWidget::Move(%3d,%3d) - %s %p\n", aX, aY, mWidget->name, this);
|
||||
mBounds.x = aX;
|
||||
mBounds.y = aY;
|
||||
gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY);
|
||||
@@ -135,12 +135,10 @@ NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY)
|
||||
|
||||
NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
||||
{
|
||||
#if DBG
|
||||
fprintf(stderr,"nsWidget::Resize called w,h(%d,%d)\n", aWidth, aHeight);
|
||||
#endif
|
||||
g_print("nsWidget::Resize(%3d,%3d) - %s %p\n", aWidth, aHeight, mWidget->name, this);
|
||||
mBounds.width = aWidth;
|
||||
mBounds.height = aHeight;
|
||||
gtk_widget_set_usize(mWidget,aWidth, aHeight);
|
||||
gtk_widget_set_usize(mWidget, aWidth, aHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -461,11 +459,17 @@ nsresult nsWidget::StandardWindowCreate(nsIWidget *aParent,
|
||||
parentWidget = GTK_WIDGET(shellWidget);
|
||||
}
|
||||
|
||||
g_print("--\n");
|
||||
|
||||
CreateNative (parentWidget);
|
||||
|
||||
gtk_widget_set_usize(mWidget, aRect.width, aRect.height);
|
||||
Resize(mBounds.width, mBounds.height, TRUE);
|
||||
|
||||
if (parentWidget)
|
||||
gtk_layout_put(GTK_LAYOUT(parentWidget), mWidget, aRect.x, aRect.y);
|
||||
{
|
||||
gtk_layout_put(GTK_LAYOUT(parentWidget), mWidget, mBounds.x, mBounds.y);
|
||||
g_print("nsWidget::SWC(%3d,%3d) - %s %p\n", mBounds.x, mBounds.y, mWidget->name, this);
|
||||
}
|
||||
|
||||
InitCallbacks();
|
||||
CreateGC();
|
||||
|
||||
@@ -148,9 +148,10 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
|
||||
gtk_container_add(GTK_CONTAINER(mainWindow), mVBox);
|
||||
|
||||
gtk_widget_show (mWidget);
|
||||
gtk_box_pack_end(GTK_BOX(mVBox), mWidget, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(mVBox), mWidget, TRUE, TRUE, 0);
|
||||
}
|
||||
// Force cursor to default setting
|
||||
gtk_widget_set_name(mWidget, "nsWindow");
|
||||
mCursor = eCursor_select;
|
||||
SetCursor(eCursor_standard);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user