Added background colour again

Added wxTextCtrl methods
  Removed Imlib

  -> Recompile


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-10-27 15:04:35 +00:00
parent b926666447
commit a81258bee4
82 changed files with 720 additions and 13159 deletions

View File

@@ -112,24 +112,28 @@ void wxButton::SetFont( const wxFont &font )
wxControl::SetFont( font );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
}
void wxButton::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( m_widget, m_widgetStyle );
}
void wxButton::SetForegroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid button" );
wxControl::SetForegroundColour( colour );
if (!m_foregroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
}

View File

@@ -119,23 +119,17 @@ void wxCheckBox::SetFont( const wxFont &font )
wxControl::SetFont( font );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
}
void wxCheckBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid checkbox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( m_widget, m_widgetStyle );
}

View File

@@ -102,18 +102,10 @@ void wxChoice::Append( const wxString &item )
gtk_widget_realize( menu_item );
gtk_widget_realize( GTK_BIN(menu_item)->child );
if (m_hasOwnStyle)
if (m_widgetStyle)
{
GtkBin *bin = GTK_BIN( menu_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_WIDGET( bin ),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( menu_item, m_widgetStyle );
gtk_widget_set_style( GTK_BIN(menu_item)->child, m_widgetStyle );
}
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
@@ -282,9 +274,7 @@ void wxChoice::SetFont( const wxFont &font )
if (bin->child) label = bin->child;
if (!label) label = GTK_BUTTON(m_widget)->child;
gtk_widget_set_style( label,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( label, GetWidgetStyle() );
child = child->next;
}
@@ -292,24 +282,21 @@ void wxChoice::SetFont( const wxFont &font )
void wxChoice::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid choice" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
gtk_widget_set_style( GTK_WIDGET( menu_shell ), gtk_style_ref( style ) );
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
GList *child = menu_shell->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET( child->data ), gtk_style_ref( style ) );
gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
child = child->next;
}
}

View File

@@ -135,15 +135,10 @@ void wxComboBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_hasOwnStyle)
if (m_widgetStyle)
{
GtkBin *bin = GTK_BIN( list_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_WIDGET(bin),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( list_item, m_widgetStyle );
gtk_widget_set_style( GTK_BIN( list_item )->child, m_widgetStyle );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -449,21 +444,16 @@ void wxComboBox::SetFont( const wxFont &font )
wxWindow::SetFont( font );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
gtk_widget_set_style( entry,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = GTK_LIST(list)->children;
GList *child = list->children;
while (child)
{
GtkBin *bin = (GtkBin*) child->data;
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( bin->child, m_widgetStyle );
child = child->next;
}
@@ -482,34 +472,23 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
void wxComboBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
m_backgroundColour = colour;
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
}
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
// gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( m_widget, style );
gtk_widget_set_style( GTK_COMBO(m_widget)->button, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->list, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
GList *child = GTK_LIST( GTK_COMBO(m_widget)->list )->children;
while (child)
{
GtkWidget *item = GTK_WIDGET(child->data);
gtk_widget_set_style( item, gtk_style_ref( style ) );
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
child = child->next;
}
}

View File

@@ -2,7 +2,7 @@
// Name: dialog.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: dnd.cpp
// Purpose: wxDropTarget class
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: filedlg.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: font.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: frame.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: gauge.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,8 +2,6 @@
// Name: gdiobj.cpp
// Purpose: wxGDIObject class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence

View File

@@ -2,9 +2,8 @@
// Name: icon.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -141,12 +141,10 @@ void wxListBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_hasOwnStyle)
if (m_widgetStyle)
{
GtkBin *bin = GTK_BIN( list_item );
gtk_widget_set_style( bin->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( list_item, m_widgetStyle );
gtk_widget_set_style( GTK_BIN( list_item )->child, m_widgetStyle );
}
gtk_signal_connect( GTK_OBJECT(list_item), "select",
@@ -473,9 +471,7 @@ void wxListBox::SetFont( const wxFont &font )
GList *child = m_list->children;
while (child)
{
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
child = child->next;
}
@@ -483,30 +479,24 @@ void wxListBox::SetFont( const wxFont &font )
void wxListBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxControl::SetBackgroundColour( colour );
return;
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_WIDGET(m_list),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
// gtk_widget_set_style( GTK_WIDGET(m_list), m_widgetStyle );
GdkWindow *window = GTK_WIDGET(m_list)->window;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
GList *child = m_list->children;
while (child)
{
gtk_widget_set_style( GTK_WIDGET(child->data),
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BIN(child->data)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
// gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
child = child->next;
}

View File

@@ -2,9 +2,8 @@
// Name: mdi.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: menu.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,7 +2,7 @@
// Name: notebook.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -150,6 +150,8 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
int wxNotebook::GetSelection() const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid notebook" );
if (m_pages.Number() == 0) return -1;
GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page;
@@ -182,6 +184,8 @@ int wxNotebook::GetRowCount() const
wxString wxNotebook::GetPageText( int page ) const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid notebook" );
wxNotebookPage* nb_page = GetNotebookPage(page);
if (nb_page)
return nb_page->m_text;
@@ -191,6 +195,8 @@ wxString wxNotebook::GetPageText( int page ) const
int wxNotebook::GetPageImage( int page ) const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid notebook" );
wxNotebookPage* nb_page = GetNotebookPage(page);
if (nb_page)
return nb_page->m_image;
@@ -200,6 +206,8 @@ int wxNotebook::GetPageImage( int page ) const
wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
{
wxCHECK_MSG( m_widget != NULL, (wxNotebookPage*)NULL, "invalid notebook" );
wxNotebookPage *nb_page = (wxNotebookPage *) NULL;
wxNode *node = m_pages.First();
@@ -218,6 +226,8 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
int wxNotebook::SetSelection( int page )
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid notebook" );
int selOld = GetSelection();
wxNotebookPage* nb_page = GetNotebookPage(page);
@@ -241,6 +251,8 @@ int wxNotebook::SetSelection( int page )
void wxNotebook::AdvanceSelection( bool bForward )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
int sel = GetSelection();
int max = GetPageCount();
@@ -257,6 +269,8 @@ void wxNotebook::SetImageList( wxImageList* imageList )
bool wxNotebook::SetPageText( int page, const wxString &text )
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
wxNotebookPage* nb_page = GetNotebookPage(page);
if (!nb_page) return FALSE;
@@ -289,6 +303,8 @@ void wxNotebook::SetPadding( const wxSize &WXUNUSED(padding) )
bool wxNotebook::DeleteAllPages()
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
wxNode *page_node = m_pages.First();
while (page_node)
{
@@ -331,6 +347,8 @@ bool wxNotebook::DeletePage( int page )
bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
bool bSelect, int imageId)
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
// we've created the notebook page in AddChild(). Now we just have to set
// the caption for the page and set the others parameters.
@@ -384,6 +402,8 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
wxWindow *wxNotebook::GetPage( int page ) const
{
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
wxNotebookPage* nb_page = GetNotebookPage(page);
if (!nb_page)
return (wxWindow *) NULL;
@@ -393,6 +413,8 @@ wxWindow *wxNotebook::GetPage( int page ) const
void wxNotebook::AddChild( wxWindow *win )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
@@ -434,6 +456,26 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
return TRUE;
}
void wxNotebook::SetFont( const wxFont &font )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
wxControl::SetFont( font );
gtk_widget_set_style( m_widget, m_widgetStyle );
}
void wxNotebook::SetBackgroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid notebook" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( m_widget, m_widgetStyle );
}
//-----------------------------------------------------------------------------
// wxNotebookEvent
//-----------------------------------------------------------------------------

View File

@@ -2,9 +2,8 @@
// Name: pen.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -397,14 +397,14 @@ void wxRadioBox::SetFont( const wxFont &font )
wxControl::SetFont( font );
gtk_widget_set_style( m_widget, m_widgetStyle );
wxNode *node = m_boxes.First();
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( button->child, m_widgetStyle );
node = node->Next();
}
@@ -412,22 +412,20 @@ void wxRadioBox::SetFont( const wxFont &font )
void wxRadioBox::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( m_widget, m_widgetStyle );
wxNode *node = m_boxes.First();
while (node)
{
GtkWidget *button = GTK_WIDGET( node->Data() );
gtk_widget_set_style( button,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( button, m_widgetStyle );
node = node->Next();
}

View File

@@ -106,23 +106,17 @@ void wxRadioButton::SetFont( const wxFont &font )
wxControl::SetFont( font );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
}
void wxRadioButton::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_widget != NULL, "invalid radiobutton" );
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
gtk_widget_set_style( GTK_BUTTON(m_widget)->child,
gtk_style_ref(
gtk_widget_get_style( m_widget ) ) );
gtk_widget_set_style( m_widget, m_widgetStyle );
}

View File

@@ -2,9 +2,8 @@
// Name: statbmp.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: statbox.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,9 +2,8 @@
// Name: stattext.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -3,7 +3,7 @@
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -15,6 +15,10 @@
#include "wx/utils.h"
#include <wx/intl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
//-----------------------------------------------------------------------------
// "changed"
//-----------------------------------------------------------------------------
@@ -152,11 +156,15 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
wxString wxTextCtrl::GetValue() const
{
wxCHECK_MSG( m_text != NULL, "", "invalid text ctrl" );
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
tmp = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
tmp = text;
g_free( text );
}
else
{
@@ -201,45 +209,189 @@ void wxTextCtrl::WriteText( const wxString &text )
}
}
bool wxTextCtrl::LoadFile( const wxString &WXUNUSED(file) )
bool wxTextCtrl::LoadFile( const wxString &file )
{
wxFAIL_MSG( "wxTextCtrl::LoadFile not implemented" );
wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" );
if (!wxFileExists(file)) return FALSE;
Clear();
FILE *fp = NULL;
struct stat statb;
if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
!(fp = fopen ((char*) (const char*) file, "r")))
{
return FALSE;
}
else
{
gint len = statb.st_size;
char *text;
if (!(text = (char*)malloc ((unsigned) (len + 1))))
{
fclose (fp);
return FALSE;
}
if (fread (text, sizeof (char), len, fp) != (size_t) len)
{
}
fclose (fp);
text[len] = 0;
if (m_windowStyle & wxTE_MULTILINE)
{
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len );
}
else
{
gtk_entry_set_text( GTK_ENTRY(m_text), text );
}
free (text);
m_modified = FALSE;
return TRUE;
}
return FALSE;
}
bool wxTextCtrl::SaveFile( const wxString &WXUNUSED(file) )
bool wxTextCtrl::SaveFile( const wxString &file )
{
wxFAIL_MSG( "wxTextCtrl::SaveFile not implemented" );
wxCHECK_MSG( m_text != NULL, FALSE, "invalid text ctrl" );
if (file == "") return FALSE;
FILE *fp;
return FALSE;
if (!(fp = fopen ((char*) (const char*) file, "w")))
{
return FALSE;
}
else
{
char *text = NULL;
gint len = 0;
if (m_windowStyle & wxTE_MULTILINE)
{
len = gtk_text_get_length( GTK_TEXT(m_text) );
text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
}
else
{
text = gtk_entry_get_text( GTK_ENTRY(m_text) );
}
if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
{
// Did not write whole file
}
// Make sure newline terminates the file
if (text[len - 1] != '\n')
fputc ('\n', fp);
fclose (fp);
if (m_windowStyle & wxTE_MULTILINE) g_free( text );
m_modified = FALSE;
return TRUE;
}
return TRUE;
}
/*
wxString wxTextCtrl::GetLineText( long lineNo ) const
{
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
if (text)
{
wxString buf("");
long i;
int currentLine = 0;
for (i = 0; currentLine != lineNo && text[i]; i++ )
if (text[i] == '\n')
currentLine++;
// Now get the text
int j;
for (j = 0; text[i] && text[i] != '\n'; i++, j++ )
buf += text[i];
g_free( text );
return buf;
}
else
return wxEmptyString;
}
else
{
if (lineNo == 0) return GetValue();
return wxEmptyString;
}
}
void wxTextCtrl::OnDropFiles( wxDropFilesEvent &event )
void wxTextCtrl::OnDropFiles( wxDropFilesEvent &WXUNUSED(event) )
{
wxFAIL_MSG( "wxTextCtrl::GetLineText( lineNo ) not implemented" );
}
long wxTextCtrl::PositionToXY( long pos, long *x, long *y ) const
long wxTextCtrl::PositionToXY( long WXUNUSED(pos), long *WXUNUSED(x), long *WXUNUSED(y) ) const
{
wxFAIL_MSG( "wxTextCtrl::XYToPosition not implemented" );
return 0;
}
long wxTextCtrl::XYToPosition( long x, long y )
long wxTextCtrl::XYToPosition( long WXUNUSED(x), long WXUNUSED(y) ) const
{
wxFAIL_MSG( "wxTextCtrl::XYToPosition not implemented" );
return 0;
}
int wxTextCtrl::GetNumberOfLines()
int wxTextCtrl::GetLineLength(long lineNo) const
{
wxString str = GetLineText (lineNo);
return (int) str.Length();
}
int wxTextCtrl::GetNumberOfLines() const
{
if (m_windowStyle & wxTE_MULTILINE)
{
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
if (text)
{
int currentLine = 0;
for (int i = 0; i < len; i++ )
if (text[i] == '\n')
currentLine++;
g_free( text );
return currentLine;
}
else
return 0;
}
else
{
return 1;
}
}
*/
void wxTextCtrl::SetInsertionPoint( long pos )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
int tmp = (int) pos;
if (m_windowStyle & wxTE_MULTILINE)
gtk_text_set_point( GTK_TEXT(m_text), tmp );
@@ -469,31 +621,17 @@ void wxTextCtrl::SetFont( const wxFont &font )
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
wxControl::SetFont( font );
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( m_text, style );
// doesn't work
}
void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
{
return;
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
m_backgroundColour = colour;
wxControl::SetBackgroundColour( colour );
if (!m_backgroundColour.Ok()) return;
if (m_windowStyle & wxTE_MULTILINE)
@@ -505,18 +643,7 @@ void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
}
else
{
GtkStyle *style = gtk_widget_get_style( m_text );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( gtk_widget_get_style( m_text ) );
}
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_text->window ) );
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_text, style );
gtk_widget_set_style( m_text, m_widgetStyle );
}
}

View File

@@ -2,7 +2,7 @@
// Name: timer.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -2,8 +2,7 @@
// Name: utils.cpp
// Purpose:
// Author: Robert Roebling
// Created: 01/02/97
// Id:
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////

View File

@@ -138,7 +138,7 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
if (gdk_event->count > 0) return;
/*
printf( "OnExpose from " );
printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
@@ -912,8 +912,8 @@ wxWindow::wxWindow()
m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
}
bool wxWindow::Create( wxWindow *parent, wxWindowID id,
@@ -1032,6 +1032,8 @@ wxWindow::~wxWindow()
DestroyChildren();
if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
if (m_scrollGC) gdk_gc_unref( m_scrollGC );
if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
@@ -1112,8 +1114,8 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
}
void wxWindow::PostCreation()
@@ -1964,18 +1966,16 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
}
else
{
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( style );
}
GtkStyle *style = GetWidgetStyle();
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
gtk_widget_set_style( m_widget, style );
style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
}
}
@@ -1986,7 +1986,28 @@ wxColour wxWindow::GetForegroundColour() const
void wxWindow::SetForegroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid window" );
m_foregroundColour = colour;
if (!m_foregroundColour.Ok()) return;
if (!m_wxwindow)
{
GtkStyle *style = GetWidgetStyle();
m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
}
}
GtkStyle *wxWindow::GetWidgetStyle()
{
if (!m_widgetStyle)
m_widgetStyle =
gtk_style_copy(
gtk_widget_get_style( m_widget ) );
return m_widgetStyle;
}
bool wxWindow::Validate()
@@ -2149,17 +2170,9 @@ void wxWindow::SetFont( const wxFont &font )
else
m_font = *wxSWISS_FONT;
GtkStyle *style = gtk_widget_get_style( m_widget );
if (!m_hasOwnStyle)
{
m_hasOwnStyle = TRUE;
style = gtk_style_copy( style );
}
GtkStyle *style = GetWidgetStyle();
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( m_widget, style );
}
wxFont *wxWindow::GetFont()