*** empty log message ***

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3924 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-10-11 02:49:06 +00:00
parent b782f2e0f6
commit 75f11ad7ca
17 changed files with 3639 additions and 969 deletions

View File

@@ -67,11 +67,19 @@ public:
~wxAcceleratorTable(); ~wxAcceleratorTable();
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if (*this == accel) return (*this); Ref(accel); return *this; } inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
inline bool operator == (const wxAcceleratorTable& accel) { return m_refData == accel.m_refData; } { if (*this == accel) return (*this); Ref(accel); return *this; };
inline bool operator != (const wxAcceleratorTable& accel) { return m_refData != accel.m_refData; } inline bool operator == (const wxAcceleratorTable& accel)
{ return m_refData == accel.m_refData; };
inline bool operator != (const wxAcceleratorTable& accel)
{ return m_refData != accel.m_refData; };
bool Ok() const; bool Ok() const;
void SetHACCEL(WXHACCEL hAccel);
WXHACCEL GetHACCEL() const;
// translate the accelerator, return TRUE if done
bool Translate(wxWindow *window, WXMSG *msg) const;
}; };
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable; WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;

View File

@@ -143,6 +143,10 @@ class WXDLLEXPORT wxDC: public wxDCBase
virtual void DoDrawSpline(wxList *points); virtual void DoDrawSpline(wxList *points);
#endif #endif
// OS2-specific member variables
int m_windowExtX;
int m_windowExtY;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Other virtuals from wxDCBase that are overridden here // Other virtuals from wxDCBase that are overridden here
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -1,21 +1,17 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: listctrl.h // Name: listctrl.h
// Purpose: wxListCtrl class // Purpose: wxListCtrl class
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTCTRL_H_ #ifndef _WX_LISTCTRL_H_
#define _WX_LISTCTRL_H_ #define _WX_LISTCTRL_H_
#ifdef __GNUG__
#pragma interface "listctrl.h"
#endif
#include "wx/control.h" #include "wx/control.h"
#include "wx/event.h" #include "wx/event.h"
#include "wx/imaglist.h" #include "wx/imaglist.h"
@@ -98,7 +94,7 @@ enum {
wxLIST_NEXT_ALL, // Searches for subsequent item by index wxLIST_NEXT_ALL, // Searches for subsequent item by index
wxLIST_NEXT_BELOW, // Searches for an item below the specified item wxLIST_NEXT_BELOW, // Searches for an item below the specified item
wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
wxLIST_NEXT_RIGHT, // Searches for an item to the right of the specified item wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
}; };
// Alignment flags for Arrange // Alignment flags for Arrange
@@ -189,6 +185,10 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Attributes // Attributes
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Sets the background colour (GetBackgroundColour already implicit in
// wxWindow class)
bool SetBackgroundColour(const wxColour& col);
// Gets information about this column // Gets information about this column
bool GetColumn(int col, wxListItem& item) const; bool GetColumn(int col, wxListItem& item) const;
@@ -285,11 +285,11 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Returns the item or -1 if unsuccessful. // Returns the item or -1 if unsuccessful.
long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ; long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
// Implementation: converts wxWindows style to MSW style. // Implementation: converts wxWindows style to OS2 style.
// Can be a single style flag or a bit list. // Can be a single style flag or a bit list.
// oldStyle is 'normalised' so that it doesn't contain // oldStyle is 'normalised' so that it doesn't contain
// conflicting styles. // conflicting styles.
long ConvertToMSWStyle(long& oldStyle, long style) const; long ConvertToOS2Style(long& oldStyle, long style) const;
// Gets one of the three image lists // Gets one of the three image lists
wxImageList *GetImageList(int which) const ; wxImageList *GetImageList(int which) const ;
@@ -390,15 +390,16 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// data is arbitrary data to be passed to the sort function. // data is arbitrary data to be passed to the sort function.
bool SortItems(wxListCtrlCompare fn, long data); bool SortItems(wxListCtrlCompare fn, long data);
/* Why should we need this function? Leave for now. // IMPLEMENTATION
* We might need it because item data may have changed, virtual bool OS2Command(WXUINT param, WXWORD id);
* but the display needs refreshing (in string callback mode) virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
// Updates an item. If the list control has the wxLI_AUTO_ARRANGE style,
// the items will be rearranged.
bool Update(long item);
*/
void Command(wxCommandEvent& event) { ProcessCommand(event); }; // bring the control in sync with current m_windowStyle value
void UpdateStyle();
// Add to pool: necessary because Windows needs to have a string
// still exist across 3 callbacks.
wxChar *AddPool(const wxString& str);
protected: protected:
wxTextCtrl* m_textCtrl; // The control used for editing a label wxTextCtrl* m_textCtrl; // The control used for editing a label
@@ -412,40 +413,9 @@ protected:
int m_colCount; // Windows doesn't have GetColumnCount so must int m_colCount; // Windows doesn't have GetColumnCount so must
// keep track of inserted/deleted columns // keep track of inserted/deleted columns
private:
bool DoCreateControl(int x, int y, int w, int h);
}; };
class WXDLLEXPORT wxListEvent: public wxCommandEvent
{
DECLARE_DYNAMIC_CLASS(wxListEvent)
public:
wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
int m_code;
long m_itemIndex;
long m_oldItemIndex;
int m_col;
bool m_cancelled;
wxPoint m_pointDrag;
wxListItem m_item;
};
typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#endif #endif
// _WX_LISTCTRL_H_ // _WX_LISTCTRL_H_

View File

@@ -3,21 +3,17 @@
// Purpose: MDI (Multiple Document Interface) classes. // Purpose: MDI (Multiple Document Interface) classes.
// This doesn't have to be implemented just like Windows, // This doesn't have to be implemented just like Windows,
// it could be a tabbed design as in wxGTK. // it could be a tabbed design as in wxGTK.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MDI_H_ #ifndef _WX_MDI_H_
#define _WX_MDI_H_ #define _WX_MDI_H_
#ifdef __GNUG__
#pragma interface "mdi.h"
#endif
#include "wx/frame.h" #include "wx/frame.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
@@ -55,40 +51,60 @@ public:
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxFrameNameStr); const wxString& name = wxFrameNameStr);
void OnSize(wxSizeEvent& event); // accessors
void OnActivate(wxActivateEvent& event); // ---------
void OnSysColourChanged(wxSysColourChangedEvent& event);
void SetMenuBar(wxMenuBar *menu_bar);
// Gets the size available for subwindows after menu size, toolbar size
// and status bar size have been subtracted. If you want to manage your own
// toolbar(s), don't call SetToolBar.
void GetClientSize(int *width, int *height) const;
// Get the active MDI child window (Windows only) // Get the active MDI child window (Windows only)
wxMDIChildFrame *GetActiveChild() const ; wxMDIChildFrame *GetActiveChild() const;
// Get the client window // Get the client window
inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
// Create the client window class (don't Create the window, // Create the client window class (don't Create the window,
// just return a new class) // just return a new class)
virtual wxMDIClientWindow *OnCreateClient() ; virtual wxMDIClientWindow *OnCreateClient(void);
WXHMENU GetWindowMenu() const { return m_windowMenu; }
// MDI operations // MDI operations
// --------------
virtual void Cascade(); virtual void Cascade();
virtual void Tile(); virtual void Tile();
virtual void ArrangeIcons(); virtual void ArrangeIcons();
virtual void ActivateNext(); virtual void ActivateNext();
virtual void ActivatePrevious(); virtual void ActivatePrevious();
// handlers
// --------
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnSize(wxSizeEvent& event);
bool HandleActivate(int state, bool minimized, WXHWND activate);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
// override window proc for MDI-specific message processing
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT, WXWPARAM, WXLPARAM);
virtual bool OS2TranslateMessage(WXMSG* msg);
protected: protected:
virtual void InternalSetMenuBar();
// TODO maybe have this member wxMDIClientWindow * m_clientWindow;
wxMDIClientWindow *m_clientWindow; wxMDIChildFrame * m_currentChild;
WXHMENU m_windowMenu;
DECLARE_EVENT_TABLE() // TRUE if MDI Frame is intercepting commands, not child
bool m_parentFrameActive;
private:
friend class WXDLLEXPORT wxMDIChildFrame;
DECLARE_EVENT_TABLE()
}; };
class WXDLLEXPORT wxMDIChildFrame: public wxFrame class WXDLLEXPORT wxMDIChildFrame: public wxFrame
@@ -118,18 +134,31 @@ public:
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr); const wxString& name = wxFrameNameStr);
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
void SetClientSize(int width, int height);
void GetPosition(int *x, int *y) const ;
// MDI operations // MDI operations
virtual void Maximize(); virtual void Maximize(bool maximize = TRUE);
virtual void Restore(); virtual void Restore();
virtual void Activate(); virtual void Activate();
private:
// supress virtual function hiding warning // Handlers
virtual void Maximize(bool maximize) { wxFrame::Maximize(maximize); };
bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
bool HandleSize(int x, int y, WXUINT);
bool HandleWindowPosChanging(void *lpPos);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
virtual bool OS2TranslateMessage(WXMSG *msg);
virtual void OS2DestroyWindow();
// Implementation
bool ResetWindowStyle(void *vrect);
protected:
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoSetClientSize(int width, int height);
virtual void InternalSetMenuBar();
}; };
/* The client window is a child of the parent MDI frame, and itself /* The client window is a child of the parent MDI frame, and itself
@@ -142,25 +171,31 @@ private:
class WXDLLEXPORT wxMDIClientWindow: public wxWindow class WXDLLEXPORT wxMDIClientWindow: public wxWindow
{ {
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
public: public:
wxMDIClientWindow() ; wxMDIClientWindow() { Init(); }
inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
{ {
Init();
CreateClient(parent, style); CreateClient(parent, style);
} }
~wxMDIClientWindow();
// Note: this is virtual, to allow overridden behaviour. // Note: this is virtual, to allow overridden behaviour.
virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); virtual bool CreateClient(wxMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL);
// Explicitly call default scroll behaviour // Explicitly call default scroll behaviour
void OnScroll(wxScrollEvent& event); void OnScroll(wxScrollEvent& event);
protected: protected:
void Init() { m_scrollX = m_scrollY = 0; }
DECLARE_EVENT_TABLE() int m_scrollX, m_scrollY;
private:
DECLARE_EVENT_TABLE()
}; };
#endif #endif

View File

@@ -1,27 +1,30 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: menu.h // Name: menu.h
// Purpose: wxMenu, wxMenuBar classes // Purpose: wxMenu, wxMenuBar classes
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENU_H_ #ifndef _WX_MENU_H_
#define _WX_MENU_H_ #define _WX_MENU_H_
#ifdef __GNUG__
#pragma interface "menu.h"
#endif
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/event.h" #include "wx/event.h"
#include "wx/dynarray.h"
#include "wx/string.h"
#if wxUSE_ACCEL
#include "wx/accel.h"
#endif // wxUSE_ACCEL
class WXDLLEXPORT wxMenuItem; class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenu; class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxFrame;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString; WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
@@ -33,140 +36,268 @@ class WXDLLEXPORT wxMenu: public wxEvtHandler
DECLARE_DYNAMIC_CLASS(wxMenu) DECLARE_DYNAMIC_CLASS(wxMenu)
public: public:
// ctor & dtor wxMenu(const wxString& title,
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL); const wxFunction func)
~wxMenu(); {
Init(title, func);
}
wxMenu( long WXUNUSED(style) )
{
Init( wxEmptyString );
}
wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
{
Init(title);
}
virtual ~wxMenu();
// construct menu // construct menu
// append items to the menu // append a separator to the menu
// separator line
void AppendSeparator(); void AppendSeparator();
// normal item // append a normal item to the menu
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString, void Append(int id, const wxString& label,
const wxString& helpString = wxEmptyString,
bool checkable = FALSE); bool checkable = FALSE);
// a submenu // append a submenu
void Append(int id, const wxString& Label, wxMenu *SubMenu, void Append(int id, const wxString& label,
wxMenu *submenu,
const wxString& helpString = wxEmptyString); const wxString& helpString = wxEmptyString);
// the most generic form (create wxMenuItem first and use it's functions) // append anything (create wxMenuItem first)
void Append(wxMenuItem *pItem); void Append(wxMenuItem *pItem);
// insert a break in the menu // insert a break in the menu
void Break(); void Break();
// delete an item // delete an item
// If it's a submenu, menu is not destroyed.
// VZ: why? shouldn't it return "wxMenu *" then?
void Delete(int id); void Delete(int id);
// menu item control // client data
void Enable(int id, bool Flag);
bool Enabled(int id) const;
inline bool IsEnabled(int id) const { return Enabled(id); };
void Check(int id, bool Flag);
bool Checked(int id) const;
inline bool IsChecked(int id) const { return IsChecked(id); };
// Client data
inline void SetClientData(void* clientData) { m_clientData = clientData; } inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void* GetClientData() const { return m_clientData; } inline void* GetClientData() const { return m_clientData; }
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; } // menu item control
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; } // enable/disable item
void Enable(int id, bool enable);
// TRUE if enabled
bool IsEnabled(int id) const;
// item properties // check/uncheck item - only for checkable items, of course
// title void Check(int id, bool check);
// TRUE if checked
bool IsChecked(int id) const;
// other properties
// the menu title
void SetTitle(const wxString& label); void SetTitle(const wxString& label);
const wxString GetTitle() const; const wxString GetTitle() const;
// label // the item label
void SetLabel(int id, const wxString& label); void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const; wxString GetLabel(int id) const;
// help string // help string
virtual void SetHelpString(int id, const wxString& helpString); virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ; virtual wxString GetHelpString(int id) const;
// get the list of items
inline wxList& GetItems() const { return (wxList &)m_menuItems; }
// find item // find item
// Finds the item id matching the given string, -1 if not found. // returns id of the item matching the given string or wxNOT_FOUND
virtual int FindItem(const wxString& itemString) const ; virtual int FindItem(const wxString& itemString) const;
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL. // returns NULL if not found
inline wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
// find wxMenuItem by ID, and item's menu too if itemMenu is !NULL
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const; wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
void ProcessCommand(wxCommandEvent& event); // Updates the UI for a menu and all submenus recursively. source is the
inline void Callback(const wxFunction func) { m_callback = func; } // object that has the update event handlers defined for it. If NULL, the
// menu or associated window will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*)NULL);
// Updates the UI for a menu and all submenus recursively. bool ProcessCommand(wxCommandEvent& event);
// source is the object that has the update event handlers
// defined for it. If NULL, the menu or associated window
// will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; } inline virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; } inline wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
inline wxList& GetItems() const { return (wxList&) m_menuItems; } // IMPLEMENTATION
bool OS2Command(WXUINT param, WXWORD id);
public: inline void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
inline wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
// semi-private accessors
// get the window which contains this menu
wxWindow *GetWindow() const;
// get the menu handle
WXHMENU GetHMenu() const;
// only for wxMenuBar
void Attach(wxMenuBar *menubar);
void Detach();
#if wxUSE_ACCEL
inline size_t GetAccelCount() const { return m_accelKeyCodes.GetCount(); }
size_t CopyAccels(wxAcceleratorEntry *accels) const;
#endif // wxUSE_ACCEL
inline wxFunction GetCallback() const { return m_callback; }
inline void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback; wxFunction m_callback;
#ifdef WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated
inline bool Enabled(int id) const { return IsEnabled(id); }
inline bool Checked(int id) const { return IsChecked(id); }
#endif // WXWIN_COMPATIBILITY
private:
// common part of all ctors
void Init(const wxString& title, const wxFunction func = NULL );
bool m_doBreak;
// This is used when m_hMenu is NULL because we don't want to
// delete it in ~wxMenu (it's been added to a parent menu).
// But we'll still need the handle for other purposes.
// Might be better to have a flag saying whether it's deleteable or not.
WXHMENU m_savehMenu ; // Used for Enable() on popup
WXHMENU m_hMenu;
int m_noItems; int m_noItems;
wxString m_title; wxString m_title;
wxMenu * m_topLevelMenu;
wxMenuBar * m_menuBar; wxMenuBar * m_menuBar;
wxList m_menuItems; wxList m_menuItems;
wxEvtHandler * m_parent; wxEvtHandler * m_parent;
wxEvtHandler * m_eventHandler; wxEvtHandler * m_eventHandler;
wxWindow *m_pInvokingWindow;
void* m_clientData; void* m_clientData;
wxWindow* m_pInvokingWindow;
#if wxUSE_ACCEL
// the accelerators data
wxArrayInt m_accelKeyCodes, m_accelFlags, m_accelIds;
#endif // wxUSE_ACCEL
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Menu Bar (a la Windows) // Menu Bar (a la Windows)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxMenuBar: public wxEvtHandler class WXDLLEXPORT wxMenuBar: public wxEvtHandler
{ {
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
// ctors & dtor
// default constructor
wxMenuBar(); wxMenuBar();
// unused under MSW
wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]); wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
~wxMenuBar(); virtual ~wxMenuBar();
// menubar construction
WXHMENU Create();
void Append(wxMenu *menu, const wxString& title); void Append(wxMenu *menu, const wxString& title);
// Must only be used AFTER menu has been attached to frame, void Insert(int pos, wxMenu * menu, const wxString& title);
void ReplaceMenu(int pos, wxMenu * new_menu, const wxString& title);
int FindMenu(const wxString& title);
void Detach();
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
// state control
// NB: must only be used AFTER menu has been attached to frame,
// otherwise use individual menus to enable/disable items // otherwise use individual menus to enable/disable items
void Enable(int Id, bool Flag); // enable the item
bool Enabled(int Id) const ; void Enable(int id, bool enable);
inline bool IsEnabled(int Id) const { return Enabled(Id); }; // TRUE if item enabled
void EnableTop(int pos, bool Flag); bool IsEnabled(int id) const;
void Check(int id, bool Flag); //
bool Checked(int id) const ; void EnableTop(int pos, bool enable);
inline bool IsChecked(int Id) const { return Checked(Id); };
// works only with checkable items
void Check(int id, bool check);
// TRUE if checked
bool IsChecked(int id) const;
void SetLabel(int id, const wxString& label) ; void SetLabel(int id, const wxString& label) ;
wxString GetLabel(int id) const ; wxString GetLabel(int id) const ;
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ;
void SetLabelTop(int pos, const wxString& label) ; void SetLabelTop(int pos, const wxString& label) ;
wxString GetLabelTop(int pos) const ; wxString GetLabelTop(int pos) const ;
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
virtual bool OnAppend(wxMenu *menu, const char *title); // notifications: return FALSE to prevent the menu from being
// appended/deleted
virtual bool OnAppend(wxMenu *menu, const wxChar *title);
virtual bool OnDelete(wxMenu *menu, int index); virtual bool OnDelete(wxMenu *menu, int index);
virtual void SetHelpString(int Id, const wxString& helpString); // item search
virtual wxString GetHelpString(int Id) const ; // by menu and item names, returns wxNOT_FOUND if not found
virtual int FindMenuItem(const wxString& menuString,
const wxString& itemString) const;
// returns NULL if not found
wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
// returns NULL if not found, fills menuForItem if !NULL
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const;
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ; // submenus access
inline int GetMenuCount() const { return m_menuCount; }
// Find wxMenuItem for item ID, and return item's inline wxMenu *GetMenu(int i) const { return m_menus[i]; }
// menu too if itemMenu is non-NULL.
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; } inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
inline int GetMenuCount() const { return m_menuCount; } #ifdef WXWIN_COMPATIBILITY
inline wxMenu* GetMenu(int i) const { return m_menus[i]; } // compatibility: these functions are deprecated
inline bool Enabled(int id) const { return IsEnabled(id); }
inline bool Checked(int id) const { return IsChecked(id); }
#endif // WXWIN_COMPATIBILITY
public: // IMPLEMENTATION
wxEvtHandler * m_eventHandler; // returns TRUE if we're attached to a frame
inline bool IsAttached() const { return m_menuBarFrame != NULL; }
// get the frame we live in
inline wxFrame *GetFrame() const { return m_menuBarFrame; }
// attach to a frame
void Attach(wxFrame *frame);
#if wxUSE_ACCEL
// get the accel table for the menus
inline const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
#endif // wxUSE_ACCEL
// get the menu handle
inline WXHMENU GetHMenu() const { return m_hMenu; }
// if the menubar is modified, the display is not updated automatically,
// call this function to update it (m_menuBarFrame should be !NULL)
void Refresh();
protected:
// common part of all ctors
void Init();
wxEvtHandler *m_eventHandler;
int m_menuCount; int m_menuCount;
wxMenu ** m_menus; wxMenu **m_menus;
wxString * m_titles; wxString *m_titles;
wxFrame * m_menuBarFrame; wxFrame *m_menuBarFrame;
/* TODO: data that represents the actual menubar when created. WXHMENU m_hMenu;
*/
#if wxUSE_ACCEL
// the accelerator table for all accelerators in all our menus
wxAcceleratorTable m_accelTable;
#endif // wxUSE_ACCEL
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -26,7 +26,7 @@
// headers - only because ownerdrw.h is not always included and I don't want // headers - only because ownerdrw.h is not always included and I don't want
// to write #ifdef's everywhere... // to write #ifdef's everywhere...
#if wxUSE_OWNER_DRAWN #if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h" #include "wx/ownerdrw.h"
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -57,13 +57,18 @@ public:
bool IsSeparator() const { return m_idItem == ID_SEPARATOR; } bool IsSeparator() const { return m_idItem == ID_SEPARATOR; }
bool IsEnabled() const { return m_bEnabled; } bool IsEnabled() const { return m_bEnabled; }
bool IsChecked() const { return m_bChecked; } bool IsChecked() const { return m_bChecked; }
bool IsSubMenu() const { return GetSubMenu() != NULL; }
int GetId() const { return m_idItem; } int GetId() const { return m_idItem; }
const wxString& GetHelp() const { return m_strHelp; } const wxString& GetHelp() const { return m_strHelp; }
wxMenu *GetSubMenu() const { return m_pSubMenu; } wxMenu *GetSubMenu() const { return m_pSubMenu; }
// the id for a popup menu is really its menu handle (as required by
// ::AppendMenu() API)
int GetRealId() const;
// operations // operations
void SetName(const wxString& strName) { m_strName = strName; } void SetName(const wxString& strName);
void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; } void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; }
void Enable(bool bDoEnable = TRUE); void Enable(bool bDoEnable = TRUE);

View File

@@ -3,11 +3,11 @@
// Purpose: wxMetaFile, wxMetaFileDC classes. // Purpose: wxMetaFile, wxMetaFileDC classes.
// This probably should be restricted to Windows platforms, // This probably should be restricted to Windows platforms,
// but if there is an equivalent on your platform, great. // but if there is an equivalent on your platform, great.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -15,74 +15,114 @@
#ifndef _WX_METAFIILE_H_ #ifndef _WX_METAFIILE_H_
#define _WX_METAFIILE_H_ #define _WX_METAFIILE_H_
#ifdef __GNUG__ #include "wx/setup.h"
#pragma interface "metafile.h"
#if wxUSE_METAFILE
#include "wx/dc.h"
#include "wx/gdiobj.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h"
#endif #endif
#include "wx/setup.h"
#include "wx/dc.h"
/* /*
* Metafile and metafile device context classes - work in Windows 3.1 only * Metafile and metafile device context classes
* *
*/ */
class WXDLLEXPORT wxDC; #define wxMetaFile wxMetafile
class WXDLLEXPORT wxMetaFile: public wxObject #define wxMetaFileDC wxMetafileDC
class WXDLLEXPORT wxMetafile;
class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
{ {
DECLARE_DYNAMIC_CLASS(wxMetaFile) friend class WXDLLEXPORT wxMetafile;
public:
wxMetafileRefData(void);
~wxMetafileRefData(void);
public:
WXHANDLE m_metafile;
int m_windowsMappingMode;
};
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
class WXDLLEXPORT wxMetafile: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxMetafile)
public: public:
wxMetaFile(const wxString& file = ""); // Copy constructor
~wxMetaFile(); inline wxMetafile(const wxMetafile& metafile)
{ Ref(metafile); }
wxMetafile(const wxString& file = "");
~wxMetafile(void);
// After this is called, the metafile cannot be used for anything // After this is called, the metafile cannot be used for anything
// since it is now owned by the clipboard. // since it is now owned by the clipboard.
virtual bool SetClipboard(int width = 0, int height = 0); virtual bool SetClipboard(int width = 0, int height = 0);
virtual bool Play(wxDC *dc); virtual bool Play(wxDC *dc);
// TODO inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
inline bool Ok() { return FALSE; };
/* TODO: Implementation // Implementation
inline WXHANDLE GetHMETAFILE() { return m_metaFile; } inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; } void SetHMETAFILE(WXHANDLE mf) ;
inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
void SetWindowsMappingMode(int mm);
// Operators
inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; }
inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; }
inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; }
protected: protected:
WXHANDLE m_metaFile;
*/
}; };
class WXDLLEXPORT wxMetaFileDC: public wxDC class WXDLLEXPORT wxMetafileDC: public wxDC
{ {
DECLARE_DYNAMIC_CLASS(wxMetaFileDC) DECLARE_DYNAMIC_CLASS(wxMetafileDC)
public: public:
// Don't supply origin and extent // Don't supply origin and extent
// Supply them to wxMakeMetaFilePlaceable instead. // Supply them to wxMakeMetaFilePlaceable instead.
wxMetaFileDC(const wxString& file = ""); wxMetafileDC(const wxString& file = "");
// Supply origin and extent (recommended). // Supply origin and extent (recommended).
// Then don't need to supply them to wxMakeMetaFilePlaceable. // Then don't need to supply them to wxMakeMetaFilePlaceable.
wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg); wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
~wxMetaFileDC(); ~wxMetafileDC(void);
// Should be called at end of drawing // Should be called at end of drawing
virtual wxMetaFile *Close(); virtual wxMetafile *Close(void);
virtual void SetMapMode(int mode); virtual void SetMapMode(int mode);
virtual void GetTextExtent(const wxString& string, float *x, float *y, virtual void GetTextExtent(const wxString& string, long *x, long *y,
float *descent = NULL, float *externalLeading = NULL, long *descent = NULL, long *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = FALSE); wxFont *theFont = NULL, bool use16bit = FALSE) const;
// Implementation // Implementation
inline wxMetaFile *GetMetaFile() { return m_metaFile; } inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; } inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
inline int GetWindowsMappingMode() { return m_windowsMappingMode; } inline int GetWindowsMappingMode(void) const { return m_windowsMappingMode; }
inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
protected: protected:
int m_windowsMappingMode; int m_windowsMappingMode;
wxMetaFile *m_metaFile; wxMetafile* m_metaFile;
private:
// function hiding warning supression
inline virtual void GetTextExtent( const wxString& string
,long* width
,long* height
,long* descent = NULL
,long* externalLeading = NULL
,wxFont* theFont = NULL
) const
{ GetTextExtent( string, width, height, descent, externalLeading, theFont, FALSE);};
}; };
/* /*
@@ -93,10 +133,56 @@ protected:
*/ */
// No origin or extent // No origin or extent
bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = 1.0); #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
// Optional origin and extent // Optional origin and extent
bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE); bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
// ----------------------------------------------------------------------------
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
// ----------------------------------------------------------------------------
// TODO: implement OLE side of things. At present, it's just for clipboard
// use.
#if wxUSE_DRAG_AND_DROP
class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
{
public:
// ctors
wxMetafileDataObject() { m_width = 0; m_height = 0; };
wxMetafileDataObject(const wxMetafile& metafile, int width = 0, int height = 0):
m_metafile(metafile), m_width(width), m_height(height) { }
void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
{ m_metafile = metafile; m_width = w; m_height = h; }
wxMetafile GetMetafile() const { return m_metafile; }
int GetWidth() const { return m_width; }
int GetHeight() const { return m_height; }
virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
/* ??
// implement base class pure virtuals
virtual wxDataFormat GetPreferredFormat() const
{ return (wxDataFormat) wxDataObject::Text; }
virtual bool IsSupportedFormat(wxDataFormat format) const
{ return format == wxDataObject::Text || format == wxDataObject::Locale; }
virtual size_t GetDataSize() const
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
virtual void GetDataHere(void *pBuf) const
{ memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
*/
private:
wxMetafile m_metafile;
int m_width;
int m_height;
};
#endif
#endif // wxUSE_METAFILE
#endif #endif
// _WX_METAFIILE_H_ // _WX_METAFIILE_H_

View File

@@ -3,21 +3,17 @@
// Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars. // Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars.
// If there is no equivalent on your platform, just make it a // If there is no equivalent on your platform, just make it a
// normal frame. // normal frame.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MINIFRAM_H_ #ifndef _WX_MINIFRAM_H_
#define _WX_MINIFRAM_H_ #define _WX_MINIFRAM_H_
#ifdef __GNUG__
#pragma interface "minifram.h"
#endif
#include "wx/frame.h" #include "wx/frame.h"
class WXDLLEXPORT wxMiniFrame: public wxFrame { class WXDLLEXPORT wxMiniFrame: public wxFrame {
@@ -25,22 +21,21 @@ class WXDLLEXPORT wxMiniFrame: public wxFrame {
DECLARE_DYNAMIC_CLASS(wxMiniFrame) DECLARE_DYNAMIC_CLASS(wxMiniFrame)
public: public:
inline wxMiniFrame() {} inline wxMiniFrame(void) {}
inline wxMiniFrame(wxWindow *parent, inline wxMiniFrame(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr) const wxString& name = wxFrameNameStr)
{ {
// Use wxFrame constructor in absence of more specific code. Create(parent, id, title, pos, size, style | wxFRAME_TOOL_WINDOW | wxFRAME_FLOAT_ON_PARENT, name);
Create(parent, id, title, pos, size, style, name);
} }
~wxMiniFrame() {}
protected: protected:
}; };
#endif #endif
// _WX_MINIFRAM_H_ // _WX_MINIFRAM_H_

View File

@@ -9,13 +9,19 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "accel.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/window.h"
#endif #endif
#include "wx/setup.h" #include "wx/os2/accel.h"
#include "wx/accel.h"
#include "wx/string.h" #include "wx/os2/private.h"
#if !USE_SHARED_LIBRARIES #if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
@@ -28,11 +34,9 @@ public:
wxAcceleratorRefData(); wxAcceleratorRefData();
~wxAcceleratorRefData(); ~wxAcceleratorRefData();
/* TODO: implementation
inline HACCEL GetHACCEL() const { return m_hAccel; } inline HACCEL GetHACCEL() const { return m_hAccel; }
protected: protected:
HACCEL m_hAccel; HACCEL m_hAccel;
*/
}; };
#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData) #define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
@@ -91,3 +95,29 @@ bool wxAcceleratorTable::Ok() const
return FALSE; return FALSE;
} }
void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel)
{
if (!M_ACCELDATA)
m_refData = new wxAcceleratorRefData;
M_ACCELDATA->m_hAccel = (HACCEL) hAccel;
}
WXHACCEL wxAcceleratorTable::GetHACCEL() const
{
if (!M_ACCELDATA)
return 0;
return (WXHACCEL) M_ACCELDATA->m_hAccel;
}
bool wxAcceleratorTable::Translate(wxWindow *window, WXMSG *wxmsg) const
{
// TODO:
/*
MSG *msg = (MSG *)wxmsg;
return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg);
*/
return FALSE;
}

View File

@@ -1,25 +1,35 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: listctrl.cpp // Name: listctrl.cpp
// Purpose: wxListCtrl. See also Robert's generic wxListCtrl // Purpose: wxListCtrl. See also Robert's generic wxListCtrl
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "listctrl.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/stubs/textctrl.h" #include "wx/listctrl.h"
#include "wx/stubs/listctrl.h" #include "wx/log.h"
#include "wx/os2/private.h"
// TODO: not sure if we will need these
/*
static void wxConvertToOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem);
static void wxConvertFromOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& tvItem, HWND getFullInfo = 0);
*/
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
#endif #endif
wxListCtrl::wxListCtrl() wxListCtrl::wxListCtrl()
@@ -29,6 +39,7 @@ wxListCtrl::wxListCtrl()
m_imageListState = NULL; m_imageListState = NULL;
m_baseStyle = 0; m_baseStyle = 0;
m_colCount = 0; m_colCount = 0;
m_textCtrl = NULL;
} }
bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
@@ -42,6 +53,11 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con
SetValidator(validator); SetValidator(validator);
SetName(name); SetName(name);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style; m_windowStyle = style;
SetParent(parent); SetParent(parent);
@@ -51,11 +67,102 @@ bool wxListCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, con
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
// TODO create list control // TODO create list control
// DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP |
// LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS;
// if ( wxStyleHasBorder(m_windowStyle) )
// wstyle |= WS_BORDER;
// m_baseStyle = wstyle;
//
// if ( !DoCreateControl(x, y, width, height) )
// return FALSE;
//
// if (parent)
// parent->AddChild(this);
return TRUE; return TRUE;
} }
bool wxListCtrl::DoCreateControl(int x, int y, int w, int h)
{
DWORD wstyle = m_baseStyle;
bool want3D;
// TODO
// WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
// if ( want3D )
// wstyle |= WS_BORDER;
// long oldStyle = 0; // Dummy
// wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
// Create the ListView control.
// m_hWnd = (WXHWND)CreateWindowEx(exStyle,
// WC_LISTVIEW,
// wxT(""),
// wstyle,
// x, y, w, h,
// GetWinHwnd(GetParent()),
// (HMENU)m_windowId,
// wxGetInstance(),
// NULL);
// if ( !m_hWnd )
// {
// wxLogError(wxT("Can't create list control window."));
//
// return FALSE;
// }
// for comctl32.dll v 4.70+ we want to have this attribute because it's
// prettier (and also because wxGTK does it like this)
#ifdef ListView_SetExtendedListViewStyle
// if ( wstyle & LVS_REPORT )
// {
// ListView_SetExtendedListViewStyle(GetHwnd(),
// LVS_EX_FULLROWSELECT);
// }
#endif // ListView_SetExtendedListViewStyle
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
SetForegroundColour(GetParent()->GetForegroundColour());
// SubclassWin(m_hWnd);
return TRUE;
}
void wxListCtrl::UpdateStyle()
{
/*
if ( GetHWND() )
{
// The new window view style
long dummy;
DWORD dwStyleNew = ConvertToMSWStyle(dummy, m_windowStyle);
dwStyleNew |= m_baseStyle;
// Get the current window style.
DWORD dwStyleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE);
// Only set the window style if the view bits have changed.
if ( dwStyleOld != dwStyleNew )
{
::SetWindowLong(GetHwnd(), GWL_STYLE, dwStyleNew);
}
}
*/
}
wxListCtrl::~wxListCtrl() wxListCtrl::~wxListCtrl()
{ {
if (m_textCtrl)
{
m_textCtrl->UnsubclassWin();
m_textCtrl->SetHWND(0);
delete m_textCtrl;
m_textCtrl = NULL;
}
} }
// Add or remove a single window style // Add or remove a single window style
@@ -89,7 +196,7 @@ void wxListCtrl::SetSingleStyle(long style, bool add)
m_windowStyle = flag; m_windowStyle = flag;
/* TODO RecreateWindow(); */ UpdateStyle();
} }
// Set the whole window style // Set the whole window style
@@ -97,9 +204,120 @@ void wxListCtrl::SetWindowStyleFlag(long flag)
{ {
m_windowStyle = flag; m_windowStyle = flag;
/* TODO RecreateWindow(); */ UpdateStyle();
} }
// Can be just a single style, or a bitlist
long wxListCtrl::ConvertToOS2Style(long& oldStyle, long style) const
{
long wstyle = 0;
/*
if ( style & wxLC_ICON )
{
if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
oldStyle -= LVS_SMALLICON;
if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
oldStyle -= LVS_REPORT;
if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
oldStyle -= LVS_LIST;
wstyle |= LVS_ICON;
}
if ( style & wxLC_SMALL_ICON )
{
if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
oldStyle -= LVS_ICON;
if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
oldStyle -= LVS_REPORT;
if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
oldStyle -= LVS_LIST;
wstyle |= LVS_SMALLICON;
}
if ( style & wxLC_LIST )
{
if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
oldStyle -= LVS_ICON;
if ( (oldStyle & LVS_TYPEMASK) == LVS_REPORT )
oldStyle -= LVS_REPORT;
if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
oldStyle -= LVS_SMALLICON;
wstyle |= LVS_LIST;
}
if ( style & wxLC_REPORT )
{
if ( (oldStyle & LVS_TYPEMASK) == LVS_ICON )
oldStyle -= LVS_ICON;
if ( (oldStyle & LVS_TYPEMASK) == LVS_LIST )
oldStyle -= LVS_LIST;
if ( (oldStyle & LVS_TYPEMASK) == LVS_SMALLICON )
oldStyle -= LVS_SMALLICON;
wstyle |= LVS_REPORT;
}
if ( style & wxLC_ALIGN_LEFT )
{
if ( oldStyle & LVS_ALIGNTOP )
oldStyle -= LVS_ALIGNTOP;
wstyle |= LVS_ALIGNLEFT;
}
if ( style & wxLC_ALIGN_TOP )
{
if ( oldStyle & LVS_ALIGNLEFT )
oldStyle -= LVS_ALIGNLEFT;
wstyle |= LVS_ALIGNTOP;
}
if ( style & wxLC_AUTOARRANGE )
wstyle |= LVS_AUTOARRANGE;
// Apparently, no such style (documentation wrong?)
// if ( style & wxLC_BUTTON )
// wstyle |= LVS_BUTTON;
if ( style & wxLC_NO_SORT_HEADER )
wstyle |= LVS_NOSORTHEADER;
if ( style & wxLC_NO_HEADER )
wstyle |= LVS_NOCOLUMNHEADER;
if ( style & wxLC_EDIT_LABELS )
wstyle |= LVS_EDITLABELS;
if ( style & wxLC_SINGLE_SEL )
wstyle |= LVS_SINGLESEL;
if ( style & wxLC_SORT_ASCENDING )
{
if ( oldStyle & LVS_SORTDESCENDING )
oldStyle -= LVS_SORTDESCENDING;
wstyle |= LVS_SORTASCENDING;
}
if ( style & wxLC_SORT_DESCENDING )
{
if ( oldStyle & LVS_SORTASCENDING )
oldStyle -= LVS_SORTASCENDING;
wstyle |= LVS_SORTDESCENDING;
}
*/
return wstyle;
}
// Sets the background colour (GetBackgroundColour already implicit in
// wxWindow class)
bool wxListCtrl::SetBackgroundColour(const wxColour& col)
{
if ( !wxWindow::SetBackgroundColour(col) )
return FALSE;
// ListView_SetBkColor(GetHwnd(), PALETTERGB(col.Red(), col.Green(), col.Blue()));
return TRUE;
}
// Gets information about this column // Gets information about this column
bool wxListCtrl::GetColumn(int col, wxListItem& item) const bool wxListCtrl::GetColumn(int col, wxListItem& item) const
@@ -567,6 +785,235 @@ bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
return FALSE; return FALSE;
} }
bool wxListCtrl::OS2Command(WXUINT cmd, WXWORD id)
{
/*
if (cmd == EN_UPDATE)
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
event.SetEventObject( this );
ProcessCommand(event);
return TRUE;
}
else if (cmd == EN_KILLFOCUS)
{
wxCommandEvent event(wxEVT_KILL_FOCUS, id);
event.SetEventObject( this );
ProcessCommand(event);
return TRUE;
}
else
return FALSE;
*/
return FALSE;
}
bool wxListCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
// TODO
/*
wxListEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
NMHDR *hdr1 = (NMHDR *) lParam;
switch ( hdr1->code )
{
case LVN_BEGINRDRAG:
eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
// fall through
case LVN_BEGINDRAG:
if ( eventType == wxEVT_NULL )
{
eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
}
{
NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam;
event.m_itemIndex = hdr->iItem;
event.m_pointDrag.x = hdr->ptAction.x;
event.m_pointDrag.y = hdr->ptAction.y;
}
break;
case LVN_BEGINLABELEDIT:
{
eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
break;
}
case LVN_COLUMNCLICK:
{
eventType = wxEVT_COMMAND_LIST_COL_CLICK;
NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
event.m_itemIndex = -1;
event.m_col = hdr->iSubItem;
break;
}
case LVN_DELETEALLITEMS:
// what's the sense of generating a wxWin event for this when
// it's absolutely not portable?
#if 0
eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
event.m_itemIndex = -1;
#endif // 0
// return TRUE to suppress all additional LVN_DELETEITEM
// notifications - this makes deleting all items from a list ctrl
// much faster
*result = TRUE;
return TRUE;
case LVN_DELETEITEM:
{
eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
event.m_itemIndex = hdr->iItem;
break;
}
case LVN_ENDLABELEDIT:
{
eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
if ( info->item.pszText == NULL || info->item.iItem == -1 )
event.m_cancelled = TRUE;
break;
}
case LVN_GETDISPINFO:
return FALSE;
// this provokes stack overflow: indeed, wxConvertFromMSWListItem()
// sends us WM_NOTIFY! As it doesn't do anything for now, just leave
// it out.
#if 0
{
// TODO: some text buffering here, I think
// TODO: API for getting Windows to retrieve values
// on demand.
eventType = wxEVT_COMMAND_LIST_GET_INFO;
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
break;
}
#endif // 0
case LVN_INSERTITEM:
{
eventType = wxEVT_COMMAND_LIST_INSERT_ITEM;
NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
event.m_itemIndex = hdr->iItem;
break;
}
case LVN_ITEMCHANGED:
{
// This needs to be sent to wxListCtrl as a rather more
// concrete event. For now, just detect a selection
// or deselection.
NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
if ( (hdr->uNewState & LVIS_SELECTED) && !(hdr->uOldState & LVIS_SELECTED) )
{
eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
event.m_itemIndex = hdr->iItem;
}
else if ( !(hdr->uNewState & LVIS_SELECTED) && (hdr->uOldState & LVIS_SELECTED) )
{
eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
event.m_itemIndex = hdr->iItem;
}
else
return FALSE;
break;
}
case LVN_KEYDOWN:
{
LV_KEYDOWN *info = (LV_KEYDOWN *)lParam;
WORD wVKey = info->wVKey;
// get the current selection
long lItem = GetNextItem(-1,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
// <Enter> or <Space> activate the selected item if any
if ( lItem != -1 && (wVKey == VK_RETURN || wVKey == VK_SPACE) )
{
// TODO this behaviour probably should be optional
eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
event.m_itemIndex = lItem;
}
else
{
eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
event.m_code = wxCharCodeMSWToWX(wVKey);
}
break;
}
case NM_DBLCLK:
// if the user processes it in wxEVT_COMMAND_LEFT_CLICK(), don't do
// anything else
if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
{
return TRUE;
}
// else translate it into wxEVT_COMMAND_LIST_ITEM_ACTIVATED event
eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
break;
case LVN_SETDISPINFO:
{
eventType = wxEVT_COMMAND_LIST_SET_INFO;
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
break;
}
default:
return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
event.SetEventObject( this );
event.SetEventType(eventType);
if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
if (hdr1->code == LVN_GETDISPINFO)
{
LV_DISPINFO *info = (LV_DISPINFO *)lParam;
if ( info->item.mask & LVIF_TEXT )
{
if ( !event.m_item.m_text.IsNull() )
{
info->item.pszText = AddPool(event.m_item.m_text);
info->item.cchTextMax = wxStrlen(info->item.pszText) + 1;
}
}
// wxConvertToMSWListItem(this, event.m_item, info->item);
}
*result = !event.IsAllowed();
*/
return TRUE;
}
wxChar *wxListCtrl::AddPool(const wxString& str)
{
// Remove the first element if 3 strings exist
if ( m_stringPool.Number() == 3 )
{
wxNode *node = m_stringPool.First();
delete[] (char *)node->Data();
delete node;
}
wxNode *node = m_stringPool.Add(WXSTRINGCAST str);
return (wxChar *)node->Data();
}
// List item structure // List item structure
wxListItem::wxListItem() wxListItem::wxListItem()
{ {
@@ -582,11 +1029,158 @@ wxListItem::wxListItem()
m_width = 0; m_width = 0;
} }
// TODO see if we need these
/*
static void wxConvertFromOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem, HWND getFullInfo)
{
info.m_data = lvItem.lParam;
info.m_mask = 0;
info.m_state = 0;
info.m_stateMask = 0;
info.m_itemId = lvItem.iItem;
long oldMask = lvItem.mask;
bool needText = FALSE;
if (getFullInfo != 0)
{
if ( lvItem.mask & LVIF_TEXT )
needText = FALSE;
else
needText = TRUE;
if ( needText )
{
lvItem.pszText = new wxChar[513];
lvItem.cchTextMax = 512;
}
// lvItem.mask |= TVIF_HANDLE | TVIF_STATE | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
lvItem.mask |= LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
::SendMessage(getFullInfo, LVM_GETITEM, 0, (LPARAM)& lvItem);
}
if ( lvItem.mask & LVIF_STATE )
{
info.m_mask |= wxLIST_MASK_STATE;
if ( lvItem.stateMask & LVIS_CUT)
{
info.m_stateMask |= wxLIST_STATE_CUT;
if ( lvItem.state & LVIS_CUT )
info.m_state |= wxLIST_STATE_CUT;
}
if ( lvItem.stateMask & LVIS_DROPHILITED)
{
info.m_stateMask |= wxLIST_STATE_DROPHILITED;
if ( lvItem.state & LVIS_DROPHILITED )
info.m_state |= wxLIST_STATE_DROPHILITED;
}
if ( lvItem.stateMask & LVIS_FOCUSED)
{
info.m_stateMask |= wxLIST_STATE_FOCUSED;
if ( lvItem.state & LVIS_FOCUSED )
info.m_state |= wxLIST_STATE_FOCUSED;
}
if ( lvItem.stateMask & LVIS_SELECTED)
{
info.m_stateMask |= wxLIST_STATE_SELECTED;
if ( lvItem.state & LVIS_SELECTED )
info.m_state |= wxLIST_STATE_SELECTED;
}
}
if ( lvItem.mask & LVIF_TEXT )
{
info.m_mask |= wxLIST_MASK_TEXT;
info.m_text = lvItem.pszText;
}
if ( lvItem.mask & LVIF_IMAGE )
{
info.m_mask |= wxLIST_MASK_IMAGE;
info.m_image = lvItem.iImage;
}
if ( lvItem.mask & LVIF_PARAM )
info.m_mask |= wxLIST_MASK_DATA;
if ( lvItem.mask & LVIF_DI_SETITEM )
info.m_mask |= wxLIST_SET_ITEM;
info.m_col = lvItem.iSubItem;
if (needText)
{
if (lvItem.pszText)
delete[] lvItem.pszText;
}
lvItem.mask = oldMask;
}
static void wxConvertToOS2ListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ITEM& lvItem)
{
lvItem.iItem = (int) info.m_itemId;
lvItem.iImage = info.m_image;
lvItem.lParam = info.m_data;
lvItem.stateMask = 0;
lvItem.state = 0;
lvItem.mask = 0;
lvItem.iSubItem = info.m_col;
if (info.m_mask & wxLIST_MASK_STATE)
{
lvItem.mask |= LVIF_STATE;
if (info.m_stateMask & wxLIST_STATE_CUT)
{
lvItem.stateMask |= LVIS_CUT;
if (info.m_state & wxLIST_STATE_CUT)
lvItem.state |= LVIS_CUT;
}
if (info.m_stateMask & wxLIST_STATE_DROPHILITED)
{
lvItem.stateMask |= LVIS_DROPHILITED;
if (info.m_state & wxLIST_STATE_DROPHILITED)
lvItem.state |= LVIS_DROPHILITED;
}
if (info.m_stateMask & wxLIST_STATE_FOCUSED)
{
lvItem.stateMask |= LVIS_FOCUSED;
if (info.m_state & wxLIST_STATE_FOCUSED)
lvItem.state |= LVIS_FOCUSED;
}
if (info.m_stateMask & wxLIST_STATE_SELECTED)
{
lvItem.stateMask |= LVIS_SELECTED;
if (info.m_state & wxLIST_STATE_SELECTED)
lvItem.state |= LVIS_SELECTED;
}
}
if (info.m_mask & wxLIST_MASK_TEXT)
{
lvItem.mask |= LVIF_TEXT;
if ( ctrl->GetWindowStyleFlag() & wxLC_USER_TEXT )
{
lvItem.pszText = LPSTR_TEXTCALLBACK;
}
else
{
lvItem.pszText = WXSTRINGCAST info.m_text;
if ( lvItem.pszText )
lvItem.cchTextMax = info.m_text.Length();
else
lvItem.cchTextMax = 0;
}
}
if (info.m_mask & wxLIST_MASK_IMAGE)
lvItem.mask |= LVIF_IMAGE;
if (info.m_mask & wxLIST_MASK_DATA)
lvItem.mask |= LVIF_PARAM;
}
*/
// List event // List event
IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent)
wxListEvent::wxListEvent(wxEventType commandType, int id): wxListEvent::wxListEvent(wxEventType commandType, int id)
wxCommandEvent(commandType, id) : wxNotifyEvent(commandType, id)
{ {
m_code = 0; m_code = 0;
m_itemIndex = 0; m_itemIndex = 0;

View File

@@ -1,11 +1,11 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: main.cpp // Name: main.cpp
// Purpose: Entry point // Purpose: Entry point
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@@ -326,9 +326,15 @@ OS2OBJS = \
..\os2\$D\iniconf.obj \ ..\os2\$D\iniconf.obj \
..\os2\$D\joystick.obj \ ..\os2\$D\joystick.obj \
..\os2\$D\listbox.obj \ ..\os2\$D\listbox.obj \
..\os2\$D\listctrl.obj \
..\os2\$D\main.obj \
..\os2\$D\mdi.obj \
..\os2\$D\menu.obj \
..\os2\$D\menuitem.obj \
..\os2\$D\metafile.obj \
..\os2\$D\minifram.obj \
..\os2\$D\window.obj ..\os2\$D\window.obj
OS2LIBOBJS = \ OS2LIBOBJS = \
accel.obj \ accel.obj \
app.obj \ app.obj \
@@ -367,6 +373,13 @@ OS2LIBOBJS = \
iniconf.obj \ iniconf.obj \
joystick.obj \ joystick.obj \
listbox.obj \ listbox.obj \
listctrl.obj \
main.obj \
mdi.obj \
menu.obj \
menuitem.obj \
metafile.obj \
minifram.obj \
window.obj window.obj
HTMLOBJS = \ HTMLOBJS = \
@@ -551,6 +564,13 @@ $(OS2LIBOBJS):
copy ..\os2\$D\iniconf.obj copy ..\os2\$D\iniconf.obj
copy ..\os2\$D\joystick.obj copy ..\os2\$D\joystick.obj
copy ..\os2\$D\listbox.obj copy ..\os2\$D\listbox.obj
copy ..\os2\$D\listctrl.obj
copy ..\os2\$D\main.obj
copy ..\os2\$D\mdi.obj
copy ..\os2\$D\menu.obj
copy ..\os2\$D\menuitem.obj
copy ..\os2\$D\metafile.obj
copy ..\os2\$D\minifram.obj
copy ..\os2\$D\window.obj copy ..\os2\$D\window.obj
# wxWindows library as DLL # wxWindows library as DLL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.cpp // Name: menuitem.cpp
// Purpose: wxMenuItem implementation // Purpose: wxMenuItem implementation
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -13,8 +13,31 @@
// headers & declarations // headers & declarations
// ============================================================================ // ============================================================================
#include "wx/menu.h" // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/font.h"
#include "wx/bitmap.h"
#include "wx/settings.h"
#include "wx/font.h"
#include "wx/window.h"
#include "wx/accel.h"
#include "wx/menu.h"
#include "wx/string.h"
#endif
#include "wx/ownerdrw.h"
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/log.h"
#include "wx/os2/private.h"
// ---------------------------------------------------------------------------
// convenience macro
// ---------------------------------------------------------------------------
#define GetHMenuOf(menu) ((HMENU)menu->GetHMenu())
// ============================================================================ // ============================================================================
// implementation // implementation
@@ -24,8 +47,13 @@
// dynamic classes implementation // dynamic classes implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !defined(USE_SHARED_LIBRARY) || !USE_SHARED_LIBRARY
#if wxUSE_OWNER_DRAWN
IMPLEMENT_DYNAMIC_CLASS2(wxMenuItem, wxObject, wxOwnerDrawn)
#else //!USE_OWNER_DRAWN
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_OWNER_DRAWN
#endif //USE_SHARED_LIBRARY #endif //USE_SHARED_LIBRARY
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -39,16 +67,34 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
const wxString& strName, const wxString& strHelp, const wxString& strName, const wxString& strHelp,
bool bCheckable, bool bCheckable,
wxMenu *pSubMenu) : wxMenu *pSubMenu) :
#if wxUSE_OWNER_DRAWN
wxOwnerDrawn(strName, bCheckable),
#else //no owner drawn support
m_bCheckable(bCheckable), m_bCheckable(bCheckable),
m_strName(strName), m_strName(strName),
#endif //owner drawn
m_strHelp(strHelp) m_strHelp(strHelp)
{ {
wxASSERT( pParentMenu != NULL ); wxASSERT_MSG( pParentMenu != NULL, wxT("a menu item should have a parent") );
#if wxUSE_OWNER_DRAWN
// set default menu colors
#define SYS_COLOR(c) (wxSystemSettings::GetSystemColour(wxSYS_COLOUR_##c))
SetTextColour(SYS_COLOR(MENUTEXT));
SetBackgroundColour(SYS_COLOR(MENU));
// we don't want normal items be owner-drawn
ResetOwnerDrawn();
#undef SYS_COLOR
#endif
m_pParentMenu = pParentMenu; m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu; m_pSubMenu = pSubMenu;
m_idItem = id;
m_bEnabled = TRUE; m_bEnabled = TRUE;
m_bChecked = FALSE;
m_idItem = id;
} }
wxMenuItem::~wxMenuItem() wxMenuItem::~wxMenuItem()
@@ -58,11 +104,16 @@ wxMenuItem::~wxMenuItem()
// misc // misc
// ---- // ----
// return the id for calling Win32 API functions
int wxMenuItem::GetRealId() const
{
return m_pSubMenu ? (int)m_pSubMenu->GetHMenu() : GetId();
}
// delete the sub menu // delete the sub menu
// -------------------
void wxMenuItem::DeleteSubMenu() void wxMenuItem::DeleteSubMenu()
{ {
wxASSERT( m_pSubMenu != NULL );
delete m_pSubMenu; delete m_pSubMenu;
m_pSubMenu = NULL; m_pSubMenu = NULL;
} }
@@ -72,24 +123,93 @@ void wxMenuItem::DeleteSubMenu()
void wxMenuItem::Enable(bool bDoEnable) void wxMenuItem::Enable(bool bDoEnable)
{ {
// TODO:
/*
if ( m_bEnabled != bDoEnable ) { if ( m_bEnabled != bDoEnable ) {
if ( m_pSubMenu == NULL ) { // normal menu item long rc = EnableMenuItem(GetHMenuOf(m_pParentMenu),
// TODO GetRealId(),
} MF_BYCOMMAND |
else // submenu (bDoEnable ? MF_ENABLED : MF_GRAYED));
{
// TODO if ( rc == -1 ) {
wxLogLastError("EnableMenuItem");
} }
m_bEnabled = bDoEnable; m_bEnabled = bDoEnable;
} }
*/
} }
void wxMenuItem::Check(bool bDoCheck) void wxMenuItem::Check(bool bDoCheck)
{ {
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
// TODO:
/*
if ( m_bChecked != bDoCheck ) { if ( m_bChecked != bDoCheck ) {
// TODO long rc = CheckMenuItem(GetHMenuOf(m_pParentMenu),
GetId(),
MF_BYCOMMAND |
(bDoCheck ? MF_CHECKED : MF_UNCHECKED));
if ( rc == -1 ) {
wxLogLastError("CheckMenuItem");
}
m_bChecked = bDoCheck; m_bChecked = bDoCheck;
} }
*/
}
void wxMenuItem::SetName(const wxString& strName)
{
// don't do anything if label didn't change
if ( m_strName == strName )
return;
m_strName = strName;
HMENU hMenu = GetHMenuOf(m_pParentMenu);
UINT id = GetRealId();
// TODO:
/*
UINT flagsOld = ::GetMenuState(hMenu, id, MF_BYCOMMAND);
if ( flagsOld == 0xFFFFFFFF )
{
wxLogLastError("GetMenuState");
}
else
{
if ( IsSubMenu() )
{
// high byte contains the number of items in a submenu for submenus
flagsOld &= 0xFF;
flagsOld |= MF_POPUP;
}
LPCTSTR data;
#if wxUSE_OWNER_DRAWN
if ( IsOwnerDrawn() )
{
flagsOld |= MF_OWNERDRAW;
data = (LPCTSTR)this;
}
else
#endif //owner drawn
{
flagsOld |= MF_STRING;
data = strName;
}
if ( ::ModifyMenu(hMenu, id,
MF_BYCOMMAND | flagsOld,
id, data) == 0xFFFFFFFF )
{
wxLogLastError(wxT("ModifyMenu"));
}
}
*/
}

View File

@@ -1,58 +1,122 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: metafile.cpp // Name: metafile.cpp
// Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional. // Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "metafile.h" #include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#endif #endif
#include "wx/object.h" #if wxUSE_METAFILE
#include "wx/string.h"
#include "wx/dc.h" #ifndef WX_PRECOMP
#include "wx/stubs/metafile.h" #include "wx/utils.h"
#include "wx/app.h"
#endif
#include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/os2/private.h"
#include <stdio.h>
#include <string.h>
extern bool wxClipboardIsOpen; extern bool wxClipboardIsOpen;
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC) IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
#endif #endif
wxMetaFile::wxMetaFile(const wxString& file) /*
* Metafiles
* Currently, the only purpose for making a metafile is to put
* it on the clipboard.
*/
wxMetafileRefData::wxMetafileRefData(void)
{ {
// TODO m_metafile = 0;
m_windowsMappingMode = wxMM_ANISOTROPIC;
} }
wxMetaFile::~wxMetaFile() wxMetafileRefData::~wxMetafileRefData(void)
{ {
// TODO if (m_metafile)
{
// TODO: DeleteMetaFile((HMETAFILE) m_metafile);
m_metafile = 0;
}
} }
bool wxMetaFile::SetClipboard(int width, int height) wxMetafile::wxMetafile(const wxString& file)
{ {
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_windowsMappingMode = wxMM_ANISOTROPIC;
M_METAFILEDATA->m_metafile = 0;
if (!file.IsNull() && (file.Cmp(wxT("")) == 0))
M_METAFILEDATA->m_metafile = (WXHANDLE)0; // TODO: GetMetaFile(file);
}
wxMetafile::~wxMetafile(void)
{
}
bool wxMetafile::SetClipboard(int width, int height)
{
if (!m_refData)
return FALSE;
bool alreadyOpen=wxClipboardOpen(); bool alreadyOpen=wxClipboardOpen();
if (!alreadyOpen) if (!alreadyOpen)
{ {
wxOpenClipboard(); wxOpenClipboard();
if (!wxEmptyClipboard()) return FALSE; if (!wxEmptyClipboard()) return FALSE;
} }
bool success = wxSetClipboardData(wxDF_METAFILE,this, width,height); bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
if (!alreadyOpen) wxCloseClipboard(); if (!alreadyOpen) wxCloseClipboard();
return (bool) success; return (bool) success;
} }
bool wxMetaFile::Play(wxDC *dc) bool wxMetafile::Play(wxDC *dc)
{ {
// TODO if (!m_refData)
return FALSE; return FALSE;
dc->BeginDrawing();
// if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
// PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
dc->EndDrawing();
return TRUE;
}
void wxMetafile::SetHMETAFILE(WXHANDLE mf)
{
if (m_refData)
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_metafile = mf;
}
void wxMetafile::SetWindowsMappingMode(int mm)
{
if (m_refData)
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_windowsMappingMode = mm;
} }
/* /*
@@ -61,41 +125,155 @@ bool wxMetaFile::Play(wxDC *dc)
*/ */
// Original constructor that does not takes origin and extent. If you use this, // Original constructor that does not takes origin and extent. If you use this,
// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. // *DO* give origin/extent arguments to wxMakeMetafilePlaceable.
wxMetaFileDC::wxMetaFileDC(const wxString& file) wxMetafileDC::wxMetafileDC(const wxString& file)
{ {
m_metaFile = NULL;
m_minX = 10000;
m_minY = 10000;
m_maxX = -10000;
m_maxY = -10000;
// m_title = NULL;
if (!file.IsNull() && wxFileExists(file))
wxRemoveFile(file);
// TODO // TODO
/*
if (!file.IsNull() && (file != wxT("")))
m_hDC = (WXHDC) CreateMetaFile(file);
else
m_hDC = (WXHDC) CreateMetaFile(NULL);
*/
m_ok = (m_hDC != (WXHDC) 0) ;
// Actual Windows mapping mode, for future reference.
m_windowsMappingMode = wxMM_TEXT;
SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
} }
// New constructor that takes origin and extent. If you use this, don't // New constructor that takes origin and extent. If you use this, don't
// give origin/extent arguments to wxMakeMetaFilePlaceable. // give origin/extent arguments to wxMakeMetafilePlaceable.
wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg) wxMetafileDC::wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
{ {
// TODO m_minX = 10000;
m_minY = 10000;
m_maxX = -10000;
m_maxY = -10000;
if (file != wxT("") && wxFileExists(file)) wxRemoveFile(file);
// m_hDC = (WXHDC) CreateMetaFile(file);
m_ok = TRUE;
// ::SetWindowOrgEx((HDC) m_hDC,xorg,yorg, NULL);
// ::SetWindowExtEx((HDC) m_hDC,xext,yext, NULL);
// Actual Windows mapping mode, for future reference.
m_windowsMappingMode = wxMM_ANISOTROPIC;
SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
} }
wxMetaFileDC::~wxMetaFileDC() wxMetafileDC::~wxMetafileDC(void)
{ {
m_hDC = 0;
} }
void wxMetaFileDC::GetTextExtent(const wxString& string, float *x, float *y, void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
float *descent, float *externalLeading, wxFont *theFont, bool use16bit) long *descent, long *externalLeading, wxFont *theFont, bool use16bit) const
{ {
// TODO wxFont *fontToUse = theFont;
if (!fontToUse)
fontToUse = (wxFont*) &m_font;
// TODO:
/*
HDC dc = GetDC(NULL);
SIZE sizeRect;
TEXTMETRIC tm;
GetTextExtentPoint(dc, WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect);
GetTextMetrics(dc, &tm);
ReleaseDC(NULL, dc);
if ( x )
*x = sizeRect.cx;
if ( y )
*y = sizeRect.cy;
if ( descent )
*descent = tm.tmDescent;
if ( externalLeading )
*externalLeading = tm.tmExternalLeading;
*/
} }
wxMetaFile *wxMetaFileDC::Close() wxMetafile *wxMetafileDC::Close(void)
{ {
// TODO SelectOldObjects(m_hDC);
HANDLE mf = 0; // TODO: CloseMetaFile((HDC) m_hDC);
m_hDC = 0;
if (mf)
{
wxMetafile *wx_mf = new wxMetafile;
wx_mf->SetHMETAFILE((WXHANDLE) mf);
wx_mf->SetWindowsMappingMode(m_windowsMappingMode);
return wx_mf;
}
return NULL; return NULL;
} }
void wxMetaFileDC::SetMapMode(int mode) void wxMetafileDC::SetMapMode(int mode)
{ {
// TODO m_mappingMode = mode;
}
#if 0 // int pixel_width = 0;
// int pixel_height = 0;
// int mm_width = 0;
// int mm_height = 0;
float mm2pixelsX = 10.0;
float mm2pixelsY = 10.0;
switch (mode)
{
case wxMM_TWIPS:
{
m_logicalScaleX = (float)(twips2mm * mm2pixelsX);
m_logicalScaleY = (float)(twips2mm * mm2pixelsY);
break;
}
case wxMM_POINTS:
{
m_logicalScaleX = (float)(pt2mm * mm2pixelsX);
m_logicalScaleY = (float)(pt2mm * mm2pixelsY);
break;
}
case wxMM_METRIC:
{
m_logicalScaleX = mm2pixelsX;
m_logicalScaleY = mm2pixelsY;
break;
}
case wxMM_LOMETRIC:
{
m_logicalScaleX = (float)(mm2pixelsX/10.0);
m_logicalScaleY = (float)(mm2pixelsY/10.0);
break;
}
default:
case wxMM_TEXT:
{
m_logicalScaleX = 1.0;
m_logicalScaleY = 1.0;
break;
}
}
m_windowExtX = 100;
m_windowExtY = 100;
}
#ifdef __WIN32__ #ifdef __WIN32__
struct RECT32 struct RECT32
@@ -132,13 +310,15 @@ struct mfPLACEABLEHEADER {
* *
*/ */
bool wxMakeMetaFilePlaceable(const wxString& filename, float scale) bool wxMakeMetafilePlaceable(const wxString& filename, float scale)
{ {
return wxMakeMetaFilePlaceable(filename, 0, 0, 0, 0, scale, FALSE); return wxMakeMetafilePlaceable(filename, 0, 0, 0, 0, scale, FALSE);
} }
bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent) bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent)
{ {
// TODO: the OS/2 PM/MM way to do this
/*
// I'm not sure if this is the correct way of suggesting a scale // I'm not sure if this is the correct way of suggesting a scale
// to the client application, but it's the only way I can find. // to the client application, but it's the only way I can find.
int unitsPerInch = (int)(576/scale); int unitsPerInch = (int)(576/scale);
@@ -146,10 +326,10 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
mfPLACEABLEHEADER header; mfPLACEABLEHEADER header;
header.key = 0x9AC6CDD7L; header.key = 0x9AC6CDD7L;
header.hmf = 0; header.hmf = 0;
header.bbox.left = (int)(x1); header.bbox.xLeft = (int)(x1);
header.bbox.top = (int)(y1); header.bbox.yTop = (int)(y1);
header.bbox.right = (int)(x2); header.bbox.xRight = (int)(x2);
header.bbox.bottom = (int)(y2); header.bbox.yBottom = (int)(y2);
header.inch = unitsPerInch; header.inch = unitsPerInch;
header.reserved = 0; header.reserved = 0;
@@ -160,12 +340,12 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
p < (WORD *)&pMFHead ->checksum; ++p) p < (WORD *)&pMFHead ->checksum; ++p)
pMFHead ->checksum ^= *p; pMFHead ->checksum ^= *p;
FILE *fd = fopen((char *)(const char *)filename, "rb"); FILE *fd = fopen(filename.fn_str(), "rb");
if (!fd) return FALSE; if (!fd) return FALSE;
char tempFileBuf[256]; wxChar tempFileBuf[256];
wxGetTempFileName("mf", tempFileBuf); wxGetTempFileName(wxT("mf"), tempFileBuf);
FILE *fHandle = fopen(tempFileBuf, "wb"); FILE *fHandle = fopen(wxConvFile.cWX2MB(tempFileBuf), "wb");
if (!fHandle) if (!fHandle)
return FALSE; return FALSE;
fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle); fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle);
@@ -232,8 +412,9 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
wxRemoveFile(filename); wxRemoveFile(filename);
wxCopyFile(tempFileBuf, filename); wxCopyFile(tempFileBuf, filename);
wxRemoveFile(tempFileBuf); wxRemoveFile(tempFileBuf);
*/
return TRUE; return TRUE;
} }
#endif #endif // wxUSE_METAFILE

View File

@@ -1,16 +1,25 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: minifram.cpp // Name: minifram.cpp
// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported. // Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported.
// Author: AUTHOR // Author: David Webster
// Modified by: // Modified by:
// Created: ??/??/98 // Created: 10/10/99
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) David Webster
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ // For compilers that support precompilation, includes "wx.h".
#pragma implementation "minifram.h" #include "wx/wxprec.h"
#include "wx/window.h"
#include "wx/os2/private.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/event.h"
#include "wx/app.h"
#include "wx/utils.h"
#endif #endif
#include "wx/minifram.h" #include "wx/minifram.h"
@@ -19,4 +28,3 @@
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
#endif #endif