Added size hints to dialog,

Corrected client data "code" for wxChoice,


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-10-19 10:51:48 +00:00
parent bcdfb2cf30
commit d6538e2c55
7 changed files with 112 additions and 133 deletions

View File

@@ -92,8 +92,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
m_clientList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() );
gtk_menu_append( GTK_MENU(menu), item );
@@ -145,18 +144,17 @@ int wxChoice::DoAppend( const wxString &item )
gtk_widget_show( menu_item );
m_clientDataList.Append( (wxObject*) NULL );
m_clientObjectList.Append( (wxObject*) NULL );
m_clientList.Append( (wxObject*) NULL );
// return the index of the item in the control
return GetCount();
return GetCount() - 1;
}
void wxChoice::DoSetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientList.Nth( n );
wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientData") );
node->SetData( (wxObject*) clientData );
@@ -166,7 +164,7 @@ void* wxChoice::DoGetClientData( int n ) const
{
wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") );
wxNode *node = m_clientDataList.Nth( n );
wxNode *node = m_clientList.Nth( n );
wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetClientData") );
return node->Data();
@@ -176,7 +174,7 @@ void wxChoice::DoSetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
wxNode *node = m_clientObjectList.Nth( n );
wxNode *node = m_clientList.Nth( n );
wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetClientObject") );
wxClientData *cd = (wxClientData*) node->Data();
@@ -189,7 +187,7 @@ wxClientData* wxChoice::DoGetClientObject( int n ) const
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid combobox") );
wxNode *node = m_clientObjectList.Nth( n );
wxNode *node = m_clientList.Nth( n );
wxCHECK_MSG( node, (wxClientData *)NULL,
wxT("invalid index in wxChoice::DoGetClientObject") );
@@ -204,16 +202,17 @@ void wxChoice::Clear()
GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientObjectList.First();
while (node)
if (m_clientDataItemsType == ClientData_Object)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
wxNode *node = m_clientList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
}
m_clientObjectList.Clear();
m_clientDataList.Clear();
m_clientList.Clear();
}
void wxChoice::Delete( int WXUNUSED(n) )

View File

@@ -118,50 +118,11 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
if (g_isIdle)
wxapp_install_idle_handler();
/* I haven''t been able to set the position of
/* I haven't been able to set the position of
the dialog before it is shown, so I set the
position in "realize" and "map" */
position in "realize" */
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
/* set size hints */
gint flag = GDK_HINT_POS;
if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE;
if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE;
if (flag)
{
gdk_window_set_hints( win->m_widget->window,
win->m_x, win->m_y,
win->GetMinWidth(), win->GetMinHeight(),
win->GetMaxWidth(), win->GetMaxHeight(),
flag );
}
/* reset the icon */
if (win->m_icon != wxNullIcon)
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
win->SetIcon( icon );
}
return FALSE;
}
//-----------------------------------------------------------------------------
// "map" from m_widget
//-----------------------------------------------------------------------------
static gint
gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
/* I haven''t been able to set the position of
the dialog before it is shown, so I set the
position in "realize" and "map" */
gtk_widget_set_uposition( widget, win->m_x, win->m_y );
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_BORDER;
@@ -198,6 +159,27 @@ gtk_dialog_map_callback( GtkWidget *widget, wxDialog *win )
else
gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
/* set size hints */
gint flag = GDK_HINT_POS;
if ((win->GetMinWidth() != -1) || (win->GetMinHeight() != -1)) flag |= GDK_HINT_MIN_SIZE;
if ((win->GetMaxWidth() != -1) || (win->GetMaxHeight() != -1)) flag |= GDK_HINT_MAX_SIZE;
if (flag)
{
gdk_window_set_hints( win->m_widget->window,
win->m_x, win->m_y,
win->GetMinWidth(), win->GetMinHeight(),
win->GetMaxWidth(), win->GetMaxHeight(),
flag );
}
/* reset the icon */
if (win->m_icon != wxNullIcon)
{
wxIcon icon( win->m_icon );
win->m_icon = wxNullIcon;
win->SetIcon( icon );
}
return FALSE;
}
@@ -304,11 +286,6 @@ bool wxDialog::Create( wxWindow *parent,
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
/* we set the position of the window after the map event. setting it
before has no effect (with KWM) */
gtk_signal_connect( GTK_OBJECT(m_widget), "map",
GTK_SIGNAL_FUNC(gtk_dialog_map_callback), (gpointer) this );
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );