start fixing file selector, fix menus under apprunner, fix font setting for

widgets.
This commit is contained in:
pavlov%pavlov.net 1999-03-05 02:48:43 +00:00
Родитель d42daa439d
Коммит 90944754dd
5 изменённых файлов: 35 добавлений и 14 удалений

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

@ -79,9 +79,9 @@ PRBool nsFileWidget::Show()
gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked",
GTK_SIGNAL_FUNC(file_cancel_clicked),
&ret);
// start new loop. ret is set in the above callbacks.
gtk_main();
// returning true causes the browser to try and display the dir structure...
// return PR_TRUE;
return ret;
}
@ -148,9 +148,6 @@ NS_METHOD nsFileWidget::Create(nsIWidget *aParent,
mWidget = gtk_file_selection_new(title);
// mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0);
// mTitle.SetLength(0);
// mTitle.Append(aTitle);
return NS_OK;
}

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

@ -28,6 +28,7 @@
#include "nsFileWidget.h"
#include "nsGUIEvent.h"
#include "nsIMenuItem.h"
#include "nsIMenuListener.h"
#include "stdio.h"
@ -566,7 +567,10 @@ gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p)
void menu_item_activate_handler(GtkWidget *w, gpointer p)
{
g_print("menu selected\n");
nsIMenuItem * menuItem = (nsIMenuItem *)p;
nsIMenuListener *menuListener = nsnull;
nsIMenuItem *menuItem = (nsIMenuItem *)p;
if (menuItem != NULL) {
nsMenuEvent mevent;
mevent.message = NS_MENU_SELECTED;
@ -580,7 +584,14 @@ void menu_item_activate_handler(GtkWidget *w, gpointer p)
mevent.time = PR_IntervalNow();
nsEventStatus status;
mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
// FIXME - THIS SHOULD WORK. FIX EVENTS FOR XP CODE!!!!! (pav)
// mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
menuItem->QueryInterface(kIMenuListenerIID, (void**)&menuListener);
if(menuListener) {
menuListener->MenuSelected(mevent);
NS_IF_RELEASE(menuListener);
}
}
}

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

@ -77,6 +77,7 @@ nsMenuItem::nsMenuItem() : nsIMenuItem()
mMenuParent = nsnull;
mPopUpParent = nsnull;
mTarget = nsnull;
mXULCommandListener = nsnull;
mIsSeparator = PR_FALSE;
}
@ -298,6 +299,9 @@ NS_METHOD nsMenuItem::GetNativeData(void *& aData)
//-------------------------------------------------------------------------
NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener)
{
NS_IF_RELEASE(mXULCommandListener);
NS_IF_ADDREF(aMenuListener);
mXULCommandListener = aMenuListener;
return NS_OK;
}
@ -319,6 +323,9 @@ NS_METHOD nsMenuItem::IsSeparator(PRBool & aIsSep)
//-------------------------------------------------------------------------
nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent)
{
if(mXULCommandListener)
return mXULCommandListener->MenuSelected(aMenuEvent);
g_print("nsMenuItem::MenuSelected\n");
return nsEventStatus_eIgnore;
}

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

@ -76,6 +76,7 @@ protected:
nsIWidget *GetMenuBarParent(nsISupports * aParentSupports);
GtkWidget *GetNativeParent();
nsIMenuListener *mXULCommandListener;
nsString mLabel;
PRUint32 mCommand;
nsIMenu *mMenuParent;

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

@ -324,24 +324,31 @@ nsIFontMetrics *nsWidget::GetFont(void)
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetFont(const nsFont &aFont)
{
nsIFontMetrics* mFontMetrics;
mContext->GetMetricsFor(aFont, mFontMetrics);
if (mFontMetrics) {
nsFontHandle fontHandle;
mFontMetrics->GetFontHandle(fontHandle);
gtk_widget_ensure_style(mWidget);
GtkStyle* style;
style= gtk_widget_get_style(mWidget);
GtkStyle *style = gtk_style_copy(mWidget->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = (GdkFont *)fontHandle;
GdkFontPrivate *pvt;
pvt = (GdkFontPrivate*) style->font;
g_print("font refcount: %i\n",pvt->ref_count);
GdkFont *font = (GdkFont *)fontHandle;
style->font = font;
gdk_font_ref(style->font);
gtk_widget_set_style(mWidget, style);
gtk_style_unref(style);
}
NS_RELEASE(mFontMetrics);
return NS_OK;
@ -583,7 +590,6 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
gtk_widget_push_colormap(gdk_rgb_get_cmap());
gtk_widget_push_visual(gdk_rgb_get_visual());
gtk_widget_push_style(gtk_style_new());
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
@ -608,7 +614,6 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
gtk_widget_pop_colormap();
gtk_widget_pop_visual();
gtk_widget_pop_style ();
DispatchStandardEvent(NS_CREATE);
InitCallbacks();