wxFont& operator = ( const wxFont& font );
bool operator == ( const wxFont& font );
bool operator != ( const wxFont& font );
- bool Ok();
+ bool Ok() const;
int GetPointSize(void) const;
wxString GetFaceName(void) const;
wxFont& operator = ( const wxFont& font );
bool operator == ( const wxFont& font );
bool operator != ( const wxFont& font );
- bool Ok();
+ bool Ok() const;
int GetPointSize(void) const;
wxString GetFaceName(void) const;
SetValidator( validator );
- wxControl::SetLabel( label );
-
m_widget = gtk_check_button_new_with_label( m_label );
wxSize newSize = size;
PostCreation();
+ SetLabel( label );
+
Show( TRUE );
return TRUE;
// local data
//-----------------------------------------------------------------------------
-static char *wx_font_family [] = {
- "wxDEFAULT", "wxDECORATIVE", "wxROMAN", "wxSCRIPT",
- "wxSWISS", "wxMODERN", "wxTELETYPE",
-};
-
-/*
-static char *wx_font_style [] = {
- "wxDEFAULT", "wxNORMAL", "wxSLANT", "wxITALIC",
-};
-
-static char *wx_font_weight [] = {
- "wxDEFAULT", "wxNORMAL", "wxBOLD", "wxLIGHT",
-};
-*/
-
extern wxFontNameDirectory *wxTheFontNameDirectory;
//-----------------------------------------------------------------------------
wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER)
{
m_byXFontName = FALSE;
- m_pointSize = -1;
- m_family = -1;
- m_style = -1;
- m_weight = -1;
+ m_pointSize = 12;
+ m_family = wxSWISS;
+ m_style = wxNORMAL;
+ m_weight = wxNORMAL;
m_underlined = FALSE;
m_fontId = 0;
m_faceName = (char *) NULL;
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
+ if (Style == wxDEFAULT) Style = wxSWISS;
M_FONTDATA->m_style = Style;
+ if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
+ if (PointSize == wxDEFAULT) PointSize = 10;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
return m_refData != font.m_refData;
}
-bool wxFont::Ok()
+bool wxFont::Ok() const
{
- return (m_refData != NULL);
+ if (!m_refData)
+ {
+ wxFAIL_MSG( "invalid font" );
+ return FALSE;
+ }
+ else
+ return TRUE;
}
int wxFont::GetPointSize(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_pointSize;
}
wxString wxFont::GetFaceString(void) const
{
+ if (!Ok()) return "";
+
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
}
wxString wxFont::GetFaceName(void) const
{
+ if (!Ok()) return "";
+
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
}
int wxFont::GetFamily(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_family;
}
wxString wxFont::GetFamilyString(void) const
{
- wxString s = wx_font_family[M_FONTDATA->m_family - wxDEFAULT];
- return s;
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_family)
+ {
+ case wxDECORATIVE: return wxString("wxDECORATIVE");
+ case wxROMAN: return wxString("wxROMAN");
+ case wxSCRIPT: return wxString("wxSCRIPT");
+ case wxSWISS: return wxString("wxSWISS");
+ case wxMODERN: return wxString("wxMODERN");
+ case wxTELETYPE: return wxString("wxTELETYPE");
+ default: return "wxDEFAULT";
+ }
+
+ return "wxDEFAULT";
}
int wxFont::GetFontId(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_fontId; // stub
}
int wxFont::GetStyle(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_style;
}
wxString wxFont::GetStyleString(void) const
{
- switch (M_FONTDATA->m_style)
- {
- case wxNORMAL:
- {
- return wxString("wxNORMAL");
- }
- case wxSLANT:
- {
- return wxString("wxSLANT");
- }
- case wxITALIC:
- {
- return wxString("wxITALIC");
- }
- case wxDEFAULT:
- default:
- {
- return wxString("wxDEFAULT");
- }
- }
- return wxString("wxDEFAULT");
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_style)
+ {
+ case wxNORMAL: return wxString("wxNORMAL");
+ case wxSLANT: return wxString("wxSLANT");
+ case wxITALIC: return wxString("wxITALIC");
+ default: return wxString("wxDEFAULT");
+ }
+
+ return wxString("wxDEFAULT");
}
int wxFont::GetWeight(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_weight;
}
wxString wxFont::GetWeightString(void) const
{
- switch (M_FONTDATA->m_weight)
- {
- case wxNORMAL:
- {
- return wxString("wxNORMAL");
- }
- case wxBOLD:
- {
- return wxString("wxBOLD");
- }
- case wxLIGHT:
- {
- return wxString("wxLIGHT");
- }
- case wxDEFAULT:
- default:
- {
- return wxString("wxDEFAULT");
- }
- }
- return wxString("wxDEFAULT");
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_weight)
+ {
+ case wxNORMAL: return wxString("wxNORMAL");
+ case wxBOLD: return wxString("wxBOLD");
+ case wxLIGHT: return wxString("wxLIGHT");
+ default: return wxString("wxDEFAULT");
+ }
+
+ return wxString("wxDEFAULT");
}
bool wxFont::GetUnderlined(void) const
{
+ if (!Ok()) return FALSE;
+
return M_FONTDATA->m_underlined;
}
m_list = GTK_LIST( gtk_list_new() );
- GtkSelectionMode mode = GTK_SELECTION_SINGLE;
+ GtkSelectionMode mode = GTK_SELECTION_BROWSE;
if (style & wxLB_MULTIPLE)
mode = GTK_SELECTION_MULTIPLE;
else if (style & wxLB_EXTENDED)
gtk_container_add (GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
gtk_widget_show( GTK_WIDGET(m_list) );
+ wxSize newSize = size;
+ if (newSize.x == -1) newSize.x = 100;
+ if (newSize.y == -1) newSize.y = 110;
+ SetSize( newSize.x, newSize.y );
+
for (int i = 0; i < n; i++)
{
GtkWidget *list_item;
int wxListBox::GetSelection(void) const
{
- GList *selection = m_list->selection;
- if (selection)
+ GList *child = m_list->children;
+ int count = 0;
+ while (child)
{
- GList *child = m_list->children;
- int count = 0;
- while (child)
- {
- if (child->data == selection->data) return count;
- count++;
- child = child->next;
- }
+ if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
+ count++;
+ child = child->next;
}
- // No, I think it's reasonable to return -1 to indicate
- // there is no selection. -- JACS
-// wxFAIL_MSG("wrong listbox index");
return -1;
}
// user and home routines
//------------------------------------------------------------------------
-char* wxGetHomeDir( char *dest )
+const char* wxGetHomeDir( wxString *home )
{
- wxString tmp = wxGetUserHome( wxString() );
- if (tmp.IsNull())
- strcpy( wxBuffer, "/" );
- else
- strcpy( wxBuffer, tmp );
- if (dest) strcpy( dest, WXSTRINGCAST tmp );
- return wxBuffer;
+ *home = wxGetUserHome( wxString() );
+ if (home->IsNull()) *home = "/";
+ return *home;
};
char *wxGetUserHome( const wxString &user )
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
+wxWindow *g_captureWindow = (wxWindow*)NULL;
//-----------------------------------------------------------------------------
// "expose_event" (of m_wxwindow, not of m_widget)
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
+
if (!win->HasVMT()) return TRUE;
if (widget->window)
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
- if (!win->HasVMT()) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
+ if (!win->HasVMT()) return TRUE;
+
if (widget->window)
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME );
+ g_captureWindow = this;
}
void wxWindow::ReleaseMouse(void)
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
+ g_captureWindow = (wxWindow*) NULL;;
}
void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
SetValidator( validator );
- wxControl::SetLabel( label );
-
m_widget = gtk_check_button_new_with_label( m_label );
wxSize newSize = size;
PostCreation();
+ SetLabel( label );
+
Show( TRUE );
return TRUE;
// local data
//-----------------------------------------------------------------------------
-static char *wx_font_family [] = {
- "wxDEFAULT", "wxDECORATIVE", "wxROMAN", "wxSCRIPT",
- "wxSWISS", "wxMODERN", "wxTELETYPE",
-};
-
-/*
-static char *wx_font_style [] = {
- "wxDEFAULT", "wxNORMAL", "wxSLANT", "wxITALIC",
-};
-
-static char *wx_font_weight [] = {
- "wxDEFAULT", "wxNORMAL", "wxBOLD", "wxLIGHT",
-};
-*/
-
extern wxFontNameDirectory *wxTheFontNameDirectory;
//-----------------------------------------------------------------------------
wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER)
{
m_byXFontName = FALSE;
- m_pointSize = -1;
- m_family = -1;
- m_style = -1;
- m_weight = -1;
+ m_pointSize = 12;
+ m_family = wxSWISS;
+ m_style = wxNORMAL;
+ m_weight = wxNORMAL;
m_underlined = FALSE;
m_fontId = 0;
m_faceName = (char *) NULL;
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
+ if (Style == wxDEFAULT) Style = wxSWISS;
M_FONTDATA->m_style = Style;
+ if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
+ if (PointSize == wxDEFAULT) PointSize = 10;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
return m_refData != font.m_refData;
}
-bool wxFont::Ok()
+bool wxFont::Ok() const
{
- return (m_refData != NULL);
+ if (!m_refData)
+ {
+ wxFAIL_MSG( "invalid font" );
+ return FALSE;
+ }
+ else
+ return TRUE;
}
int wxFont::GetPointSize(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_pointSize;
}
wxString wxFont::GetFaceString(void) const
{
+ if (!Ok()) return "";
+
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
}
wxString wxFont::GetFaceName(void) const
{
+ if (!Ok()) return "";
+
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
}
int wxFont::GetFamily(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_family;
}
wxString wxFont::GetFamilyString(void) const
{
- wxString s = wx_font_family[M_FONTDATA->m_family - wxDEFAULT];
- return s;
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_family)
+ {
+ case wxDECORATIVE: return wxString("wxDECORATIVE");
+ case wxROMAN: return wxString("wxROMAN");
+ case wxSCRIPT: return wxString("wxSCRIPT");
+ case wxSWISS: return wxString("wxSWISS");
+ case wxMODERN: return wxString("wxMODERN");
+ case wxTELETYPE: return wxString("wxTELETYPE");
+ default: return "wxDEFAULT";
+ }
+
+ return "wxDEFAULT";
}
int wxFont::GetFontId(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_fontId; // stub
}
int wxFont::GetStyle(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_style;
}
wxString wxFont::GetStyleString(void) const
{
- switch (M_FONTDATA->m_style)
- {
- case wxNORMAL:
- {
- return wxString("wxNORMAL");
- }
- case wxSLANT:
- {
- return wxString("wxSLANT");
- }
- case wxITALIC:
- {
- return wxString("wxITALIC");
- }
- case wxDEFAULT:
- default:
- {
- return wxString("wxDEFAULT");
- }
- }
- return wxString("wxDEFAULT");
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_style)
+ {
+ case wxNORMAL: return wxString("wxNORMAL");
+ case wxSLANT: return wxString("wxSLANT");
+ case wxITALIC: return wxString("wxITALIC");
+ default: return wxString("wxDEFAULT");
+ }
+
+ return wxString("wxDEFAULT");
}
int wxFont::GetWeight(void) const
{
+ if (!Ok()) return 0;
+
return M_FONTDATA->m_weight;
}
wxString wxFont::GetWeightString(void) const
{
- switch (M_FONTDATA->m_weight)
- {
- case wxNORMAL:
- {
- return wxString("wxNORMAL");
- }
- case wxBOLD:
- {
- return wxString("wxBOLD");
- }
- case wxLIGHT:
- {
- return wxString("wxLIGHT");
- }
- case wxDEFAULT:
- default:
- {
- return wxString("wxDEFAULT");
- }
- }
- return wxString("wxDEFAULT");
+ if (!Ok()) return "wxDEFAULT";
+
+ switch (M_FONTDATA->m_weight)
+ {
+ case wxNORMAL: return wxString("wxNORMAL");
+ case wxBOLD: return wxString("wxBOLD");
+ case wxLIGHT: return wxString("wxLIGHT");
+ default: return wxString("wxDEFAULT");
+ }
+
+ return wxString("wxDEFAULT");
}
bool wxFont::GetUnderlined(void) const
{
+ if (!Ok()) return FALSE;
+
return M_FONTDATA->m_underlined;
}
m_list = GTK_LIST( gtk_list_new() );
- GtkSelectionMode mode = GTK_SELECTION_SINGLE;
+ GtkSelectionMode mode = GTK_SELECTION_BROWSE;
if (style & wxLB_MULTIPLE)
mode = GTK_SELECTION_MULTIPLE;
else if (style & wxLB_EXTENDED)
gtk_container_add (GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
gtk_widget_show( GTK_WIDGET(m_list) );
+ wxSize newSize = size;
+ if (newSize.x == -1) newSize.x = 100;
+ if (newSize.y == -1) newSize.y = 110;
+ SetSize( newSize.x, newSize.y );
+
for (int i = 0; i < n; i++)
{
GtkWidget *list_item;
int wxListBox::GetSelection(void) const
{
- GList *selection = m_list->selection;
- if (selection)
+ GList *child = m_list->children;
+ int count = 0;
+ while (child)
{
- GList *child = m_list->children;
- int count = 0;
- while (child)
- {
- if (child->data == selection->data) return count;
- count++;
- child = child->next;
- }
+ if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
+ count++;
+ child = child->next;
}
- // No, I think it's reasonable to return -1 to indicate
- // there is no selection. -- JACS
-// wxFAIL_MSG("wrong listbox index");
return -1;
}
// user and home routines
//------------------------------------------------------------------------
-char* wxGetHomeDir( char *dest )
+const char* wxGetHomeDir( wxString *home )
{
- wxString tmp = wxGetUserHome( wxString() );
- if (tmp.IsNull())
- strcpy( wxBuffer, "/" );
- else
- strcpy( wxBuffer, tmp );
- if (dest) strcpy( dest, WXSTRINGCAST tmp );
- return wxBuffer;
+ *home = wxGetUserHome( wxString() );
+ if (home->IsNull()) *home = "/";
+ return *home;
};
char *wxGetUserHome( const wxString &user )
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
+wxWindow *g_captureWindow = (wxWindow*)NULL;
//-----------------------------------------------------------------------------
// "expose_event" (of m_wxwindow, not of m_widget)
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return TRUE;
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
+
if (!win->HasVMT()) return TRUE;
if (widget->window)
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (widget->window != gdk_event->window) return TRUE;
- if (!win->HasVMT()) return TRUE;
+
+ if ((g_captureWindow) && (win != g_captureWindow)) return TRUE;
+
if (g_blockEventsOnDrag) return TRUE;
+ if (!win->HasVMT()) return TRUE;
+
if (widget->window)
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME );
+ g_captureWindow = this;
}
void wxWindow::ReleaseMouse(void)
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
+ g_captureWindow = (wxWindow*) NULL;;
}
void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
event.m_x = event.m_x + x;
event.m_y = event.m_y + y;
+
ProcessItemEvent(item, event, dragType);
}
void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle)
{
wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
-
+
+ if (dragItem) childHandler = (wxResourceEditorControlHandler *)dragItem->GetEventHandler();
+
long x, y;
event.Position(&x, &y);
int keys = 0;
strcat(buf, "\\dialoged.ini");
m_optionsResourceFilename = buf;
#elif defined(__WXGTK__)
- /*
- wxString buf;
- wxGetHomeDir(&buf);
- buf += "/.dialogedrc";
- m_optionsResourceFilename = buf;
- */
- m_optionsResourceFilename = ".dialoged.rc";
+ wxGetHomeDir( &m_optionsResourceFilename );
+ m_optionsResourceFilename += "/.dialogedrc";
#else
#error "Unsupported platform."
#endif