// ---------------------------------------------------------------------------
virtual bool Destroy();
- virtual bool IsIconized() const;
- virtual void Centre(int direction = wxBOTH);
- virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
-
- virtual int ShowModal();
- virtual void EndModal(int retCode);
+ virtual void DoSetClientSize(int width, int height);
+ virtual void GetPosition(int *x, int *y) const;
- void SetClientSize(int width, int height) { wxWindow::DoSetClientSize(width, height); };
- void SetClientSize( const wxSize& size ) { wxWindow::DoSetClientSize(size.x, size.y); };
- void SetClientSize(const wxRect& rect) { SetClientSize( rect.width, rect.height ); };
+ bool Show(bool show);
+ bool IsShown() const;
+ void Iconize(bool iconize);
- void GetPosition(int *x, int *y) const;
- bool Show(bool show);
- void Iconize(bool iconize);
-
- void Fit();
+ virtual bool IsIconized() const;
+ void Fit();
void SetTitle(const wxString& title);
wxString GetTitle() const ;
- void OnCharHook(wxKeyEvent& event);
- void OnCloseWindow(wxCloseEvent& event);
+ void OnSize(wxSizeEvent& event);
+ bool OnClose();
+ void OnCharHook(wxKeyEvent& event);
+ void OnPaint(wxPaintEvent& event);
+ void OnCloseWindow(wxCloseEvent& event);
- void SetModal(bool flag);
+ void SetModal(bool flag);
+
+ virtual void Centre(int direction = wxBOTH);
+ virtual bool IsModal() const;
+
+ // For now, same as Show(TRUE) but returns return code
+ virtual int ShowModal();
+ virtual void EndModal(int retCode);
// Standard buttons
void OnOK(wxCommandEvent& event);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
+ // implementation
+ // --------------
+ virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+ virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+
+ bool IsModalShowing() const { return m_modalShowing; }
+
+ // tooltip management
+#if wxUSE_TOOLTIPS
+ WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
+ void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
+#endif // tooltips
+
+protected:
+ bool m_modalShowing;
+ WXHWND m_hwndOldFocus; // the window which had focus before we were shown
+
+private:
+#if wxUSE_TOOLTIPS
+ WXHWND m_hwndToolTip;
+#endif // tooltips
+
+private:
+
DECLARE_EVENT_TABLE()
};
#ifndef _WX_SETUP_H_
#define _WX_SETUP_H_
-/*
- * General features
- *
- */
+// ----------------------------------------------------------------------------
+// global settings
+// ----------------------------------------------------------------------------
+
+// define this to 0 when building wxBase library
+#define wxUSE_GUI 1
+
+#define WXWIN_COMPATIBILITY 0
+ // Compatibility with 1.68 API.
+ // Level 0: no backward compatibility, all new features
+ // Level 1: Some compatibility. In fact
+ // the compatibility code is now very minimal so there
+ // is little advantage to setting it to 1.
+
+// ----------------------------------------------------------------------------
+// General features
+// ----------------------------------------------------------------------------
#define wxUSE_CONFIG 1
// Use wxConfig, with CreateConfig in wxApp
#ifndef _WX_SETUP_H_
#define _WX_SETUP_H_
-/*
- * General features
- *
- */
+// ----------------------------------------------------------------------------
+// global settings
+// ----------------------------------------------------------------------------
+
+// define this to 0 when building wxBase library
+#define wxUSE_GUI 1
+
+#define WXWIN_COMPATIBILITY 0
+ // Compatibility with 1.68 API.
+ // Level 0: no backward compatibility, all new features
+ // Level 1: Some compatibility. In fact
+ // the compatibility code is now very minimal so there
+ // is little advantage to setting it to 1.
+
+// ----------------------------------------------------------------------------
+// General features
+// ----------------------------------------------------------------------------
#define wxUSE_CONFIG 1
// Use wxConfig, with CreateConfig in wxApp
// Transfers data to any child controls
void OnInitDialog(wxInitDialogEvent& event);
+ virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+
protected:
// Caret data
if ( !m_hWnd )
{
#ifdef __WXDEBUG__
- wxLogError(_T("Failed to create a control of class '%s'"), classname);
+ wxLogError(T("Failed to create a control of class '%s'"), classname);
#endif // DEBUG
return FALSE;
wxColour wxNullColour;
// Default window names
-const wxChar *wxButtonNameStr = _T("button");
-const wxChar *wxCanvasNameStr = _T("canvas");
-const wxChar *wxCheckBoxNameStr = _T("check");
-const wxChar *wxChoiceNameStr = _T("choice");
-const wxChar *wxComboBoxNameStr = _T("comboBox");
-const wxChar *wxDialogNameStr = _T("dialog");
-const wxChar *wxFrameNameStr = _T("frame");
-const wxChar *wxGaugeNameStr = _T("gauge");
-const wxChar *wxStaticBoxNameStr = _T("groupBox");
-const wxChar *wxListBoxNameStr = _T("listBox");
-const wxChar *wxStaticTextNameStr = _T("message");
-const wxChar *wxStaticBitmapNameStr = _T("message");
-const wxChar *wxMultiTextNameStr = _T("multitext");
-const wxChar *wxPanelNameStr = _T("panel");
-const wxChar *wxRadioBoxNameStr = _T("radioBox");
-const wxChar *wxRadioButtonNameStr = _T("radioButton");
-const wxChar *wxBitmapRadioButtonNameStr = _T("radioButton");
-const wxChar *wxScrollBarNameStr = _T("scrollBar");
-const wxChar *wxSliderNameStr = _T("slider");
-const wxChar *wxStaticNameStr = _T("static");
-const wxChar *wxTextCtrlWindowNameStr = _T("textWindow");
-const wxChar *wxTextCtrlNameStr = _T("text");
-const wxChar *wxVirtListBoxNameStr = _T("virtListBox");
-const wxChar *wxButtonBarNameStr = _T("buttonbar");
-const wxChar *wxEnhDialogNameStr = _T("Shell");
-const wxChar *wxToolBarNameStr = _T("toolbar");
-const wxChar *wxStatusLineNameStr = _T("status_line");
-const wxChar *wxEmptyString = _T("");
-const wxChar *wxGetTextFromUserPromptStr = _T("Input Text");
-const wxChar *wxMessageBoxCaptionStr = _T("Message");
-const wxChar *wxFileSelectorPromptStr = _T("Select a file");
-const wxChar *wxFileSelectorDefaultWildcardStr = _T("*.*");
-const wxChar *wxInternalErrorStr = _T("wxWindows Internal Error");
-const wxChar *wxFatalErrorStr = _T("wxWindows Fatal Error");
-const wxChar *wxTreeCtrlNameStr = _T("treeCtrl");
-const wxChar *wxDirDialogNameStr = _T("wxDirCtrl");
-const wxChar *wxDirDialogDefaultFolderStr = _T("/");
+const wxChar *wxButtonNameStr = T("button");
+const wxChar *wxCanvasNameStr = T("canvas");
+const wxChar *wxCheckBoxNameStr = T("check");
+const wxChar *wxChoiceNameStr = T("choice");
+const wxChar *wxComboBoxNameStr = T("comboBox");
+const wxChar *wxDialogNameStr = T("dialog");
+const wxChar *wxFrameNameStr = T("frame");
+const wxChar *wxGaugeNameStr = T("gauge");
+const wxChar *wxStaticBoxNameStr = T("groupBox");
+const wxChar *wxListBoxNameStr = T("listBox");
+const wxChar *wxStaticTextNameStr = T("message");
+const wxChar *wxStaticBitmapNameStr = T("message");
+const wxChar *wxMultiTextNameStr = T("multitext");
+const wxChar *wxPanelNameStr = T("panel");
+const wxChar *wxRadioBoxNameStr = T("radioBox");
+const wxChar *wxRadioButtonNameStr = T("radioButton");
+const wxChar *wxBitmapRadioButtonNameStr = T("radioButton");
+const wxChar *wxScrollBarNameStr = T("scrollBar");
+const wxChar *wxSliderNameStr = T("slider");
+const wxChar *wxStaticNameStr = T("static");
+const wxChar *wxTextCtrlWindowNameStr = T("textWindow");
+const wxChar *wxTextCtrlNameStr = T("text");
+const wxChar *wxVirtListBoxNameStr = T("virtListBox");
+const wxChar *wxButtonBarNameStr = T("buttonbar");
+const wxChar *wxEnhDialogNameStr = T("Shell");
+const wxChar *wxToolBarNameStr = T("toolbar");
+const wxChar *wxStatusLineNameStr = T("status_line");
+const wxChar *wxEmptyString = T("");
+const wxChar *wxGetTextFromUserPromptStr = T("Input Text");
+const wxChar *wxMessageBoxCaptionStr = T("Message");
+const wxChar *wxFileSelectorPromptStr = T("Select a file");
+const wxChar *wxFileSelectorDefaultWildcardStr = T("*.*");
+const wxChar *wxInternalErrorStr = T("wxWindows Internal Error");
+const wxChar *wxFatalErrorStr = T("wxWindows Fatal Error");
+const wxChar *wxTreeCtrlNameStr = T("treeCtrl");
+const wxChar *wxDirDialogNameStr = T("wxDirCtrl");
+const wxChar *wxDirDialogDefaultFolderStr = T("/");
// See wx/utils.h
-const wxChar *wxFloatToStringStr = _T("%.2f");
-const wxChar *wxDoubleToStringStr = _T("%.2f");
+const wxChar *wxFloatToStringStr = T("%.2f");
+const wxChar *wxDoubleToStringStr = T("%.2f");
#ifdef __WXMSW__
-const wxChar *wxUserResourceStr = _T("TEXT");
+const wxChar *wxUserResourceStr = T("TEXT");
#endif
#if wxUSE_SHARED_LIBRARY
wxPaintDC::wxPaintDC(wxWindow *canvas)
{
- wxCHECK_RET( canvas, _T("NULL canvas in wxPaintDC ctor") );
+ wxCHECK_RET( canvas, T("NULL canvas in wxPaintDC ctor") );
#ifdef __WXDEBUG__
if ( g_isPainting <= 0 )
{
- wxFAIL_MSG( _T("wxPaintDC may be created only in EVT_PAINT handler!") );
+ wxFAIL_MSG( T("wxPaintDC may be created only in EVT_PAINT handler!") );
return;
}
size_t index;
wxPaintDCInfo *info = FindInCache(&index);
- wxCHECK_RET( info, _T("existing DC should have a cache entry") );
+ wxCHECK_RET( info, T("existing DC should have a cache entry") );
if ( !--info->count )
{
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: dcprint.cpp
+// Purpose: wxPrinterDC class
+// Author: Julian Smart
+// Modified by:
+// Created: 01/02/97
+// RCS-ID: $Id$
+// Copyright: (c) Julian Smart and Markus Holzem
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "dcprint.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/string.h"
+#include "wx/log.h"
+#include "wx/window.h"
+#include "wx/os2/private.h"
+#include "wx/dcprint.h"
+#include "math.h"
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxPrinterDC, wxDC)
+#endif
+
+#define INCL_DEV
+#define INCL_GPI
+#define INCL_PM
+#include<os2.h>
+
+// This form is deprecated
+wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, const wxString& file, bool interactive, int orientation)
+{
+ LONG lType;
+ HAB hab;
+ DEVOPENSTRUC devOpen = { (char*)device_name.c_str()
+ ,(char*)driver_name.c_str()
+ ,NULL
+ ,NULL
+ ,NULL
+ ,NULL
+ ,NULL
+ ,NULL
+ ,NULL
+ };
+
+ m_isInteractive = interactive;
+
+ if (!file.IsNull() && file != T(""))
+ m_printData.SetFilename(file);
+
+/*
+ Implement PM's version of this
+#if wxUSE_COMMON_DIALOGS
+ if (interactive)
+ {
+ PRINTDLG pd;
+
+ pd.lStructSize = sizeof( PRINTDLG );
+ pd.hwndOwner=(HWND) NULL;
+ pd.hDevMode=(HANDLE)NULL;
+ pd.hDevNames=(HANDLE)NULL;
+ pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
+ pd.nFromPage=0;
+ pd.nToPage=0;
+ pd.nMinPage=0;
+ pd.nMaxPage=0;
+ pd.nCopies=1;
+ pd.hInstance=(HINSTANCE)NULL;
+
+ if ( PrintDlg( &pd ) != 0 )
+ {
+ m_hDC = (WXHDC) pd.hDC;
+ m_ok = TRUE;
+ }
+ else
+ {
+ m_ok = FALSE;
+ return;
+ }
+
+ // m_dontDelete = TRUE;
+ }
+ else
+#endif
+*/
+ if ((!driver_name.IsNull() && driver_name != T("")) &&
+ (!device_name.IsNull() && device_name != T("")) &&
+ (!file.IsNull() && file != T("")))
+ {
+ m_hDC = (WXHDC) ::DevOpenDC( hab
+ ,OD_QUEUED
+ ,"*"
+ ,5L
+ ,(PDEVOPENDATA)&devOpen
+ ,NULLHANDLE
+ );
+ m_ok = m_hDC ? TRUE: FALSE;
+ }
+ else
+ {
+ wxPrintData printData;
+ printData.SetOrientation(orientation);
+ m_hDC = wxGetPrinterDC(printData);
+ m_ok = m_hDC ? TRUE: FALSE;
+ }
+
+ if (m_hDC)
+ {
+ // int width = GetDeviceCaps(m_hDC, VERTRES);
+ // int height = GetDeviceCaps(m_hDC, HORZRES);
+ SetMapMode(wxMM_TEXT);
+ }
+ SetBrush(*wxBLACK_BRUSH);
+ SetPen(*wxBLACK_PEN);
+}
+
+wxPrinterDC::wxPrinterDC(const wxPrintData& printData)
+{
+ m_printData = printData;
+
+ m_isInteractive = FALSE;
+
+ m_hDC = wxGetPrinterDC(printData);
+ m_ok = (m_hDC != 0);
+
+ if (m_hDC)
+ SetMapMode(wxMM_TEXT);
+
+ SetBrush(*wxBLACK_BRUSH);
+ SetPen(*wxBLACK_PEN);
+}
+
+
+wxPrinterDC::wxPrinterDC(WXHDC theDC)
+{
+ m_isInteractive = FALSE;
+
+ m_hDC = theDC;
+ m_ok = TRUE;
+ if (m_hDC)
+ {
+ // int width = GetDeviceCaps(m_hDC, VERTRES);
+ // int height = GetDeviceCaps(m_hDC, HORZRES);
+ SetMapMode(wxMM_TEXT);
+ }
+ SetBrush(*wxBLACK_BRUSH);
+ SetPen(*wxBLACK_PEN);
+}
+
+wxPrinterDC::~wxPrinterDC(void)
+{
+}
+
+bool wxPrinterDC::StartDoc(const wxString& message)
+{
+/* TODO: PM's implementation
+ DOCINFO docinfo;
+ docinfo.cbSize = sizeof(DOCINFO);
+ docinfo.lpszDocName = (const wxChar*)message;
+
+ wxString filename(m_printData.GetFilename());
+
+ if (filename.IsEmpty())
+ docinfo.lpszOutput = NULL;
+ else
+ docinfo.lpszOutput = (const wxChar *) filename;
+
+#if defined(__WIN95__)
+ docinfo.lpszDatatype = NULL;
+ docinfo.fwType = 0;
+#endif
+
+ if (!m_hDC)
+ return FALSE;
+
+ int ret =
+#ifndef __WIN32__
+ ::StartDoc((HDC) m_hDC, &docinfo);
+#else
+#ifdef UNICODE
+ ::StartDocW((HDC) m_hDC, &docinfo);
+#else
+#ifdef __TWIN32__
+ ::StartDoc((HDC) m_hDC, &docinfo);
+#else
+ ::StartDocA((HDC) m_hDC, &docinfo);
+#endif
+#endif
+#endif
+
+#ifndef __WIN16__
+ if (ret <= 0)
+ {
+ DWORD lastError = GetLastError();
+ wxLogDebug(T("wxDC::StartDoc failed with error: %d\n"), lastError);
+ }
+#endif
+ return (ret > 0);
+*/
+ return(TRUE);
+}
+
+void wxPrinterDC::EndDoc(void)
+{
+// if (m_hDC) ::EndDoc((HDC) m_hDC);
+}
+
+void wxPrinterDC::StartPage(void)
+{
+// if (m_hDC)
+// ::StartPage((HDC) m_hDC);
+}
+
+void wxPrinterDC::EndPage(void)
+{
+// if (m_hDC)
+// ::EndPage((HDC) m_hDC);
+}
+
+// Returns default device and port names
+static bool wxGetDefaultDeviceName(wxString& deviceName, wxString& portName)
+{
+ deviceName = "";
+/*
+ LPDEVNAMES lpDevNames;
+ LPSTR lpszDriverName;
+ LPSTR lpszDeviceName;
+ LPSTR lpszPortName;
+
+ PRINTDLG pd;
+
+ // Cygwin has trouble believing PRINTDLG is 66 bytes - thinks it is 68
+#ifdef __GNUWIN32__
+ pd.lStructSize = 66; // sizeof(PRINTDLG);
+#else
+ pd.lStructSize = sizeof(PRINTDLG);
+#endif
+
+ pd.hwndOwner = (HWND)NULL;
+ pd.hDevMode = NULL; // Will be created by PrintDlg
+ pd.hDevNames = NULL; // Ditto
+ pd.Flags = PD_RETURNDEFAULT;
+ pd.nCopies = 1;
+
+ if (!PrintDlg((LPPRINTDLG)&pd))
+ {
+ if ( pd.hDevMode )
+ GlobalFree(pd.hDevMode);
+ if (pd.hDevNames)
+ GlobalFree(pd.hDevNames);
+
+ return FALSE;
+ }
+
+ if (pd.hDevNames)
+ {
+ lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
+ lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
+ lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
+ lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
+ GlobalUnlock(pd.hDevNames);
+ GlobalFree(pd.hDevNames);
+ pd.hDevNames=NULL;
+
+ deviceName = lpszDeviceName;
+ portName = lpszPortName;
+ }
+
+ if (pd.hDevMode)
+ {
+ GlobalFree(pd.hDevMode);
+ pd.hDevMode=NULL;
+ }
+ return ( deviceName != T("") );
+*/
+ return(TRUE);
+}
+
+// Gets an HDC for the specified printer configuration
+WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst)
+{
+ HDC hDC;
+/*
+ wxPrintData printData = printDataConst;
+ printData.ConvertToNative();
+
+ wxChar* driverName = (wxChar*) NULL;
+
+ wxString devNameStr = printData.GetPrinterName();
+ wxChar* deviceName;
+ wxChar* portName = (wxChar*) NULL; // Obsolete in WIN32
+
+ if (devNameStr == T(""))
+ deviceName = (wxChar*) NULL;
+ else
+ deviceName = WXSTRINGCAST devNameStr;
+
+ LPDEVMODE lpDevMode = (LPDEVMODE) NULL;
+
+ HGLOBAL hDevMode = (HGLOBAL)(DWORD) printData.GetNativeData();
+
+ if ( hDevMode )
+ lpDevMode = (DEVMODE*) GlobalLock(hDevMode);
+
+ if (devNameStr == T(""))
+ {
+ // Retrieve the default device name
+ wxString portName;
+ bool ret = wxGetDefaultDeviceName(devNameStr, portName);
+
+ wxASSERT_MSG( ret, T("Could not get default device name.") );
+
+ deviceName = WXSTRINGCAST devNameStr;
+ }
+
+#ifdef __WIN32__
+ HDC hDC = CreateDC(driverName, deviceName, portName, (DEVMODE *) lpDevMode);
+#else
+ HDC hDC = CreateDC(driverName, deviceName, portName, (LPSTR) lpDevMode);
+#endif
+
+ if (hDevMode && lpDevMode)
+ GlobalUnlock(hDevMode);
+*/
+ return (WXHDC) hDC;
+}
+
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "dialog.h"
-#endif
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
#include "wx/dialog.h"
#include "wx/utils.h"
#include "wx/frame.h"
#include "wx/app.h"
#include "wx/settings.h"
+#include "wx/intl.h"
+#include "wx/log.h"
+#endif
+
+#include "wx/os2/private.h"
+#include "wx/log.h"
+
+#if wxUSE_COMMON_DIALOGS
+#include <commdlg.h>
+#endif
+
+#define wxDIALOG_DEFAULT_X 300
+#define wxDIALOG_DEFAULT_Y 300
// Lists to keep track of windows, so we can disable/enable them
// for modal dialogs
-wxList wxModalDialogs;
-wxList wxModelessWindows; // Frames and modeless dialogs
-extern wxList wxPendingDelete;
+wxWindowList wxModalDialogs;
+wxWindowList wxModelessWindows; // Frames and modeless dialogs
+extern wxList WXDLLEXPORT wxPendingDelete;
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
-
-BEGIN_EVENT_TABLE(wxDialog, wxPanel)
- EVT_BUTTON(wxID_OK, wxDialog::OnOK)
- EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
- EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
- EVT_CHAR_HOOK(wxDialog::OnCharHook)
- EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
- EVT_CLOSE(wxDialog::OnCloseWindow)
-END_EVENT_TABLE()
-
+ IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
+
+ BEGIN_EVENT_TABLE(wxDialog, wxPanel)
+ EVT_SIZE(wxDialog::OnSize)
+ EVT_BUTTON(wxID_OK, wxDialog::OnOK)
+ EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
+ EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+ EVT_CHAR_HOOK(wxDialog::OnCharHook)
+ EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+ EVT_CLOSE(wxDialog::OnCloseWindow)
+ END_EVENT_TABLE()
#endif
wxDialog::wxDialog()
{
+ m_isShown = FALSE;
+ m_modalShowing = FALSE;
+
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
}
long style,
const wxString& name)
{
- m_windowStyle = style;
-
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
- SetName(name);
-
- if (!parent)
- wxTopLevelWindows.Append(this);
+#if wxUSE_TOOLTIPS
+ m_hwndToolTip = 0;
+#endif
- if (parent) parent->AddChild(this);
+ SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+ SetName(name);
- if ( id == -1 )
- m_windowId = (int)NewControlId();
- else
- m_windowId = id;
+ if (!parent)
+ wxTopLevelWindows.Append(this);
- // TODO: create dialog
+ if (parent) parent->AddChild(this);
- return FALSE;
+ if ( id == -1 )
+ m_windowId = (int)NewControlId();
+ else
+ m_windowId = id;
+
+ int x = pos.x;
+ int y = pos.y;
+ int width = size.x;
+ int height = size.y;
+
+ if (x < 0) x = wxDIALOG_DEFAULT_X;
+ if (y < 0) y = wxDIALOG_DEFAULT_Y;
+
+ m_windowStyle = style;
+
+ m_isShown = FALSE;
+ m_modalShowing = FALSE;
+
+ if (width < 0)
+ width = 500;
+ if (height < 0)
+ height = 500;
+
+ // TODO: convert below to OS/2 PM code
+
+ // All dialogs should really have this style
+// m_windowStyle |= wxTAB_TRAVERSAL;
+//
+// WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle);
+// if (m_windowStyle & wxSTAY_ON_TOP)
+// extendedStyle |= WS_EX_TOPMOST;
+//
+ // Allows creation of dialogs with & without captions under MSWindows,
+ // resizeable or not (but a resizeable dialog always has caption -
+ // otherwise it would look too strange)
+// const wxChar *dlg;
+// if ( style & wxRESIZE_BORDER )
+// dlg = T("wxResizeableDialog");
+// else if ( style & wxCAPTION )
+// dlg = T("wxCaptionDialog");
+// else
+// dlg = T("wxNoCaptionDialog");
+// MSWCreate(m_windowId, parent, NULL, this, NULL,
+// x, y, width, height,
+// 0, // style is not used if we have dlg template
+// dlg,
+// extendedStyle);
+//
+// HWND hwnd = (HWND)GetHWND();
+//
+// if ( !hwnd )
+// {
+// wxLogError(T("Failed to create dialog."));
+//
+// return FALSE;
+// }
+//
+// SubclassWin(GetHWND());
+//
+// SetWindowText(hwnd, title);
+// SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+//
+ return TRUE;
}
void wxDialog::SetModal(bool flag)
{
- if ( flag )
- m_windowStyle |= wxDIALOG_MODAL ;
- else
- if ( m_windowStyle & wxDIALOG_MODAL )
- m_windowStyle -= wxDIALOG_MODAL ;
-
- wxModelessWindows.DeleteObject(this);
- if (!flag)
- wxModelessWindows.Append(this);
+ if ( flag )
+ m_windowStyle |= wxDIALOG_MODAL ;
+ else if ( m_windowStyle & wxDIALOG_MODAL )
+ m_windowStyle -= wxDIALOG_MODAL ;
+
+ wxModelessWindows.DeleteObject(this);
+ if (!flag)
+ wxModelessWindows.Append(this);
}
wxDialog::~wxDialog()
{
- // TODO
+ m_isBeingDeleted = TRUE;
+
wxTopLevelWindows.DeleteObject(this);
+ Show(FALSE);
+
+ if (m_modalShowing)
+ {
+ if (GetParent() && GetParent()->GetHWND())
+ // TODO: bring the parent to the top
+ return;
+ }
+
+ m_modalShowing = FALSE;
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
- wxModelessWindows.DeleteObject(this);
+ wxModelessWindows.DeleteObject(this);
+
// If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
// By default, pressing escape cancels the dialog
void wxDialog::OnCharHook(wxKeyEvent& event)
{
- if (event.m_keyCode == WXK_ESCAPE)
- {
- // Behaviour changed in 2.0: we'll send a Cancel message
- // to the dialog instead of Close.
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent);
+ if (GetHWND())
+ {
+ if (event.m_keyCode == WXK_ESCAPE)
+ {
+ // Behaviour changed in 2.0: we'll send a Cancel message
+ // to the dialog instead of Close.
+ wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+ cancelEvent.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(cancelEvent);
- return;
- }
- // We didn't process this event.
- event.Skip();
+ return;
+ }
+ }
+ // We didn't process this event.
+ event.Skip();
+}
+
+void wxDialog::OnPaint(wxPaintEvent& event)
+{
+ // No: if you call the default procedure, it makes
+ // the following painting code not work.
+// wxWindow::OnPaint(event);
+}
+
+void wxDialog::Fit()
+{
+ wxWindow::Fit();
}
void wxDialog::Iconize(bool WXUNUSED(iconize))
{
- // TODO
+ // Windows dialog boxes can't be iconized
}
bool wxDialog::IsIconized() const
{
- // TODO
return FALSE;
}
+void wxDialog::DoSetClientSize(int width, int height)
+{
+ // TODO: Convert the below to OS/2 PM code
+
+// HWND hWnd = (HWND) GetHWND();
+// RECT rect;
+// ::GetClientRect(hWnd, &rect);
+//
+// RECT rect2;
+// GetWindowRect(hWnd, &rect2);
+//
+ // Find the difference between the entire window (title bar and all)
+ // and the client area; add this to the new client size to move the
+ // window
+// int actual_width = rect2.right - rect2.left - rect.right + width;
+// int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
+
+// MoveWindow(hWnd, rect2.left, rect2.top, actual_width, actual_height, TRUE);
+//
+// wxSizeEvent event(wxSize(actual_width, actual_height), m_windowId);
+// event.SetEventObject( this );
+// GetEventHandler()->ProcessEvent(event);
+}
void wxDialog::GetPosition(int *x, int *y) const
{
- // TODO
+ // TODO: Convert
+// HWND hWnd = (HWND) GetHWND();
+// RECT rect;
+// GetWindowRect(hWnd, &rect);
+
+// *x = rect.left;
+// *y = rect.top;
+}
+
+bool wxDialog::IsShown() const
+{
+ return m_isShown;
+}
+
+bool wxDialog::IsModal() const
+{
+ return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast
}
bool wxDialog::Show(bool show)
{
- // TODO
+ // TODO: This is involved code, look at msw port for details
return FALSE;
}
void wxDialog::SetTitle(const wxString& title)
{
- // TODO
+ ::WinSetWindowText((HWND) GetHWND(), title.c_str());
}
wxString wxDialog::GetTitle() const
{
- // TODO
- return wxString("");
+ ::WinQueryWindowText((HWND) GetHWND(), 1000, wxBuffer);
+ return wxString(wxBuffer);
}
void wxDialog::Centre(int direction)
int wxDialog::ShowModal()
{
m_windowStyle |= wxDIALOG_MODAL;
- // TODO: modal showing
- Show(TRUE);
- return GetReturnCode();
+ Show(TRUE);
+ return GetReturnCode();
}
void wxDialog::EndModal(int retCode)
{
- SetReturnCode(retCode);
+ SetReturnCode(retCode);
// TODO modal un-showing
- Show(FALSE);
+ Show(FALSE);
}
+// Define for each class of dialog and control
+WXHBRUSH wxDialog::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+ return 0;
+}
// Standard buttons
void wxDialog::OnOK(wxCommandEvent& event)
{
- if ( Validate() && TransferDataFromWindow() )
- {
+ if ( Validate() && TransferDataFromWindow() )
+ {
if ( IsModal() )
EndModal(wxID_OK);
else
{
- SetReturnCode(wxID_OK);
- this->Show(FALSE);
+ SetReturnCode(wxID_OK);
+ this->Show(FALSE);
}
- }
+ }
}
void wxDialog::OnApply(wxCommandEvent& event)
{
- if (Validate())
- TransferDataFromWindow();
- // TODO probably need to disable the Apply button until things change again
+ if (Validate())
+ TransferDataFromWindow();
+ // TODO probably need to disable the Apply button until things change again
}
void wxDialog::OnCancel(wxCommandEvent& event)
else
{
SetReturnCode(wxID_CANCEL);
- this->Show(FALSE);
+ this->Show(FALSE);
}
}
// Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy()
{
- if (!wxPendingDelete.Member(this))
- wxPendingDelete.Append(this);
- return TRUE;
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+ return TRUE;
+}
+
+void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
+{
+ // if we're using constraints - do use them
+ #if wxUSE_CONSTRAINTS
+ if ( GetAutoLayout() )
+ {
+ Layout();
+ }
+ #endif
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
Refresh();
}
-void wxDialog::Fit()
+MRESULT wxDialog::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
+ MRESULT rc = 0;
+ bool processed = FALSE;
+
+ switch ( message )
+ {
+ case WM_CLOSE:
+ // if we can't close, tell the system that we processed the
+ // message - otherwise it would close us
+ processed = !Close();
+ break;
+ }
+
+ if ( !processed )
+ rc = wxWindow::OS2WindowProc(hwnd, message, wParam, lParam);
+
+ return rc;
}
+
..\os2\$D\dcprint.obj \
..\os2\$D\dcscreen.obj \
..\os2\$D\dialog.obj \
+ ..\os2\$D\dirdlg.obj \
..\os2\$D\frame.obj \
..\os2\$D\window.obj
dcprint.obj \
dcscreen.obj \
dialog.obj \
+ dirdlg.obj \
frame.obj \
window.obj
copy ..\os2\$D\dcprint.obj
copy ..\os2\$D\dcscreen.obj
copy ..\os2\$D\dialog.obj
+ copy ..\os2\$D\dirdlg.obj
copy ..\os2\$D\frame.obj
copy ..\os2\$D\window.obj
long style,
const wxString& name)
{
- wxCHECK_MSG( parent, FALSE, _T("can't create wxWindow without parent") );
+ wxCHECK_MSG( parent, FALSE, T("can't create wxWindow without parent") );
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
if (m_hWnd)
{
if(!WinDestroyWindow(GetHWND()))
- wxLogLastError(_T("DestroyWindow"));
+ wxLogLastError(T("DestroyWindow"));
// remove hWnd <-> wxWindow association
wxRemoveHandleAssociation(this);
}
int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf);
if ( !chars )
{
- wxLogLastError(_T("GetMenuString"));
+ wxLogLastError(T("GetMenuString"));
continue;
}
- if ( wxStrcmp(buf, _T("&Window")) == 0 )
+ if ( wxStrcmp(buf, T("&Window")) == 0 )
{
WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
break;
// adding NULL hWnd is (first) surely a result of an error and
// (secondly) breaks menu command processing
wxCHECK_RET( hWnd != (HWND)NULL,
- _T("attempt to add a NULL hWnd to window list ignored") );
+ T("attempt to add a NULL hWnd to window list ignored") );
if ( !wxWinHandleList->Find((long)hWnd) )
wxWinHandleList->Append((long)hWnd, win);
void wxWindow::SubclassWin(WXHWND hWnd)
{
- wxASSERT_MSG( !m_oldWndProc, _T("subclassing window twice?") );
+ wxASSERT_MSG( !m_oldWndProc, T("subclassing window twice?") );
HWND hwnd = (HWND)hWnd;
/*
* TODO: implement something like this:
-* wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in SubclassWin") );
+* wxCHECK_RET( ::IsWindow(hwnd), T("invalid HWND in SubclassWin") );
*
* wxAssociateWinWithHandle(hwnd, this);
*
{
m_hWnd = 0;
- wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in UnsubclassWin") );
+ wxCHECK_RET( ::IsWindow(hwnd), T("invalid HWND in UnsubclassWin") );
FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )