*** 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();
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { 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 wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
{ 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; };
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;

View File

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

View File

@ -1,21 +1,17 @@
/////////////////////////////////////////////////////////////////////////////
// Name: listctrl.h
// Purpose: wxListCtrl class
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTCTRL_H_
#define _WX_LISTCTRL_H_
#ifdef __GNUG__
#pragma interface "listctrl.h"
#endif
#include "wx/control.h"
#include "wx/event.h"
#include "wx/imaglist.h"
@ -98,7 +94,7 @@ enum {
wxLIST_NEXT_ALL, // Searches for subsequent item by index
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_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
@ -189,6 +185,10 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Attributes
////////////////////////////////////////////////////////////////////////////
// Sets the background colour (GetBackgroundColour already implicit in
// wxWindow class)
bool SetBackgroundColour(const wxColour& col);
// Gets information about this column
bool GetColumn(int col, wxListItem& item) const;
@ -285,11 +285,11 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Returns the item or -1 if unsuccessful.
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.
// oldStyle is 'normalised' so that it doesn't contain
// conflicting styles.
long ConvertToMSWStyle(long& oldStyle, long style) const;
long ConvertToOS2Style(long& oldStyle, long style) const;
// Gets one of the three image lists
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.
bool SortItems(wxListCtrlCompare fn, long data);
/* Why should we need this function? Leave for now.
* We might need it because item data may have changed,
* but the display needs refreshing (in string callback mode)
// Updates an item. If the list control has the wxLI_AUTO_ARRANGE style,
// the items will be rearranged.
bool Update(long item);
*/
// IMPLEMENTATION
virtual bool OS2Command(WXUINT param, WXWORD id);
virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
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:
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
// 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
// _WX_LISTCTRL_H_

View File

@ -3,21 +3,17 @@
// Purpose: MDI (Multiple Document Interface) classes.
// This doesn't have to be implemented just like Windows,
// it could be a tabbed design as in wxGTK.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MDI_H_
#define _WX_MDI_H_
#ifdef __GNUG__
#pragma interface "mdi.h"
#endif
#include "wx/frame.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
@ -55,40 +51,60 @@ public:
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxFrameNameStr);
void OnSize(wxSizeEvent& event);
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
// accessors
// ---------
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
// 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 client window
wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
// Get the active MDI child window (Windows only)
wxMDIChildFrame *GetActiveChild() const ;
// Create the client window class (don't Create the window,
// just return a new class)
virtual wxMDIClientWindow *OnCreateClient(void);
// Get the client window
inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
WXHMENU GetWindowMenu() const { return m_windowMenu; }
// Create the client window class (don't Create the window,
// just return a new class)
virtual wxMDIClientWindow *OnCreateClient() ;
// MDI operations
// --------------
virtual void Cascade();
virtual void Tile();
virtual void ArrangeIcons();
virtual void ActivateNext();
virtual void ActivatePrevious();
// MDI operations
virtual void Cascade();
virtual void Tile();
virtual void ArrangeIcons();
virtual void ActivateNext();
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:
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
@ -118,18 +134,31 @@ public:
long style = wxDEFAULT_FRAME_STYLE,
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
virtual void Maximize(bool maximize = TRUE);
virtual void Restore();
virtual void Activate();
// MDI operations
virtual void Maximize();
virtual void Restore();
virtual void Activate();
private:
// supress virtual function hiding warning
virtual void Maximize(bool maximize) { wxFrame::Maximize(maximize); };
// Handlers
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
@ -142,25 +171,31 @@ private:
class WXDLLEXPORT wxMDIClientWindow: public wxWindow
{
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
public:
wxMDIClientWindow() ;
inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
{
CreateClient(parent, style);
}
wxMDIClientWindow() { Init(); }
wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
{
Init();
~wxMDIClientWindow();
CreateClient(parent, style);
}
// Note: this is virtual, to allow overridden behaviour.
virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL);
// Note: this is virtual, to allow overridden behaviour.
virtual bool CreateClient(wxMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL);
// Explicitly call default scroll behaviour
void OnScroll(wxScrollEvent& event);
// Explicitly call default scroll behaviour
void OnScroll(wxScrollEvent& event);
protected:
void Init() { m_scrollX = m_scrollY = 0; }
DECLARE_EVENT_TABLE()
int m_scrollX, m_scrollY;
private:
DECLARE_EVENT_TABLE()
};
#endif

View File

@ -1,27 +1,30 @@
/////////////////////////////////////////////////////////////////////////////
// Name: menu.h
// Purpose: wxMenu, wxMenuBar classes
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENU_H_
#define _WX_MENU_H_
#ifdef __GNUG__
#pragma interface "menu.h"
#endif
#include "wx/defs.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 wxMenuBar;
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxFrame;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
@ -33,140 +36,268 @@ class WXDLLEXPORT wxMenu: public wxEvtHandler
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
// ctor & dtor
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
~wxMenu();
wxMenu(const wxString& title,
const wxFunction func)
{
Init(title, func);
}
// construct menu
// append items to the menu
// separator line
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);
wxMenu( long WXUNUSED(style) )
{
Init( wxEmptyString );
}
// menu item control
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); };
wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
{
Init(title);
}
// Client data
inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void* GetClientData() const { return m_clientData; }
virtual ~wxMenu();
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
// construct menu
// 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
// title
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 ;
// insert a break in the menu
void Break();
// find item
// Finds the item id matching the given string, -1 if not found.
virtual int FindItem(const wxString& itemString) const ;
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
// 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 ProcessCommand(wxCommandEvent& event);
inline void Callback(const wxFunction func) { m_callback = func; }
// client data
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.
// 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);
// menu item control
// enable/disable item
void Enable(int id, bool enable);
// TRUE if enabled
bool IsEnabled(int id) const;
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
// check/uncheck item - only for checkable items, of course
void Check(int id, bool check);
// 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:
wxFunction m_callback;
// get the list of items
inline wxList& GetItems() const { return (wxList &)m_menuItems; }
int m_noItems;
wxString m_title;
wxMenuBar * m_menuBar;
wxList m_menuItems;
wxEvtHandler * m_parent;
wxEvtHandler * m_eventHandler;
void* m_clientData;
wxWindow* m_pInvokingWindow;
// find item
// returns id of the item matching the given string or wxNOT_FOUND
virtual int FindItem(const wxString& itemString) const;
// 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;
// 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)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxMenuBar: public wxEvtHandler
{
DECLARE_DYNAMIC_CLASS(wxMenuBar)
wxMenuBar();
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
~wxMenuBar();
public:
// ctors & dtor
// 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);
// Must only be used AFTER menu has been attached to frame,
// otherwise use individual menus to enable/disable items
void Enable(int Id, bool Flag);
bool Enabled(int Id) const ;
inline bool IsEnabled(int Id) const { return Enabled(Id); };
void EnableTop(int pos, bool Flag);
void Check(int id, bool Flag);
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);
// menubar construction
WXHMENU Create();
void Append(wxMenu *menu, const wxString& title);
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 */
virtual void SetHelpString(int Id, const wxString& helpString);
virtual wxString GetHelpString(int Id) const ;
// state control
// 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
// menu too if itemMenu is non-NULL.
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
void SetLabel(int id, const wxString& label) ;
wxString GetLabel(int id) const ;
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ;
inline int GetMenuCount() const { return m_menuCount; }
inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
void SetLabelTop(int pos, const wxString& label) ;
wxString GetLabelTop(int pos) const ;
public:
wxEvtHandler * m_eventHandler;
int m_menuCount;
wxMenu ** m_menus;
wxString * m_titles;
wxFrame * m_menuBarFrame;
/* TODO: data that represents the actual menubar when created.
*/
// 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);
// item search
// 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_

View File

@ -2,7 +2,7 @@
// Name: menuitem.h
// Purpose: wxMenuItem class
// Author: Vadim Zeitlin
// Modified by:
// Modified by:
// Created: 11.11.97
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@ -26,7 +26,7 @@
// headers - only because ownerdrw.h is not always included and I don't want
// to write #ifdef's everywhere...
#if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h"
#include "wx/ownerdrw.h"
#endif
// ----------------------------------------------------------------------------
@ -55,15 +55,20 @@ public:
// accessors (some more are inherited from wxOwnerDrawn or are below)
bool IsSeparator() const { return m_idItem == ID_SEPARATOR; }
bool IsEnabled() const { return m_bEnabled; }
bool IsChecked() const { return m_bChecked; }
bool IsEnabled() const { return m_bEnabled; }
bool IsChecked() const { return m_bChecked; }
bool IsSubMenu() const { return GetSubMenu() != NULL; }
int GetId() const { return m_idItem; }
const wxString& GetHelp() const { return m_strHelp; }
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
void SetName(const wxString& strName) { m_strName = strName; }
void SetName(const wxString& strName);
void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; }
void Enable(bool bDoEnable = TRUE);

View File

@ -3,86 +3,126 @@
// Purpose: wxMetaFile, wxMetaFileDC classes.
// This probably should be restricted to Windows platforms,
// but if there is an equivalent on your platform, great.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_METAFIILE_H_
#define _WX_METAFIILE_H_
#ifdef __GNUG__
#pragma interface "metafile.h"
#include "wx/setup.h"
#if wxUSE_METAFILE
#include "wx/dc.h"
#include "wx/gdiobj.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dataobj.h"
#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;
class WXDLLEXPORT wxMetaFile: public wxObject
#define wxMetaFile wxMetafile
#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:
wxMetaFile(const wxString& file = "");
~wxMetaFile();
// Copy constructor
inline wxMetafile(const wxMetafile& metafile)
{ Ref(metafile); }
wxMetafile(const wxString& file = "");
~wxMetafile(void);
// After this is called, the metafile cannot be used for anything
// since it is now owned by the clipboard.
virtual bool SetClipboard(int width = 0, int height = 0);
virtual bool Play(wxDC *dc);
// TODO
inline bool Ok() { return FALSE; };
inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
/* TODO: Implementation
inline WXHANDLE GetHMETAFILE() { return m_metaFile; }
inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; }
// Implementation
inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
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:
WXHANDLE m_metaFile;
*/
};
class WXDLLEXPORT wxMetaFileDC: public wxDC
class WXDLLEXPORT wxMetafileDC: public wxDC
{
DECLARE_DYNAMIC_CLASS(wxMetaFileDC)
DECLARE_DYNAMIC_CLASS(wxMetafileDC)
public:
// Don't supply origin and extent
// Supply them to wxMakeMetaFilePlaceable instead.
wxMetaFileDC(const wxString& file = "");
wxMetafileDC(const wxString& file = "");
// Supply origin and extent (recommended).
// 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
virtual wxMetaFile *Close();
virtual wxMetafile *Close(void);
virtual void SetMapMode(int mode);
virtual void GetTextExtent(const wxString& string, float *x, float *y,
float *descent = NULL, float *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = FALSE);
virtual void GetTextExtent(const wxString& string, long *x, long *y,
long *descent = NULL, long *externalLeading = NULL,
wxFont *theFont = NULL, bool use16bit = FALSE) const;
// Implementation
inline wxMetaFile *GetMetaFile() { return m_metaFile; }
inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; }
inline int GetWindowsMappingMode() { return m_windowsMappingMode; }
inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
inline int GetWindowsMappingMode(void) const { return m_windowsMappingMode; }
inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
protected:
int m_windowsMappingMode;
wxMetaFile *m_metaFile;
int m_windowsMappingMode;
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
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
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
// _WX_METAFIILE_H_

View File

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

View File

@ -9,13 +9,19 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "accel.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/window.h"
#endif
#include "wx/setup.h"
#include "wx/accel.h"
#include "wx/string.h"
#include "wx/os2/accel.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
@ -28,11 +34,9 @@ public:
wxAcceleratorRefData();
~wxAcceleratorRefData();
/* TODO: implementation
inline HACCEL GetHACCEL() const { return m_hAccel; }
protected:
HACCEL m_hAccel;
*/
};
#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
@ -91,3 +95,29 @@ bool wxAcceleratorTable::Ok() const
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
// Purpose: Entry point
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/app.h"

View File

@ -326,9 +326,15 @@ OS2OBJS = \
..\os2\$D\iniconf.obj \
..\os2\$D\joystick.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
OS2LIBOBJS = \
accel.obj \
app.obj \
@ -367,6 +373,13 @@ OS2LIBOBJS = \
iniconf.obj \
joystick.obj \
listbox.obj \
listctrl.obj \
main.obj \
mdi.obj \
menu.obj \
menuitem.obj \
metafile.obj \
minifram.obj \
window.obj
HTMLOBJS = \
@ -551,6 +564,13 @@ $(OS2LIBOBJS):
copy ..\os2\$D\iniconf.obj
copy ..\os2\$D\joystick.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
# 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
// Purpose: wxMenuItem implementation
// Author: AUTHOR
// Modified by:
// Created: ??/??/98
// Author: David Webster
// Modified by:
// Created: 10/10/98
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
@ -13,8 +13,31 @@
// 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/log.h"
#include "wx/os2/private.h"
// ---------------------------------------------------------------------------
// convenience macro
// ---------------------------------------------------------------------------
#define GetHMenuOf(menu) ((HMENU)menu->GetHMenu())
// ============================================================================
// implementation
@ -24,8 +47,13 @@
// 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)
#endif //USE_OWNER_DRAWN
#endif //USE_SHARED_LIBRARY
// ----------------------------------------------------------------------------
@ -39,32 +67,55 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
const wxString& strName, const wxString& strHelp,
bool bCheckable,
wxMenu *pSubMenu) :
#if wxUSE_OWNER_DRAWN
wxOwnerDrawn(strName, bCheckable),
#else //no owner drawn support
m_bCheckable(bCheckable),
m_strName(strName),
#endif //owner drawn
m_strHelp(strHelp)
{
wxASSERT( pParentMenu != NULL );
wxASSERT_MSG( pParentMenu != NULL, wxT("a menu item should have a parent") );
m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu;
m_idItem = id;
m_bEnabled = TRUE;
#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_pSubMenu = pSubMenu;
m_bEnabled = TRUE;
m_bChecked = FALSE;
m_idItem = id;
}
wxMenuItem::~wxMenuItem()
wxMenuItem::~wxMenuItem()
{
}
// 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
// -------------------
void wxMenuItem::DeleteSubMenu()
{
wxASSERT( m_pSubMenu != NULL );
delete m_pSubMenu;
m_pSubMenu = NULL;
delete m_pSubMenu;
m_pSubMenu = NULL;
}
// change item state
@ -72,24 +123,93 @@ void wxMenuItem::DeleteSubMenu()
void wxMenuItem::Enable(bool bDoEnable)
{
if ( m_bEnabled != bDoEnable ) {
if ( m_pSubMenu == NULL ) { // normal menu item
// TODO
}
else // submenu
{
// TODO
}
// TODO:
/*
if ( m_bEnabled != bDoEnable ) {
long rc = EnableMenuItem(GetHMenuOf(m_pParentMenu),
GetRealId(),
MF_BYCOMMAND |
(bDoEnable ? MF_ENABLED : MF_GRAYED));
m_bEnabled = bDoEnable;
}
if ( rc == -1 ) {
wxLogLastError("EnableMenuItem");
}
m_bEnabled = bDoEnable;
}
*/
}
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
// Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 04/01/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "metafile.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/dc.h"
#include "wx/stubs/metafile.h"
#if wxUSE_METAFILE
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#endif
#include "wx/metafile.h"
#include "wx/clipbrd.h"
#include "wx/os2/private.h"
#include <stdio.h>
#include <string.h>
extern bool wxClipboardIsOpen;
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC)
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
#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();
if (!alreadyOpen)
{
wxOpenClipboard();
if (!wxEmptyClipboard()) return FALSE;
}
bool success = wxSetClipboardData(wxDF_METAFILE,this, width,height);
bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
if (!alreadyOpen) wxCloseClipboard();
return (bool) success;
}
bool wxMetaFile::Play(wxDC *dc)
bool wxMetafile::Play(wxDC *dc)
{
// TODO
return FALSE;
if (!m_refData)
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,
// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
wxMetaFileDC::wxMetaFileDC(const wxString& file)
// *DO* give origin/extent arguments to wxMakeMetafilePlaceable.
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
// give origin/extent arguments to wxMakeMetaFilePlaceable.
wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
// give origin/extent arguments to wxMakeMetafilePlaceable.
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,
float *descent, float *externalLeading, wxFont *theFont, bool use16bit)
void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
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
return NULL;
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;
}
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__
struct RECT32
@ -131,41 +309,43 @@ struct mfPLACEABLEHEADER {
* and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
*
*/
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
// to the client application, but it's the only way I can find.
int unitsPerInch = (int)(576/scale);
mfPLACEABLEHEADER header;
header.key = 0x9AC6CDD7L;
header.hmf = 0;
header.bbox.left = (int)(x1);
header.bbox.top = (int)(y1);
header.bbox.right = (int)(x2);
header.bbox.bottom = (int)(y2);
header.bbox.xLeft = (int)(x1);
header.bbox.yTop = (int)(y1);
header.bbox.xRight = (int)(x2);
header.bbox.yBottom = (int)(y2);
header.inch = unitsPerInch;
header.reserved = 0;
// Calculate checksum
// Calculate checksum
WORD *p;
mfPLACEABLEHEADER *pMFHead = &header;
for (p =(WORD *)pMFHead,pMFHead -> checksum = 0;
p < (WORD *)&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;
char tempFileBuf[256];
wxGetTempFileName("mf", tempFileBuf);
FILE *fHandle = fopen(tempFileBuf, "wb");
wxChar tempFileBuf[256];
wxGetTempFileName(wxT("mf"), tempFileBuf);
FILE *fHandle = fopen(wxConvFile.cWX2MB(tempFileBuf), "wb");
if (!fHandle)
return FALSE;
fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle);
@ -179,12 +359,12 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
// Read metafile header and write
METAHEADER metaHeader;
fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd);
if (useOriginAndExtent)
metaHeader.mtSize += 15;
else
metaHeader.mtSize += 5;
fwrite((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fHandle);
// Write SetMapMode, SetWindowOrigin and SetWindowExt records
@ -211,7 +391,7 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
extentRecord->rdParm[1] = extentX;
fwrite((void *)modeBuffer, sizeof(char), 8, fHandle);
if (useOriginAndExtent)
{
fwrite((void *)originBuffer, sizeof(char), 10, fHandle);
@ -232,8 +412,9 @@ bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, i
wxRemoveFile(filename);
wxCopyFile(tempFileBuf, filename);
wxRemoveFile(tempFileBuf);
*/
return TRUE;
}
#endif
#endif // wxUSE_METAFILE

View File

@ -1,16 +1,25 @@
/////////////////////////////////////////////////////////////////////////////
// Name: minifram.cpp
// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/10/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "minifram.h"
// For compilers that support precompilation, includes "wx.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
#include "wx/minifram.h"
@ -19,4 +28,3 @@
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
#endif