Applied patch for multiple file selection, documented.

Fixed some compilation warnings,
  Minor change to OpenGL code.
  Documented wxImageHandler::GetImageCount() and related.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-12-01 14:08:42 +00:00
parent fb073f86d2
commit 7941ba111c
22 changed files with 244 additions and 124 deletions

View File

@ -26,7 +26,7 @@ If path is ``", the current directory will be used. If filename is ``",
no default filename will be supplied. The wildcard determines what files
are displayed in the file selector, and file extension supplies a type
extension for the required filename. Flags may be a combination of wxOPEN,
wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0.
wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxMULTIPLE or 0.
Both the X and Windows versions implement a wildcard filter. Typing a
filename containing wildcards (*, ?) in the filename text item, and

View File

@ -481,7 +481,7 @@ If path is empty, the current directory will be used. If filename is empty,
no default filename will be supplied. The wildcard determines what files
are displayed in the file selector, and file extension supplies a type
extension for the required filename. Flags may be a combination of wxOPEN,
wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0.
wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxMULTIPLE or 0.
Both the Unix and Windows versions implement a wildcard filter. Typing a
filename containing wildcards (*, ?) in the filename text item, and

View File

@ -625,6 +625,20 @@ Gets the name of this handler.
Gets the file extension associated with this handler.
\membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
\func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
If the image file contains more than one image and the image handler is capable
of retrieving these individually, this function will return the number of
available images.
\docparam{stream}{Opened input stream for reading image file.}
\wxheading{Return value}
Number of available images. For most image handles, this defaults to 1.
\membersection{wxImageHandler::GetType}
\constfunc{long}{GetType}{\void}
@ -639,16 +653,21 @@ Gets the MIME type associated with this handler.
\membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}}
\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=TRUE}, \param{int}{ index=0}}
Loads a image from a stream, putting the resulting data into {\it image}.
Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
more than one image and the image handler is capable of retrieving these individually, {\it index}
indicates which image to read from the stream.
\wxheading{Parameters}
\docparam{image}{The image object which is to be affected by this operation.}
\docparam{stream}{Opened input stream.
The meaning of {\it stream} is determined by the {\it type} parameter.}
\docparam{stream}{Opened input stream for reading images.}
\docparam{verbose}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.}
\docparam{index}{The index of the image in the file (starting from zero).}
\wxheading{Return value}
@ -670,7 +689,7 @@ Saves a image in the output stream.
\docparam{image}{The image object which is to be affected by this operation.}
\docparam{stream}{A stream. The meaning of {\it stream} is determined by the {\it type} parameter.}
\docparam{stream}{An opened stream for writing images.}
\wxheading{Return value}

View File

@ -154,7 +154,11 @@ public:
wxString GetFilename() const { return m_fileName; }
wxString GetWildcard() const { return m_wildCard; }
long GetStyle() const { return m_dialogStyle; }
int GetFilterIndex() const { return m_filterIndex ; }
int GetFilterIndex() const { return m_filterIndex; }
// for multiple file selection
void GetPaths(wxArrayString& paths) const;
void GetFilenames(wxArrayString& files) const;
void OnSelected( wxListEvent &event );
void OnActivated( wxListEvent &event );
@ -195,7 +199,8 @@ enum
wxSAVE = 2,
wxOVERWRITE_PROMPT = 4,
wxHIDE_READONLY = 8,
wxFILE_MUST_EXIST = 16
wxFILE_MUST_EXIST = 16,
wxMULTIPLE = 32
};
// File selector - backward compatibility

View File

@ -5,7 +5,7 @@
; First, some wxWindows documentation files:
;
0 wx.html ;wxWindows: Help index; additional keywords like overview
1 wx34.htm#classref ; wxWindows Class References
1 wxwin.htm ; wxWindows Class References
2 wx204.htm#functions ; wxWindows Function References; methods
;
; Some doc++ generated files:

View File

@ -574,6 +574,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
m_message = message;
m_dialogStyle = style;
if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
m_dialogStyle &= ~wxMULTIPLE;
m_dir = defaultDir;
if (m_dir.IsEmpty())
{
@ -657,8 +661,12 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
staticsizer->Add( m_static, 1 );
mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, wxSize(440,180),
wxLC_LIST | wxSUNKEN_BORDER | wxLC_SINGLE_SEL );
if (m_dialogStyle & wxMULTIPLE)
m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition,
wxSize(440,180), wxLC_LIST | wxSUNKEN_BORDER );
else
m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition,
wxSize(440,180), wxLC_LIST | wxSUNKEN_BORDER | wxLC_SINGLE_SEL );
mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
@ -890,6 +898,44 @@ void wxFileDialog::SetPath( const wxString& path )
}
}
void wxFileDialog::GetPaths( wxArrayString& paths ) const
{
paths.Empty();
paths.Alloc( m_list->GetSelectedItemCount() );
wxString dir;
m_list->GetDir( dir );
if (dir != wxT("/")) dir += wxT("/");
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT;
item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
while ( item.m_itemId != -1 ) {
m_list->GetItem( item );
paths.Add( dir + item.m_text );
item.m_itemId = m_list->GetNextItem( item.m_itemId + 1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
}
}
void wxFileDialog::GetFilenames(wxArrayString& files) const
{
files.Empty();
files.Alloc( m_list->GetSelectedItemCount() );
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT;
item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
while ( item.m_itemId != -1 ) {
m_list->GetItem( item );
files.Add( item.m_text );
item.m_itemId = m_list->GetNextItem( item.m_itemId + 1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
}
}
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------

View File

@ -226,12 +226,25 @@ void wxapp_install_idle_handler()
{
wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
/* this routine gets called by all event handlers
indicating that the idle is over. */
/* This routine gets called by all event handlers
indicating that the idle is over. It may also
get called from other thread for sending events
to the main thread (and processing these in
idle time). */
#if wxUSE_THREADS
if (!wxThread::IsMain())
GDK_THREADS_ENTER ();
#endif
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
g_isIdle = FALSE;
#if wxUSE_THREADS
if (!wxThread::IsMain())
GDK_THREADS_LEAVE ();
#endif
}
#if wxUSE_THREADS

View File

@ -204,7 +204,7 @@ size_t wxFileDataObject::GetDataSize() const
return res + 1;
}
bool wxFileDataObject::SetData(size_t size, const void *buf)
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
// VZ: old format
#if 0

View File

@ -188,7 +188,7 @@ wxFont::wxFont( const wxString& fontname, const wxFontData& fontdata )
tmp = tn.GetNextToken(); // pointsize
long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10);
M_FONTDATA->m_pointSize = num / 10;
M_FONTDATA->m_pointSize = (int)(num / 10);
tn.GetNextToken(); // x-res
tn.GetNextToken(); // y-res

View File

@ -48,7 +48,7 @@ extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
static void
gtk_mdi_page_change_callback( GtkNotebook *widget,
gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page,
gint WXUNUSED(page_num),
wxMDIParentFrame *parent )

View File

@ -179,7 +179,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
GDK_BUTTON1_MOTION_MASK),
(GdkWindow *) NULL,
(GdkCursor *) NULL,
GDK_CURRENT_TIME );
(unsigned int) GDK_CURRENT_TIME );
win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y;

View File

@ -201,7 +201,7 @@ gtk_pizza_new ()
return GTK_WIDGET (pizza);
}
void
static void
gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
GtkAdjustment *hadj,
GtkAdjustment *vadj)

View File

@ -226,12 +226,25 @@ void wxapp_install_idle_handler()
{
wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
/* this routine gets called by all event handlers
indicating that the idle is over. */
/* This routine gets called by all event handlers
indicating that the idle is over. It may also
get called from other thread for sending events
to the main thread (and processing these in
idle time). */
#if wxUSE_THREADS
if (!wxThread::IsMain())
GDK_THREADS_ENTER ();
#endif
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
g_isIdle = FALSE;
#if wxUSE_THREADS
if (!wxThread::IsMain())
GDK_THREADS_LEAVE ();
#endif
}
#if wxUSE_THREADS

View File

@ -204,7 +204,7 @@ size_t wxFileDataObject::GetDataSize() const
return res + 1;
}
bool wxFileDataObject::SetData(size_t size, const void *buf)
bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
{
// VZ: old format
#if 0

View File

@ -188,7 +188,7 @@ wxFont::wxFont( const wxString& fontname, const wxFontData& fontdata )
tmp = tn.GetNextToken(); // pointsize
long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10);
M_FONTDATA->m_pointSize = num / 10;
M_FONTDATA->m_pointSize = (int)(num / 10);
tn.GetNextToken(); // x-res
tn.GetNextToken(); // y-res

View File

@ -48,7 +48,7 @@ extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
static void
gtk_mdi_page_change_callback( GtkNotebook *widget,
gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page,
gint WXUNUSED(page_num),
wxMDIParentFrame *parent )

View File

@ -179,7 +179,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
GDK_BUTTON1_MOTION_MASK),
(GdkWindow *) NULL,
(GdkCursor *) NULL,
GDK_CURRENT_TIME );
(unsigned int) GDK_CURRENT_TIME );
win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y;

View File

@ -201,7 +201,7 @@ gtk_pizza_new ()
return GTK_WIDGET (pizza);
}
void
static void
gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
GtkAdjustment *hadj,
GtkAdjustment *vadj)

View File

@ -154,6 +154,26 @@ gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
return FALSE;
}
//-----------------------------------------------------------------------------
// "map" from m_wxwindow
//-----------------------------------------------------------------------------
static gint
gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
{
if (win->m_glContext/* && win->m_exposed*/)
{
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->m_exposed = FALSE;
win->GetUpdateRegion().Clear();
}
return FALSE;
}
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
@ -314,6 +334,9 @@ bool wxGLCanvas::Create( wxWindow *parent,
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map",
GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );

View File

@ -12,12 +12,10 @@
# on your system.
#
CC = g++
CC = gcc
cube: cube.o glcanvas.o
$(CC) -o cube \
cube.o glcanvas.o \
`wx-config --libs` -lMesaGL -lMesaGLU
$(CC) -o cube cube.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU
cube.o: cube.cpp
$(CC) `wx-config --cflags` -I../../gtk -c cube.cpp

View File

@ -76,6 +76,7 @@ void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
/*------------------------------------------------------------------
Dialog for defining a keypress
-------------------------------------------------------------------*/
class ScanCodeDialog : public wxDialog
{
public:
@ -85,16 +86,8 @@ public:
private:
ScanCodeCtrl *m_ScanCode;
wxTextCtrl *m_Description;
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( ScanCodeDialog, wxDialog )
//
END_EVENT_TABLE()
/* ---------------------------------------------------------------- */
ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id,
const int code, const wxString &descr, const wxString& title )
: wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
@ -172,46 +165,49 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxGLCanvas(parent, NULL, id, pos, size, style, name )
{
m_init = FALSE;
m_gllist = 0;
m_rleft = WXK_LEFT;
m_rright = WXK_RIGHT;
m_init = FALSE;
m_gllist = 0;
m_rleft = WXK_LEFT;
m_rright = WXK_RIGHT;
}
TestGLCanvas::TestGLCanvas(wxWindow *parent, const TestGLCanvas &other,
wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
const wxString& name ) :
wxGLCanvas(parent, other.GetContext(), id, pos, size, style, name )
{
m_init = FALSE;
m_gllist = other.m_gllist; /* share display list */
m_rleft = WXK_LEFT;
m_rright = WXK_RIGHT;
m_init = FALSE;
m_gllist = other.m_gllist; /* share display list */
m_rleft = WXK_LEFT;
m_rright = WXK_RIGHT;
}
TestGLCanvas::~TestGLCanvas(void)
TestGLCanvas::~TestGLCanvas()
{
}
void TestGLCanvas::Render( void )
void TestGLCanvas::Render()
{
wxPaintDC dc(this);
wxPaintDC dc(this);
#ifndef __WXMOTIF__
if (!GetContext()) return;
if (!GetContext()) return;
#endif
SetCurrent();
/* init OpenGL once, but after SetCurrent */
if (!m_init)
{
InitGL();
m_init = TRUE;
}
/* clear color and depth buffers */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetCurrent();
/* init OpenGL once, but after SetCurrent */
if (!m_init)
{
InitGL();
m_init = TRUE;
}
/* clear color and depth buffers */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if( m_gllist == 0 )
{
m_gllist = glGenLists( 1 );
printf( "List=%d\n", m_gllist );
glNewList( m_gllist, GL_COMPILE_AND_EXECUTE );
/* draw six faces of a cube */
glBegin(GL_QUADS);
@ -251,26 +247,26 @@ void TestGLCanvas::Render( void )
void TestGLCanvas::OnEnterWindow( wxMouseEvent& event )
{
SetFocus();
SetFocus();
}
void TestGLCanvas::OnPaint( wxPaintEvent& event )
{
Render();
Render();
}
void TestGLCanvas::OnSize(wxSizeEvent& event)
{
int width, height;
GetClientSize(& width, & height);
int width, height;
GetClientSize(& width, & height);
#ifndef __WXMOTIF__
if (GetContext())
if (GetContext())
#endif
{
SetCurrent();
glViewport(0, 0, width, height);
}
{
SetCurrent();
glViewport(0, 0, width, height);
}
}
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
@ -278,25 +274,25 @@ void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
// Do nothing, to avoid flashing.
}
void TestGLCanvas::InitGL(void)
void TestGLCanvas::InitGL()
{
SetCurrent();
SetCurrent();
/* set viewing projection */
glMatrixMode(GL_PROJECTION);
glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
/* set viewing projection */
glMatrixMode(GL_PROJECTION);
glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
/* position viewer */
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0F, 0.0F, -2.0F);
/* position viewer */
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0F, 0.0F, -2.0F);
/* position object */
glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
/* position object */
glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
GLfloat TestGLCanvas::CalcRotateSpeed( unsigned long acceltime )
@ -314,65 +310,74 @@ GLfloat TestGLCanvas::CalcRotateSpeed( unsigned long acceltime )
return(v);
}
GLfloat TestGLCanvas::CalcRotateAngle( unsigned long lasttime,
unsigned long acceltime )
{
GLfloat t,s1,s2;
GLfloat t,s1,s2;
t = ((GLfloat)(acceltime - lasttime)) / 1000.0f;
s1 = CalcRotateSpeed( lasttime );
s2 = CalcRotateSpeed( acceltime );
return( t * (s1 + s2) * 135.0f );
t = ((GLfloat)(acceltime - lasttime)) / 1000.0f;
s1 = CalcRotateSpeed( lasttime );
s2 = CalcRotateSpeed( acceltime );
return( t * (s1 + s2) * 135.0f );
}
void TestGLCanvas::Action( long code, unsigned long lasttime,
unsigned long acceltime )
{
GLfloat angle = CalcRotateAngle( lasttime, acceltime );
GLfloat angle = CalcRotateAngle( lasttime, acceltime );
if( code == m_rleft ) Rotate( angle );
else if( code == m_rright ) Rotate( -angle );
if (code == m_rleft)
Rotate( angle );
else if (code == m_rright)
Rotate( -angle );
}
void TestGLCanvas::OnKeyDown( wxKeyEvent& event )
{
long evkey = event.KeyCode();
if( evkey == 0 ) return;
long evkey = event.KeyCode();
if (evkey == 0) return;
if( !m_TimeInitialized )
{
m_TimeInitialized = 1;
m_xsynct = event.m_timeStamp;
m_gsynct = wxStopWatch(&m_secbase);
if (!m_TimeInitialized)
{
m_TimeInitialized = 1;
m_xsynct = event.m_timeStamp;
m_gsynct = wxStopWatch(&m_secbase);
m_Key = evkey;
m_StartTime = 0;
m_LastTime = 0;
m_LastRedraw = 0;
}
m_Key = evkey;
m_StartTime = 0;
m_LastTime = 0;
m_LastRedraw = 0;
}
unsigned long currTime = event.m_timeStamp - m_xsynct;
unsigned long currTime = event.m_timeStamp - m_xsynct;
if( evkey != m_Key )
{
m_Key = evkey;
m_LastRedraw = m_StartTime = m_LastTime = currTime;
}
if (evkey != m_Key)
{
m_Key = evkey;
m_LastRedraw = m_StartTime = m_LastTime = currTime;
}
if( currTime >= m_LastRedraw ) // Redraw:
{
Action( m_Key, m_LastTime-m_StartTime, currTime-m_StartTime );
if (currTime >= m_LastRedraw) // Redraw:
{
Action( m_Key, m_LastTime-m_StartTime, currTime-m_StartTime );
m_LastRedraw = wxStopWatch(&m_secbase) - m_gsynct;
m_LastTime = currTime;
}
m_LastRedraw = wxStopWatch(&m_secbase) - m_gsynct;
m_LastTime = currTime;
}
event.Skip();
}
void TestGLCanvas::OnKeyUp( wxKeyEvent& event )
{
m_Key = 0;
m_StartTime = 0;
m_LastTime = 0;
m_LastRedraw = 0;
m_Key = 0;
m_StartTime = 0;
m_LastTime = 0;
m_LastRedraw = 0;
event.Skip();
}
void TestGLCanvas::Rotate( GLfloat deg )

View File

@ -12,16 +12,14 @@
# on your system.
#
CPP = g++
CPP = gcc
CC = gcc
Penguin: penguin.o trackball.o lw.o glcanvas.o
$(CPP) -o Penguin \
penguin.o trackball.o lw.o glcanvas.o \
`wx-config --libs` -lMesaGL -lMesaGLU
$(CPP) -o Penguin penguin.o trackball.o lw.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU
penguin.o: penguin.cpp
$(CPP) `wx-config --cflags` -g -I../../gtk -c penguin.cpp
$(CPP) `wx-config --cflags` -I../../gtk -c penguin.cpp
lw.o: lw.cpp
$(CPP) `wx-config --cflags` -I../../gtk -c lw.cpp