*** 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); // Get the active MDI child window (Windows only)
wxMDIChildFrame *GetActiveChild() const;
// Gets the size available for subwindows after menu size, toolbar size // Get the client window
// and status bar size have been subtracted. If you want to manage your own wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
// toolbar(s), don't call SetToolBar.
void GetClientSize(int *width, int *height) const;
// Get the active MDI child window (Windows only) // Create the client window class (don't Create the window,
wxMDIChildFrame *GetActiveChild() const ; // just return a new class)
virtual wxMDIClientWindow *OnCreateClient(void);
// Get the client window WXHMENU GetWindowMenu() const { return m_windowMenu; }
inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
// Create the client window class (don't Create the window, // MDI operations
// just return a new class) // --------------
virtual wxMDIClientWindow *OnCreateClient() ; virtual void Cascade();
virtual void Tile();
virtual void ArrangeIcons();
virtual void ActivateNext();
virtual void ActivatePrevious();
// MDI operations // handlers
virtual void Cascade(); // --------
virtual void Tile();
virtual void ArrangeIcons(); // Responds to colour changes
virtual void ActivateNext(); void OnSysColourChanged(wxSysColourChangedEvent& event);
virtual void ActivatePrevious();
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 // MDI operations
void SetMenuBar(wxMenuBar *menu_bar); virtual void Maximize(bool maximize = TRUE);
void SetClientSize(int width, int height); virtual void Restore();
void GetPosition(int *x, int *y) const ; virtual void Activate();
// MDI operations // Handlers
virtual void Maximize();
virtual void Restore(); bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
virtual void Activate(); bool HandleSize(int x, int y, WXUINT);
private: bool HandleWindowPosChanging(void *lpPos);
// supress virtual function hiding warning bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
virtual void Maximize(bool maximize) { wxFrame::Maximize(maximize); };
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)
{ {
CreateClient(parent, style); Init();
}
~wxMDIClientWindow(); CreateClient(parent, style);
}
// 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);
}
// construct menu wxMenu( long WXUNUSED(style) )
// append items to the menu {
// separator line Init( wxEmptyString );
void AppendSeparator(); }
// normal item
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
bool checkable = FALSE);
// a submenu
void Append(int id, const wxString& Label, wxMenu *SubMenu,
const wxString& helpString = wxEmptyString);
// the most generic form (create wxMenuItem first and use it's functions)
void Append(wxMenuItem *pItem);
// insert a break in the menu
void Break();
// delete an item
void Delete(int id);
// menu item control wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
void Enable(int id, bool Flag); {
bool Enabled(int id) const; Init(title);
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 virtual ~wxMenu();
inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void* GetClientData() const { return m_clientData; }
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; } // construct menu
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; } // append a separator to the menu
void AppendSeparator();
// append a normal item to the menu
void Append(int id, const wxString& label,
const wxString& helpString = wxEmptyString,
bool checkable = FALSE);
// append a submenu
void Append(int id, const wxString& label,
wxMenu *submenu,
const wxString& helpString = wxEmptyString);
// append anything (create wxMenuItem first)
void Append(wxMenuItem *pItem);
// item properties // insert a break in the menu
// title void Break();
void SetTitle(const wxString& label);
const wxString GetTitle() const;
// label
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
// help string
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ;
// find item // delete an item
// Finds the item id matching the given string, -1 if not found. // If it's a submenu, menu is not destroyed.
virtual int FindItem(const wxString& itemString) const ; // VZ: why? shouldn't it return "wxMenu *" then?
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL. void Delete(int id);
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
void ProcessCommand(wxCommandEvent& event); // client data
inline void Callback(const wxFunction func) { m_callback = func; } inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void* GetClientData() const { return m_clientData; }
// Updates the UI for a menu and all submenus recursively. // menu item control
// source is the object that has the update event handlers // enable/disable item
// defined for it. If NULL, the menu or associated window void Enable(int id, bool enable);
// will be used. // TRUE if enabled
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL); bool IsEnabled(int id) const;
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; } // check/uncheck item - only for checkable items, of course
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } void Check(int id, bool check);
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; } // TRUE if checked
bool IsChecked(int id) const;
inline wxList& GetItems() const { return (wxList&) m_menuItems; } // other properties
// the menu title
void SetTitle(const wxString& label);
const wxString GetTitle() const;
// the item label
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
// help string
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const;
public: // get the list of items
wxFunction m_callback; inline wxList& GetItems() const { return (wxList &)m_menuItems; }
int m_noItems; // find item
wxString m_title; // returns id of the item matching the given string or wxNOT_FOUND
wxMenuBar * m_menuBar; virtual int FindItem(const wxString& itemString) const;
wxList m_menuItems; // returns NULL if not found
wxEvtHandler * m_parent; inline wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
wxEvtHandler * m_eventHandler; // find wxMenuItem by ID, and item's menu too if itemMenu is !NULL
void* m_clientData; wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
wxWindow* m_pInvokingWindow;
// Updates the UI for a menu and all submenus recursively. 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);
bool ProcessCommand(wxCommandEvent& event);
inline virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
// IMPLEMENTATION
bool OS2Command(WXUINT param, WXWORD id);
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;
#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;
wxString m_title;
wxMenu * m_topLevelMenu;
wxMenuBar * m_menuBar;
wxList m_menuItems;
wxEvtHandler * m_parent;
wxEvtHandler * m_eventHandler;
wxWindow *m_pInvokingWindow;
void* m_clientData;
#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)
wxMenuBar(); public:
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]); // ctors & dtor
~wxMenuBar(); // default constructor
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[]);
virtual ~wxMenuBar();
void Append(wxMenu *menu, const wxString& title); // menubar construction
// Must only be used AFTER menu has been attached to frame, WXHMENU Create();
// otherwise use individual menus to enable/disable items void Append(wxMenu *menu, const wxString& title);
void Enable(int Id, bool Flag); void Insert(int pos, wxMenu * menu, const wxString& title);
bool Enabled(int Id) const ; void ReplaceMenu(int pos, wxMenu * new_menu, const wxString& title);
inline bool IsEnabled(int Id) const { return Enabled(Id); }; int FindMenu(const wxString& title);
void EnableTop(int pos, bool Flag); void Detach();
void Check(int id, bool Flag); virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
bool Checked(int id) const ;
inline bool IsChecked(int Id) const { return Checked(Id); };
void SetLabel(int id, const wxString& label) ;
wxString GetLabel(int id) const ;
void SetLabelTop(int pos, const wxString& label) ;
wxString GetLabelTop(int pos) const ;
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
virtual bool OnAppend(wxMenu *menu, const char *title);
virtual bool OnDelete(wxMenu *menu, int index);
virtual void SetHelpString(int Id, const wxString& helpString); // state control
virtual wxString GetHelpString(int Id) const ; // NB: must only be used AFTER menu has been attached to frame,
// otherwise use individual menus to enable/disable items
// enable the item
void Enable(int id, bool enable);
// TRUE if item enabled
bool IsEnabled(int id) const;
//
void EnableTop(int pos, bool enable);
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ; // works only with checkable items
void Check(int id, bool check);
// TRUE if checked
bool IsChecked(int id) const;
// Find wxMenuItem for item ID, and return item's void SetLabel(int id, const wxString& label) ;
// menu too if itemMenu is non-NULL. wxString GetLabel(int id) const ;
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; } virtual void SetHelpString(int id, const wxString& helpString);
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; } virtual wxString GetHelpString(int id) const ;
inline int GetMenuCount() const { return m_menuCount; } void SetLabelTop(int pos, const wxString& label) ;
inline wxMenu* GetMenu(int i) const { return m_menus[i]; } wxString GetLabelTop(int pos) const ;
public: // notifications: return FALSE to prevent the menu from being
wxEvtHandler * m_eventHandler; // appended/deleted
int m_menuCount; virtual bool OnAppend(wxMenu *menu, const wxChar *title);
wxMenu ** m_menus; virtual bool OnDelete(wxMenu *menu, int index);
wxString * m_titles;
wxFrame * m_menuBarFrame; // item search
/* TODO: data that represents the actual menubar when created. // 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;
// submenus access
inline int GetMenuCount() const { return m_menuCount; }
inline wxMenu *GetMenu(int i) const { return m_menus[i]; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
#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
// IMPLEMENTATION
// 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;
wxMenu **m_menus;
wxString *m_titles;
wxFrame *m_menuBarFrame;
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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -55,15 +55,20 @@ public:
// accessors (some more are inherited from wxOwnerDrawn or are below) // accessors (some more are inherited from wxOwnerDrawn or are below)
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,86 +3,126 @@
// 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
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#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;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// 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
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/app.h" #include "wx/app.h"

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") );
m_pParentMenu = pParentMenu; #if wxUSE_OWNER_DRAWN
m_pSubMenu = pSubMenu; // set default menu colors
m_idItem = id; #define SYS_COLOR(c) (wxSystemSettings::GetSystemColour(wxSYS_COLOUR_##c))
m_bEnabled = TRUE;
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_pSubMenu = pSubMenu;
m_bEnabled = TRUE;
m_bChecked = FALSE;
m_idItem = id;
} }
wxMenuItem::~wxMenuItem() wxMenuItem::~wxMenuItem()
@@ -58,13 +104,18 @@ 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;
m_pSubMenu = NULL;
delete m_pSubMenu;
m_pSubMenu = NULL;
} }
// change item state // change item state
@@ -72,24 +123,93 @@ void wxMenuItem::DeleteSubMenu()
void wxMenuItem::Enable(bool bDoEnable) void wxMenuItem::Enable(bool bDoEnable)
{ {
if ( m_bEnabled != bDoEnable ) { // TODO:
if ( m_pSubMenu == NULL ) { // normal menu item /*
// TODO if ( m_bEnabled != bDoEnable ) {
} long rc = EnableMenuItem(GetHMenuOf(m_pParentMenu),
else // submenu GetRealId(),
{ MF_BYCOMMAND |
// TODO (bDoEnable ? MF_ENABLED : MF_GRAYED));
}
m_bEnabled = bDoEnable; if ( rc == -1 ) {
} wxLogLastError("EnableMenuItem");
}
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 ) {
long rc = CheckMenuItem(GetHMenuOf(m_pParentMenu),
GetId(),
MF_BYCOMMAND |
(bDoCheck ? MF_CHECKED : MF_UNCHECKED));
if ( rc == -1 ) {
wxLogLastError("CheckMenuItem");
}
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"));
}
}
*/
}
if ( m_bChecked != bDoCheck ) {
// TODO
m_bChecked = bDoCheck;
}

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)
{ {
// TODO 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
/*
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);
return NULL; 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;
} }
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