lots and lots of code cleanup.

This commit is contained in:
pavlov%pavlov.net 1998-12-19 18:04:06 +00:00
Родитель 0a03230a26
Коммит 340357e342
17 изменённых файлов: 248 добавлений и 388 удалений

Просмотреть файл

@ -62,14 +62,9 @@ CPPSRCS= \
nsWidget.cpp \ nsWidget.cpp \
nsWindow.cpp nsWindow.cpp
CSRCS = gtklayout.c \
$(NULL)
TARGETS = $(LIBRARY) TARGETS = $(LIBRARY)
MKSHLIB := MKSHLIB :=
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
gtklayout.o nsWindow.o: gtklayout.h

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -80,39 +80,6 @@ nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
return nsWidget::QueryInterface(aIID,aInstancePtr); return nsWidget::QueryInterface(aIID,aInstancePtr);
} }
//-------------------------------------------------------------------------
//
// Armed
//
//-------------------------------------------------------------------------
void nsCheckButton::Armed()
{
mIsArmed = PR_TRUE;
mValueWasSet = PR_FALSE;
mInitialState = GTK_TOGGLE_BUTTON(mWidget)->active;
}
//-------------------------------------------------------------------------
//
// DisArmed
//
//-------------------------------------------------------------------------
void nsCheckButton::DisArmed()
{
if (mValueWasSet) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), PR_TRUE);
/*
XmToggleButtonSetState(mWidget, mNewValue, PR_TRUE);
*/
} else {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), PR_TRUE);
/*
XmToggleButtonSetState(mWidget, mInitialState, PR_TRUE);
*/
}
mIsArmed = PR_FALSE;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Set this button label // Set this button label
@ -120,11 +87,6 @@ void nsCheckButton::DisArmed()
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetState(const PRBool aState) NS_METHOD nsCheckButton::SetState(const PRBool aState)
{ {
int state = aState;
if (mIsArmed) {
mNewValue = aState;
mValueWasSet = PR_TRUE;
}
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), aState); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), aState);
return NS_OK; return NS_OK;
} }
@ -136,16 +98,8 @@ NS_METHOD nsCheckButton::SetState(const PRBool aState)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetState(PRBool& aState) NS_METHOD nsCheckButton::GetState(PRBool& aState)
{ {
int state = GTK_TOGGLE_BUTTON(mWidget)->active; gint state = GTK_TOGGLE_BUTTON(mWidget)->active;
if (mIsArmed) {
if (mValueWasSet) {
aState = mNewValue;
} else {
aState = state; aState = state;
}
} else {
aState = state;
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -49,20 +49,9 @@ public:
virtual PRBool OnPaint(nsPaintEvent &aEvent); virtual PRBool OnPaint(nsPaintEvent &aEvent);
virtual PRBool OnResize(nsSizeEvent &aEvent); virtual PRBool OnResize(nsSizeEvent &aEvent);
// These are needed to Override the auto check behavior
void Armed();
void DisArmed();
protected: protected:
NS_IMETHOD nsCheckButton::CreateNative(GtkWidget *parentWindow); NS_IMETHOD nsCheckButton::CreateNative(GtkWidget *parentWindow);
GtkWidget *mLabel; GtkWidget *mLabel;
private:
PRBool mInitialState;
PRBool mNewValue;
PRBool mValueWasSet;
PRBool mIsArmed;
}; };
#endif // nsCheckButton_h__ #endif // nsCheckButton_h__

Просмотреть файл

@ -42,7 +42,7 @@ nsComboBox::nsComboBox() : nsWidget(), nsIListWidget(), nsIComboBox()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mMultiSelect = PR_FALSE; mMultiSelect = PR_FALSE;
mBackground = NS_RGB(124, 124, 124); // mBackground = NS_RGB(124, 124, 124);
mItems = nsnull; mItems = nsnull;
mNumItems = 0; mNumItems = 0;

Просмотреть файл

@ -360,6 +360,7 @@ gint nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
//============================================================== //==============================================================
gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p) gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
{ {
#if 0
nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w)); nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w));
if (GTK_TOGGLE_BUTTON(w)->active) if (GTK_TOGGLE_BUTTON(w)->active)
checkBtn->Armed(); checkBtn->Armed();
@ -367,6 +368,7 @@ gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
checkBtn->DisArmed(); checkBtn->DisArmed();
return PR_FALSE; return PR_FALSE;
#endif
} }
//============================================================== //==============================================================
@ -406,7 +408,6 @@ gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
//============================================================== //==============================================================
gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p) gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
{ {
// nsScrollbar *widget = (nsScrollbar*)gtk_object_get_user_data(GTK_OBJECT(w));
nsScrollbar *widget = (nsScrollbar*) p; nsScrollbar *widget = (nsScrollbar*) p;
nsScrollbarEvent sevent; nsScrollbarEvent sevent;

Просмотреть файл

@ -36,7 +36,7 @@ nsListBox::nsListBox() : nsWidget(), nsIListWidget(), nsIListBox()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mMultiSelect = PR_FALSE; mMultiSelect = PR_FALSE;
mBackground = NS_RGB(124, 124, 124); // mBackground = NS_RGB(124, 124, 124);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -46,6 +46,11 @@ nsListBox::nsListBox() : nsWidget(), nsIListWidget(), nsIListBox()
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
nsListBox::~nsListBox() nsListBox::~nsListBox()
{ {
if (mCList)
{
::gtk_widget_destroy(mCList);
mCList = nsnull;
}
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -337,7 +342,7 @@ NS_METHOD nsListBox::CreateNative(GtkWidget *parentWindow)
gtk_widget_set_name(mWidget, "nsListBox"); gtk_widget_set_name(mWidget, "nsListBox");
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mWidget), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mWidget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS); GTK_POLICY_AUTOMATIC);
mCList = ::gtk_clist_new(1); mCList = ::gtk_clist_new(1);
gtk_clist_column_titles_hide(GTK_CLIST(mCList)); gtk_clist_column_titles_hide(GTK_CLIST(mCList));

Просмотреть файл

@ -37,6 +37,7 @@ NS_IMPL_RELEASE(nsRadioButton)
nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton() nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mLabel = nsnull;
} }
@ -82,35 +83,6 @@ NS_METHOD nsRadioButton::CreateNative(GtkWidget *parentWindow)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
//
// Armed
//
//-------------------------------------------------------------------------
void nsRadioButton::Armed()
{
mIsArmed = PR_TRUE;
mValueWasSet = PR_FALSE;
mInitialState = GTK_TOGGLE_BUTTON(mWidget)->active;
}
//-------------------------------------------------------------------------
//
// DisArmed
//
//-------------------------------------------------------------------------
void nsRadioButton::DisArmed()
{
if (mValueWasSet) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), PR_TRUE);
// XmToggleButtonSetState(mRadioBtn, mNewValue, PR_TRUE);
} else {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), PR_TRUE);
// XmToggleButtonSetState(mRadioBtn, mInitialState, PR_TRUE);
}
mIsArmed = PR_FALSE;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Set this button label // Set this button label
@ -118,12 +90,6 @@ void nsRadioButton::DisArmed()
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsRadioButton::SetState(const PRBool aState) NS_METHOD nsRadioButton::SetState(const PRBool aState)
{ {
int state = aState;
if (mIsArmed) {
mNewValue = aState;
mValueWasSet = PR_TRUE;
}
// XmToggleButtonSetState(mRadioBtn, aState, PR_TRUE);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), aState); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mWidget), aState);
return NS_OK; return NS_OK;
} }
@ -134,17 +100,8 @@ NS_METHOD nsRadioButton::SetState(const PRBool aState)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsRadioButton::GetState(PRBool& aState) NS_METHOD nsRadioButton::GetState(PRBool& aState)
{ {
// int state = XmToggleButtonGetState(mRadioBtn);
int state = GTK_TOGGLE_BUTTON(mWidget)->active; int state = GTK_TOGGLE_BUTTON(mWidget)->active;
if (mIsArmed) {
if (mValueWasSet) {
return mNewValue;
} else {
return state; return state;
}
} else {
return state;
}
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

Просмотреть файл

@ -59,12 +59,6 @@ protected:
NS_IMETHOD nsRadioButton::CreateNative(GtkWidget *parentWindow); NS_IMETHOD nsRadioButton::CreateNative(GtkWidget *parentWindow);
GtkWidget *mLabel; GtkWidget *mLabel;
private:
PRBool mInitialState;
PRBool mNewValue;
PRBool mValueWasSet;
PRBool mIsArmed;
}; };
#endif // nsRadioButton_h__ #endif // nsRadioButton_h__

Просмотреть файл

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License * The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in * Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at * compliance with the NPL. You may obtain a copy of the NPL at
@ -25,17 +25,17 @@
#include "nsGtkEventHandler.h" #include "nsGtkEventHandler.h"
NS_IMPL_ADDREF(nsScrollbar); NS_IMPL_ADDREF (nsScrollbar);
NS_IMPL_RELEASE(nsScrollbar); NS_IMPL_RELEASE (nsScrollbar);
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// nsScrollbar constructor // nsScrollbar constructor
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget(), nsIScrollbar() nsScrollbar::nsScrollbar (PRBool aIsVertical):nsWidget (), nsIScrollbar ()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT ();
mOrientation = (aIsVertical) ? mOrientation = (aIsVertical) ?
GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL; GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
@ -43,40 +43,41 @@ nsScrollbar::nsScrollbar(PRBool aIsVertical) : nsWidget(), nsIScrollbar()
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Create the native scrollbar widget // nsScrollbar destructor
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::CreateNative(GtkWidget *parentWindow) nsScrollbar::~nsScrollbar ()
{ {
// Create scrollbar, random default values
mAdjustment = gtk_adjustment_new(0, 0, 100, 1, 25, 25);
if (mOrientation == GTK_ORIENTATION_HORIZONTAL) {
mWidget = gtk_hscrollbar_new(GTK_ADJUSTMENT(mAdjustment));
} else {
mWidget = gtk_vscrollbar_new(GTK_ADJUSTMENT(mAdjustment));
}
gtk_widget_set_name(mWidget, "nsScrollbar");
gtk_object_set_user_data(GTK_OBJECT(mAdjustment), mWidget);
gtk_signal_connect(GTK_OBJECT (mAdjustment),
"changed",
GTK_SIGNAL_FUNC(nsGtkWidget_Scrollbar_Callback),
this);
gtk_signal_connect(GTK_OBJECT (mAdjustment),
"value_changed",
GTK_SIGNAL_FUNC(nsGtkWidget_Scrollbar_Callback),
this);
return NS_OK;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// nsScrollbar destructor // Create the native scrollbar widget
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
nsScrollbar::~nsScrollbar() NS_METHOD nsScrollbar::CreateNative (GtkWidget * parentWindow)
{ {
// Create scrollbar, random default values
mAdjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 100, 1, 25, 25));
switch (mOrientation)
{
case GTK_ORIENTATION_HORIZONTAL:
mWidget = gtk_hscrollbar_new (mAdjustment);
break;
case GTK_ORIENTATION_VERTICAL:
mWidget = gtk_vscrollbar_new (mAdjustment);
break;
}
gtk_widget_set_name (mWidget, "nsScrollbar");
gtk_signal_connect (GTK_OBJECT (mAdjustment),
"value_changed",
GTK_SIGNAL_FUNC (nsGtkWidget_Scrollbar_Callback),
this);
return NS_OK;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -84,20 +85,22 @@ nsScrollbar::~nsScrollbar()
// Query interface implementation // Query interface implementation
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) nsresult nsScrollbar::QueryInterface (const nsIID & aIID, void **aInstancePtr)
{ {
if (aInstancePtr == NULL) { if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
// get parent's interface // get parent's interface
nsresult result = nsWidget::QueryInterface(aIID, aInstancePtr); nsresult result = nsWidget::QueryInterface (aIID, aInstancePtr);
static NS_DEFINE_IID(kInsScrollbarIID, NS_ISCROLLBAR_IID); static NS_DEFINE_IID (kInsScrollbarIID, NS_ISCROLLBAR_IID);
// if not asking for parent, check for our interface IID // if not asking for parent, check for our interface IID
if (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) { if (result == NS_NOINTERFACE && aIID.Equals (kInsScrollbarIID))
*aInstancePtr = (void*) ((nsIScrollbar*)this); {
AddRef(); *aInstancePtr = (void *) ((nsIScrollbar *) this);
AddRef ();
result = NS_OK; result = NS_OK;
} }
@ -109,10 +112,10 @@ nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// Define the range settings // Define the range settings
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange)
{ {
GTK_ADJUSTMENT(mAdjustment)->upper = aEndRange; GTK_ADJUSTMENT (mAdjustment)->upper = (float) aEndRange;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed"); gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
return NS_OK; return NS_OK;
} }
@ -122,9 +125,9 @@ NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange)
// Return the range settings // Return the range settings
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetMaxRange(PRUint32 & aMaxRange) NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange)
{ {
aMaxRange = (PRUint32) GTK_ADJUSTMENT(mAdjustment)->upper; aMaxRange = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->upper;
return NS_OK; return NS_OK;
} }
@ -134,9 +137,9 @@ NS_METHOD nsScrollbar::GetMaxRange(PRUint32 & aMaxRange)
// Set the thumb position // Set the thumb position
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos)
{ {
gtk_adjustment_set_value(GTK_ADJUSTMENT(mAdjustment), aPos); gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), (float) aPos);
return NS_OK; return NS_OK;
} }
@ -146,9 +149,9 @@ NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos)
// Get the current thumb position. // Get the current thumb position.
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetPosition(PRUint32 & aPos) NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos)
{ {
aPos = (PRUint32) GTK_ADJUSTMENT(mAdjustment)->value; aPos = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->value;
return NS_OK; return NS_OK;
} }
@ -158,12 +161,13 @@ NS_METHOD nsScrollbar::GetPosition(PRUint32 & aPos)
// Set the thumb size // Set the thumb size
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize)
{ {
if (aSize > 0) { if (aSize > 0)
GTK_ADJUSTMENT(mAdjustment)->page_increment = aSize; {
GTK_ADJUSTMENT(mAdjustment)->page_size = aSize; GTK_ADJUSTMENT (mAdjustment)->page_increment = (float) aSize;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed"); GTK_ADJUSTMENT (mAdjustment)->page_size = (float) aSize;
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
} }
return NS_OK; return NS_OK;
} }
@ -174,9 +178,9 @@ NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize)
// Get the thumb size // Get the thumb size
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetThumbSize(PRUint32 & aThumbSize) NS_METHOD nsScrollbar::GetThumbSize (PRUint32 & aThumbSize)
{ {
aThumbSize = (PRUint32) GTK_ADJUSTMENT(mAdjustment)->page_size; aThumbSize = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->page_size;
return NS_OK; return NS_OK;
} }
@ -186,11 +190,12 @@ NS_METHOD nsScrollbar::GetThumbSize(PRUint32 & aThumbSize)
// Set the line increment for this scrollbar // Set the line increment for this scrollbar
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement) NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement)
{ {
if (aLineIncrement > 0) { if (aLineIncrement > 0)
GTK_ADJUSTMENT(mAdjustment)->step_increment = aLineIncrement; {
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed"); GTK_ADJUSTMENT (mAdjustment)->step_increment = (float) aLineIncrement;
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
} }
return NS_OK; return NS_OK;
} }
@ -201,9 +206,9 @@ NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
// Get the line increment for this scrollbar // Get the line increment for this scrollbar
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 & aLineInc) NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc)
{ {
aLineInc = (PRUint32) GTK_ADJUSTMENT(mAdjustment)->step_increment; aLineInc = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->step_increment;
return NS_OK; return NS_OK;
} }
@ -213,23 +218,23 @@ NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 & aLineInc)
// Set all scrolling parameters // Set all scrolling parameters
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize,
PRUint32 aPosition, PRUint32 aLineIncrement) PRUint32 aPosition, PRUint32 aLineIncrement)
{ {
int thumbSize = (((int)aThumbSize) > 0?aThumbSize:1); int thumbSize = (((int) aThumbSize) > 0 ? aThumbSize : 1);
int maxRange = (((int)aMaxRange) > 0?aMaxRange:10); int maxRange = (((int) aMaxRange) > 0 ? aMaxRange : 10);
int mLineIncrement = (((int)aLineIncrement) > 0?aLineIncrement:1); int mLineIncrement = (((int) aLineIncrement) > 0 ? aLineIncrement : 1);
int maxPos = maxRange - thumbSize; int maxPos = maxRange - thumbSize;
int pos = ((int)aPosition) > maxPos ? maxPos-1 : ((int)aPosition); int pos = ((int) aPosition) > maxPos ? maxPos - 1 : ((int) aPosition);
GTK_ADJUSTMENT(mAdjustment)->lower = 0; GTK_ADJUSTMENT (mAdjustment)->lower = 0;
GTK_ADJUSTMENT(mAdjustment)->upper = maxRange; GTK_ADJUSTMENT (mAdjustment)->upper = maxRange;
GTK_ADJUSTMENT(mAdjustment)->page_size = thumbSize; GTK_ADJUSTMENT (mAdjustment)->page_size = thumbSize;
GTK_ADJUSTMENT(mAdjustment)->page_increment = thumbSize; GTK_ADJUSTMENT (mAdjustment)->page_increment = thumbSize;
GTK_ADJUSTMENT(mAdjustment)->step_increment = mLineIncrement; GTK_ADJUSTMENT (mAdjustment)->step_increment = mLineIncrement;
// this will emit the changed signal for us // this will emit the changed signal for us
gtk_adjustment_set_value(GTK_ADJUSTMENT(mAdjustment), pos); gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), pos);
return NS_OK; return NS_OK;
} }
@ -239,24 +244,24 @@ NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
// paint message. Don't send the paint out // paint message. Don't send the paint out
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
PRBool nsScrollbar::OnPaint(nsPaintEvent &aEvent) PRBool nsScrollbar::OnPaint (nsPaintEvent & aEvent)
{ {
return PR_FALSE; return PR_FALSE;
} }
PRBool nsScrollbar::OnResize(nsSizeEvent &aEvent) PRBool nsScrollbar::OnResize (nsSizeEvent & aEvent)
{ {
return PR_FALSE; return PR_FALSE;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
int nsScrollbar::AdjustScrollBarPosition(int aPosition) int nsScrollbar::AdjustScrollBarPosition (int aPosition)
{ {
int maxRange; int maxRange;
int sliderSize; int sliderSize;
#if 0 #if 0
XtVaGetValues(mWidget, XmNmaximum, &maxRange, XtVaGetValues (mWidget, XmNmaximum, &maxRange,
XmNsliderSize, &sliderSize, XmNsliderSize, &sliderSize,
nsnull); nsnull);
int cap = maxRange - sliderSize; int cap = maxRange - sliderSize;
@ -270,32 +275,34 @@ int nsScrollbar::AdjustScrollBarPosition(int aPosition)
// Deal with scrollbar messages (actually implemented only in nsScrollbar) // Deal with scrollbar messages (actually implemented only in nsScrollbar)
// //
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) PRBool nsScrollbar::OnScroll (nsScrollbarEvent & aEvent, PRUint32 cPos)
{ {
PRBool result = PR_TRUE; PRBool result = PR_TRUE;
float newPosition; float newPosition;
switch (aEvent.message) { switch (aEvent.message)
{
// scroll one line right or down // scroll one line right or down
case NS_SCROLLBAR_LINE_NEXT: case NS_SCROLLBAR_LINE_NEXT:
{ {
newPosition = GTK_ADJUSTMENT(mAdjustment)->value; newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
// newPosition += mLineIncrement; // newPosition += mLineIncrement;
newPosition += 10; newPosition += 10;
PRUint32 thumbSize; PRUint32 thumbSize;
PRUint32 maxRange; PRUint32 maxRange;
GetThumbSize(thumbSize); GetThumbSize (thumbSize);
GetMaxRange(maxRange); GetMaxRange (maxRange);
PRUint32 max = maxRange - thumbSize; PRUint32 max = maxRange - thumbSize;
if (newPosition > (int)max) if (newPosition > (int) max)
newPosition = (int)max; newPosition = (int) max;
// if an event callback is registered, give it the chance // if an event callback is registered, give it the chance
// to change the increment // to change the increment
if (mEventCallback) { if (mEventCallback)
aEvent.position = newPosition; {
result = ConvertStatus((*mEventCallback)(&aEvent)); aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position; newPosition = aEvent.position;
} }
break; break;
@ -305,7 +312,7 @@ PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
// scroll one line left or up // scroll one line left or up
case NS_SCROLLBAR_LINE_PREV: case NS_SCROLLBAR_LINE_PREV:
{ {
newPosition = GTK_ADJUSTMENT(mAdjustment)->value; newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
// newPosition -= mLineIncrement; // newPosition -= mLineIncrement;
newPosition -= 10; newPosition -= 10;
@ -314,10 +321,11 @@ PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
// if an event callback is registered, give it the chance // if an event callback is registered, give it the chance
// to change the decrement // to change the decrement
if (mEventCallback) { if (mEventCallback)
aEvent.position = newPosition; {
aEvent.widget = (nsWidget*)this; aEvent.position = (PRUint32) newPosition;
result = ConvertStatus((*mEventCallback)(&aEvent)); aEvent.widget = (nsWidget *) this;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position; newPosition = aEvent.position;
} }
break; break;
@ -326,21 +334,22 @@ PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
// Scrolls one page right or down // Scrolls one page right or down
case NS_SCROLLBAR_PAGE_NEXT: case NS_SCROLLBAR_PAGE_NEXT:
{ {
newPosition = GTK_ADJUSTMENT(mAdjustment)->value; newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
PRUint32 thumbSize; PRUint32 thumbSize;
GetThumbSize(thumbSize); GetThumbSize (thumbSize);
PRUint32 maxRange; PRUint32 maxRange;
GetThumbSize(thumbSize); GetThumbSize (thumbSize);
GetMaxRange(maxRange); GetMaxRange (maxRange);
PRUint32 max = maxRange - thumbSize; PRUint32 max = maxRange - thumbSize;
if (newPosition > (int)max) if (newPosition > (int) max)
newPosition = (int)max; newPosition = (int) max;
// if an event callback is registered, give it the chance // if an event callback is registered, give it the chance
// to change the increment // to change the increment
if (mEventCallback) { if (mEventCallback)
aEvent.position = newPosition; {
result = ConvertStatus((*mEventCallback)(&aEvent)); aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position; newPosition = aEvent.position;
} }
break; break;
@ -349,15 +358,16 @@ PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
// Scrolls one page left or up. // Scrolls one page left or up.
case NS_SCROLLBAR_PAGE_PREV: case NS_SCROLLBAR_PAGE_PREV:
{ {
newPosition = GTK_ADJUSTMENT(mAdjustment)->value; newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
if (newPosition < 0) if (newPosition < 0)
newPosition = 0; newPosition = 0;
// if an event callback is registered, give it the chance // if an event callback is registered, give it the chance
// to change the increment // to change the increment
if (mEventCallback) { if (mEventCallback)
aEvent.position = newPosition; {
result = ConvertStatus((*mEventCallback)(&aEvent)); aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position; newPosition = aEvent.position;
} }
break; break;
@ -372,9 +382,10 @@ PRBool nsScrollbar::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
// if an event callback is registered, give it the chance // if an event callback is registered, give it the chance
// to change the increment // to change the increment
if (mEventCallback) { if (mEventCallback)
aEvent.position = newPosition; {
result = ConvertStatus((*mEventCallback)(&aEvent)); aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position; newPosition = aEvent.position;
} }
break; break;

Просмотреть файл

@ -61,7 +61,7 @@ protected:
private: private:
int mOrientation; int mOrientation;
GtkObject* mAdjustment; GtkAdjustment *mAdjustment;
int AdjustScrollBarPosition(int aPosition); int AdjustScrollBarPosition(int aPosition);
}; };

Просмотреть файл

@ -125,7 +125,6 @@ NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword)
{ {
mIsPassword = aIsPassword?PR_FALSE:PR_TRUE; mIsPassword = aIsPassword?PR_FALSE:PR_TRUE;
if (GTK_IS_ENTRY(mWidget)) { if (GTK_IS_ENTRY(mWidget)) {
g_print("gtk_entry_set_visibility(GTK_ENTRY(%p), %d);\n",mWidget, mIsPassword);
gtk_entry_set_visibility(GTK_ENTRY(mWidget), mIsPassword); gtk_entry_set_visibility(GTK_ENTRY(mWidget), mIsPassword);
} }
// this won't work for gtk_texts // this won't work for gtk_texts
@ -139,7 +138,6 @@ NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldReadOnlyF
"SetReadOnly - Widget is NULL, Create may not have been called!"); "SetReadOnly - Widget is NULL, Create may not have been called!");
aOldReadOnlyFlag = mIsReadOnly; aOldReadOnlyFlag = mIsReadOnly;
mIsReadOnly = aReadOnlyFlag?PR_FALSE:PR_TRUE; mIsReadOnly = aReadOnlyFlag?PR_FALSE:PR_TRUE;
g_print("gtk_editable_set_editable(GTK_EDITABLE(%p), %d);\n",mWidget, mIsReadOnly);
gtk_editable_set_editable(GTK_EDITABLE(mWidget), mIsReadOnly); gtk_editable_set_editable(GTK_EDITABLE(mWidget), mIsReadOnly);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -19,6 +19,27 @@
#include "nsToolkit.h" #include "nsToolkit.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
//-------------------------------------------------------------------------
//
// constructor
//
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
{
NS_INIT_REFCNT();
/* XSetErrorHandler(nsToolkitErrorHandler); */
}
//-------------------------------------------------------------------------
//
// destructor
//
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
}
void RunPump(void* arg) void RunPump(void* arg)
{ {
} }
@ -41,27 +62,6 @@ void RunPump(void* arg)
//} //}
//-------------------------------------------------------------------------
//
// constructor
//
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
{
NS_INIT_REFCNT();
/* XSetErrorHandler(nsToolkitErrorHandler); */
}
//-------------------------------------------------------------------------
//
// destructor
//
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// nsISupports implementation macro // nsISupports implementation macro

Просмотреть файл

@ -58,6 +58,13 @@ nsWidget::nsWidget()
nsWidget::~nsWidget() nsWidget::~nsWidget()
{ {
if (mWidget)
{
if (GTK_IS_WIDGET(mWidget))
gtk_widget_destroy(mWidget);
mWidget = nsnull;
}
nsBaseWidget::Destroy();
} }
NS_METHOD nsWidget::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) NS_METHOD nsWidget::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
@ -81,6 +88,7 @@ NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
NS_IMETHODIMP nsWidget::Destroy(void) NS_IMETHODIMP nsWidget::Destroy(void)
{ {
::gtk_widget_destroy(mWidget); ::gtk_widget_destroy(mWidget);
mWidget = nsnull;
return NS_OK; return NS_OK;
} }
@ -132,7 +140,9 @@ NS_METHOD nsWidget::Show(PRBool bState)
NS_METHOD nsWidget::IsVisible(PRBool &aState) NS_METHOD nsWidget::IsVisible(PRBool &aState)
{ {
gint RealVis = GTK_WIDGET_VISIBLE(mWidget);
aState = mShown; aState = mShown;
g_return_val_if_fail(RealVis == mShown, NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
@ -219,47 +229,6 @@ NS_METHOD nsWidget::GetBounds(nsRect &aRect)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
//
// Get the foreground color
//
//-------------------------------------------------------------------------
nscolor nsWidget::GetForegroundColor(void)
{
/* can we safely cache this? */
return mForeground;
}
//-------------------------------------------------------------------------
//
// Set the foreground color
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetForegroundColor(const nscolor &aColor)
{
GtkStyle *style;
GdkColor color;
mForeground = aColor;
NSCOLOR_TO_GDKCOLOR(color, aColor);
style = gtk_style_copy(mWidget->style);
style->fg[GTK_STATE_NORMAL] = color;
gtk_widget_set_style(mWidget, style);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get the background color
//
//-------------------------------------------------------------------------
nscolor nsWidget::GetBackgroundColor(void)
{
/* can we safely cache this? */
return mBackground;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Set the background color // Set the background color
@ -271,6 +240,9 @@ NS_METHOD nsWidget::SetBackgroundColor(const nscolor &aColor)
GdkColor color; GdkColor color;
mBackground = aColor; mBackground = aColor;
nsBaseWidget::SetBackgroundColor(aColor);
/* FIXME do we need the rest of this? (look at the windows code) */
NSCOLOR_TO_GDKCOLOR(color, aColor); NSCOLOR_TO_GDKCOLOR(color, aColor);
#ifdef DBG #ifdef DBG
g_print("nsWidget::SetBackgroundColor %d %d %d\n", color.red, color.blue, color.green); g_print("nsWidget::SetBackgroundColor %d %d %d\n", color.red, color.blue, color.green);
@ -304,17 +276,6 @@ NS_METHOD nsWidget::SetFont(const nsFont &aFont)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
//
// Get this component cursor
//
//-------------------------------------------------------------------------
nsCursor nsWidget::GetCursor(void)
{
NS_NOTYETIMPLEMENTED("nsWidget::GetCursor");
return eCursor_standard;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Set this component cursor // Set this component cursor

Просмотреть файл

@ -74,20 +74,15 @@ class nsWidget : public nsBaseWidget
NS_IMETHOD GetBounds(nsRect &aRect); NS_IMETHOD GetBounds(nsRect &aRect);
nscolor GetForegroundColor(void);
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
nscolor GetBackgroundColor(void);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
nsIFontMetrics *GetFont(void); nsIFontMetrics *GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont); NS_IMETHOD SetFont(const nsFont &aFont);
nsCursor GetCursor(void);
NS_IMETHOD SetCursor(nsCursor aCursor); NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetColorMap(nsColorMap *aColorMap); NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
void* GetNativeData(PRUint32 aDataType); void* GetNativeData(PRUint32 aDataType);
nsIRenderingContext *GetRenderingContext(void); nsIRenderingContext *GetRenderingContext(void);
nsIDeviceContext *GetDeviceContext(void); nsIDeviceContext *GetDeviceContext(void);

Просмотреть файл

@ -548,8 +548,8 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget)); GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget));
horiz->value -= aDx; horiz->value -= aDx;
vert->value -= aDy; vert->value -= aDy;
gtk_signal_emit_by_name(GTK_OBJECT(horiz), "value_changed"); gtk_adjustment_value_changed(horiz);
gtk_signal_emit_by_name(GTK_OBJECT(vert), "value_changed"); gtk_adjustment_value_changed(vert);
} }
return NS_OK; return NS_OK;
} }