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 \
nsWindow.cpp
CSRCS = gtklayout.c \
$(NULL)
TARGETS = $(LIBRARY)
MKSHLIB :=
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);
}
//-------------------------------------------------------------------------
//
// 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
@ -120,11 +87,6 @@ void nsCheckButton::DisArmed()
//-------------------------------------------------------------------------
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);
return NS_OK;
}
@ -136,16 +98,8 @@ NS_METHOD nsCheckButton::SetState(const PRBool aState)
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetState(PRBool& aState)
{
int state = GTK_TOGGLE_BUTTON(mWidget)->active;
if (mIsArmed) {
if (mValueWasSet) {
aState = mNewValue;
} else {
aState = state;
}
} else {
aState = state;
}
gint state = GTK_TOGGLE_BUTTON(mWidget)->active;
aState = state;
return NS_OK;
}

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

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

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

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

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

@ -360,6 +360,7 @@ gint nsGtkWidget_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));
if (GTK_TOGGLE_BUTTON(w)->active)
checkBtn->Armed();
@ -367,6 +368,7 @@ gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
checkBtn->DisArmed();
return PR_FALSE;
#endif
}
//==============================================================
@ -406,7 +408,6 @@ gint nsGtkWidget_RadioButton_DisArmCallback(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;
nsScrollbarEvent sevent;

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

@ -36,7 +36,7 @@ nsListBox::nsListBox() : nsWidget(), nsIListWidget(), nsIListBox()
{
NS_INIT_REFCNT();
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()
{
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_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mWidget),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
GTK_POLICY_AUTOMATIC);
mCList = ::gtk_clist_new(1);
gtk_clist_column_titles_hide(GTK_CLIST(mCList));

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

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

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

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

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

@ -1,5 +1,5 @@
/* -*- 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
* 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
@ -25,81 +25,84 @@
#include "nsGtkEventHandler.h"
NS_IMPL_ADDREF(nsScrollbar);
NS_IMPL_RELEASE(nsScrollbar);
NS_IMPL_ADDREF (nsScrollbar);
NS_IMPL_RELEASE (nsScrollbar);
//-------------------------------------------------------------------------
//
// 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;
}
//-------------------------------------------------------------------------
//
// Create the native scrollbar widget
//
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::CreateNative(GtkWidget *parentWindow)
{
// 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
//
//-------------------------------------------------------------------------
nsScrollbar::~nsScrollbar()
nsScrollbar::~nsScrollbar ()
{
}
//-------------------------------------------------------------------------
//
// Create the native scrollbar widget
//
//-------------------------------------------------------------------------
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;
}
//-------------------------------------------------------------------------
//
// Query interface implementation
//
//-------------------------------------------------------------------------
nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr)
nsresult nsScrollbar::QueryInterface (const nsIID & aIID, void **aInstancePtr)
{
if (aInstancePtr == NULL) {
return NS_ERROR_NULL_POINTER;
}
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// 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 (result == NS_NOINTERFACE && aIID.Equals(kInsScrollbarIID)) {
*aInstancePtr = (void*) ((nsIScrollbar*)this);
AddRef();
result = NS_OK;
}
if (result == NS_NOINTERFACE && aIID.Equals (kInsScrollbarIID))
{
*aInstancePtr = (void *) ((nsIScrollbar *) this);
AddRef ();
result = NS_OK;
}
return result;
}
@ -109,10 +112,10 @@ nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr)
// Define the range settings
//
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange)
NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange)
{
GTK_ADJUSTMENT(mAdjustment)->upper = aEndRange;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed");
GTK_ADJUSTMENT (mAdjustment)->upper = (float) aEndRange;
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
return NS_OK;
}
@ -122,9 +125,9 @@ NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange)
// 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;
}
@ -134,9 +137,9 @@ NS_METHOD nsScrollbar::GetMaxRange(PRUint32 & aMaxRange)
// 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;
}
@ -146,9 +149,9 @@ NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos)
// 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;
}
@ -158,13 +161,14 @@ NS_METHOD nsScrollbar::GetPosition(PRUint32 & aPos)
// Set the thumb size
//
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize)
NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize)
{
if (aSize > 0) {
GTK_ADJUSTMENT(mAdjustment)->page_increment = aSize;
GTK_ADJUSTMENT(mAdjustment)->page_size = aSize;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed");
}
if (aSize > 0)
{
GTK_ADJUSTMENT (mAdjustment)->page_increment = (float) aSize;
GTK_ADJUSTMENT (mAdjustment)->page_size = (float) aSize;
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
}
return NS_OK;
}
@ -174,9 +178,9 @@ NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize)
// 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;
}
@ -186,12 +190,13 @@ NS_METHOD nsScrollbar::GetThumbSize(PRUint32 & aThumbSize)
// Set the line increment for this scrollbar
//
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement)
{
if (aLineIncrement > 0) {
GTK_ADJUSTMENT(mAdjustment)->step_increment = aLineIncrement;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "changed");
}
if (aLineIncrement > 0)
{
GTK_ADJUSTMENT (mAdjustment)->step_increment = (float) aLineIncrement;
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
}
return NS_OK;
}
@ -201,9 +206,9 @@ NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aLineIncrement)
// 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;
}
@ -213,23 +218,23 @@ NS_METHOD nsScrollbar::GetLineIncrement(PRUint32 & aLineInc)
// Set all scrolling parameters
//
//-------------------------------------------------------------------------
NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
PRUint32 aPosition, PRUint32 aLineIncrement)
NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize,
PRUint32 aPosition, PRUint32 aLineIncrement)
{
int thumbSize = (((int)aThumbSize) > 0?aThumbSize:1);
int maxRange = (((int)aMaxRange) > 0?aMaxRange:10);
int mLineIncrement = (((int)aLineIncrement) > 0?aLineIncrement:1);
int thumbSize = (((int) aThumbSize) > 0 ? aThumbSize : 1);
int maxRange = (((int) aMaxRange) > 0 ? aMaxRange : 10);
int mLineIncrement = (((int) aLineIncrement) > 0 ? aLineIncrement : 1);
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)->upper = maxRange;
GTK_ADJUSTMENT(mAdjustment)->page_size = thumbSize;
GTK_ADJUSTMENT(mAdjustment)->page_increment = thumbSize;
GTK_ADJUSTMENT(mAdjustment)->step_increment = mLineIncrement;
GTK_ADJUSTMENT (mAdjustment)->lower = 0;
GTK_ADJUSTMENT (mAdjustment)->upper = maxRange;
GTK_ADJUSTMENT (mAdjustment)->page_size = thumbSize;
GTK_ADJUSTMENT (mAdjustment)->page_increment = thumbSize;
GTK_ADJUSTMENT (mAdjustment)->step_increment = mLineIncrement;
// 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;
}
@ -239,30 +244,30 @@ NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize,
// paint message. Don't send the paint out
//
//-------------------------------------------------------------------------
PRBool nsScrollbar::OnPaint(nsPaintEvent &aEvent)
PRBool nsScrollbar::OnPaint (nsPaintEvent & aEvent)
{
return PR_FALSE;
}
PRBool nsScrollbar::OnResize(nsSizeEvent &aEvent)
PRBool nsScrollbar::OnResize (nsSizeEvent & aEvent)
{
return PR_FALSE;
}
//-------------------------------------------------------------------------
int nsScrollbar::AdjustScrollBarPosition(int aPosition)
int nsScrollbar::AdjustScrollBarPosition (int aPosition)
{
int maxRange;
int sliderSize;
#if 0
XtVaGetValues(mWidget, XmNmaximum, &maxRange,
XmNsliderSize, &sliderSize,
nsnull);
XtVaGetValues (mWidget, XmNmaximum, &maxRange,
XmNsliderSize, &sliderSize,
nsnull);
int cap = maxRange - sliderSize;
return aPosition > cap ? cap : aPosition;
#endif
return 0; /* XXX */
return 0; /* XXX */
}
//-------------------------------------------------------------------------
@ -270,126 +275,132 @@ int nsScrollbar::AdjustScrollBarPosition(int aPosition)
// 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;
float newPosition;
switch (aEvent.message) {
// scroll one line right or down
case NS_SCROLLBAR_LINE_NEXT:
switch (aEvent.message)
{
newPosition = GTK_ADJUSTMENT(mAdjustment)->value;
// newPosition += mLineIncrement;
newPosition += 10;
PRUint32 thumbSize;
PRUint32 maxRange;
GetThumbSize(thumbSize);
GetMaxRange(maxRange);
PRUint32 max = maxRange - thumbSize;
if (newPosition > (int)max)
newPosition = (int)max;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback) {
aEvent.position = newPosition;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
// scroll one line right or down
case NS_SCROLLBAR_LINE_NEXT:
{
newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
// newPosition += mLineIncrement;
newPosition += 10;
PRUint32 thumbSize;
PRUint32 maxRange;
GetThumbSize (thumbSize);
GetMaxRange (maxRange);
PRUint32 max = maxRange - thumbSize;
if (newPosition > (int) max)
newPosition = (int) max;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback)
{
aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position;
}
break;
}
break;
}
// scroll one line left or up
case NS_SCROLLBAR_LINE_PREV:
{
newPosition = GTK_ADJUSTMENT(mAdjustment)->value;
// scroll one line left or up
case NS_SCROLLBAR_LINE_PREV:
{
newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
// newPosition -= mLineIncrement;
newPosition -= 10;
if (newPosition < 0)
newPosition = 0;
// newPosition -= mLineIncrement;
newPosition -= 10;
if (newPosition < 0)
newPosition = 0;
// if an event callback is registered, give it the chance
// to change the decrement
if (mEventCallback) {
aEvent.position = newPosition;
aEvent.widget = (nsWidget*)this;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
// if an event callback is registered, give it the chance
// to change the decrement
if (mEventCallback)
{
aEvent.position = (PRUint32) newPosition;
aEvent.widget = (nsWidget *) this;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position;
}
break;
}
break;
}
// Scrolls one page right or down
case NS_SCROLLBAR_PAGE_NEXT:
{
newPosition = GTK_ADJUSTMENT(mAdjustment)->value;
PRUint32 thumbSize;
GetThumbSize(thumbSize);
PRUint32 maxRange;
GetThumbSize(thumbSize);
GetMaxRange(maxRange);
PRUint32 max = maxRange - thumbSize;
if (newPosition > (int)max)
newPosition = (int)max;
// Scrolls one page right or down
case NS_SCROLLBAR_PAGE_NEXT:
{
newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
PRUint32 thumbSize;
GetThumbSize (thumbSize);
PRUint32 maxRange;
GetThumbSize (thumbSize);
GetMaxRange (maxRange);
PRUint32 max = maxRange - thumbSize;
if (newPosition > (int) max)
newPosition = (int) max;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback) {
aEvent.position = newPosition;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback)
{
aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position;
}
break;
}
break;
}
// Scrolls one page left or up.
case NS_SCROLLBAR_PAGE_PREV:
{
newPosition = GTK_ADJUSTMENT(mAdjustment)->value;
if (newPosition < 0)
newPosition = 0;
// Scrolls one page left or up.
case NS_SCROLLBAR_PAGE_PREV:
{
newPosition = GTK_ADJUSTMENT (mAdjustment)->value;
if (newPosition < 0)
newPosition = 0;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback) {
aEvent.position = newPosition;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback)
{
aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position;
}
break;
}
break;
}
// Scrolls to the absolute position. The current position is specified by
// the cPos parameter.
case NS_SCROLLBAR_POS:
{
newPosition = cPos;
// Scrolls to the absolute position. The current position is specified by
// the cPos parameter.
case NS_SCROLLBAR_POS:
{
newPosition = cPos;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback) {
aEvent.position = newPosition;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
// if an event callback is registered, give it the chance
// to change the increment
if (mEventCallback)
{
aEvent.position = (PRUint32) newPosition;
result = ConvertStatus ((*mEventCallback) (&aEvent));
newPosition = aEvent.position;
}
break;
}
break;
}
}
/*
GTK_ADJUSTMENT(mAdjustment)->value = newPosition;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "value_changed");
*/
GTK_ADJUSTMENT(mAdjustment)->value = newPosition;
gtk_signal_emit_by_name(GTK_OBJECT(mAdjustment), "value_changed");
*/
/*
if (mEventCallback) {
aEvent.position = cPos;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
}
*/
if (mEventCallback) {
aEvent.position = cPos;
result = ConvertStatus((*mEventCallback)(&aEvent));
newPosition = aEvent.position;
}
*/
return result;
}

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

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

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

@ -125,7 +125,6 @@ NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword)
{
mIsPassword = aIsPassword?PR_FALSE:PR_TRUE;
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);
}
// 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!");
aOldReadOnlyFlag = mIsReadOnly;
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);
return NS_OK;
}

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

@ -19,6 +19,27 @@
#include "nsToolkit.h"
#include "nsGUIEvent.h"
//-------------------------------------------------------------------------
//
// constructor
//
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
{
NS_INIT_REFCNT();
/* XSetErrorHandler(nsToolkitErrorHandler); */
}
//-------------------------------------------------------------------------
//
// destructor
//
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
}
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

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

@ -58,6 +58,13 @@ 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)
@ -81,6 +88,7 @@ NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
NS_IMETHODIMP nsWidget::Destroy(void)
{
::gtk_widget_destroy(mWidget);
mWidget = nsnull;
return NS_OK;
}
@ -132,7 +140,9 @@ NS_METHOD nsWidget::Show(PRBool bState)
NS_METHOD nsWidget::IsVisible(PRBool &aState)
{
gint RealVis = GTK_WIDGET_VISIBLE(mWidget);
aState = mShown;
g_return_val_if_fail(RealVis == mShown, NS_ERROR_FAILURE);
return NS_OK;
}
@ -219,47 +229,6 @@ NS_METHOD nsWidget::GetBounds(nsRect &aRect)
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
@ -271,6 +240,9 @@ NS_METHOD nsWidget::SetBackgroundColor(const nscolor &aColor)
GdkColor color;
mBackground = aColor;
nsBaseWidget::SetBackgroundColor(aColor);
/* FIXME do we need the rest of this? (look at the windows code) */
NSCOLOR_TO_GDKCOLOR(color, aColor);
#ifdef DBG
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;
}
//-------------------------------------------------------------------------
//
// Get this component cursor
//
//-------------------------------------------------------------------------
nsCursor nsWidget::GetCursor(void)
{
NS_NOTYETIMPLEMENTED("nsWidget::GetCursor");
return eCursor_standard;
}
//-------------------------------------------------------------------------
//
// Set this component cursor

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

@ -74,20 +74,15 @@ class nsWidget : public nsBaseWidget
NS_IMETHOD GetBounds(nsRect &aRect);
nscolor GetForegroundColor(void);
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
nscolor GetBackgroundColor(void);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
nsIFontMetrics *GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont);
nsCursor GetCursor(void);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
void* GetNativeData(PRUint32 aDataType);
nsIRenderingContext *GetRenderingContext(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));
horiz->value -= aDx;
vert->value -= aDy;
gtk_signal_emit_by_name(GTK_OBJECT(horiz), "value_changed");
gtk_signal_emit_by_name(GTK_OBJECT(vert), "value_changed");
gtk_adjustment_value_changed(horiz);
gtk_adjustment_value_changed(vert);
}
return NS_OK;
}