some cleanup, add placeholders for not-yet-implemented widgets, implement statusbars. not part of the build.

This commit is contained in:
bryner%netscape.com 2005-08-20 07:12:28 +00:00
Родитель 478597e821
Коммит c4364fddf4
7 изменённых файлов: 208 добавлений и 51 удалений

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

@ -54,6 +54,8 @@ extern GtkWidget* gEntryWidget;
extern GtkWidget* gArrowWidget;
extern GtkWidget* gDropdownButtonWidget;
extern GtkWidget* gHandleBoxWidget;
extern GtkWidget* gFrameWidget;
extern GtkWidget* gProtoWindow;
extern GtkTooltips* gTooltipWidget;
GtkStateType
@ -160,20 +162,16 @@ moz_gtk_checkbox_paint(GdkWindow* window, GtkStyle* style,
}
void
moz_gtk_arrow_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect, GtkWidgetState* state)
calculate_arrow_dimensions(GdkRectangle* rect, GdkRectangle* arrow_rect)
{
GtkMisc* misc = GTK_MISC(gArrowWidget);
gint extent = MIN(rect->width - misc->xpad * 2, rect->height - misc->ypad * 2);
gint x = ((rect->x + misc->xpad) * (1.0 - misc->xalign) +
arrow_rect->x = ((rect->x + misc->xpad) * (1.0 - misc->xalign) +
(rect->x + rect->width - extent - misc->xpad) * misc->xalign);
gint y = ((rect->y + misc->ypad) * (1.0 - misc->yalign) +
arrow_rect->y = ((rect->y + misc->ypad) * (1.0 - misc->yalign) +
(rect->y + rect->height - extent - misc->ypad) * misc->yalign);
gtk_paint_arrow(style, window, ConvertGtkState(state),
state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT, cliprect,
gArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE, x,
y, extent, extent);
arrow_rect->width = arrow_rect->height = extent;
}
void
@ -183,9 +181,12 @@ moz_gtk_scrollbar_button_paint(GdkWindow* window, GtkStyle* style,
{
GtkStateType state_type = ConvertGtkState(state);
GtkShadowType shadow_type = (state->active) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
GdkRectangle arrow_rect;
calculate_arrow_dimensions(rect, &arrow_rect);
gtk_paint_arrow(style, window, state_type, shadow_type, cliprect,
gScrollbarWidget, (type < 2) ? "vscrollbar" : "hscrollbar",
type, TRUE, rect->x, rect->y, rect->width, rect->height);
type, TRUE, arrow_rect.x, arrow_rect.y, arrow_rect.width,
arrow_rect.height);
}
void
@ -318,7 +319,9 @@ moz_gtk_dropdown_arrow_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* rect, GdkRectangle* cliprect,
GtkWidgetState* state)
{
GdkRectangle arrow_rect;
GdkRectangle arrow_rect, real_arrow_rect;
GtkStateType state_type = ConvertGtkState(state);
GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
moz_gtk_button_paint(window, gDropdownButtonWidget->style, rect, cliprect,
state, GTK_RELIEF_NORMAL);
@ -329,7 +332,11 @@ moz_gtk_dropdown_arrow_paint(GdkWindow* window, GtkStyle* style,
arrow_rect.width = MAX(1, rect->width - (arrow_rect.x - rect->x) * 2);
arrow_rect.height = MAX(1, rect->height - (arrow_rect.y - rect->y) * 2);
moz_gtk_arrow_paint(window, style, &arrow_rect, cliprect, state);
calculate_arrow_dimensions(&arrow_rect, &real_arrow_rect);
gtk_paint_arrow(style, window, state_type, shadow_type, cliprect,
gScrollbarWidget, "arrow", GTK_ARROW_DOWN, TRUE,
real_arrow_rect.x, real_arrow_rect.y,
real_arrow_rect.width, real_arrow_rect.height);
}
void
@ -371,3 +378,15 @@ moz_gtk_tooltip_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
rect->y, rect->width, rect->height);
}
void
moz_gtk_frame_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect)
{
gtk_paint_flat_box(gProtoWindow->style, window, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
NULL, gProtoWindow, "base", rect->x, rect->y,
rect->width, rect->height);
gtk_paint_shadow(style, window, GTK_STATE_NORMAL, GTK_SHADOW_IN, cliprect,
gFrameWidget, "frame", rect->x, rect->y, rect->width,
rect->height);
}

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

@ -111,6 +111,10 @@ void
moz_gtk_tooltip_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect);
void
moz_gtk_frame_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect);
#ifdef __cplusplus
}
#endif /* __cplusplus */

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

@ -64,11 +64,12 @@ GtkWidget* gDropdownButonWidget;
GtkWidget* gArrowWidget;
GtkWidget* gDropdownButtonWidget;
GtkWidget* gHandleBoxWidget;
GtkWidget* gFrameWidget;
GtkWidget* gProtoWindow;
GtkTooltips* gTooltipWidget;
nsNativeThemeGTK::nsNativeThemeGTK()
: mProtoWindow(nsnull),
mProtoLayout(nsnull)
: mProtoLayout(nsnull)
{
NS_INIT_ISUPPORTS();
mDisabledAtom = do_GetAtom("disabled");
@ -81,8 +82,8 @@ nsNativeThemeGTK::nsNativeThemeGTK()
nsNativeThemeGTK::~nsNativeThemeGTK() {
// This will destroy all of our widgets
if (mProtoWindow)
gtk_widget_destroy(mProtoWindow);
if (gProtoWindow)
gtk_widget_destroy(gProtoWindow);
if (gTooltipWidget)
gtk_object_unref(GTK_OBJECT(gTooltipWidget));
}
@ -266,6 +267,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
{
EnsureScrollbarWidget();
EnsureArrowWidget();
GtkArrowType arrowType = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
moz_gtk_scrollbar_button_paint(window, gScrollbarWidget->style,
&gdk_rect, &gdk_clip, &state, arrowType);
@ -318,16 +320,23 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
&gdk_clip, &state,
(aWidgetType == NS_THEME_RADIO_CONTAINER));
break;
case NS_THEME_TOOLBOX:
EnsureHandleBoxWidget();
moz_gtk_toolbar_paint(window, gHandleBoxWidget->style, &gdk_rect,
&gdk_clip);
break;
case NS_THEME_TOOLTIP:
EnsureTooltipWidget();
moz_gtk_tooltip_paint(window, gTooltipWidget->tip_window->style, &gdk_rect,
&gdk_clip);
break;
case NS_THEME_STATUSBAR_PANEL:
EnsureFrameWidget();
moz_gtk_frame_paint(window, gFrameWidget->style, &gdk_rect, &gdk_clip);
break;
}
return NS_OK;
@ -378,6 +387,10 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
case NS_THEME_RADIO_CONTAINER:
aResult->top = aResult->bottom = aResult->left = aResult->right = 1;
break;
case NS_THEME_STATUSBAR_PANEL:
EnsureFrameWidget();
WidgetBorderToMargin(gFrameWidget, aResult);
break;
}
return NS_OK;
@ -511,26 +524,69 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
{
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_RADIO:
case NS_THEME_CHECKBOX:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_TOOLBOX:
// case NS_THEME_TOOLBAR: (not in skin)
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
// case NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN:
// case NS_THEME_TOOLBAR_SEPARATOR:
case NS_THEME_TOOLBAR_GRIPPER:
case NS_THEME_STATUSBAR:
case NS_THEME_STATUSBAR_PANEL:
// case NS_THEME_RESIZER:
// case NS_THEME_LISTBOX:
// case NS_THEME_LISTBOX_LISTITEM:
// case NS_THEME_TREEVIEW:
// case NS_THEME_TREEVIEW_TREEITEM:
// case NS_THEME_TREEVIEW_TWISTY:
// case NS_THEME_TREEVIEW_LINE:
// case NS_THEME_TREEVIEW_HEADER:
// case NS_THEME_TREEVIEW_HEADER_CELL:
// case NS_THEME_TREEVIEW_HEADER_SORTARROW:
// case NS_THEME_TREEVIEW_TWISTY_OPEN:
// case NS_THEME_PROGRESSBAR:
// case NS_THEME_PROGRESSBAR_CHUNK:
// case NS_THEME_PROGRESSBAR_VERTICAL:
// case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
// case NS_THEME_TAB:
// case NS_THEME_TAB_PANEL:
// case NS_THEME_TAB_LEFT_EDGE:
// case NS_THEME_TAB_RIGHT_EDGE:
// case NS_THEME_TAB_PANELS:
case NS_THEME_TOOLTIP:
// case NS_THEME_SPINNER:
// case NS_THEME_SPINNER_UP_BUTTON:
// case NS_THEME_SPINNER_DOWN_BUTTON:
// case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
case NS_THEME_TOOLBAR_GRIPPER:
case NS_THEME_RADIO:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
// case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
// case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
case NS_THEME_TEXTFIELD:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_TEXTFIELD_CARET:
// case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_TOOLBOX:
case NS_THEME_TOOLTIP:
// case NS_THEME_DROPDOWN_TEXT:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_SLIDER:
// case NS_THEME_SLIDER_THUMB:
// case NS_THEME_SLIDER_THUMB_START:
// case NS_THEME_SLIDER_THUMB_END:
// case NS_THEME_SLIDER_TICK:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
// case NS_THEME_WINDOW:
// case NS_THEME_DIALOG:
// case NS_THEME_MENU:
// case NS_THEME_MENUBAR:
return PR_TRUE;
}
@ -551,10 +607,10 @@ nsNativeThemeGTK::WidgetIsContainer(PRUint8 aWidgetType)
void
nsNativeThemeGTK::SetupWidgetPrototype(GtkWidget* widget)
{
if (!mProtoWindow) {
mProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
if (!gProtoWindow) {
gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
mProtoLayout = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(mProtoWindow), mProtoLayout);
gtk_container_add(GTK_CONTAINER(gProtoWindow), mProtoLayout);
}
gtk_container_add(GTK_CONTAINER(mProtoLayout), widget);
@ -640,3 +696,12 @@ nsNativeThemeGTK::EnsureTooltipWidget()
}
}
void
nsNativeThemeGTK::EnsureFrameWidget()
{
if (!gFrameWidget) {
gFrameWidget = gtk_frame_new(NULL);
SetupWidgetPrototype(gFrameWidget);
}
}

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

@ -97,6 +97,7 @@ protected:
void EnsureArrowWidget();
void EnsureHandleBoxWidget();
void EnsureTooltipWidget();
void EnsureFrameWidget();
private:
nsCOMPtr<nsIAtom> mCheckedAtom;
@ -107,6 +108,5 @@ private:
nsCOMPtr<nsIAtom> mInputAtom;
nsCOMPtr<nsIAtom> mFocusedAtom;
GtkWidget* mProtoWindow;
GtkWidget* mProtoLayout;
};

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

@ -111,6 +111,10 @@ void
moz_gtk_tooltip_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect);
void
moz_gtk_frame_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* cliprect);
#ifdef __cplusplus
}
#endif /* __cplusplus */

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

@ -64,11 +64,12 @@ GtkWidget* gDropdownButonWidget;
GtkWidget* gArrowWidget;
GtkWidget* gDropdownButtonWidget;
GtkWidget* gHandleBoxWidget;
GtkWidget* gFrameWidget;
GtkWidget* gProtoWindow;
GtkTooltips* gTooltipWidget;
nsNativeThemeGTK::nsNativeThemeGTK()
: mProtoWindow(nsnull),
mProtoLayout(nsnull)
: mProtoLayout(nsnull)
{
NS_INIT_ISUPPORTS();
mDisabledAtom = do_GetAtom("disabled");
@ -81,8 +82,8 @@ nsNativeThemeGTK::nsNativeThemeGTK()
nsNativeThemeGTK::~nsNativeThemeGTK() {
// This will destroy all of our widgets
if (mProtoWindow)
gtk_widget_destroy(mProtoWindow);
if (gProtoWindow)
gtk_widget_destroy(gProtoWindow);
if (gTooltipWidget)
gtk_object_unref(GTK_OBJECT(gTooltipWidget));
}
@ -266,6 +267,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
{
EnsureScrollbarWidget();
EnsureArrowWidget();
GtkArrowType arrowType = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
moz_gtk_scrollbar_button_paint(window, gScrollbarWidget->style,
&gdk_rect, &gdk_clip, &state, arrowType);
@ -318,16 +320,23 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
&gdk_clip, &state,
(aWidgetType == NS_THEME_RADIO_CONTAINER));
break;
case NS_THEME_TOOLBOX:
EnsureHandleBoxWidget();
moz_gtk_toolbar_paint(window, gHandleBoxWidget->style, &gdk_rect,
&gdk_clip);
break;
case NS_THEME_TOOLTIP:
EnsureTooltipWidget();
moz_gtk_tooltip_paint(window, gTooltipWidget->tip_window->style, &gdk_rect,
&gdk_clip);
break;
case NS_THEME_STATUSBAR_PANEL:
EnsureFrameWidget();
moz_gtk_frame_paint(window, gFrameWidget->style, &gdk_rect, &gdk_clip);
break;
}
return NS_OK;
@ -378,6 +387,10 @@ nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
case NS_THEME_RADIO_CONTAINER:
aResult->top = aResult->bottom = aResult->left = aResult->right = 1;
break;
case NS_THEME_STATUSBAR_PANEL:
EnsureFrameWidget();
WidgetBorderToMargin(gFrameWidget, aResult);
break;
}
return NS_OK;
@ -511,26 +524,69 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
{
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_RADIO:
case NS_THEME_CHECKBOX:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_TOOLBOX:
// case NS_THEME_TOOLBAR: (not in skin)
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
// case NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN:
// case NS_THEME_TOOLBAR_SEPARATOR:
case NS_THEME_TOOLBAR_GRIPPER:
case NS_THEME_STATUSBAR:
case NS_THEME_STATUSBAR_PANEL:
// case NS_THEME_RESIZER:
// case NS_THEME_LISTBOX:
// case NS_THEME_LISTBOX_LISTITEM:
// case NS_THEME_TREEVIEW:
// case NS_THEME_TREEVIEW_TREEITEM:
// case NS_THEME_TREEVIEW_TWISTY:
// case NS_THEME_TREEVIEW_LINE:
// case NS_THEME_TREEVIEW_HEADER:
// case NS_THEME_TREEVIEW_HEADER_CELL:
// case NS_THEME_TREEVIEW_HEADER_SORTARROW:
// case NS_THEME_TREEVIEW_TWISTY_OPEN:
// case NS_THEME_PROGRESSBAR:
// case NS_THEME_PROGRESSBAR_CHUNK:
// case NS_THEME_PROGRESSBAR_VERTICAL:
// case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
// case NS_THEME_TAB:
// case NS_THEME_TAB_PANEL:
// case NS_THEME_TAB_LEFT_EDGE:
// case NS_THEME_TAB_RIGHT_EDGE:
// case NS_THEME_TAB_PANELS:
case NS_THEME_TOOLTIP:
// case NS_THEME_SPINNER:
// case NS_THEME_SPINNER_UP_BUTTON:
// case NS_THEME_SPINNER_DOWN_BUTTON:
// case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
case NS_THEME_TOOLBAR_GRIPPER:
case NS_THEME_RADIO:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
// case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL:
// case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL:
case NS_THEME_TEXTFIELD:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_TEXTFIELD_CARET:
// case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_TOOLBOX:
case NS_THEME_TOOLTIP:
// case NS_THEME_DROPDOWN_TEXT:
case NS_THEME_DROPDOWN_TEXTFIELD:
// case NS_THEME_SLIDER:
// case NS_THEME_SLIDER_THUMB:
// case NS_THEME_SLIDER_THUMB_START:
// case NS_THEME_SLIDER_THUMB_END:
// case NS_THEME_SLIDER_TICK:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
// case NS_THEME_WINDOW:
// case NS_THEME_DIALOG:
// case NS_THEME_MENU:
// case NS_THEME_MENUBAR:
return PR_TRUE;
}
@ -551,10 +607,10 @@ nsNativeThemeGTK::WidgetIsContainer(PRUint8 aWidgetType)
void
nsNativeThemeGTK::SetupWidgetPrototype(GtkWidget* widget)
{
if (!mProtoWindow) {
mProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
if (!gProtoWindow) {
gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
mProtoLayout = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(mProtoWindow), mProtoLayout);
gtk_container_add(GTK_CONTAINER(gProtoWindow), mProtoLayout);
}
gtk_container_add(GTK_CONTAINER(mProtoLayout), widget);
@ -640,3 +696,12 @@ nsNativeThemeGTK::EnsureTooltipWidget()
}
}
void
nsNativeThemeGTK::EnsureFrameWidget()
{
if (!gFrameWidget) {
gFrameWidget = gtk_frame_new(NULL);
SetupWidgetPrototype(gFrameWidget);
}
}

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

@ -97,6 +97,7 @@ protected:
void EnsureArrowWidget();
void EnsureHandleBoxWidget();
void EnsureTooltipWidget();
void EnsureFrameWidget();
private:
nsCOMPtr<nsIAtom> mCheckedAtom;
@ -107,6 +108,5 @@ private:
nsCOMPtr<nsIAtom> mInputAtom;
nsCOMPtr<nsIAtom> mFocusedAtom;
GtkWidget* mProtoWindow;
GtkWidget* mProtoLayout;
};