More OS/2 stuff

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 1999-10-12 22:49:24 +00:00
parent 1b68e0b5b9
commit cdf1e71425
19 changed files with 4006 additions and 837 deletions

View File

@ -23,7 +23,7 @@
#elif defined(__WXMAC__)
#include "wx/mac/dnd.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj.h"
#include "wx/os2/dnd.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dnd.h"
#endif

View File

@ -16,7 +16,7 @@
#elif defined(__WXMAC__)
#include "wx/generic/listctrl.h"
#elif defined(__WXPM__)
#include "wx/generic/listctrl.h"
#include "wx/os2/listctrl.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/listctrl.h"
#endif
@ -38,7 +38,7 @@ public:
wxPoint m_pointDrag;
wxListItem m_item;
inline int GetCode() { return m_code; }
inline long GetIndex() { return m_itemIndex; }
inline long GetOldIndex() { return m_oldItemIndex; }

View File

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

View File

@ -1,26 +1,22 @@
/////////////////////////////////////////////////////////////////////////////
// Name: notebook.h
// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
// Author: AUTHOR
// Author: David Webster
// Modified by:
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_
#define _WX_NOTEBOOK_H_
#ifdef __GNUG__
#pragma interface "notebook.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/dynarray.h"
#include "wx/event.h"
#include "wx/control.h"
#ifndef _DYNARRAY_H
#include <wx/dynarray.h>
#endif //_DYNARRAY_H
// ----------------------------------------------------------------------------
// types
@ -31,38 +27,17 @@ class WXDLLEXPORT wxImageList;
class WXDLLEXPORT wxWindow;
// array of notebook pages
typedef wxWindow wxNotebookPage; // so far, any window can be a page
typedef wxWindow WXDLLEXPORT wxNotebookPage; // so far, any window can be a page
WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages);
// ----------------------------------------------------------------------------
// notebook events
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNotebookEvent : public wxCommandEvent
{
public:
wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
int nSel = -1, int nOldSel = -1)
: wxCommandEvent(commandType, id) { m_nSel = nSel; m_nOldSel = nOldSel; }
// accessors
int GetSelection() const { return m_nSel; }
int GetOldSelection() const { return m_nOldSel; }
private:
int m_nSel, // currently selected page
m_nOldSel; // previously selected page
DECLARE_DYNAMIC_CLASS(wxNotebookEvent)
};
// ----------------------------------------------------------------------------
// wxNotebook
// ----------------------------------------------------------------------------
// @@@ this class should really derive from wxTabCtrl, but the interface is not
// exactly the same, so I can't do it right now and instead we reimplement
// part of wxTabCtrl here
class wxNotebook : public wxControl
// FIXME this class should really derive from wxTabCtrl, but the interface is not
// exactly the same, so I can't do it right now and instead we reimplement
// part of wxTabCtrl here
class WXDLLEXPORT wxNotebook : public wxControl
{
public:
// ctors
@ -71,14 +46,14 @@ public:
wxNotebook();
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
wxWindowID id,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "notebook");
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
@ -128,9 +103,6 @@ public:
// set the padding between tabs (in pixels)
void SetPadding(const wxSize& padding);
// Sets the size of the tabs (assumes all tabs are the same size)
void SetTabSize(const wxSize& sz);
// operations
// ----------
// remove one page from the notebook
@ -154,16 +126,20 @@ public:
// get the panel which represents the given page
wxNotebookPage *GetPage(int nPage) { return m_aPages[nPage]; }
// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
// style.
void SetTabSize(const wxSize& sz);
// callbacks
// ---------
void OnSize(wxSizeEvent& event);
void OnSelChange(wxNotebookEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event);
// base class virtuals
// -------------------
virtual void Command(wxCommandEvent& event);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
virtual void SetConstraintSizes(bool recurse = TRUE);
virtual bool DoPhase(int nPhase);
@ -183,27 +159,4 @@ protected:
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// event macros
// ----------------------------------------------------------------------------
typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
#define EVT_NOTEBOOK_PAGE_CHANGED(id, fn) \
{ \
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
},
#define EVT_NOTEBOOK_PAGE_CHANGING(id, fn) \
{ \
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, \ \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
NULL \
},
#endif // _WX_NOTEBOOK_H_

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Purpose: wxPalette class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PALETTE_H_
#define _WX_PALETTE_H_
#ifdef __GNUG__
#pragma interface "palette.h"
#endif
#include "wx/gdiobj.h"
class WXDLLEXPORT wxPalette;
@ -26,10 +22,8 @@ class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
public:
wxPaletteRefData();
~wxPaletteRefData();
/* TODO: implementation
protected:
WXHPALETTE m_hPalette;
*/
};
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
@ -54,11 +48,15 @@ public:
inline bool operator == (const wxPalette& palette) { return m_refData == palette.m_refData; }
inline bool operator != (const wxPalette& palette) { return m_refData != palette.m_refData; }
/* TODO: implementation
virtual bool FreeResource(bool force = FALSE);
inline WXHPALETTE GetHPALETTE() const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
void SetHPALETTE(WXHPALETTE pal);
*/
};
#define wxColorMap wxPalette
#define wxColourMap wxPalette
#endif
// _WX_PALETTE_H_

View File

@ -1,23 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: pen.h
// Purpose: wxPen class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PEN_H_
#define _WX_PEN_H_
#ifdef __GNUG__
#pragma interface "pen.h"
#endif
#include "wx/gdiobj.h"
#include "wx/colour.h"
#include "wx/bitmap.h"
typedef long wxDash ;
@ -41,9 +36,7 @@ protected:
int m_nbDash ;
wxDash * m_dash ;
wxColour m_colour;
/* TODO: implementation
WXHPEN m_hPen;
*/
};
#define M_PENDATA ((wxPenRefData *)m_refData)
@ -91,9 +84,9 @@ public:
// Useful helper: create the brush resource
bool RealizeResource();
// When setting properties, we must make sure we're not changing
// another object
bool FreeResource(bool force = FALSE);
WXHANDLE GetResourceHandle() ;
bool IsFree() const;
void Unshare();
};

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobox.h
// Purpose: wxRadioBox class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBOX_H_
#define _WX_RADIOBOX_H_
#ifdef __GNUG__
#pragma interface "radiobox.h"
#endif
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxRadioBoxNameStr;
@ -46,17 +42,20 @@ public:
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr);
virtual bool OS2Command(WXUINT param, WXWORD id);
int FindString(const wxString& s) const;
void SetSelection(int N);
int GetSelection() const;
wxString GetString(int N) const;
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void GetSize(int *x, int *y) const;
void GetPosition(int *x, int *y) const;
wxString GetLabel() const;
void SetLabel(const wxString& label);
void SetLabel(int item, const wxString& label) ;
wxString GetLabel(int item) const;
wxString GetLabel() const;
bool Show(bool show);
void SetFocus();
bool Enable(bool enable);
@ -74,14 +73,20 @@ public:
inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
protected:
/* TODO: implementation
void SubclassRadioButton(WXHWND hWndBtn);
WXHWND * m_radioButtons;
*/
int m_majorDim ;
int * m_radioWidth; // for bitmaps
int * m_radioHeight;
int m_noItems;
int m_noRowsOrCols;
int m_selectedButton;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
};
#endif

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobut.h
// Purpose: wxRadioButton class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 01/02/97
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBUT_H_
#define _WX_RADIOBUT_H_
#ifdef __GNUG__
#pragma interface "radiobut.h"
#endif
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxRadioButtonNameStr;
@ -47,11 +43,11 @@ class WXDLLEXPORT wxRadioButton: public wxControl
virtual void SetValue(bool val);
virtual bool GetValue() const ;
bool OS2Command(WXUINT param, WXWORD id);
void Command(wxCommandEvent& event);
};
// Not implemented
#if 0
class WXDLLEXPORT wxBitmap ;
WXDLLEXPORT_DATA(extern const char*) wxBitmapRadioButtonNameStr;
@ -83,8 +79,11 @@ class WXDLLEXPORT wxBitmapRadioButton: public wxRadioButton
virtual void SetLabel(const wxBitmap *label);
virtual void SetValue(bool val) ;
virtual bool GetValue() const ;
private:
// virtual function hiding suppression, do not use
virtual void SetLabel(const wxString& label)
{ wxRadioButton::SetLabel(label); };
};
#endif
#endif
// _WX_RADIOBUT_H_

View File

@ -3,63 +3,55 @@
// Purpose: wxWindow class
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_
#define _WX_WINDOW_H_
#ifdef __GNUG__
#pragma interface "window.h"
#endif
#define wxUSE_MOUSEEVENT_HACK 0
#define INCL_DOS
#define INCL_PM
#include <os2.h>
#define wxKEY_SHIFT 1
#define wxKEY_CTRL 2
// ---------------------------------------------------------------------------
// headers
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// forward declarations
// ---------------------------------------------------------------------------
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxButton;
#if wxUSE_DRAG_AND_DROP
class WXDLLEXPORT wxDropTarget;
#endif
// ---------------------------------------------------------------------------
// constants
// ---------------------------------------------------------------------------
#if wxUSE_WX_RESOURCES
class WXDLLEXPORT wxResourceTable;
class WXDLLEXPORT wxItemResource;
#endif
WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
class WXDLLEXPORT wxWindow: public wxWindowBase
// FIXME does anybody use those? they're unused by wxWindows...
enum
{
DECLARE_ABSTRACT_CLASS(wxWindow)
wxKEY_SHIFT = 1,
wxKEY_CTRL = 2
};
friend class wxDC;
friend class wxPaintDC;
// ---------------------------------------------------------------------------
// wxWindow declaration for OS/2 PM
// ---------------------------------------------------------------------------
class WXDLLEXPORT wxWindow : public wxWindowBase
{
DECLARE_DYNAMIC_CLASS(wxWindow);
public:
wxWindow() { Init(); };
inline wxWindow( wxWindow* parent
,wxWindowID id
,const wxPoint& pos = wxDefaultPosition
,const wxSize& size = wxDefaultSize
,long style = 0
,const wxString& name = wxPanelNameStr
)
wxWindow() { Init(); }
wxWindow(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, id, pos, size, style, name);
@ -67,174 +59,119 @@ public:
virtual ~wxWindow();
bool Create( wxWindow* parent
,wxWindowID id
,const wxPoint& pos = wxDefaultPosition
,const wxSize& size = wxDefaultSize
,long style = 0
,const wxString& name = wxPanelNameStr
);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
// ---------------------------------------------------------------------------
// wxWindowBase pure virtual implementations
// ---------------------------------------------------------------------------
// implement base class pure virtuals
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
// Z order
virtual void Raise();
virtual void Lower();
// Set the focus to this window
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual void SetFocus();
// Warp the pointer the given position
virtual void WarpPointer(int x_pos, int y_pos) ;
// Capture/release mouse
virtual bool Reparent( wxWindow *newParent );
virtual void WarpPointer(int x, int y);
virtual void CaptureMouse();
virtual void ReleaseMouse();
// Send the window a refresh event
virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
// Clear the window
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
// Set window's font
virtual bool SetFont(const wxFont& f);
// Get character size
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string
,int* x
,int* y
,int* descent = NULL
,int* externalLeading = NULL
,const wxFont* theFont = NULL
) const;
// Configure the window's scrollbar
virtual void SetScrollbar( int orient
,int pos
,int thumbVisible
,int range
,bool refresh = TRUE
);
virtual void SetScrollPos( int orient
,int pos
,bool refresh = TRUE
);
virtual int GetScrollPos(int orient) const;
virtual int GetScrollRange(int orient) const;
virtual int GetScrollThumb(int orient) const;
virtual void ScrollWindow( int dx
,int dy
,const wxRect* rect = NULL
);
#if wxUSE_DRAG_AND_DROP
void SetDropTarget(wxDropTarget *pDropTarget);
#endif
// coordinates translation
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
// retrieve the position/size of the window
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
virtual void DoGetClientSize( int *width, int *height ) const;
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = (int *) NULL,
int *externalLeading = (int *) NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
// this is the virtual function to be overriden in any derived class which
// wants to change how SetSize() or Move() works - it is called by all
// versions of these functions in the base class
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
// same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height);
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
// ---------------------------------------------------------------------------
// wxWindowBase virtual implementations that need to be overriden
// ---------------------------------------------------------------------------
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = TRUE );
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual int GetScrollPos( int orient ) const;
virtual int GetScrollThumb( int orient ) const;
virtual int GetScrollRange( int orient ) const;
virtual void ScrollWindow( int dx, int dy,
const wxRect* rect = (wxRect *) NULL );
// Fit the window around the items
virtual void Fit();
// Show or hide the window
virtual bool Show(bool show); // check if base implementation is OK
// Enable or disable the window
virtual bool Enable(bool enable); // check if base implementation is OK
// Set the cursor
virtual bool SetCursor(const wxCursor& cursor); // check if base implementation is OK
// ---------------------------------------------------------------------------
// additional functions
// ---------------------------------------------------------------------------
// Dialog support: override these and call
// base class members to add functionality
// that can't be done using validators.
void SetClientSize( int width, int height )
{ DoSetClientSize(width, height); }
void SetClientSize( const wxSize& size )
{ DoSetClientSize(size.x, size.y); }
void SetClientSize(const wxRect& rect)
{ SetClientSize( rect.width, rect.height ); }
// Validate controls. If returns FALSE,
// validation failed: don't quit
virtual bool Validate();
// Return code for dialogs
inline void SetReturnCode(int retCode);
inline int GetReturnCode();
// Get the window with the focus
static wxWindow *FindFocus();
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
// Most windows have the concept of a label; for frames, this is the
// title; for items, this is the label or button text.
inline virtual wxString GetLabel() const { return GetTitle(); }
#if WXWIN_COMPATIBILITY
// Set/get scroll attributes
virtual void SetScrollRange(int orient, int range, bool refresh = TRUE);
virtual void SetScrollPage(int orient, int page, bool refresh = TRUE);
virtual int OldGetScrollRange(int orient) const;
virtual int GetScrollPage(int orient) const;
#if wxUSE_CARET && WXWIN_COMPATIBILITY
// Caret manipulation
virtual void CreateCaret(int w, int h);
virtual void CreateCaret(const wxBitmap *bitmap);
virtual void DestroyCaret();
virtual void ShowCaret(bool show);
virtual void SetCaretPos(int x, int y);
virtual void GetCaretPos(int *x, int *y) const;
#endif
// Handle a control command
// event handlers
// Handle a control command
virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
// Get the default button, if there is one
inline virtual wxButton *GetDefaultItem() const;
inline virtual void SetDefaultItem(wxButton *but);
// Override to define new behaviour for default action (e.g. double
// clicking on a listbox)
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
#endif // WXWIN_COMPATIBILITY
// Override to define new behaviour for default action (e.g. double clicking
// on a listbox)
virtual void OnDefaultAction(wxControl *initiatingItem);
#if wxUSE_CARET && WXWIN_COMPATIBILITY
// caret manipulation (old MSW only functions, see wxCaret class for the
// new API)
void CreateCaret(int w, int h);
void CreateCaret(const wxBitmap *bitmap);
void DestroyCaret();
void ShowCaret(bool show);
void SetCaretPos(int x, int y);
void GetCaretPos(int *x, int *y) const;
#endif // wxUSE_CARET
// EventHandlers
void OnEraseBackground(wxEraseEvent& event);
void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event);
// Native resource loading (implemented in src/msw/nativdlg.cpp)
// FIXME: should they really be all virtual?
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
wxWindow* GetWindowChild1(wxWindowID id);
wxWindow* GetWindowChild(wxWindowID id);
// Accessors
// implementation from now on
// --------------------------
// simple accessors
// ----------------
WXHWND GetHWND() const { return m_hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return GetHWND(); }
public:
// ---------------------------------------------------------------------------
// IMPLEMENTATION
// ---------------------------------------------------------------------------
bool GetUseCtl3D() const { return m_useCtl3D; }
bool GetTransparentBackground() const { return m_backgroundTransparent; }
void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; }
// event handlers
// --------------
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
public:
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
@ -253,71 +190,236 @@ public:
wxWindow *FindItem(long id) const;
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
// Make a Windows extended style from the given wxWindows window style
static WXDWORD MakeExtendedStyle(long style,
bool eliminateBorders = TRUE);
// Determine whether 3D effects are wanted
WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
// PM only: TRUE if this control is part of the main control
// MSW only: TRUE if this control is part of the main control
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
// Executes the default message
virtual long Default();
// returns TRUE if the window has been created
bool OS2Create(int id,
wxWindow *parent,
const wxChar *wclass,
wxWindow *wx_win,
const wxChar *title,
int x, int y, int width, int height,
WXDWORD style,
const wxChar *dialog_template = NULL,
WXDWORD exendedStyle = 0);
virtual bool OS2Command(WXUINT param, WXWORD id);
// Constraint implementation
void UnsetConstraints(wxLayoutConstraints *c);
// Back-pointer to other windows we're involved with, so if we delete
// this window, we must delete any constraints we're involved with.
#if WXWIN_COMPATIBILITY
wxObject *GetChild(int number) const;
virtual void OS2DeviceToLogical(float *x, float *y) const;
#endif // WXWIN_COMPATIBILITY
wxObject *GetChild(int number) const ;
// Create an appropriate wxWindow from a HWND
virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
// Transfers data to any child controls
void OnInitDialog(wxInitDialogEvent& event);
// Make sure the window style reflects the HWND style (roughly)
virtual void AdoptAttributesFromHWND();
// Setup background and foreground colours correctly
virtual void SetupColours();
// ------------------------------------------------------------------------
// helpers for message handlers: these perform the same function as the
// message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
// the correct parameters
// ------------------------------------------------------------------------
void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *code, WXWORD *pos, WXHWND *hwnd);
void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
// ------------------------------------------------------------------------
// internal handlers for MSW messages: all handlers return a boolen value:
// TRUE means that the handler processed the event and FALSE that it didn't
// ------------------------------------------------------------------------
// there are several cases where we have virtual functions for Windows
// message processing: this is because these messages often require to be
// processed in a different manner in the derived classes. For all other
// messages, however, we do *not* have corresponding MSWOnXXX() function
// and if the derived class wants to process them, it should override
// MSWWindowProc() directly.
// scroll event (both horizontal and vertical)
virtual bool OS2OnScroll(int orientation, WXWORD nSBCode,
WXWORD pos, WXHWND control);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// owner-drawn controls need to process these messages
virtual bool OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *item);
virtual bool OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
// the rest are not virtual
bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
bool HandleInitDialog(WXHWND hWndFocus);
bool HandleDestroy();
bool HandlePaint();
bool HandleEraseBkgnd(WXHDC pDC);
bool HandleMinimize();
bool HandleMaximize();
bool HandleSize(int x, int y, WXUINT flag);
bool HandleGetMinMaxInfo(void *mmInfo);
bool HandleShow(bool show, int status);
bool HandleActivate(int flag, bool minimized, WXHWND activate);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam);
bool HandleCtlColor(WXHBRUSH *hBrush,
WXHDC hdc,
WXHWND hWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
bool HandlePaletteChanged(WXHWND hWndPalChange);
bool HandleQueryNewPalette();
bool HandleSysColorChange();
bool HandleQueryEndSession(long logOff, bool *mayEnd);
bool HandleEndSession(bool endSession, long logOff);
bool HandleSetFocus(WXHWND wnd);
bool HandleKillFocus(WXHWND wnd);
bool HandleDropFiles(WXWPARAM wParam);
bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
bool HandleMouseMove(int x, int y, WXUINT flags);
bool HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE);
bool HandleKeyDown(WXWORD wParam, WXLPARAM lParam);
bool HandleKeyUp(WXWORD wParam, WXLPARAM lParam);
bool HandleQueryDragIcon(WXHICON *hIcon);
bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
// Window procedure
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// Calls an appropriate default window procedure
virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual bool OS2ProcessMessage(WXMSG* pMsg);
virtual bool OS2TranslateMessage(WXMSG* pMsg);
virtual void OS2DestroyWindow();
// Detach "Window" menu from menu bar so it doesn't get deleted
void OS2DetachWindowMenu();
// this function should return the brush to paint the window background
// with or 0 for the default brush
virtual WXHBRUSH OnCtlColor(WXHDC hDC,
WXHWND hWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
#if WXWIN_COMPATIBILITY
void SetShowing(bool show) { (void)Show(show); }
bool IsUserEnabled() const { return IsEnabled(); }
#endif // WXWIN_COMPATIBILITY
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
protected:
// Caret data
int m_caretWidth;
int m_caretHeight;
bool m_caretEnabled;
bool m_caretShown;
wxButton * m_defaultItem;
public:
WXFARPROC m_oldWndProc;
int m_returnCode;
bool m_isBeingDeleted;
bool m_isShown;
bool m_winCaptured;
bool m_mouseInWindow;
bool m_backgroundTransparent;
// handles
// the window handle
WXHWND m_hWnd;
WXHMENU m_hMenu; // Menu, if any
// the old window proc (we subclass all windows)
WXFARPROC m_oldWndProc;
// additional (MSW specific) flags
bool m_useCtl3D:1; // Using CTL3D for this control
bool m_backgroundTransparent:1;
bool m_mouseInWindow:1;
bool m_doubleClickAllowed:1;
bool m_winCaptured:1;
// the size of one page for scrolling
int m_xThumbSize;
int m_yThumbSize;
long m_lDlgCode;
DECLARE_EVENT_TABLE()
#if wxUSE_MOUSEEVENT_HACK
// the coordinates of the last mouse event and the type of it
long m_lastMouseX,
m_lastMouseY;
int m_lastMouseEvent;
#endif // wxUSE_MOUSEEVENT_HACK
WXHMENU m_hMenu; // Menu, if any
// the return value of WM_GETDLGCODE handler
long m_lDlgCode;
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
virtual void DoGetClientSize( int *width, int *height ) const;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
// get the size which best suits the window: e.g., for a static text it
// will be the width and height of the text
virtual wxSize DoGetBestSize();
// move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange
// themselves inside the given rectangle
virtual void DoMoveWindow(int x, int y, int width, int height);
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
private:
void Init();
void PMDetachWindowMenu();
// common part of all ctors
void Init();
// the (non-virtual) handlers for the events
bool HandleMove(int x, int y);
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
DECLARE_NO_COPY_CLASS(wxWindow);
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////////
//// INLINES
inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
inline int wxWindow::GetReturnCode() { return m_returnCode; }
// Get the active window.
wxWindow* WXDLLEXPORT wxGetActiveWindow();
// ---------------------------------------------------------------------------
// global functions
// ---------------------------------------------------------------------------
// kbd code translation
WXDLLEXPORT int wxCharCodeOS2ToWX(int keySym);
WXDLLEXPORT int wxCharCodeWXToOS2(int id, bool *IsVirtual);
#endif
// _WX_WINDOW_H_

View File

@ -12,12 +12,12 @@
#elif defined(__WXMAC__)
#include "wx/mac/printdlg.h"
#elif defined(__WXPM__)
#include "wx/os2/printdlg.h"
#include "wx/generic/prntdlgg.h"
#elif defined(__WXSTUBS__)
#include "wx/generic/prntdlgg.h"
#endif
#if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXPM__)
#if !defined(__WXMSW__) && !defined(__WXMAC__)
#define wxPrintDialog wxGenericPrintDialog
#define sm_classwxPrintDialog sm_classwxGenericPrintDialog

View File

@ -333,6 +333,16 @@ OS2OBJS = \
..\os2\$D\menuitem.obj \
..\os2\$D\metafile.obj \
..\os2\$D\minifram.obj \
..\os2\$D\msgdlg.obj \
..\os2\$D\nativdlg.obj \
..\os2\$D\notebook.obj \
..\os2\$D\ownerdrw.obj \
..\os2\$D\palette.obj \
..\os2\$D\pen.obj \
..\os2\$D\pngread.obj \
..\os2\$D\print.obj \
..\os2\$D\radiobox.obj \
..\os2\$D\radiobut.obj \
..\os2\$D\window.obj
OS2LIBOBJS = \
@ -380,6 +390,16 @@ OS2LIBOBJS = \
menuitem.obj \
metafile.obj \
minifram.obj \
msgdlg.obj \
nativdlg.obj \
notebook.obj \
ownerdrw.obj \
palette.obj \
pen.obj \
pngread.obj \
print.obj \
radiobox.obj \
radiobut.obj \
window.obj
HTMLOBJS = \
@ -571,6 +591,16 @@ $(OS2LIBOBJS):
copy ..\os2\$D\menuitem.obj
copy ..\os2\$D\metafile.obj
copy ..\os2\$D\minifram.obj
copy ..\os2\$D\msgdlg.obj
copy ..\os2\$D\nativdlg.obj
copy ..\os2\$D\notebook.obj
copy ..\os2\$D\ownerdrw.obj
copy ..\os2\$D\pallet.obj
copy ..\os2\$D\pen.obj
copy ..\os2\$D\pngread.obj
copy ..\os2\$D\print.obj
copy ..\os2\$D\radiobox.obj
copy ..\os2\$D\radiobut.obj
copy ..\os2\$D\window.obj
# wxWindows library as DLL

View File

@ -1,19 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Purpose: wxMessageDialog
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 04/01/98
// Created: 10/10/99
// RCS-ID: $$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "msgdlg.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/utils.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#endif
#include "wx/stubs/msgdlg.h"
#include "wx/os2/private.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_CLASS(wxMessageDialog, wxDialog)

View File

@ -1,52 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: notebook.cpp
// Purpose: implementation of wxNotebook
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "notebook.h"
#endif
// wxWindows
#ifndef WX_PRECOMP
#include <wx/string.h>
#endif // WX_PRECOMP
#include <wx/string.h>
#include <wx/log.h>
#include <wx/imaglist.h>
#include <wx/event.h>
#include <wx/control.h>
#include <wx/notebook.h>
#include <wx/os2/private.h>
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// check that the page index is valid
#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
// hide the ugly cast
#define m_hwnd (HWND)GetHWND()
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// This is a work-around for missing defines in gcc-2.95 headers
#ifndef TCS_RIGHT
#define TCS_RIGHT 0x0002
#endif
#ifndef TCS_VERTICAL
#define TCS_VERTICAL 0x0080
#endif
#ifndef TCS_BOTTOM
#define TCS_BOTTOM TCS_RIGHT
#endif
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARIES
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE()
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
#endif
// ============================================================================
@ -91,19 +110,53 @@ bool wxNotebook::Create(wxWindow *parent,
long style,
const wxString& name)
{
// base init
SetName(name);
SetParent(parent);
// base init
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
m_windowId = id == -1 ? NewControlId() : id;
// colors and font
m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
m_foregroundColour = *wxBLACK ;
// style
m_windowStyle = style;
// TODO:
/*
// style
m_windowStyle = style | wxTAB_TRAVERSAL;
if ( parent != NULL )
parent->AddChild(this);
long tabStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TABS;
// TODO
if (m_windowStyle & wxCLIP_CHILDREN)
tabStyle |= WS_CLIPCHILDREN;
if ( m_windowStyle & wxTC_MULTILINE )
tabStyle |= TCS_MULTILINE;
if ( m_windowStyle & wxBORDER )
tabStyle &= WS_BORDER;
if (m_windowStyle & wxNB_FIXEDWIDTH)
tabStyle |= TCS_FIXEDWIDTH ;
if (m_windowStyle & wxNB_BOTTOM)
tabStyle |= TCS_RIGHT;
if (m_windowStyle & wxNB_LEFT)
tabStyle |= TCS_VERTICAL;
if (m_windowStyle & wxNB_RIGHT)
tabStyle |= TCS_VERTICAL|TCS_RIGHT;
if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
this, NULL, pos.x, pos.y, size.x, size.y,
tabStyle, NULL, 0) )
{
return FALSE;
}
// Not all compilers recognise SetWindowFont
::SendMessage(GetHwnd(), WM_SETFONT,
(WPARAM)::GetStockObject(DEFAULT_GUI_FONT), TRUE);
if ( parent != NULL )
parent->AddChild(this);
*/
SubclassWin(m_hWnd);
return FALSE;
}
@ -129,7 +182,7 @@ int wxNotebook::GetRowCount() const
int wxNotebook::SetSelection(int nPage)
{
wxASSERT( IS_VALID_PAGE(nPage) );
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
ChangePage(m_nSelection, nPage);
@ -149,7 +202,7 @@ void wxNotebook::AdvanceSelection(bool bForward)
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
{
wxASSERT( IS_VALID_PAGE(nPage) );
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
// TODO
return FALSE;
@ -157,7 +210,7 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText)
wxString wxNotebook::GetPageText(int nPage) const
{
wxASSERT( IS_VALID_PAGE(nPage) );
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
// TODO
return wxString("");
@ -165,7 +218,7 @@ wxString wxNotebook::GetPageText(int nPage) const
int wxNotebook::GetPageImage(int nPage) const
{
wxASSERT( IS_VALID_PAGE(nPage) );
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
// TODO
return 0;
@ -173,7 +226,7 @@ int wxNotebook::GetPageImage(int nPage) const
bool wxNotebook::SetPageImage(int nPage, int nImage)
{
wxASSERT( IS_VALID_PAGE(nPage) );
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
// TODO
return FALSE;
@ -185,6 +238,11 @@ void wxNotebook::SetImageList(wxImageList* imageList)
// TODO
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
// TODO
}
// ----------------------------------------------------------------------------
// wxNotebook operations
// ----------------------------------------------------------------------------
@ -192,7 +250,7 @@ void wxNotebook::SetImageList(wxImageList* imageList)
// remove one page from the notebook
bool wxNotebook::DeletePage(int nPage)
{
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
// TODO: delete native widget page
@ -205,7 +263,7 @@ bool wxNotebook::DeletePage(int nPage)
// remove one page from the notebook, without deleting the window
bool wxNotebook::RemovePage(int nPage)
{
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
m_aPages.Remove(nPage);
@ -303,8 +361,21 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
{
// is it our tab control?
if ( event.GetEventObject() == this )
ChangePage(event.GetOldSelection(), event.GetSelection());
{
int sel = event.GetOldSelection();
if ( sel != -1 )
m_aPages[sel]->Show(FALSE);
sel = event.GetSelection();
if ( sel != -1 )
{
wxNotebookPage *pPage = m_aPages[sel];
pPage->Show(TRUE);
pPage->SetFocus();
}
m_nSelection = sel;
}
// we want to give others a chance to process this message as well
event.Skip();
}
@ -350,9 +421,33 @@ bool wxNotebook::DoPhase(int /* nPhase */)
return TRUE;
}
void wxNotebook::Command(wxCommandEvent& event)
bool wxNotebook::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
{
wxFAIL_MSG("wxNotebook::Command not implemented");
wxNotebookEvent event(wxEVT_NULL, m_windowId);
//TODO:
/*
NMHDR* hdr = (NMHDR *)lParam;
switch ( hdr->code ) {
case TCN_SELCHANGE:
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
break;
case TCN_SELCHANGING:
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
break;
default:
return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
*/
event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
event.SetOldSelection(m_nSelection);
event.SetEventObject(this);
event.SetInt(idCtrl);
bool processed = GetEventHandler()->ProcessEvent(event);
*result = !event.IsAllowed();
return processed;
}
// ----------------------------------------------------------------------------
@ -362,21 +457,35 @@ void wxNotebook::Command(wxCommandEvent& event)
// hide the currently active panel and show the new one
void wxNotebook::ChangePage(int nOldSel, int nSel)
{
wxASSERT( nOldSel != nSel ); // impossible
// MT-FIXME should use a real semaphore
static bool s_bInsideChangePage = FALSE;
if ( nOldSel != -1 ) {
m_aPages[nOldSel]->Show(FALSE);
// when we call ProcessEvent(), our own OnSelChange() is called which calls
// this function - break the infinite loop
if ( s_bInsideChangePage )
return;
// it's not an error (the message may be generated by the tab control itself)
// and it may happen - just do nothing
if ( nSel == nOldSel )
return;
s_bInsideChangePage = TRUE;
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
event.SetSelection(nSel);
event.SetOldSelection(nOldSel);
event.SetEventObject(this);
if ( ProcessEvent(event) && !event.IsAllowed() )
{
// program doesn't allow the page change
s_bInsideChangePage = FALSE;
return;
}
wxNotebookPage *pPage = m_aPages[nSel];
pPage->Show(TRUE);
pPage->SetFocus();
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
ProcessEvent(event);
m_nSelection = nSel;
}
void wxNotebook::SetTabSize(const wxSize& sz)
{
// TODO
s_bInsideChangePage = FALSE;
}

View File

@ -9,16 +9,22 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "palette.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/palette.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
#endif
#define INCL_PM
#define INCL_GPI
#include <os2.h>
#include "assert.h"
/*
* Palette
*
@ -26,12 +32,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
wxPaletteRefData::wxPaletteRefData()
{
// TODO
m_hPalette = 0;
}
wxPaletteRefData::~wxPaletteRefData()
{
// TODO
if ( m_hPalette )
return;
// TODO: ::DeleteObject((HPALETTE) m_hPalette);
}
wxPalette::wxPalette()
@ -47,6 +55,15 @@ wxPalette::~wxPalette()
{
}
bool wxPalette::FreeResource(bool force)
{
if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette)
{
// TODO: DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette);
}
return TRUE;
}
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
@ -54,8 +71,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
m_refData = new wxPaletteRefData;
// TODO
/*
NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
(WORD)n * sizeof(PALETTEENTRY));
if (!npPal)
return(FALSE);
return FALSE;
npPal->palVersion = 0x300;
npPal->palNumEntries = n;
int i;
for (i = 0; i < n; i ++)
{
npPal->palPalEntry[i].peRed = red[i];
npPal->palPalEntry[i].peGreen = green[i];
npPal->palPalEntry[i].peBlue = blue[i];
npPal->palPalEntry[i].peFlags = 0;
}
M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
LocalFree((HANDLE)npPal);
*/
}
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
@ -74,9 +109,27 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
if (index < 0 || index > 255)
return FALSE;
// TODO
/*
PALETTEENTRY entry;
if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
{
*red = entry.peRed;
*green = entry.peGreen;
*blue = entry.peBlue;
return TRUE;
} else
return FALSE;
*/
return FALSE;
}
// TODO
return FALSE;
void wxPalette::SetHPALETTE(WXHPALETTE pal)
{
if ( !m_refData )
m_refData = new wxPaletteRefData;
M_PALETTEDATA->m_hPalette = pal;
}

View File

@ -1,26 +1,29 @@
/////////////////////////////////////////////////////////////////////////////
// Name: pen.cpp
// Purpose: wxPen
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "pen.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/pen.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
#endif
#include "wx/os2/private.h"
#include "assert.h"
wxPenRefData::wxPenRefData()
{
m_style = wxSOLID;
@ -29,9 +32,7 @@ wxPenRefData::wxPenRefData()
m_cap = wxCAP_ROUND ;
m_nbDash = 0 ;
m_dash = 0 ;
/* TODO: null data
m_hPen = 0;
*/
}
wxPenRefData::wxPenRefData(const wxPenRefData& data)
@ -73,13 +74,22 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
m_refData = new wxPenRefData;
M_PENDATA->m_colour = col;
// M_PENDATA->m_stipple = NULL;
M_PENDATA->m_width = Width;
M_PENDATA->m_style = Style;
M_PENDATA->m_join = wxJOIN_ROUND ;
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ;
M_PENDATA->m_hPen = 0 ;
// TODO:
/*
if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
(Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
(Style == wxUSER_DASH))
M_PENDATA->m_width = 1;
*/
RealizeResource();
if ( wxThePenList )
@ -97,6 +107,7 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ;
M_PENDATA->m_hPen = 0 ;
RealizeResource();
@ -104,19 +115,44 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
wxThePenList->AddPen(this);
}
bool wxPen::RealizeResource()
{
// TODO: create actual pen
return FALSE;
}
WXHANDLE wxPen::GetResourceHandle()
{
if ( !M_PENDATA )
return 0;
else
return (WXHANDLE)M_PENDATA->m_hPen;
}
bool wxPen::FreeResource(bool force)
{
if (M_PENDATA && (M_PENDATA->m_hPen != 0))
{
DeleteObject((HPEN) M_PENDATA->m_hPen);
M_PENDATA->m_hPen = 0;
return TRUE;
}
else return FALSE;
}
void wxPen::Unshare()
{
// Don't change shared data
if (!m_refData)
// Don't change shared data
if (!m_refData)
{
m_refData = new wxPenRefData();
}
m_refData = new wxPenRefData();
}
else
{
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
UnRef();
m_refData = ref;
}
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxPen::SetColour(const wxColour& col)
@ -193,10 +229,57 @@ void wxPen::SetCap(int Cap)
RealizeResource();
}
bool wxPen::RealizeResource()
void wxPen::SetCap(int Cap)
{
// TODO: create actual pen
return FALSE;
Unshare();
M_PENDATA->m_cap = Cap;
RealizeResource();
}
int wx2os2PenStyle(int wx_style)
{
int cstyle;
// TODO:
/*
switch (wx_style)
{
case wxDOT:
cstyle = PS_DOT;
break;
case wxDOT_DASH:
cstyle = PS_DASHDOT;
break;
case wxSHORT_DASH:
case wxLONG_DASH:
cstyle = PS_DASH;
break;
case wxTRANSPARENT:
cstyle = PS_NULL;
break;
case wxUSER_DASH:
#ifdef __WIN32__
// Win32s doesn't have PS_USERSTYLE
if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
cstyle = PS_USERSTYLE;
else
cstyle = PS_DOT; // We must make a choice... This is mine!
#else
cstyle = PS_DASH;
#endif
break;
case wxSOLID:
default:
cstyle = PS_SOLID;
break;
}
*/
return cstyle;
}

View File

@ -9,12 +9,20 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "print.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"
#endif
#include "wx/stubs/print.h"
#include "wx/stubs/printdlg.h"
#include "wx/os2/print.h"
#include "wx/print.h"
#include "wx/generic/printdlg.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase)

View File

@ -1,38 +1,149 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobox.cpp
// Purpose: wxRadioBox
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "radiobox.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/bitmap.h"
#include "wx/brush.h"
#include "wx/radiobox.h"
#endif
#include "wx/radiobox.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
#endif
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
// wnd proc for radio buttons
MRESULT _EXPORT wxRadioBtnWndProc(HWND hWnd,
UINT message,
MPARAM wParam,
MPARAM lParam);
// ---------------------------------------------------------------------------
// global vars
// ---------------------------------------------------------------------------
// the pointer to standard radio button wnd proc
static s_wndprocRadioBtn = NULL;
// ===========================================================================
// implementation
// ===========================================================================
// ---------------------------------------------------------------------------
// wxRadioBox
// ---------------------------------------------------------------------------
int wxRadioBox::GetNumVer() const
{
if ( m_windowStyle & wxRA_SPECIFY_ROWS )
{
return m_majorDim;
}
else
{
return (m_noItems + m_majorDim - 1)/m_majorDim;
}
}
int wxRadioBox::GetNumHor() const
{
if ( m_windowStyle & wxRA_SPECIFY_ROWS )
{
return (m_noItems + m_majorDim - 1)/m_majorDim;
}
else
{
return m_majorDim;
}
}
bool wxRadioBox::OS2Command(WXUINT cmd, WXWORD id)
{
// TODO:
/*
if ( cmd == BN_CLICKED )
{
int selectedButton = -1;
for ( int i = 0; i < m_noItems; i++ )
{
if ( id == wxGetWindowId(m_radioButtons[i]) )
{
selectedButton = i;
break;
}
}
wxASSERT_MSG( selectedButton != -1, wxT("click from alien button?") );
if ( selectedButton != m_selectedButton )
{
m_selectedButton = selectedButton;
SendNotificationEvent();
}
//else: don't generate events when the selection doesn't change
return TRUE;
}
else
return FALSE;
*/
return FALSE;
}
#if WXWIN_COMPATIBILITY
wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
int x, int y, int width, int height,
int n, char **choices,
int majorDim, long style, const char *name)
{
wxString *choices2 = new wxString[n];
for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
wxDefaultValidator, name);
Callback(func);
delete choices2;
}
#endif
// Radio box item
wxRadioBox::wxRadioBox()
{
m_selectedButton = -1;
m_noItems = 0;
m_noRowsOrCols = 0;
m_majorDim = 0 ;
m_radioButtons = NULL;
m_majorDim = 0;
m_radioWidth = NULL;
m_radioHeight = NULL;
}
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
int majorDim, long style,
const wxValidator& val, const wxString& name)
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
int majorDim, long style,
const wxValidator& val, const wxString& name)
{
m_selectedButton = -1;
m_noItems = n;
@ -41,56 +152,181 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
SetValidator(val);
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowStyle = (long&)style;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
if ( majorDim == 0 )
m_majorDim = n;
else
m_majorDim = majorDim;
m_noRowsOrCols = majorDim;
if (majorDim==0)
m_majorDim = n ;
else
m_majorDim = majorDim ;
long msStyle = GROUP_FLAGS;
bool want3D;
WXDWORD exStyle = Determine3DEffects(0, &want3D);
// TODO create radiobox
return FALSE;
HWND hwndParent = (HWND)parent->GetHWND();
/*
m_hWnd = (WXHWND)::CreateWindowEx
(
(DWORD)exStyle,
GROUP_CLASS,
title,
msStyle,
0, 0, 0, 0,
hwndParent,
(HMENU)m_windowId,
wxGetInstance(),
NULL
);
#if wxUSE_CTL3D
if (want3D)
{
Ctl3dSubclassCtl((HWND)m_hWnd);
m_useCtl3D = TRUE;
}
#endif // wxUSE_CTL3D
*/
SetFont(parent->GetFont());
SubclassWin(m_hWnd);
// Some radio boxes test consecutive id.
(void)NewControlId();
m_radioButtons = new WXHWND[n];
m_radioWidth = new int[n];
m_radioHeight = new int[n];
int i;
for (i = 0; i < n; i++)
{
// TODO:
/*
m_radioWidth[i] = m_radioHeight[i] = -1;
long groupStyle = 0;
if ( i == 0 && style == 0 )
groupStyle = WS_GROUP;
long newId = NewControlId();
long msStyle = groupStyle | RADIO_FLAGS;
HWND hwndBtn = CreateWindowEx(exStyle, RADIO_CLASS,
choices[i], msStyle,
0,0,0,0,
hwndParent,
(HMENU)newId, wxGetInstance(),
NULL);
m_radioButtons[i] = (WXHWND)hwndBtn;
SubclassRadioButton((WXHWND)hwndBtn);
wxFont& font = GetFont();
if ( font.Ok() )
{
SendMessage(hwndBtn, WM_SETFONT,
(WPARAM)font.GetResourceHandle(), 0L);
}
m_subControls.Append((wxObject *)(WXDWORD)(WXWORD)newId);
*/
}
// Create a dummy radio control to end the group.
(void)CreateWindowEx(0, RADIO_CLASS, wxT(""), WS_GROUP | RADIO_FLAGS,
0, 0, 0, 0, hwndParent,
(HMENU)NewControlId(), wxGetInstance(), NULL);
SetSelection(0);
SetSize(x, y, width, height);
return TRUE;
}
wxRadioBox::~wxRadioBox()
{
// TODO
m_isBeingDeleted = TRUE;
if (m_radioButtons)
{
int i;
// TODO:
/*
for (i = 0; i < m_noItems; i++)
::DestroyWindow((HWND)m_radioButtons[i]);
delete[] m_radioButtons;
*/
}
if (m_radioWidth)
delete[] m_radioWidth;
if (m_radioHeight)
delete[] m_radioHeight;
}
wxString wxRadioBox::GetLabel(int item) const
{
// TODO
return wxString("");
wxCHECK_MSG( item >= 0 && item < m_noItems, wxT(""), wxT("invalid radiobox index") );
return wxGetWindowText(m_radioButtons[item]);
}
void wxRadioBox::SetLabel(int item, const wxString& label)
{
// TODO
wxCHECK_RET( item >= 0 && item < m_noItems, wxT("invalid radiobox index") );
m_radioWidth[item] = m_radioHeight[item] = -1;
// TODO: SetWindowText((HWND)m_radioButtons[item], label.c_str());
}
void wxRadioBox::SetLabel(int item, wxBitmap *bitmap)
{
/*
m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN;
m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN;
*/
wxFAIL_MSG(wxT("not implemented"));
}
int wxRadioBox::FindString(const wxString& s) const
{
// TODO
return -1;
for (int i = 0; i < m_noItems; i++)
{
if ( s == wxGetWindowText(m_radioButtons[i]) )
return i;
}
return wxNOT_FOUND;
}
void wxRadioBox::SetSelection(int n)
void wxRadioBox::SetSelection(int N)
{
if ((n < 0) || (n >= m_noItems))
return;
// TODO
wxCHECK_RET( (N >= 0) && (N < m_noItems), wxT("invalid radiobox index") );
m_selectedButton = n;
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
// TODO:
/*
if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
::SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
::SendMessage((HWND)m_radioButtons[N], BM_SETCHECK, 1, 0L);
::SetFocus((HWND)m_radioButtons[N]);
*/
m_selectedButton = N;
}
// Get single selection, for single choice list items
@ -100,80 +336,309 @@ int wxRadioBox::GetSelection() const
}
// Find string for position
wxString wxRadioBox::GetString(int n) const
wxString wxRadioBox::GetString(int N) const
{
// TODO
return wxString("");
return wxGetWindowText(m_radioButtons[N]);
}
void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
// Restored old code.
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
// TODO
int currentX, currentY;
GetPosition(&currentX, &currentY);
int widthOld, heightOld;
GetSize(&widthOld, &heightOld);
int xx = x;
int yy = y;
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
xx = currentX;
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
yy = currentY;
wxString buf;
int y_offset = yy;
int x_offset = xx;
int current_width, cyf;
int cx1,cy1;
wxGetCharSize(m_hWnd, &cx1, &cy1, & GetFont());
// Attempt to have a look coherent with other platforms: We compute the
// biggest toggle dim, then we align all items according this value.
int maxWidth = -1;
int maxHeight = -1;
int i;
for (i = 0 ; i < m_noItems; i++)
{
int eachWidth;
int eachHeight;
if (m_radioWidth[i]<0)
{
// It's a labelled toggle
buf = wxGetWindowText(m_radioButtons[i]);
GetTextExtent(buf, &current_width, &cyf);
eachWidth = (int)(current_width + RADIO_SIZE);
eachHeight = (int)((3*cyf)/2);
}
else
{
eachWidth = m_radioWidth[i];
eachHeight = m_radioHeight[i];
}
if (maxWidth<eachWidth)
maxWidth = eachWidth;
if (maxHeight<eachHeight)
maxHeight = eachHeight;
}
if (m_hWnd)
{
int totWidth;
int totHeight;
int nbHor = GetNumHor(),
nbVer = GetNumVer();
// this formula works, but I don't know why.
// Please, be sure what you do if you modify it!!
if (m_radioWidth[0]<0)
totHeight = (nbVer * maxHeight) + cy1/2;
else
totHeight = nbVer * (maxHeight+cy1/2);
totWidth = nbHor * (maxWidth+cx1);
int extraHeight = cy1;
// only change our width/height if asked for
if ( width == -1 )
{
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
width = totWidth + cx1;
else
width = widthOld;
}
if ( height == -1 )
{
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
height = totHeight + extraHeight;
else
height = heightOld;
}
MoveWindow(GetHwnd(), x_offset, y_offset, width, height, TRUE);
x_offset += cx1;
y_offset += cy1;
}
int startX = x_offset;
int startY = y_offset;
for ( i = 0 ; i < m_noItems; i++)
{
// Bidimensional radio adjustment
if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
{
if (m_windowStyle & wxRA_VERTICAL)
{
y_offset = startY;
x_offset += maxWidth + cx1;
}
else
{
x_offset = startX;
y_offset += maxHeight;
if (m_radioWidth[0]>0)
y_offset += cy1/2;
}
}
int eachWidth;
int eachHeight;
if (m_radioWidth[i]<0)
{
// It's a labeled item
buf = wxGetWindowText(m_radioButtons[i]);
GetTextExtent(buf, &current_width, &cyf);
// How do we find out radio button bitmap size!!
// By adjusting them carefully, manually :-)
eachWidth = (int)(current_width + RADIO_SIZE);
eachHeight = (int)((3*cyf)/2);
}
else
{
eachWidth = m_radioWidth[i];
eachHeight = m_radioHeight[i];
}
// TODO:
/*
MoveWindow((HWND)m_radioButtons[i], x_offset, y_offset,
eachWidth, eachHeight,
TRUE);
*/
if (m_windowStyle & wxRA_SPECIFY_ROWS)
{
y_offset += maxHeight;
if (m_radioWidth[0]>0)
y_offset += cy1/2;
}
else
x_offset += maxWidth + cx1;
}
}
void wxRadioBox::GetSize(int *width, int *height) const
{
// TODO
RECT rect;
rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
if (m_hWnd)
wxFindMaxSize(m_hWnd, &rect);
int i;
for (i = 0; i < m_noItems; i++)
wxFindMaxSize(m_radioButtons[i], &rect);
*width = rect.right - rect.left;
*height = rect.bottom - rect.top;
}
void wxRadioBox::GetPosition(int *x, int *y) const
{
// TODO
}
wxWindow *parent = GetParent();
RECT rect;
rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
wxString wxRadioBox::GetLabel() const
{
// TODO
return wxString("");
}
int i;
for (i = 0; i < m_noItems; i++)
wxFindMaxSize(m_radioButtons[i], &rect);
void wxRadioBox::SetLabel(const wxString& label)
{
// TODO
if (m_hWnd)
wxFindMaxSize(m_hWnd, &rect);
// Since we now have the absolute screen coords,
// if there's a parent we must subtract its top left corner
POINT point;
point.x = rect.left;
point.y = rect.top;
// TODO:
/*
if (parent)
{
::ScreenToClient((HWND) parent->GetHWND(), &point);
}
*/
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
point.x -= pt.x;
point.y -= pt.y;
}
*x = point.x;
*y = point.y;
}
void wxRadioBox::SetFocus()
{
// TODO
// TODO:
/*
if (m_noItems > 0)
{
if (m_selectedButton == -1)
::SetFocus((HWND) m_radioButtons[0]);
else
::SetFocus((HWND) m_radioButtons[m_selectedButton]);
}
*/
}
bool wxRadioBox::Show(bool show)
{
// TODO
return FALSE;
if ( !wxControl::Show(show) )
return FALSE;
int nCmdShow = show ? SW_SHOW : SW_HIDE;
for ( int i = 0; i < m_noItems; i++ )
{
// TODO: ::ShowWindow((HWND)m_radioButtons[i], nCmdShow);
}
return TRUE;
}
// Enable a specific button
void wxRadioBox::Enable(int item, bool enable)
{
// TODO
wxCHECK_RET( item >= 0 && item < m_noItems,
wxT("invalid item in wxRadioBox::Enable()") );
// TODO: ::EnableWindow((HWND) m_radioButtons[item], enable);
}
// Enable all controls
void wxRadioBox::Enable(bool enable)
bool wxRadioBox::Enable(bool enable)
{
wxControl::Enable(enable);
if ( !wxControl::Enable(enable) )
return FALSE;
// TODO
// TODO:
/*
for (int i = 0; i < m_noItems; i++)
::EnableWindow((HWND) m_radioButtons[i], enable);
*/
return TRUE;
}
// Show a specific button
void wxRadioBox::Show(int item, bool show)
{
// TODO
wxCHECK_RET( item >= 0 && item < m_noItems,
wxT("invalid item in wxRadioBox::Show()") );
// TODO: ::ShowWindow((HWND)m_radioButtons[item], show ? SW_SHOW : SW_HIDE);
}
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
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);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
// For single selection items only
wxString wxRadioBox::GetStringSelection () const
wxString wxRadioBox::GetStringSelection() const
{
int sel = GetSelection ();
wxString result;
int sel = GetSelection();
if (sel > -1)
return this->GetString (sel);
else
return wxString("");
result = GetString(sel);
return result;
}
bool wxRadioBox::SetStringSelection (const wxString& s)
bool wxRadioBox::SetStringSelection(const wxString& s)
{
int sel = FindString (s);
if (sel > -1)
@ -185,10 +650,124 @@ bool wxRadioBox::SetStringSelection (const wxString& s)
return FALSE;
}
bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
{
int i;
for (i = 0; i < Number(); i++)
{
if (GetRadioButtons()[i] == hWnd)
return TRUE;
}
return FALSE;
}
void wxRadioBox::Command (wxCommandEvent & event)
{
SetSelection (event.m_commandInt);
ProcessCommand (event);
}
void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
{
HWND hwndBtn = (HWND)hWndBtn;
// TODO:
/*
if ( !s_wndprocRadioBtn )
s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC);
// No GWL_USERDATA in Win16, so omit this subclassing.
::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
*/
}
void wxRadioBox::SendNotificationEvent()
{
wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
event.SetInt( m_selectedButton );
event.SetString( GetString(m_selectedButton) );
event.SetEventObject( this );
ProcessCommand(event);
}
// ---------------------------------------------------------------------------
// window proc for radio buttons
// ---------------------------------------------------------------------------
MRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
UINT msg,
MPARAM wParam,
MPARAM lParam)
{
bool processed = TRUE;
if ( msg != WM_KEYDOWN )
processed = FALSE;
if ( processed )
{
wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA);
wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
int sel = radiobox->GetSelection();
// TODO:
/*
switch ( wParam )
{
case VK_UP:
sel--;
break;
case VK_LEFT:
sel -= radiobox->GetNumVer();
break;
case VK_DOWN:
sel++;
break;
case VK_RIGHT:
sel += radiobox->GetNumVer();
break;
case VK_TAB:
{
wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
event.SetWindowChange(FALSE);
event.SetEventObject(radiobox);
if ( radiobox->GetEventHandler()->ProcessEvent(event) )
return 0;
}
// fall through
default:
processed = FALSE;
}
*/
if ( processed )
{
if ( sel >= 0 && sel < radiobox->Number() )
{
radiobox->SetSelection(sel);
// emulate the button click
radiobox->SendNotificationEvent();
}
}
}
// TODO:
/*
if ( !processed )
return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, msg, wParam, lParam);
else
return 0;
*/
return 0;
}

View File

@ -1,26 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobut.cpp
// Purpose: wxRadioButton
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "radiobut.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/radiobut.h"
#include "wx/brush.h"
#endif
#include "wx/msw/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
#endif
bool wxRadioButton::OS2Command(WXUINT param, WXWORD id)
{
if (param == BN_CLICKED)
{
wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId);
event.SetEventObject( this );
ProcessCommand(event);
return TRUE;
}
else return FALSE;
}
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
@ -31,15 +53,73 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour());
if ( id == -1 )
m_windowId = (int)NewControlId();
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowId = id;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style ;
// TODO create radiobutton
return FALSE;
// TODO create radiobutton
/*
long groupStyle = 0;
if (m_windowStyle & wxRB_GROUP)
groupStyle = WS_GROUP;
// long msStyle = groupStyle | RADIO_FLAGS;
long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
bool want3D;
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
SetFont(parent->GetFont());
// Subclass again for purposes of dialog editing mode
SubclassWin((WXHWND)m_hWnd);
// SetValue(value);
*/
// start GRW fix
if (label != wxT(""))
{
int label_width, label_height;
GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont());
if (width < 0)
width = (int)(label_width + RADIO_SIZE);
if (height<0)
{
height = (int)(label_height);
if (height < RADIO_SIZE)
height = RADIO_SIZE;
}
}
else
{
if (width < 0)
width = RADIO_SIZE;
if (height < 0)
height = RADIO_SIZE;
}
// end GRW fix
SetSize(x, y, width, height);
return FALSE;
}
void wxRadioButton::SetLabel(const wxString& label)
@ -65,4 +145,69 @@ void wxRadioButton::Command (wxCommandEvent & event)
ProcessCommand (event);
}
bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap *bitmap,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour());
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;
m_windowStyle = style ;
long groupStyle = 0;
if (m_windowStyle & wxRB_GROUP)
groupStyle = WS_GROUP;
// TODO:
/*
// long msStyle = groupStyle | RADIO_FLAGS;
// long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
msStyle,0,0,0,0,
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
*/
// Subclass again for purposes of dialog editing mode
SubclassWin(GetHWND());
SetSize(x, y, width, height);
return TRUE;
}
void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap)
{
}
void wxBitmapRadioButton::SetValue(bool value)
{
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
// SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
}
// Get single selection, for single choice list items
bool wxBitmapRadioButton::GetValue(void) const
{
// return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);
return FALSE;
}

File diff suppressed because it is too large Load Diff