*** empty log message ***

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 1999-10-14 04:43:46 +00:00
parent b5f788a51e
commit 37f214d588
25 changed files with 2221 additions and 726 deletions

View File

@ -12,12 +12,12 @@
#elif defined(__WXMAC__)
#include "wx/generic/colrdlgg.h"
#elif defined(__WXPM__)
#include "wx/generic/colrdlgg.h"
#include "wx/os2/colordlg.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/colrdlgg.h"
#endif
#ifndef __WXMSW__
#if defined(__WXMSW__)
#define wxColourDialog wxGenericColourDialog
#define sm_classwxColourDialog sm_classwxColourDialog
#endif

View File

@ -76,18 +76,14 @@ public:
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array
// Copy constructors
wxAcceleratorTable(const wxAcceleratorTable& accel)
{ Ref(accel); }
inline wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); }
inline wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); }
~wxAcceleratorTable();
wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
{ if ( *this != accel ) Ref(accel); return *this; }
bool operator == (const wxAcceleratorTable& accel) const
{ return m_refData == accel.m_refData; }
bool operator != (const wxAcceleratorTable& accel) const
{ return m_refData != accel.m_refData; }
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if ( *this != accel ) Ref(accel); return *this; }
inline bool operator == (const wxAcceleratorTable& accel) const { return m_refData == accel.m_refData; }
inline bool operator != (const wxAcceleratorTable& accel) const { return m_refData != accel.m_refData; }
bool Ok() const;
void SetHACCEL(WXHACCEL hAccel);

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpbuttn.h
// Purpose: wxBitmapButton class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBUTTN_H_
#define _WX_BMPBUTTN_H_
#ifdef __GNUG__
#pragma interface "bmpbuttn.h"
#endif
#include "wx/button.h"
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
@ -49,6 +45,10 @@ class WXDLLEXPORT wxBitmapButton: public wxButton
virtual void SetBitmapLabel(const wxBitmap& bitmap);
#if WXWIN_COMPATIBILITY
wxBitmap *GetBitmap() const { return (wxBitmap *) & m_buttonBitmap; }
#endif
inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; }
inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; }
inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; }
@ -62,13 +62,11 @@ class WXDLLEXPORT wxBitmapButton: public wxButton
inline int GetMarginX() { return m_marginX; }
inline int GetMarginY() { return m_marginY; }
/*
// TODO: Implementation
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
virtual void SetDefault();
// virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *item);
virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
*/
protected:
wxBitmap m_buttonBitmap;

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: brush.h
// Purpose: wxBrush class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_
#define _WX_BRUSH_H_
#ifdef __GNUG__
#pragma interface "brush.h"
#endif
#include "wx/gdicmn.h"
#include "wx/gdiobj.h"
#include "wx/bitmap.h"

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.h
// Purpose: wxCheckBox class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_
#define _WX_CHECKBOX_H_
#ifdef __GNUG__
#pragma interface "checkbox.h"
#endif
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxCheckBoxNameStr;
@ -42,11 +38,18 @@ class WXDLLEXPORT wxCheckBox: public wxControl
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual void SetValue(bool);
virtual bool GetValue() const ;
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual bool OS2Command(WXUINT param, WXWORD id);
virtual void SetLabel(const wxString& label);
virtual void Command(wxCommandEvent& event);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
protected:
virtual wxSize DoGetBestSize();
};
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
@ -72,9 +75,7 @@ class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual void SetValue(bool);
virtual bool GetValue() const ;
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void SetLabel(const wxBitmap& bitmap);
private:
virtual void SetLabel(const wxString& string)

View File

@ -2,26 +2,24 @@
// Name: checklst.h
// Purpose: wxCheckListBox class - a listbox with checkable items
// Note: this is an optional class.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKLST_H_
#define _WX_CHECKLST_H_
#ifdef __GNUG__
#pragma interface "checklst.h"
#endif
#include <stddef.h>
#include "wx/listbox.h"
#include "wx/setup.h"
typedef unsigned int size_t;
class wxCheckListBoxItem; // fwd decl, define in checklst.cpp
class wxCheckListBox : public wxListBox
class WXDLLEXPORT wxCheckListBox : public wxListBox
{
DECLARE_DYNAMIC_CLASS(wxCheckListBox)
public:
@ -36,9 +34,37 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
// override base class virtuals
virtual void Delete(int n);
virtual void InsertItems(int nItems, const wxString items[], int pos);
virtual bool SetFont( const wxFont &font );
// items may be checked
bool IsChecked(size_t uiIndex) const;
void Check(size_t uiIndex, bool bCheck = TRUE);
bool IsChecked(size_t uiIndex) const;
void Check(size_t uiIndex, bool bCheck = TRUE);
// accessors
size_t GetItemHeight() const { return m_nItemHeight; }
protected:
// we create our items ourselves and they have non-standard size,
// so we need to override these functions
virtual wxOwnerDrawn *CreateItem(size_t n);
// virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT *item);
// pressing space or clicking the check box toggles the item
void OnChar(wxKeyEvent& event);
void OnLeftClick(wxMouseEvent& event);
private:
size_t m_nItemHeight; // height of checklistbox items (the same for all)
//Virtual function hiding suppression, do not use
virtual wxControl *CreateItem(const wxItemResource* childResource,
const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL)
{ return(wxWindowBase::CreateItem(childResource, parentResource, table));};
DECLARE_EVENT_TABLE()
};

View File

@ -1,23 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choice.h
// Purpose: wxChoice class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_
#define _WX_CHOICE_H_
#ifdef __GNUG__
#pragma interface "choice.h"
#endif
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxChoiceNameStr;
// Choice item
@ -26,7 +20,7 @@ class WXDLLEXPORT wxChoice: public wxControl
DECLARE_DYNAMIC_CLASS(wxChoice)
public:
inline wxChoice() { m_noStrings = 0; }
inline wxChoice() { }
inline wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
@ -47,26 +41,42 @@ class WXDLLEXPORT wxChoice: public wxControl
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr);
virtual void Append(const wxString& item);
virtual int DoAppend(const wxString& item);
virtual void Delete(int n);
virtual void Clear();
virtual int GetCount() const;
virtual int GetSelection() const ;
virtual void SetSelection(int n);
virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const ;
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual wxString GetStringSelection() const ;
virtual bool SetStringSelection(const wxString& sel);
virtual inline int Number() const { return m_noStrings; }
virtual void Command(wxCommandEvent& event);
virtual inline void SetColumns(int WXUNUSED(n) = 1 ) { /* No effect */ } ;
virtual inline int GetColumns() const { return 1 ; };
// OS2 only
virtual bool OS2Command(WXUINT param, WXWORD id);
MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected:
int m_noStrings;
virtual void DoSetClientData( int n, void* clientData );
virtual void* DoGetClientData( int n ) const;
virtual void DoSetClientObject( int n, wxClientData* clientData );
virtual wxClientData* DoGetClientObject( int n ) const;
// OS2 implementation
virtual wxSize DoGetBestSize();
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private:
// Virtual function hiding supression
inline virtual void DoSetClientData( void *data )
{ wxWindowBase::DoSetClientData(data); }
inline virtual void DoSetClientObject( wxClientData *data )
{ wxWindowBase::DoSetClientObject(data); }
inline virtual wxClientData *DoGetClientObject() const
{ return(wxWindowBase::DoGetClientObject());}
inline virtual void *DoGetClientData() const
{ return(wxWindowBase::DoGetClientData());}
};
#endif
// _WX_CHOICE_H_
#endif // _WX_CHOICE_H_

View File

@ -4,101 +4,109 @@
// Note: this functionality is under review, and
// is derived from wxWindows 1.xx code. Please contact
// the wxWindows developers for further information.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_
#define _WX_CLIPBRD_H_
#ifdef __GNUG__
#pragma interface "clipbrd.h"
#endif
#include "wx/defs.h"
#include "wx/setup.h"
#if wxUSE_CLIPBOARD
#include "wx/list.h"
#include "wx/module.h"
#include "wx/dataobj.h" // for wxDataFormat
bool WXDLLEXPORT wxOpenClipboard();
bool WXDLLEXPORT wxClipboardOpen();
bool WXDLLEXPORT wxCloseClipboard();
bool WXDLLEXPORT wxEmptyClipboard();
bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat);
bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0);
wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL);
int WXDLLEXPORT wxEnumClipboardFormats(int dataFormat);
int WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount);
// These functions superceded by wxClipboard, but retained in order to
// implement wxClipboard, and for compatibility.
/* A clipboard client holds data belonging to the clipboard.
For plain text, a client is not necessary. */
class WXDLLEXPORT wxClipboardClient : public wxObject
{
DECLARE_ABSTRACT_CLASS(wxClipboardClient)
// open/close the clipboard
WXDLLEXPORT bool wxOpenClipboard();
WXDLLEXPORT bool wxIsClipboardOpened();
#define wxClipboardOpen wxIsClipboardOpened
WXDLLEXPORT bool wxCloseClipboard();
public:
/* This list should be filled in with strings indicating the formats
this client can provide. Almost all clients will provide "TEXT".
Format names should be 4 characters long, so things will work
out on the Macintosh */
wxStringList formats;
// get/set data
WXDLLEXPORT bool wxEmptyClipboard();
WXDLLEXPORT bool wxSetClipboardData(wxDataFormat dataFormat,
const void *data,
int width = 0, int height = 0);
WXDLLEXPORT void* wxGetClipboardData(wxDataFormat dataFormat,
long *len = NULL);
/* This method is called when the client is losing the selection. */
virtual void BeingReplaced() = 0;
// clipboard formats
WXDLLEXPORT bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
WXDLLEXPORT wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat);
WXDLLEXPORT int wxRegisterClipboardFormat(wxChar *formatName);
WXDLLEXPORT bool wxGetClipboardFormatName(wxDataFormat dataFormat,
wxChar *formatName,
int maxCount);
/* This method is called when someone wants the data this client is
supplying to the clipboard. "format" is a string indicating the
format of the data - one of the strings from the "formats"
list. "*size" should be filled with the size of the resulting
data. In the case of text, "*size" does not count the
NULL terminator. */
virtual char *GetData(char *format, long *size) = 0;
};
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
/* ONE instance of this class: */
class WXDLLEXPORT wxDataObject;
class WXDLLEXPORT wxClipboard : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxClipboard)
DECLARE_DYNAMIC_CLASS(wxClipboard)
public:
wxClipboardClient *clipOwner;
char *cbString, *sentString, *receivedString;
void *receivedTargets;
long receivedLength;
public:
wxClipboard();
~wxClipboard();
wxClipboard();
~wxClipboard();
// open the clipboard before SetData() and GetData()
virtual bool Open();
/* Set the clipboard data owner. "time" comes from the event record. */
void SetClipboardClient(wxClipboardClient *, long time);
// close the clipboard after SetData() and GetData()
virtual void Close();
/* Set the clipboard string; does not require a client. */
void SetClipboardString(char *, long time);
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
/* Get data from the clipboard in the format "TEXT". */
char *GetClipboardString(long time);
// add to the clipboard data.
virtual bool AddData( wxDataObject *data );
/* Get data from the clipboard */
char *GetClipboardData(char *format, long *length, long time);
// ask if data in correct format is available
virtual bool IsSupported( wxDataFormat format );
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject *data );
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
/// X11 has two clipboards which get selected by this call. Empty on MSW.
void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
/* Get the clipboard client directly. Will be NULL if clipboard data
is a string, or if some other application owns the clipboard.
This can be useful for shortcutting data translation, if the
clipboard user can check for a specific client. (This is used
by the wxMediaEdit class.) */
wxClipboardClient *GetClipboardClient();
};
/* Initialize wxTheClipboard. Can be called repeatedly */
void WXDLLEXPORT wxInitClipboard();
/* The clipboard */
// The global clipboard object
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
//-----------------------------------------------------------------------------
// wxClipboardModule: module responsible for initializing the global clipboard
// object
//-----------------------------------------------------------------------------
class wxClipboardModule : public wxModule
{
DECLARE_DYNAMIC_CLASS(wxClipboardModule)
public:
wxClipboardModule() { }
bool OnInit();
void OnExit();
};
#endif // wxUSE_CLIPBOARD
#endif
// _WX_CLIPBRD_H_

View File

@ -2,21 +2,17 @@
// Name: colordlg.h
// Purpose: wxColourDialog class. Use generic version if no
// platform-specific implementation.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLORDLG_H_
#define _WX_COLORDLG_H_
#ifdef __GNUG__
#pragma interface "colordlg.h"
#endif
#include "wx/setup.h"
#include "wx/dialog.h"
#include "wx/cmndata.h"

View File

@ -1,23 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colour.h
// Purpose: wxColour class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_
#define _WX_COLOUR_H_
#ifdef __GNUG__
#pragma interface "colour.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
// Colour
class WXDLLEXPORT wxColour: public wxObject
@ -66,8 +61,8 @@ public:
// comparison
bool operator == (const wxColour& colour) const
{
return (m_red == colour.m_red &&
m_green == colour.m_green &&
return (m_red == colour.m_red &&
m_green == colour.m_green &&
m_blue == colour.m_blue);
}
bool operator != (const wxColour& colour) const { return !(*this == colour); }
@ -85,10 +80,7 @@ private:
unsigned char m_green;
public:
/* TODO: implementation
WXCOLORREF m_pixel ;
*/
private:
DECLARE_DYNAMIC_CLASS(wxColour)
};

View File

@ -1,23 +1,21 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox.h
// Purpose: wxComboBox class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_
#define _WX_COMBOBOX_H_
#ifdef __GNUG__
#pragma interface "combobox.h"
#endif
#include "wx/choice.h"
#if wxUSE_COMBOBOX
WXDLLEXPORT_DATA(extern const char*) wxComboBoxNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
@ -50,35 +48,33 @@ class WXDLLEXPORT wxComboBox: public wxChoice
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
// List functions
virtual void Append(const wxString& item);
virtual void Delete(int n);
virtual void Clear();
virtual int GetSelection() const ;
virtual void SetSelection(int n);
virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const ;
virtual wxString GetStringSelection() const ;
virtual bool SetStringSelection(const wxString& sel);
virtual inline int Number() const { return m_noStrings; }
// Text field functions
virtual wxString GetValue() const ;
virtual void SetValue(const wxString& value);
// List functions: see wxChoice
// Clipboard operations
virtual void Copy();
virtual void Cut();
virtual void Paste();
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const ;
virtual long GetLastPosition() const ;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
wxString GetValue() const { return GetLabel(); }
virtual void SetValue(const wxString& value);
// Clipboard operations
virtual void Copy();
virtual void Cut();
virtual void Paste();
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const;
virtual long GetLastPosition() const;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
virtual bool OS2Command(WXUINT param, WXWORD id);
protected:
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
};
#endif // wxUSE_COMBOBOX
#endif
// _WX_COMBOBOX_H_

View File

@ -12,10 +12,6 @@
#ifndef _WX_CONTROL_H_
#define _WX_CONTROL_H_
#ifdef __GNUG__
#pragma interface "control.h"
#endif
// General item class
class WXDLLEXPORT wxControl : public wxControlBase
{

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.h
// Purpose: wxCursor class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CURSOR_H_
#define _WX_CURSOR_H_
#ifdef __GNUG__
#pragma interface "cursor.h"
#endif
#include "wx/bitmap.h"
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
@ -27,9 +23,8 @@ public:
~wxCursorRefData();
protected:
/* TODO: implementation
WXHCURSOR m_hCursor;
*/
bool m_destroyCursor;
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
@ -48,28 +43,22 @@ public:
wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
/* TODO: make default type suit platform */
wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_CUR_RESOURCE,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(int cursor_type);
~wxCursor();
// TODO: also verify the internal cursor handle
virtual bool Ok() const { return (m_refData != NULL) ; }
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
/* TODO: implementation
void SetHCURSOR(WXHCURSOR cursor);
inline WXHCURSOR GetHCURSOR() const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
*/
};
extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);
bool FreeResource(bool force = FALSE);
};
#endif
// _WX_CURSOR_H_

View File

@ -132,9 +132,9 @@ protected:
#endif
private:
//Virtual function hiding suppression, do not use
wxControl *CreateItem(const wxItemResource* childResource,
const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL)
virtual wxControl *CreateItem(const wxItemResource* childResource,
const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL)
{ return(wxWindowBase::CreateItem(childResource, parentResource, table));};
};

View File

@ -1,24 +1,30 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpbuttn.cpp
// Purpose: wxBitmapButton
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "bmpbuttn.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/bmpbuttn.h"
#endif
#include "wx/bmpbuttn.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
#endif
#define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1)
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size, long style,
@ -28,6 +34,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
m_buttonBitmap = bitmap;
SetName(name);
SetValidator(validator);
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ;
@ -36,6 +43,12 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
m_marginX = 0;
m_marginY = 0;
if ( style & wxBU_AUTODRAW )
{
m_marginX = wxDEFAULT_BUTTON_MARGIN;
m_marginY = wxDEFAULT_BUTTON_MARGIN;
}
int x = pos.x;
int y = pos.y;
int width = size.x;
@ -47,13 +60,32 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
m_windowId = id;
if ( width == -1 && bitmap.Ok())
width = bitmap.GetWidth() + 2*m_marginX;
width = bitmap.GetWidth() + 2*m_marginX;
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
height = bitmap.GetHeight() + 2*m_marginY;
/* TODO: create bitmap button
*/
// TODO:
/*
m_hWnd = (WXHWND)CreateWindowEx
(
0,
wxT("BUTTON"),
wxT(""),
WS_VISIBLE | WS_TABSTOP | WS_CHILD | BS_OWNERDRAW ,
0, 0, 0, 0,
GetWinHwnd(parent),
(HMENU)m_windowId,
wxGetInstance(),
NULL
);
*/
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
SetFont(parent->GetFont()) ;
SetSize(x, y, width, height);
return FALSE;
}
@ -63,3 +95,189 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
m_buttonBitmap = bitmap;
}
// TODO:
/*
bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
#if defined(__WIN95__)
long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE);
if (style & BS_BITMAP)
{
// Let default procedure draw the bitmap, which is defined
// in the Windows resource.
return FALSE;
}
#endif
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) item;
wxBitmap* bitmap = &m_buttonBitmap;
UINT state = lpDIS->itemState;
if ((state & ODS_SELECTED) && m_buttonBitmapSelected.Ok())
bitmap = &m_buttonBitmapSelected;
else if ((state & ODS_FOCUS) && m_buttonBitmapFocus.Ok())
bitmap = &m_buttonBitmapFocus;
else if ((state & ODS_DISABLED) && m_buttonBitmapDisabled.Ok())
bitmap = &m_buttonBitmapDisabled;
if ( !bitmap->Ok() )
return FALSE;
HDC hDC = lpDIS->hDC;
HDC memDC = ::CreateCompatibleDC(hDC);
HBITMAP old = (HBITMAP) ::SelectObject(memDC, (HBITMAP) bitmap->GetHBITMAP());
if (!old)
return FALSE;
int x = lpDIS->rcItem.left;
int y = lpDIS->rcItem.top;
int width = lpDIS->rcItem.right - x;
int height = lpDIS->rcItem.bottom - y;
// Draw the face, if auto-drawing
if ( GetWindowStyleFlag() & wxBU_AUTODRAW )
DrawFace((WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom,
((state & ODS_SELECTED) == ODS_SELECTED));
// Centre the bitmap in the control area
int x1 = (int) (x + ((width - bitmap->GetWidth()) / 2));
int y1 = (int) (y + ((height - bitmap->GetHeight()) / 2));
if ( (state & ODS_SELECTED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
{
x1 ++;
y1 ++;
}
::BitBlt(hDC, x1, y1, bitmap->GetWidth(), bitmap->GetHeight(), memDC, 0, 0, SRCCOPY);
if ( (state & ODS_DISABLED) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
DrawButtonDisable( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, TRUE ) ;
else if ( (state & ODS_FOCUS) && (GetWindowStyleFlag() & wxBU_AUTODRAW) )
DrawButtonFocus( (WXHDC) hDC, lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right, lpDIS->rcItem.bottom, ((state & ODS_SELECTED) == ODS_SELECTED));
::SelectObject(memDC, old);
::DeleteDC(memDC);
return TRUE;
}
*/
void wxBitmapButton::DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel )
{
// TODO:
/*
HPEN oldp;
HBRUSH oldb ;
HPEN penBorder;
HPEN penLight;
HPEN penShadow;
HBRUSH brushFace;
COLORREF ms_color;
ms_color = GetSysColor(COLOR_WINDOWFRAME) ;
penBorder = CreatePen(PS_SOLID,0,ms_color) ;
ms_color = GetSysColor(COLOR_BTNSHADOW) ;
penShadow = CreatePen(PS_SOLID,0,ms_color) ;
ms_color = GetSysColor(COLOR_BTNHIGHLIGHT) ;
penLight = CreatePen(PS_SOLID,0,ms_color) ;
ms_color = GetSysColor(COLOR_BTNFACE) ;
brushFace = CreateSolidBrush(ms_color) ;
oldp = (HPEN) SelectObject( (HDC) dc, GetStockObject( NULL_PEN ) ) ;
oldb = (HBRUSH) SelectObject( (HDC) dc, brushFace ) ;
Rectangle( (HDC) dc, left, top, right, bottom ) ;
SelectObject( (HDC) dc, penBorder) ;
MoveToEx((HDC) dc,left+1,top,NULL);LineTo((HDC) dc,right-1,top);
MoveToEx((HDC) dc,left,top+1,NULL);LineTo((HDC) dc,left,bottom-1);
MoveToEx((HDC) dc,left+1,bottom-1,NULL);LineTo((HDC) dc,right-1,bottom-1);
MoveToEx((HDC) dc,right-1,top+1,NULL);LineTo((HDC) dc,right-1,bottom-1);
SelectObject( (HDC) dc, penShadow) ;
if (sel)
{
MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
LineTo((HDC) dc, left+1 ,top+1) ;
LineTo((HDC) dc, right-2 ,top+1) ;
}
else
{
MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
LineTo((HDC) dc, right-2 ,bottom-2) ;
LineTo((HDC) dc, right-2 ,top) ;
MoveToEx((HDC) dc,left+2 ,bottom-3 ,NULL) ;
LineTo((HDC) dc, right-3 ,bottom-3) ;
LineTo((HDC) dc, right-3 ,top+1) ;
SelectObject( (HDC) dc, penLight) ;
MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
LineTo((HDC) dc, left+1 ,top+1) ;
LineTo((HDC) dc, right-2 ,top+1) ;
}
SelectObject((HDC) dc,oldp) ;
SelectObject((HDC) dc,oldb) ;
DeleteObject(penBorder);
DeleteObject(penLight);
DeleteObject(penShadow);
DeleteObject(brushFace);
*/
}
#define FOCUS_MARGIN 6
void wxBitmapButton::DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel )
{
// TODO:
/*
RECT rect;
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
InflateRect( &rect, - FOCUS_MARGIN, - FOCUS_MARGIN ) ;
if ( sel )
OffsetRect( &rect, 1, 1 ) ;
DrawFocusRect( (HDC) dc, &rect ) ;
*/
}
// extern HBRUSH wxDisableButtonBrush;
void wxBitmapButton::DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg )
{
// TODO:
/*
HBRUSH old = (HBRUSH) SelectObject( (HDC) dc, wxDisableButtonBrush ) ;
if ( with_marg )
::PatBlt( (HDC) dc, left + m_marginX, top + m_marginY,
right - 2 * m_marginX, bottom - 2 * m_marginY,
#ifdef __SALFORDC__
0xfa0089L ) ;
#else
0xfa0089UL ) ;
#endif
else ::PatBlt( (HDC) dc, left, top, right, bottom,
#ifdef __SALFORDC__
0xfa0089L ) ;
#else
0xfa0089UL ) ;
#endif
::SelectObject( (HDC) dc, old ) ;
*/
}
void wxBitmapButton::SetDefault()
{
wxButton::SetDefault();
}

View File

@ -1,21 +1,29 @@
/////////////////////////////////////////////////////////////////////////////
// Name: brush.cpp
// Purpose: wxBrush
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "brush.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/brush.h"
#endif
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/brush.h"
#include "wx/os2/private.h"
#include "assert.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
@ -24,17 +32,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
wxBrushRefData::wxBrushRefData()
{
m_style = wxSOLID;
// TODO: null data
m_hBrush = 0;
}
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
/* TODO: null data
m_hBrush = 0;
*/
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
m_hBrush = 0;
}
wxBrushRefData::~wxBrushRefData()
@ -61,6 +67,7 @@ wxBrush::wxBrush(const wxColour& col, int Style)
M_BRUSHDATA->m_colour = col;
M_BRUSHDATA->m_style = Style;
M_BRUSHDATA->m_hBrush = 0;
RealizeResource();
@ -74,6 +81,7 @@ wxBrush::wxBrush(const wxBitmap& stipple)
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_stipple = stipple;
M_BRUSHDATA->m_hBrush = 0;
RealizeResource();
@ -81,6 +89,117 @@ wxBrush::wxBrush(const wxBitmap& stipple)
wxTheBrushList->AddBrush(this);
}
bool wxBrush::RealizeResource(void)
{
// TODO:
/*
if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0))
{
if (M_BRUSHDATA->m_style==wxTRANSPARENT)
{
M_BRUSHDATA->m_hBrush = (WXHBRUSH) ::GetStockObject(NULL_BRUSH);
return TRUE;
}
COLORREF ms_colour = 0 ;
ms_colour = M_BRUSHDATA->m_colour.GetPixel() ;
switch (M_BRUSHDATA->m_style)
{
//
// Don't reset cbrush, wxTRANSPARENT is handled by wxBrush::SelectBrush()
// this could save (many) time if frequently switching from
// wxSOLID to wxTRANSPARENT, because Create... is not always called!!
//
// NB August 95: now create and select a Null brush instead.
// This could be optimized as above.
case wxTRANSPARENT:
M_BRUSHDATA->m_hBrush = NULL; // Must always select a suitable background brush
// - could choose white always for a quick solution
break;
//
case wxBDIAGONAL_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_BDIAGONAL,ms_colour) ;
break ;
case wxCROSSDIAG_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_DIAGCROSS,ms_colour) ;
break ;
case wxFDIAGONAL_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_FDIAGONAL,ms_colour) ;
break ;
case wxCROSS_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_CROSS,ms_colour) ;
break ;
case wxHORIZONTAL_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_HORIZONTAL,ms_colour) ;
break ;
case wxVERTICAL_HATCH:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_VERTICAL,ms_colour) ;
break ;
case wxSTIPPLE:
if (M_BRUSHDATA->m_stipple.Ok())
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreatePatternBrush((HBITMAP) M_BRUSHDATA->m_stipple.GetHBITMAP()) ;
else
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
break ;
case wxSOLID:
default:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
break;
}
#ifdef WXDEBUG_CREATE
if (M_BRUSHDATA->m_hBrush==NULL) wxError("Cannot create brush","Internal error") ;
#endif
return TRUE;
}
else
return FALSE;
*/
return FALSE;
}
WXHANDLE wxBrush::GetResourceHandle(void)
{
return (WXHANDLE) M_BRUSHDATA->m_hBrush;
}
bool wxBrush::FreeResource(bool WXUNUSED(force))
{
if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush != 0))
{
// TODO DeleteObject((HBRUSH) M_BRUSHDATA->m_hBrush);
M_BRUSHDATA->m_hBrush = 0;
return TRUE;
}
else return FALSE;
}
bool wxBrush::IsFree() const
{
return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
}
void wxBrush::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxBrush::SetColour(const wxColour& col)
{
@ -118,45 +237,3 @@ void wxBrush::SetStipple(const wxBitmap& Stipple)
RealizeResource();
}
bool wxBrush::RealizeResource()
{
// TODO: create the brush
return FALSE;
}
WXHANDLE wxBrush::GetResourceHandle(void)
{
return (WXHANDLE) M_BRUSHDATA->m_hBrush;
}
bool wxBrush::FreeResource(bool WXUNUSED(force))
{
if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush != 0))
{
// TODO DeleteObject((HBRUSH) M_BRUSHDATA->m_hBrush);
M_BRUSHDATA->m_hBrush = 0;
return TRUE;
}
else return FALSE;
}
bool wxBrush::IsFree() const
{
return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
}
void wxBrush::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
UnRef();
m_refData = ref;
}
}

View File

@ -81,7 +81,7 @@ wxSize wxButton::DoGetBestSize()
wBtn += 3*wChar;
// the button height is proportional to the height of the font used
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
int hBtn = 0;// TODO: BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
return wxSize(wBtn, hBtn);
}

View File

@ -1,25 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.cpp
// Purpose: wxCheckBox
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 04/01/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "checkbox.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/checkbox.h"
#include "wx/brush.h"
#endif
#include "wx/checkbox.h"
#include "wx/os2/private.h"
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
#endif
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxCheckBox
// ----------------------------------------------------------------------------
bool wxCheckBox::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
{
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId);
event.SetInt(GetValue());
event.SetEventObject(this);
ProcessCommand(event);
return TRUE;
}
// Single check box item
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos,
@ -29,17 +54,36 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
{
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
m_windowStyle = style;
if (parent) parent->AddChild(this);
wxString Label = label;
if (Label == wxT(""))
Label = wxT(" "); // Apparently needed or checkbox won't show
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
// TODO: create checkbox
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
SetFont(parent->GetFont());
SetSize(x, y, width, height);
return FALSE;
}
@ -48,9 +92,27 @@ void wxCheckBox::SetLabel(const wxString& label)
// TODO
}
void wxCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
wxSize wxCheckBox::DoGetBestSize()
{
// TODO
int wCheckbox, hCheckbox;
wxString str = wxGetWindowText(GetHWND());
if ( !str.IsEmpty() )
{
GetTextExtent(str, &wCheckbox, &hCheckbox);
wCheckbox += RADIO_SIZE;
if ( hCheckbox < RADIO_SIZE )
hCheckbox = RADIO_SIZE;
}
else
{
wCheckbox = RADIO_SIZE;
hCheckbox = RADIO_SIZE;
}
return wxSize(wCheckbox, hCheckbox);
}
void wxCheckBox::SetValue(bool val)
@ -58,19 +120,59 @@ void wxCheckBox::SetValue(bool val)
// TODO
}
#ifndef BST_CHECKED
#define BST_CHECKED 0x0001
#endif
bool wxCheckBox::GetValue() const
{
// TODO
return FALSE;
}
WXHBRUSH wxCheckBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
*/
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
void wxCheckBox::Command (wxCommandEvent & event)
{
SetValue ((event.GetInt() != 0));
ProcessCommand (event);
}
// Bitmap checkbox
// ----------------------------------------------------------------------------
// wxBitmapCheckBox
// ----------------------------------------------------------------------------
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
const wxPoint& pos,
const wxSize& size, long style,
@ -79,39 +181,42 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *l
{
SetName(name);
SetValidator(validator);
m_windowStyle = style;
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
m_windowStyle = style;
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: Create the bitmap checkbox
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
return FALSE;
checkWidth = -1 ;
checkHeight = -1 ;
long msStyle = CHECK_FLAGS;
HWND wx_button = 0; // TODO: Create the bitmap checkbox
m_hWnd = (WXHWND)wx_button;
// Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND)wx_button);
SetSize(x, y, width, height);
// TODO: ShowWindow(wx_button, SW_SHOW);
return TRUE;
}
void wxBitmapCheckBox::SetLabel(const wxBitmap& bitmap)
{
// TODO
wxFAIL_MSG(wxT("not implemented"));
}
void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
{
// TODO
}
void wxBitmapCheckBox::SetValue(bool val)
{
// TODO
}
bool wxBitmapCheckBox::GetValue() const
{
// TODOD
return FALSE;
}

View File

@ -1,11 +1,11 @@
///////////////////////////////////////////////////////////////////////////////
// Name: checklst.cpp
// Purpose: implementation of wxCheckListBox class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
@ -13,11 +13,32 @@
// headers & declarations
// ============================================================================
#ifdef __GNUG__
#pragma implementation "checklst.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/checklst.h"
#if wxUSE_OWNER_DRAWN
#include "wx/object.h"
#include "wx/colour.h"
#include "wx/font.h"
#include "wx/bitmap.h"
#include "wx/window.h"
#include "wx/listbox.h"
#include "wx/ownerdrw.h"
#include "wx/settings.h"
#include "wx/dcmemory.h"
#include "wx/os2/checklst.h"
#include "wx/log.h"
#define INCL_PM
#include <os2.h>
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// get item (converted to right type)
#define GetItem(n) ((wxCheckListBoxItem *)(GetItem(n)))
// ============================================================================
// implementation
@ -27,6 +48,194 @@
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
#endif
// ----------------------------------------------------------------------------
// declaration and implementation of wxCheckListBoxItem class
// ----------------------------------------------------------------------------
class wxCheckListBoxItem : public wxOwnerDrawn
{
friend class wxCheckListBox;
public:
// ctor
wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex);
// drawing functions
virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
// simple accessors
bool IsChecked() const { return m_bChecked; }
void Check(bool bCheck);
void Toggle() { Check(!IsChecked()); }
private:
bool m_bChecked;
wxCheckListBox *m_pParent;
size_t m_nIndex;
};
wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex)
: wxOwnerDrawn("", TRUE) // checkable
{
m_bChecked = FALSE;
m_pParent = pParent;
m_nIndex = nIndex;
// we don't initialize m_nCheckHeight/Width vars because it's
// done in OnMeasure while they are used only in OnDraw and we
// know that there will always be OnMeasure before OnDraw
// fix appearance
SetMarginWidth(GetDefaultMarginWidth());
}
/*
* JACS - I've got the owner-draw stuff partially working with WIN16,
* with a really horrible-looking cross for wxCheckListBox instead of a
* check - could use a bitmap check-mark instead, defined in wx.rc.
* Also there's a refresh problem whereby it doesn't always draw the
* check until you click to the right of it, which is OK for WIN32.
*/
bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
wxODAction act, wxODStatus stat)
{
if ( IsChecked() )
stat = (wxOwnerDrawn::wxODStatus)(stat | wxOwnerDrawn::wxODChecked);
// TODO:
/*
if ( wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) {
// ## using native API for performance and precision
size_t nCheckWidth = GetDefaultMarginWidth(),
nCheckHeight = m_pParent->GetItemHeight();
int x = rc.GetX(),
y = rc.GetY();
HDC hdc = (HDC)dc.GetHDC();
// create pens
HPEN hpenBack = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOW)),
hpenGray = CreatePen(PS_SOLID, 0, RGB(128, 128, 128)),
hpenPrev = (HPEN)SelectObject(hdc, hpenBack);
// we erase the 1-pixel border
Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight);
// shift check mark 1 pixel to the right (it looks better like this)
x++;
if ( IsChecked() ) {
// first create a monochrome bitmap in a memory DC
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmpCheck = CreateBitmap(nCheckWidth, nCheckHeight, 1, 1, 0);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmpCheck);
// then draw a check mark into it
RECT rect ;
rect.left = 0 ;
rect.top = 0 ;
rect.right = nCheckWidth ;
rect.bottom = nCheckHeight ;
#ifdef __WIN32__
#ifndef __SC__
DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
#endif
#else
// In WIN16, draw a cross
HPEN blackPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
HPEN whiteBrush = (HPEN)GetStockObject(WHITE_BRUSH);
HPEN hPenOld = (HPEN)::SelectObject(hdcMem, blackPen);
HPEN hBrushOld = (HPEN)::SelectObject(hdcMem, whiteBrush);
::SetROP2(hdcMem, R2_COPYPEN);
Rectangle(hdcMem, 0, 0, nCheckWidth, nCheckHeight);
MoveTo(hdcMem, 0, 0);
LineTo(hdcMem, nCheckWidth, nCheckHeight);
MoveTo(hdcMem, nCheckWidth, 0);
LineTo(hdcMem, 0, nCheckHeight);
::SelectObject(hdcMem, hPenOld);
::SelectObject(hdcMem, hBrushOld);
::DeleteObject(blackPen);
#endif
// finally copy it to screen DC and clean up
BitBlt(hdc, x, y, nCheckWidth - 1, nCheckHeight,
hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmpOld);
DeleteObject(hbmpCheck);
DeleteDC(hdcMem);
}
// now we draw the smaller rectangle
y++;
nCheckWidth -= 2;
nCheckHeight -= 2;
// draw hollow gray rectangle
(void)SelectObject(hdc, hpenGray);
HBRUSH hbrPrev = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH));
Rectangle(hdc, x, y, x + nCheckWidth, y + nCheckHeight);
// clean up
(void)SelectObject(hdc, hpenPrev);
(void)SelectObject(hdc, hbrPrev);
DeleteObject(hpenBack);
DeleteObject(hpenGray);
//
// dc.DrawRectangle(x, y, nCheckWidth, nCheckHeight);
//
// if ( IsChecked() ) {
// dc.DrawLine(x, y, x + nCheckWidth, y + nCheckHeight);
// dc.DrawLine(x, y + nCheckHeight, x + nCheckWidth, y);
// }
//
return TRUE;
}
*/
return FALSE;
}
// change the state of the item and redraw it
void wxCheckListBoxItem::Check(bool check)
{
m_bChecked = check;
// index may be chanegd because new items were added/deleted
if ( m_pParent->GetItemIndex(this) != (int)m_nIndex )
{
// update it
int index = m_pParent->GetItemIndex(this);
wxASSERT_MSG( index != wxNOT_FOUND, wxT("what does this item do here?") );
m_nIndex = (size_t)index;
}
HWND hwndListbox = (HWND)m_pParent->GetHWND();
// TODO:
/*
RECT rcUpdate;
if ( ::SendMessage(hwndListbox, LB_GETITEMRECT,
m_nIndex, (LPARAM)&rcUpdate) == LB_ERR )
{
wxLogDebug(wxT("LB_GETITEMRECT failed"));
}
InvalidateRect(hwndListbox, &rcUpdate, FALSE);
*/
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId());
event.SetInt(m_nIndex);
event.SetEventObject(m_pParent);
m_pParent->ProcessCommand(event);
}
// ----------------------------------------------------------------------------
// implementation of wxCheckListBox class
// ----------------------------------------------------------------------------
@ -34,6 +243,8 @@
// define event table
// ------------------
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
EVT_CHAR(wxCheckListBox::OnChar)
EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
END_EVENT_TABLE()
// control creation
@ -52,23 +263,129 @@ wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
const wxString& name)
: wxListBox()
{
// TODO: you'll probably need a separate Create instead of using
// the wxListBox one as here.
Create(parent, id, pos, size, nStrings, choices, style|wxLB_OWNERDRAW, val, name);
Create(parent, id, pos, size, nStrings, choices,
style | wxLB_OWNERDRAW, val, name);
}
void wxCheckListBox::Delete(int N)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
wxT("invalid index in wxListBox::Delete") );
wxListBox::Delete(N);
// free memory
delete m_aItems[N];
m_aItems.Remove(N);
}
void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos)
{
wxCHECK_RET( pos >= 0 && pos <= m_noItems,
wxT("invalid index in wxCheckListBox::InsertItems") );
wxListBox::InsertItems(nItems, items, pos);
int i;
for ( i = 0; i < nItems; i++ ) {
wxOwnerDrawn *pNewItem = CreateItem((size_t)(pos + i));
pNewItem->SetName(items[i]);
m_aItems.Insert(pNewItem, (size_t)(pos + i));
// ListBox_SetItemData((HWND)GetHWND(), i + pos, pNewItem);
}
}
bool wxCheckListBox::SetFont( const wxFont &font )
{
size_t i;
for (i=0; i < m_aItems.GetCount(); i++)
m_aItems[i]->SetFont(font);
wxListBox::SetFont(font);
return TRUE;
}
// create/retrieve item
// --------------------
// create a check list box item
wxOwnerDrawn *wxCheckListBox::CreateItem(size_t nIndex)
{
wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex);
return pItem;
}
// return item size
// ----------------
// TODO:
/*
bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
{
if ( wxListBox::MSWOnMeasure(item) ) {
MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
// save item height
m_nItemHeight = pStruct->itemHeight;
// add place for the check mark
pStruct->itemWidth += wxOwnerDrawn::GetDefaultMarginWidth();
return TRUE;
}
return FALSE;
}
*/
// check items
// -----------
bool wxCheckListBox::IsChecked(unsigned int uiIndex) const
bool wxCheckListBox::IsChecked(size_t uiIndex) const
{
// TODO
return FALSE;
return GetItem(uiIndex)->IsChecked();
}
void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck)
void wxCheckListBox::Check(size_t uiIndex, bool bCheck)
{
// TODO
GetItem(uiIndex)->Check(bCheck);
}
// process events
// --------------
void wxCheckListBox::OnChar(wxKeyEvent& event)
{
if ( event.KeyCode() == WXK_SPACE )
GetItem(GetSelection())->Toggle();
else
event.Skip();
}
void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
{
// clicking on the item selects it, clicking on the checkmark toggles
if ( event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) {
// TODO:
/*
size_t nItem = (size_t)::SendMessage
(
(HWND)GetHWND(),
LB_ITEMFROMPOINT,
0,
MAKELPARAM(event.GetX(), event.GetY())
);
*/
size_t nItem = 0;
if ( nItem < (size_t)m_noItems )
GetItem(nItem)->Toggle();
//else: it's not an error, just click outside of client zone
}
else {
// implement default behaviour: clicking on the item selects it
event.Skip();
}
}
#endif

View File

@ -1,119 +1,279 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choice.cpp
// Purpose: wxChoice
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "choice.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/choice.h"
#include "wx/utils.h"
#include "wx/log.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/choice.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
#endif
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
bool wxChoice::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
SetName(name);
SetValidator(validator);
m_noStrings = n;
m_windowStyle = style;
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return FALSE;
// TODO:
/*
long msStyle = WS_CHILD | CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
if ( style & wxCB_SORT )
msStyle |= CBS_SORT;
if (parent) parent->AddChild(this);
// the experience shows that wxChoice vs. wxComboBox distinction confuses
// quite a few people - try to help them
wxASSERT_MSG( !(style & wxCB_DROPDOWN) &&
!(style & wxCB_READONLY) &&
!(style & wxCB_SIMPLE),
wxT("this style flag is ignored by wxChoice, you "
"probably want to use a wxComboBox") );
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
if ( !OS2CreateControl(wxT("COMBOBOX"), msStyle) )
return FALSE;
// TODO: create choice control
return FALSE;
for ( int i = 0; i < n; i++ )
{
Append(choices[i]);
}
*/
SetSize(pos.x, pos.y, size.x, size.y);
return TRUE;
}
void wxChoice::Append(const wxString& item)
// ----------------------------------------------------------------------------
// adding/deleting items to/from the list
// ----------------------------------------------------------------------------
int wxChoice::DoAppend(const wxString& item)
{
// TODO
m_noStrings ++;
// TODO:
/*
int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LONG)item.c_str());
if ( n == CB_ERR )
{
wxLogLastError("SendMessage(CB_ADDSTRING)");
}
*/
return 0; //n
}
void wxChoice::Delete(int n)
{
// TODO
m_noStrings --;
wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
// TODO: SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
}
void wxChoice::Clear()
{
// TODO
m_noStrings = 0;
// TODO: SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0);
}
// ----------------------------------------------------------------------------
// selection
// ----------------------------------------------------------------------------
int wxChoice::GetSelection() const
{
// TODO
// TODO: return (int)SendMessage(GetHwnd(), CB_GETCURSEL, 0, 0);
return 0;
}
void wxChoice::SetSelection(int n)
{
// TODO
// TODO: SendMessage(GetHwnd(), CB_SETCURSEL, n, 0);
}
// ----------------------------------------------------------------------------
// string list functions
// ----------------------------------------------------------------------------
int wxChoice::GetCount() const
{
// TODO: return (int)SendMessage(GetHwnd(), CB_GETCOUNT, 0, 0);
return 0;
}
int wxChoice::FindString(const wxString& s) const
{
// TODO
// TODO:
/*
int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT,
(WPARAM)-1, (LPARAM)s.c_str());
return pos == LB_ERR ? wxNOT_FOUND : pos;
*/
return 0;
}
wxString wxChoice::GetString(int n) const
{
// TODO
return wxString("");
}
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
{
// TODO
}
wxString wxChoice::GetStringSelection () const
{
int sel = GetSelection ();
if (sel > -1)
return wxString(this->GetString (sel));
else
return wxString("");
}
bool wxChoice::SetStringSelection (const wxString& s)
{
int sel = FindString (s);
if (sel > -1)
{
SetSelection (sel);
return TRUE;
size_t len = 0; // TODO: (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0);
wxString str = "";
// TODO:
/*
if (len) {
if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n,
(LPARAM)str.GetWriteBuf(len)) == CB_ERR ) {
wxLogLastError("SendMessage(CB_GETLBTEXT)");
}
else
return FALSE;
str.UngetWriteBuf();
}
*/
return str;
}
void wxChoice::Command(wxCommandEvent & event)
// ----------------------------------------------------------------------------
// client data
// ----------------------------------------------------------------------------
void wxChoice::DoSetClientData( int n, void* clientData )
{
SetSelection (event.GetInt());
ProcessCommand (event);
// TODO:
/*
if ( SendMessage(GetHwnd(), CB_SETITEMDATA, n, (LPARAM)clientData) == CB_ERR )
{
wxLogLastError(wxT("CB_SETITEMDATA"));
}
*/
}
void* wxChoice::DoGetClientData( int n ) const
{
// TODO:
/*
LPARAM rc = SendMessage(GetHwnd(), CB_GETITEMDATA, n, 0);
if ( rc == CB_ERR )
{
wxLogLastError(wxT("CB_GETITEMDATA"));
// unfortunately, there is no way to return an error code to the user
rc = (LPARAM) NULL;
}
return (void *)rc;
*/
return NULL;
}
void wxChoice::DoSetClientObject( int n, wxClientData* clientData )
{
DoSetClientData(n, clientData);
}
wxClientData* wxChoice::DoGetClientObject( int n ) const
{
// TODO: return (wxClientData *)DoGetClientData(n);
return NULL;
}
// ----------------------------------------------------------------------------
// wxOS2 specific helpers
// ----------------------------------------------------------------------------
void wxChoice::DoSetSize(int x, int y,
int width, int height,
int sizeFlags)
{
// Ignore height parameter because height doesn't mean 'initially
// displayed' height, it refers to the drop-down menu as well. The
// wxWindows interpretation is different; also, getting the size returns
// the _displayed_ size (NOT the drop down menu size) so
// setting-getting-setting size would not work.
wxControl::DoSetSize(x, y, width, -1, sizeFlags);
}
wxSize wxChoice::DoGetBestSize()
{
// find the widest string
int wLine;
int wChoice = 0;
int nItems = GetCount();
for ( int i = 0; i < nItems; i++ )
{
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
if ( wLine > wChoice )
wChoice = wLine;
}
// give it some reasonable default value if there are no strings in the
// list
if ( wChoice == 0 )
wChoice = 100;
// the combobox should be larger than the widest string
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
wChoice += 5*cx;
// Choice drop-down list depends on number of items (limited to 10)
size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1;
int hChoice = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*nStrings;
return wxSize(wChoice, hChoice);
}
MRESULT wxChoice::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
if ( nMsg == WM_LBUTTONUP )
{
int x = (int)LOWORD(lParam);
int y = (int)HIWORD(lParam);
// Ok, this is truly weird, but if a panel with a wxChoice loses the
// focus, then you get a *fake* WM_LBUTTONUP message with x = 65535 and
// y = 65535. Filter out this nonsense.
//
// VZ: I'd like to know how to reproduce this please...
if ( x == 65535 && y == 65535 )
return 0;
}
*/
return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam);
}
bool wxChoice::OS2Command(WXUINT param, WXWORD WXUNUSED(id))
{
// TODO:
/*
if ( param != CBN_SELCHANGE)
{
// "selection changed" is the only event we're after
return FALSE;
}
*/
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
event.SetInt(GetSelection());
event.SetEventObject(this);
// TODO: event.SetString(GetStringSelection());
ProcessCommand(event);
return TRUE;
}

View File

@ -1,237 +1,629 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.cpp
// Purpose: Clipboard functionality
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
#pragma implementation "clipbrd.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#endif
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/bitmap.h"
#include "wx/utils.h"
#include "wx/metafile.h"
#if wxUSE_CLIPBOARD
#ifndef WX_PRECOMP
#include "wx/object.h"
#include "wx/event.h"
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/bitmap.h"
#include "wx/utils.h"
#include "wx/intl.h"
#endif
#if wxUSE_METAFILE
#include "wx/metafile.h"
#endif
#include "wx/log.h"
#include "wx/clipbrd.h"
#include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
#define INCL_DOS
#define INCL_PM
#include <os2.h>
#include "wx/os2/private.h"
// wxDataObject is tied to OLE/drag and drop implementation,
// therefore so is wxClipboard :-(
#if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h"
static bool wxSetClipboardData(wxDataObject *data);
#endif
// ===========================================================================
// implementation
// ===========================================================================
// ---------------------------------------------------------------------------
// old-style clipboard functions using Windows API
// ---------------------------------------------------------------------------
static bool gs_wxClipboardIsOpen = FALSE;
bool wxOpenClipboard()
{
// TODO
wxCHECK_MSG( !gs_wxClipboardIsOpen, TRUE, wxT("clipboard already opened.") );
// TODO:
/*
wxWindow *win = wxTheApp->GetTopWindow();
if ( win )
{
gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0;
if ( !gs_wxClipboardIsOpen )
wxLogSysError(_("Failed to open the clipboard."));
return gs_wxClipboardIsOpen;
}
else
{
wxLogDebug(wxT("Can not open clipboard without a main window."));
return FALSE;
}
*/
return FALSE;
}
bool wxCloseClipboard()
{
// TODO
return FALSE;
wxCHECK_MSG( gs_wxClipboardIsOpen, FALSE, wxT("clipboard is not opened") );
// TODO:
/*
gs_wxClipboardIsOpen = FALSE;
if ( ::CloseClipboard() == 0 )
{
wxLogSysError(_("Failed to close the clipboard."));
return FALSE;
}
*/
return TRUE;
}
bool wxEmptyClipboard()
{
// TODO
// TODO:
/*
if ( ::EmptyClipboard() == 0 )
{
wxLogSysError(_("Failed to empty the clipboard."));
return FALSE;
}
*/
return TRUE;
}
bool wxIsClipboardOpened()
{
return gs_wxClipboardIsOpen;
}
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
// TODO: return ::IsClipboardFormatAvailable(dataFormat) != 0;
return FALSE;
}
bool wxClipboardOpen()
#if wxUSE_DRAG_AND_DROP
static bool wxSetClipboardData(wxDataObject *data)
{
// TODO
return FALSE;
// TODO:
/*
size_t size = data->GetDataSize();
HANDLE hGlobal = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size);
if ( !hGlobal )
{
wxLogSysError(_("Failed to allocate %dKb of memory for clipboard "
"transfer."), size / 1024);
return FALSE;
}
LPVOID lpGlobalMemory = ::GlobalLock(hGlobal);
data->GetDataHere(lpGlobalMemory);
GlobalUnlock(hGlobal);
wxDataFormat format = data->GetPreferredFormat();
if ( !::SetClipboardData(format, hGlobal) )
{
wxLogSysError(_("Failed to set clipboard data in format %s"),
wxDataObject::GetFormatName(format));
return FALSE;
}
*/
return TRUE;
}
#endif // wxUSE_DRAG_AND_DROP
bool wxSetClipboardData(wxDataFormat dataFormat,
const void *data,
int width, int height)
{
// TODO:
/*
HANDLE handle = 0; // return value of SetClipboardData
switch (dataFormat)
{
case wxDF_BITMAP:
{
wxBitmap *bitmap = (wxBitmap *)data;
HDC hdcMem = CreateCompatibleDC((HDC) NULL);
HDC hdcSrc = CreateCompatibleDC((HDC) NULL);
HBITMAP old = (HBITMAP)
::SelectObject(hdcSrc, (HBITMAP)bitmap->GetHBITMAP());
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSrc,
bitmap->GetWidth(),
bitmap->GetHeight());
if (!hBitmap)
{
SelectObject(hdcSrc, old);
DeleteDC(hdcMem);
DeleteDC(hdcSrc);
return FALSE;
}
HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hBitmap);
BitBlt(hdcMem, 0, 0, bitmap->GetWidth(), bitmap->GetHeight(),
hdcSrc, 0, 0, SRCCOPY);
// Select new bitmap out of memory DC
SelectObject(hdcMem, old1);
// Set the data
handle = ::SetClipboardData(CF_BITMAP, hBitmap);
// Clean up
SelectObject(hdcSrc, old);
DeleteDC(hdcSrc);
DeleteDC(hdcMem);
break;
}
case wxDF_DIB:
{
#if wxUSE_IMAGE_LOADING_IN_MSW
wxBitmap *bitmap = (wxBitmap *)data;
HBITMAP hBitmap = (HBITMAP)bitmap->GetHBITMAP();
// NULL palette means to use the system one
HANDLE hDIB = wxBitmapToDIB(hBitmap, (HPALETTE)NULL);
handle = SetClipboardData(CF_DIB, hDIB);
#endif
break;
}
#if wxUSE_METAFILE
case wxDF_METAFILE:
{
wxMetafile *wxMF = (wxMetafile *)data;
HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1);
METAFILEPICT *mf = (METAFILEPICT *)GlobalLock(data);
mf->mm = wxMF->GetWindowsMappingMode();
mf->xExt = width;
mf->yExt = height;
mf->hMF = (HMETAFILE) wxMF->GetHMETAFILE();
GlobalUnlock(data);
wxMF->SetHMETAFILE((WXHANDLE) NULL);
handle = SetClipboardData(CF_METAFILEPICT, data);
break;
}
#endif
case CF_SYLK:
case CF_DIF:
case CF_TIFF:
case CF_PALETTE:
default:
{
wxLogError(_("Unsupported clipboard format."));
return FALSE;
}
case wxDF_OEMTEXT:
dataFormat = wxDF_TEXT;
// fall through
case wxDF_TEXT:
{
char *s = (char *)data;
width = strlen(s) + 1;
height = 1;
DWORD l = (width * height);
HANDLE hGlobalMemory = GlobalAlloc(GHND, l);
if ( hGlobalMemory )
{
LPSTR lpGlobalMemory = (LPSTR)GlobalLock(hGlobalMemory);
memcpy(lpGlobalMemory, s, l);
GlobalUnlock(hGlobalMemory);
}
handle = SetClipboardData(dataFormat, hGlobalMemory);
break;
}
}
if ( handle == 0 )
{
wxLogSysError(_("Failed to set clipboard data."));
return FALSE;
}
*/
return TRUE;
}
bool wxIsClipboardFormatAvailable(int dataFormat)
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
// TODO
return FALSE;
}
void *retval = NULL;
// TODO:
/*
switch ( dataFormat )
{
case wxDF_BITMAP:
{
BITMAP bm;
HBITMAP hBitmap = (HBITMAP) GetClipboardData(CF_BITMAP);
if (!hBitmap)
break;
bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
{
// TODO
return FALSE;
}
HDC hdcMem = CreateCompatibleDC((HDC) NULL);
HDC hdcSrc = CreateCompatibleDC((HDC) NULL);
wxObject *wxGetClipboardData(int dataFormat, long *len)
{
// TODO
HBITMAP old = (HBITMAP) ::SelectObject(hdcSrc, hBitmap);
GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
HBITMAP hNewBitmap = CreateBitmapIndirect(&bm);
if (!hNewBitmap)
{
SelectObject(hdcSrc, old);
DeleteDC(hdcMem);
DeleteDC(hdcSrc);
break;
}
HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hNewBitmap);
BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight,
hdcSrc, 0, 0, SRCCOPY);
// Select new bitmap out of memory DC
SelectObject(hdcMem, old1);
// Clean up
SelectObject(hdcSrc, old);
DeleteDC(hdcSrc);
DeleteDC(hdcMem);
// Create and return a new wxBitmap
wxBitmap *wxBM = new wxBitmap;
wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap);
wxBM->SetWidth(bm.bmWidth);
wxBM->SetHeight(bm.bmHeight);
wxBM->SetDepth(bm.bmPlanes);
wxBM->SetOk(TRUE);
retval = wxBM;
break;
}
case wxDF_METAFILE:
case CF_SYLK:
case CF_DIF:
case CF_TIFF:
case CF_PALETTE:
case wxDF_DIB:
{
wxLogError(_("Unsupported clipboard format."));
return FALSE;
}
case wxDF_OEMTEXT:
dataFormat = wxDF_TEXT;
// fall through
case wxDF_TEXT:
{
HANDLE hGlobalMemory = ::GetClipboardData(dataFormat);
if (!hGlobalMemory)
break;
DWORD hsize = ::GlobalSize(hGlobalMemory);
if (len)
*len = hsize;
char *s = new char[hsize];
if (!s)
break;
LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory);
memcpy(s, lpGlobalMemory, hsize);
::GlobalUnlock(hGlobalMemory);
retval = s;
break;
}
default:
{
HANDLE hGlobalMemory = ::GetClipboardData(dataFormat);
if ( !hGlobalMemory )
break;
DWORD size = ::GlobalSize(hGlobalMemory);
if ( len )
*len = size;
void *buf = malloc(size);
if ( !buf )
break;
LPSTR lpGlobalMemory = (LPSTR)::GlobalLock(hGlobalMemory);
memcpy(buf, lpGlobalMemory, size);
::GlobalUnlock(hGlobalMemory);
retval = buf;
break;
}
}
if ( !retval )
{
wxLogSysError(_("Failed to retrieve data from the clipboard."));
}
return retval;
*/
return NULL;
}
int wxEnumClipboardFormats(int dataFormat)
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
// TODO
return 0;
// TODO: return ::EnumClipboardFormats(dataFormat);
return dataFormat;
}
int wxRegisterClipboardFormat(char *formatName)
int wxRegisterClipboardFormat(wxChar *formatName)
{
// TODO
return 0;
// TODO: return ::RegisterClipboardFormat(formatName);
return 0;
}
bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
bool wxGetClipboardFormatName(wxDataFormat dataFormat,
wxChar *formatName,
int maxCount)
{
// TODO
return FALSE;
// TODO: return ::GetClipboardFormatName((int)dataFormat, formatName, maxCount) > 0;
return 0;
}
/*
* Generalized clipboard implementation by Matthew Flatt
*/
// ---------------------------------------------------------------------------
// wxClipboard
// ---------------------------------------------------------------------------
wxClipboard *wxTheClipboard = NULL;
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
void wxInitClipboard()
{
if (!wxTheClipboard)
wxTheClipboard = new wxClipboard;
}
wxClipboard* wxTheClipboard = (wxClipboard *)NULL;
wxClipboard::wxClipboard()
{
clipOwner = NULL;
cbString = NULL;
}
wxClipboard::~wxClipboard()
{
if (clipOwner)
clipOwner->BeingReplaced();
if (cbString)
delete[] cbString;
Clear();
}
static int FormatStringToID(char *str)
void wxClipboard::Clear()
{
if (!strcmp(str, "TEXT"))
return wxDF_TEXT;
return wxRegisterClipboardFormat(str);
}
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
bool wxClipboard::Open()
{
bool got_selection;
return wxOpenClipboard();
}
if (clipOwner)
clipOwner->BeingReplaced();
clipOwner = client;
if (cbString) {
delete[] cbString;
cbString = NULL;
}
bool wxClipboard::SetData( wxDataObject *data )
{
(void)wxEmptyClipboard();
// TODO:
/*
if ( data )
return AddData(data);
else
return TRUE;
*/
return TRUE;
}
if (wxOpenClipboard()) {
char **formats, *data;
int i;
int ftype;
long size;
bool wxClipboard::AddData( wxDataObject *data )
{
wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
formats = clipOwner->formats.ListToArray(FALSE);
for (i = clipOwner->formats.Number(); i--; ) {
ftype = FormatStringToID(formats[i]);
data = clipOwner->GetData(formats[i], &size);
if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
got_selection = FALSE;
break;
}
#if wxUSE_DRAG_AND_DROP
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
// wxDataFormat format = data->GetFormat();
// TODO:
/*
switch ( format )
{
case wxDF_TEXT:
case wxDF_OEMTEXT:
{
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
wxString str(textDataObject->GetText());
return wxSetClipboardData(format, str.c_str());
}
case wxDF_BITMAP:
case wxDF_DIB:
{
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap bitmap(bitmapDataObject->GetBitmap());
return wxSetClipboardData(data->GetFormat(), &bitmap);
}
#if wxUSE_METAFILE
case wxDF_METAFILE:
{
wxMetafileDataObject* metaFileDataObject =
(wxMetafileDataObject*) data;
wxMetafile metaFile = metaFileDataObject->GetMetafile();
return wxSetClipboardData(wxDF_METAFILE, &metaFile,
metaFileDataObject->GetWidth(),
metaFileDataObject->GetHeight());
}
#endif // wxUSE_METAFILE
default:
return wxSetClipboardData(data);
}
if (i < 0)
got_selection = wxCloseClipboard();
} else
got_selection = FALSE;
got_selection = FALSE; // Assume another process takes over
if (!got_selection) {
clipOwner->BeingReplaced();
clipOwner = NULL;
}
#else // !wxUSE_DRAG_AND_DROP
*/
return FALSE;
#endif // wxUSE_DRAG_AND_DROP/!wxUSE_DRAG_AND_DROP
}
wxClipboardClient *wxClipboard::GetClipboardClient()
void wxClipboard::Close()
{
return clipOwner;
wxCloseClipboard();
}
void wxClipboard::SetClipboardString(char *str, long time)
bool wxClipboard::IsSupported( wxDataFormat format )
{
bool got_selection;
if (clipOwner) {
clipOwner->BeingReplaced();
clipOwner = NULL;
}
if (cbString)
delete[] cbString;
cbString = str;
if (wxOpenClipboard()) {
if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
got_selection = FALSE;
else
got_selection = wxCloseClipboard();
} else
got_selection = FALSE;
got_selection = FALSE; // Assume another process takes over
if (!got_selection) {
delete[] cbString;
cbString = NULL;
}
return wxIsClipboardFormatAvailable(format);
}
char *wxClipboard::GetClipboardString(long time)
bool wxClipboard::GetData( wxDataObject *data )
{
char *str;
long length;
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
str = GetClipboardData("TEXT", &length, time);
if (!str) {
str = new char[1];
*str = 0;
}
#if wxUSE_DRAG_AND_DROP
// wxDataFormat format = data->GetFormat();
// TODO:
/*
switch ( format )
{
case wxDF_TEXT:
case wxDF_OEMTEXT:
{
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
char* s = (char*) wxGetClipboardData(format);
if ( s )
{
textDataObject->SetText(s);
delete[] s;
return TRUE;
}
else
return FALSE;
}
return str;
case wxDF_BITMAP:
case wxDF_DIB:
{
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject *)data;
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
if (bitmap)
{
bitmapDataObject->SetBitmap(* bitmap);
delete bitmap;
return TRUE;
}
else
return FALSE;
}
#if wxUSE_METAFILE
case wxDF_METAFILE:
{
wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject *)data;
wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
if (metaFile)
{
metaFileDataObject->SetMetafile(*metaFile);
delete metaFile;
return TRUE;
}
else
return FALSE;
}
#endif
default:
{
long len;
void *buf = wxGetClipboardData(format, &len);
if ( buf )
{
// FIXME this is for testing only!!
((wxPrivateDataObject *)data)->SetData(buf, len);
free(buf);
return TRUE;
}
}
return FALSE;
}
#else
*/
return FALSE;
#endif
}
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
//-----------------------------------------------------------------------------
// wxClipboardModule
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
bool wxClipboardModule::OnInit()
{
if (clipOwner) {
if (clipOwner->formats.Member(format))
return clipOwner->GetData(format, length);
else
return NULL;
} else if (cbString) {
if (!strcmp(format, "TEXT"))
return copystring(cbString);
else
return NULL;
} else {
if (wxOpenClipboard()) {
receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
length);
wxCloseClipboard();
} else
receivedString = NULL;
wxTheClipboard = new wxClipboard();
return receivedString;
}
return TRUE;
}
void wxClipboardModule::OnExit()
{
if (wxTheClipboard) delete wxTheClipboard;
wxTheClipboard = (wxClipboard*) NULL;
}
#else
#error "Please turn wxUSE_CLIPBOARD on to compile this file."
#endif // wxUSE_CLIPBOARD

View File

@ -2,19 +2,44 @@
// Name: colordlg.cpp
// Purpose: wxColourDialog class. NOTE: you can use the generic class
// if you wish, instead of implementing this.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "colordlg.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/defs.h"
#include "wx/bitmap.h"
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/colour.h"
#include "wx/gdicmn.h"
#include "wx/utils.h"
#include "wx/frame.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#endif
#include "wx/stubs/colordlg.h"
#define INCL_PM
#include <os2.h>
#include "wx/os2/private.h"
#include "wx/colordlg.h"
#include "wx/cmndata.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define wxDIALOG_DEFAULT_X 300
#define wxDIALOG_DEFAULT_Y 300
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
@ -37,7 +62,7 @@ wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
{
m_dialogParent = parent;
if (data)
m_colourData = *data;
return TRUE;

View File

@ -1,20 +1,21 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colour.cpp
// Purpose: wxColour class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "colour.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/gdicmn.h"
#include "wx/colour.h"
#define INCL_GPI
#define INCL_PM
#include<os2.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
@ -25,10 +26,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
wxColour::wxColour ()
{
m_isInit = FALSE;
m_red = m_blue = m_green = 0;
/* TODO
m_pixel = 0;
*/
m_red = m_blue = m_green = 0;
}
wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
@ -37,9 +36,7 @@ wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
m_green = g;
m_blue = b;
m_isInit = TRUE;
/* TODO
m_pixel = PALETTERGB (m_red, m_green, m_blue);
*/
// m_pixel = PALETTERGB (m_red, m_green, m_blue);
}
wxColour::wxColour (const wxColour& col)
@ -48,9 +45,7 @@ wxColour::wxColour (const wxColour& col)
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
/* TODO
m_pixel = col.m_pixel;
*/
}
wxColour& wxColour::operator =(const wxColour& col)
@ -59,9 +54,7 @@ wxColour& wxColour::operator =(const wxColour& col)
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
/* TODO
m_pixel = col.m_pixel;
*/
return *this;
}
@ -101,3 +94,14 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
m_pixel = PALETTERGB (m_red, m_green, m_blue);
*/
}
// Obsolete
#if WXWIN_COMPATIBILITY
void wxColour::Get (unsigned char *r, unsigned char *g, unsigned char *b) const
{
*r = m_red;
*g = m_green;
*b = m_blue;
}
#endif

View File

@ -1,165 +1,301 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox.cpp
// Purpose: wxComboBox class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "combobox.h"
#include "wx/combobox.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#endif
#if wxUSE_COMBOBOX
#include "wx/combobox.h"
#include "wx/clipbrd.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
#endif
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
bool wxComboBox::OS2Command(WXUINT param, WXWORD WXUNUSED(id))
{
SetName(name);
SetValidator(validator);
m_noStrings = n;
m_windowStyle = style;
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
// TODO: create combobox control
// TODO:
/*
if (param == CBN_SELCHANGE)
{
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId);
event.SetInt(GetSelection());
event.SetEventObject(this);
event.SetString(GetStringSelection());
ProcessCommand(event);
return TRUE;
}
else if (param == CBN_EDITCHANGE)
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
event.SetString(GetValue());
event.SetEventObject(this);
ProcessCommand(event);
return TRUE;
}
else
return FALSE;
*/
return FALSE;
}
wxString wxComboBox::GetValue() const
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
// TODO
return wxString("");
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
m_windowStyle = style;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
// TODO:
/*
long msStyle = WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
CBS_NOINTEGRALHEIGHT;
if (m_windowStyle & wxCB_READONLY)
msStyle |= CBS_DROPDOWNLIST;
else if (m_windowStyle & wxCB_SIMPLE)
msStyle |= CBS_SIMPLE; // A list (shown always) and edit control
else
msStyle |= CBS_DROPDOWN;
if (m_windowStyle & wxCB_SORT)
msStyle |= CBS_SORT;
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("COMBOBOX"), NULL,
msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create combobox") );
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
SetFont(parent->GetFont());
int i;
for (i = 0; i < n; i++)
{
Append(choices[i]);
}
SetSelection(i);
SetSize(x, y, width, height);
if ( !value.IsEmpty() )
{
SetValue(value);
}
*/
return TRUE;
}
void wxComboBox::SetValue(const wxString& value)
{
// TODO
// If newlines are denoted by just 10, must stick 13 in front.
int singletons = 0;
int len = value.Length();
int i;
for (i = 0; i < len; i ++)
{
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
singletons ++;
}
if (singletons > 0)
{
wxChar *tmp = new wxChar[len + singletons + 1];
int j = 0;
for (i = 0; i < len; i ++)
{
if ((i > 0) && (value[i] == 10) && (value[i-1] != 13))
{
tmp[j] = 13;
j ++;
}
tmp[j] = value[i];
j ++;
}
tmp[j] = 0;
// SetWindowText(GetHwnd(), tmp);
delete[] tmp;
}
// else
// SetWindowText(GetHwnd(), value);
}
// Clipboard operations
void wxComboBox::Copy()
{
// TODO
HWND hWnd = GetHwnd();
// SendMessage(hWnd, WM_COPY, 0, 0L);
}
void wxComboBox::Cut()
{
// TODO
HWND hWnd = GetHwnd();
// SendMessage(hWnd, WM_CUT, 0, 0L);
}
void wxComboBox::Paste()
{
// TODO
HWND hWnd = GetHwnd();
// SendMessage(hWnd, WM_PASTE, 0, 0L);
}
void wxComboBox::SetEditable(bool editable)
{
// TODO
// Can't implement in MSW?
// HWND hWnd = GetHwnd();
// SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
}
void wxComboBox::SetInsertionPoint(long pos)
{
// TODO
/*
HWND hWnd = GetHwnd();
SendMessage(hWnd, EM_SETSEL, pos, pos);
SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
char *nothing = "";
SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
*/
}
void wxComboBox::SetInsertionPointEnd()
{
// TODO
/*
long pos = GetLastPosition();
SetInsertionPoint(pos);
*/
}
long wxComboBox::GetInsertionPoint() const
{
// TODO
return 0;
/*
DWORD Pos=(DWORD)SendMessage(GetHwnd(), EM_GETSEL, 0, 0L);
return Pos&0xFFFF;
*/
return 0;
}
long wxComboBox::GetLastPosition() const
{
// TODO
return 0;
/*
HWND hWnd = GetHwnd();
// Will always return a number > 0 (according to docs)
int noLines = (int)SendMessage(hWnd, EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0L);
// This gets the char index for the _beginning_ of the last line
int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)(noLines-1), (LPARAM)0L);
// Get number of characters in the last line. We'll add this to the character
// index for the last line, 1st position.
int lineLength = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0L);
return (long)(charIndex + lineLength);
*/
return 0;
}
void wxComboBox::Replace(long from, long to, const wxString& value)
{
// TODO
#if wxUSE_CLIPBOARD
HWND hWnd = GetHwnd();
long fromChar = from;
long toChar = to;
// Set selection and remove it
// SendMessage(hWnd, CB_SETEDITSEL, fromChar, toChar);
// SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
// Now replace with 'value', by pasting.
wxSetClipboardData(wxDF_TEXT, (wxObject *)(const wxChar *)value, 0, 0);
// Paste into edit control
// SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L);
#endif
}
void wxComboBox::Remove(long from, long to)
{
// TODO
HWND hWnd = GetHwnd();
long fromChar = from;
long toChar = to;
// Cut all selected text
// SendMessage(hWnd, CB_SETEDITSEL, fromChar, toChar);
// SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0);
}
void wxComboBox::SetSelection(long from, long to)
{
// TODO
HWND hWnd = GetHwnd();
long fromChar = from;
long toChar = to;
// if from and to are both -1, it means
// (in wxWindows) that all text should be selected.
// This translates into Windows convention
if ((from == -1) && (to == -1))
{
fromChar = 0;
toChar = -1;
}
// SendMessage(hWnd, CB_SETEDITSEL, (WPARAM)fromChar, (LPARAM)toChar);
// SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
}
void wxComboBox::Append(const wxString& item)
void wxComboBox::DoSetSize(int x, int y,
int width, int height,
int sizeFlags)
{
// TODO
wxControl::DoSetSize(x, y, width, height, sizeFlags);
}
void wxComboBox::Delete(int n)
{
// TODO
}
#endif
// wxUSE_COMBOBOX
void wxComboBox::Clear()
{
// TODO
}
int wxComboBox::GetSelection() const
{
// TODO
return -1;
}
void wxComboBox::SetSelection(int n)
{
// TODO
}
int wxComboBox::FindString(const wxString& s) const
{
// TODO
return -1;
}
wxString wxComboBox::GetString(int n) const
{
// TODO
return wxString("");
}
wxString wxComboBox::GetStringSelection() const
{
// TODO
return wxString("");
}
bool wxComboBox::SetStringSelection(const wxString& sel)
{
// TODO
return FALSE;
}

View File

@ -1,41 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.cpp
// Purpose: wxCursor class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/13/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "cursor.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/cursor.h"
#include "wx/icon.h"
#endif
#include "wx/os2/private.h"
#include "assert.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
#endif
wxCursorRefData::wxCursorRefData()
wxCursorRefData::wxCursorRefData(void)
{
m_width = 32; m_height = 32;
/* TODO
m_hCursor = 0 ;
*/
m_width = 32; m_height = 32;
m_hCursor = 0 ;
m_destroyCursor = FALSE;
}
wxCursorRefData::~wxCursorRefData()
wxCursorRefData::~wxCursorRefData(void)
{
// TODO: destroy cursor
// if ( m_hCursor && m_destroyCursor)
// ::DestroyCursor((HICON) m_hCursor);
}
// Cursors
wxCursor::wxCursor()
wxCursor::wxCursor(void)
{
}
@ -46,142 +55,190 @@ wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSE
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
m_refData = new wxCursorRefData;
m_refData = new wxCursorRefData;
// TODO: create cursor from a file
M_CURSORDATA->m_destroyCursor = FALSE;
M_CURSORDATA->m_hCursor = 0;
M_CURSORDATA->m_ok = FALSE;
// TODO:
/*
if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
if (M_CURSORDATA->m_hCursor)
M_CURSORDATA->m_ok = TRUE;
else
M_CURSORDATA->m_ok = FALSE;
}
else if (flags & wxBITMAP_TYPE_CUR)
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
}
else if (flags & wxBITMAP_TYPE_ICO)
{
}
else if (flags & wxBITMAP_TYPE_BMP)
{
}
*/
}
// Cursors by stock number
wxCursor::wxCursor(int cursor_type)
{
m_refData = new wxCursorRefData;
/* TODO
// TODO:
/*
switch (cursor_type)
{
case wxCURSOR_WAIT:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
break;
case wxCURSOR_IBEAM:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
break;
case wxCURSOR_CROSS:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
break;
case wxCURSOR_SIZENWSE:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
break;
case wxCURSOR_SIZENESW:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
break;
case wxCURSOR_SIZEWE:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
break;
case wxCURSOR_SIZENS:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
break;
case wxCURSOR_CHAR:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_HAND:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
break;
}
case wxCURSOR_BULLSEYE:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
break;
}
case wxCURSOR_PENCIL:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
break;
}
case wxCURSOR_MAGNIFIER:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
break;
}
case wxCURSOR_NO_ENTRY:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
break;
}
case wxCURSOR_LEFT_BUTTON:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_RIGHT_BUTTON:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_MIDDLE_BUTTON:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_SIZING:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
break;
}
case wxCURSOR_WATCH:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
break;
}
case wxCURSOR_SPRAYCAN:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
break;
}
case wxCURSOR_PAINT_BRUSH:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
break;
}
case wxCURSOR_POINT_LEFT:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
break;
}
case wxCURSOR_POINT_RIGHT:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
break;
}
case wxCURSOR_QUESTION_ARROW:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
break;
}
case wxCURSOR_BLANK:
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK");
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
break;
}
default:
case wxCURSOR_ARROW:
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW);
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
*/
}
wxCursor::~wxCursor()
wxCursor::~wxCursor(void)
{
// FreeResource(TRUE);
}
bool wxCursor::FreeResource(bool WXUNUSED(force))
{
// if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
// {
// DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
// M_CURSORDATA->m_hCursor = 0;
// }
return TRUE;
}
void wxCursor::SetHCURSOR(WXHCURSOR cursor)
{
if ( !M_CURSORDATA )
m_refData = new wxCursorRefData;
M_CURSORDATA->m_hCursor = cursor;
}
// Global cursor setting
void wxSetCursor(const wxCursor& cursor)
{
// TODO (optional on platforms with no global cursor)
extern wxCursor *g_globalCursor;
if ( cursor.Ok() && cursor.GetHCURSOR() )
{
// ::SetCursor((HCURSOR) cursor.GetHCURSOR());
if ( g_globalCursor )
(*g_globalCursor) = cursor;
}
}