Fixes for the outstanding errors in minimal.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2000-04-16 21:31:58 +00:00
parent 231237044b
commit 831026c188
4 changed files with 186 additions and 96 deletions

View File

@@ -25,22 +25,31 @@ WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog : public wxDialog class WXDLLEXPORT wxMessageDialog : public wxDialog
{ {
DECLARE_DYNAMIC_CLASS(wxMessageDialog) DECLARE_DYNAMIC_CLASS(wxMessageDialog)
protected:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
public: public:
wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, wxMessageDialog( wxWindow* pParent
long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition); ,const wxString& rsMessage
,const wxString& rsCaption = wxMessageBoxCaptionStr
,long lStyle = wxOK|wxCENTRE
,const wxPoint& rPos = wxDefaultPosition
);
int ShowModal(); int ShowModal(void);
};
protected:
wxString m_sCaption;
wxString m_sMessage;
long m_lDialogStyle;
wxWindow* m_pParent;
}; // end of CLASS wxMessageDialog
int WXDLLEXPORT wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, int WXDLLEXPORT wxMessageBox( const wxString& rsMessage
long style = wxOK|wxCENTRE, ,const wxString& rsCaption = wxMessageBoxCaptionStr
wxWindow *parent = NULL, int x = -1, int y = -1); ,long lStyle = wxOK|wxCENTRE
,wxWindow* pParent = NULL
,int nX = -1
,int nY = -1
);
#endif #endif
// _WX_MSGBOXDLG_H_ // _WX_MSGBOXDLG_H_

View File

@@ -42,59 +42,101 @@ protected:
wxAcceleratorRefData::wxAcceleratorRefData() wxAcceleratorRefData::wxAcceleratorRefData()
{ {
// TODO m_ok = FALSE;
/* m_hAccel = 0;
HACCEL m_hAccel; } // end of wxAcceleratorRefData::wxAcceleratorRefData
*/
}
wxAcceleratorRefData::~wxAcceleratorRefData() wxAcceleratorRefData::~wxAcceleratorRefData()
{ {
/*
if (m_hAccel) if (m_hAccel)
{ {
DestroyAcceleratorTable((HACCEL) m_hAccel); WinDestroyAccelTable((HACCEL) m_hAccel);
} }
m_hAccel = 0 ; m_hAccel = 0 ;
*/ } // end of wxAcceleratorRefData::~wxAcceleratorRefData
}
wxAcceleratorTable::wxAcceleratorTable() wxAcceleratorTable::wxAcceleratorTable()
{ {
m_refData = NULL; m_refData = NULL;
} } // end of wxAcceleratorTable::wxAcceleratorTable
wxAcceleratorTable::~wxAcceleratorTable() wxAcceleratorTable::~wxAcceleratorTable()
{ {
} } // end of wxAcceleratorTable::~wxAcceleratorTable
// Load from .rc resource // Load from .rc resource
wxAcceleratorTable::wxAcceleratorTable(const wxString& resource) wxAcceleratorTable::wxAcceleratorTable(
const wxString& rResource
)
{ {
HACCEL hAccel;
ULONG ulId;
m_refData = new wxAcceleratorRefData; m_refData = new wxAcceleratorRefData;
/* TODO: load acelerator from resource, if appropriate for your platform ulId = atol((char*)rResource.c_str());
hAccel = ::WinLoadAccelTable( vHabmain
,NULL // resources always in .exe
,(ULONG)ulId
);
M_ACCELDATA->m_hAccel = hAccel; M_ACCELDATA->m_hAccel = hAccel;
M_ACCELDATA->m_ok = (hAccel != 0); M_ACCELDATA->m_ok = (hAccel != 0);
*/
} }
extern int wxCharCodeWXToOS2(int id, bool *isVirtual); extern int wxCharCodeWXToOS2(
int nId
, bool* pbIsVirtual
);
// Create from an array // Create from an array
wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[]) wxAcceleratorTable::wxAcceleratorTable(
int n
, wxAcceleratorEntry vaEntries[]
)
{ {
m_refData = new wxAcceleratorRefData; int nAccelLength = ((sizeof(ACCEL) * n) + sizeof(ACCELTABLE));
PACCELTABLE pArr;
int i;
/* TODO: create table from entries m_refData = new wxAcceleratorRefData;
*/ pArr = (PACCELTABLE) new int[nAccelLength];
for (i = 0; i < n; i++)
{
USHORT uVirt = 0;
if (vaEntries[i].GetFlags() & wxACCEL_ALT)
uVirt |= AF_ALT;
if (vaEntries[i].GetFlags() & wxACCEL_SHIFT)
uVirt |= AF_SHIFT;
if (vaEntries[i].GetFlags() & wxACCEL_CTRL)
uVirt |= AF_CONTROL;
bool bIsVirtual;
USHORT uKey = wxCharCodeWXToOS2( vaEntries[i].GetKeyCode()
,&bIsVirtual
);
uVirt |= AF_VIRTUALKEY;
USHORT uCmd = vaEntries[i].GetCommand();
pArr->aaccel[i].fs = uVirt;
pArr->aaccel[i].key = uKey;
pArr->aaccel[i].cmd = uCmd;
} }
pArr->codepage = 437; // default to english Fix???
pArr->cAccel = (USHORT)n;
M_ACCELDATA->m_hAccel = ::WinCreateAccelTable( vHabmain
,pArr
);
delete[] pArr;
M_ACCELDATA->m_ok = (M_ACCELDATA->m_hAccel != 0);
} // end of wxAcceleratorTable::wxAcceleratorTable
bool wxAcceleratorTable::Ok() const bool wxAcceleratorTable::Ok() const
{ {
// TODO return(M_ACCELDATA && (M_ACCELDATA->m_ok));
return FALSE; } // end of wxAcceleratorTable::Ok
}
void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel) void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel)
{ {
@@ -111,14 +153,17 @@ WXHACCEL wxAcceleratorTable::GetHACCEL() const
return (WXHACCEL) M_ACCELDATA->m_hAccel; return (WXHACCEL) M_ACCELDATA->m_hAccel;
} }
bool wxAcceleratorTable::Translate(wxWindow *window, WXMSG *wxmsg) const bool wxAcceleratorTable::Translate(
wxWindow* pWindow
, WXMSG* pWxmsg
) const
{ {
// TODO: PQMSG pMsg = (PQMSG)pWxmsg;
/*
MSG *msg = (MSG *)wxmsg;
return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg); return Ok() && ::WinTranslateAccel( vHabmain
*/ ,GetHwndOf(pWindow)
return FALSE; ,GetHaccel()
} ,pMsg
);
} // end of wxAcceleratorTable::Translate

View File

@@ -35,69 +35,105 @@
IMPLEMENT_CLASS(wxMessageDialog, wxDialog) IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, wxMessageDialog::wxMessageDialog(
long style, const wxPoint& pos) wxWindow* pParent
, const wxString& rsMessage
, const wxString& rsCaption
, long lStyle
, const wxPoint& pPos
)
{ {
m_caption = caption; m_sCaption = rsCaption;
m_message = message; m_sMessage = rsMessage;
m_dialogStyle = style; m_lDialogStyle = lStyle;
m_parent = parent; m_pParent = NULL; // pParent;
} } // end of wxMessageDialog::wxMessageDialog
int wxMessageDialog::ShowModal() int wxMessageDialog::ShowModal()
{ {
HWND hWnd = 0; HWND hWnd = 0;
if (m_parent) hWnd = (HWND) m_parent->GetHWND(); ULONG ulStyle = MB_OK;
unsigned int msStyle = MB_OK; int nAns = wxOK;
if (m_dialogStyle & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
msStyle = MB_YESNOCANCEL;
else
msStyle = MB_YESNO;
if (m_dialogStyle & wxNO_DEFAULT) if (!wxTheApp->GetTopWindow())
msStyle |= MB_DEFBUTTON2; {
//
// when the message box is shown from wxApp::OnInit() (i.e. before the
// message loop is entered), this must be done or the next message box
// will never be shown - just try putting 2 calls to wxMessageBox() in
// OnInit() to see it
//
while (wxTheApp->Pending())
wxTheApp->Dispatch();
} }
if (m_dialogStyle & wxOK) if (m_pParent)
hWnd = (HWND) m_pParent->GetHWND();
else
hWnd = HWND_DESKTOP;
if (m_lDialogStyle & wxYES_NO)
{ {
if (m_dialogStyle & wxCANCEL) if (m_lDialogStyle & wxCANCEL)
msStyle = MB_OKCANCEL; ulStyle = MB_YESNOCANCEL;
else else
msStyle = MB_OK; ulStyle = MB_YESNO;
if (m_lDialogStyle & wxNO_DEFAULT)
ulStyle |= MB_DEFBUTTON2;
} }
if (m_dialogStyle & wxICON_EXCLAMATION)
msStyle |= MB_ICONEXCLAMATION;
else if (m_dialogStyle & wxICON_HAND)
msStyle |= MB_ICONHAND;
else if (m_dialogStyle & wxICON_INFORMATION)
msStyle |= MB_INFORMATION;
else if (m_dialogStyle & wxICON_QUESTION)
msStyle |= MB_ICONQUESTION;
if (hWnd) if (m_lDialogStyle & wxOK)
msStyle |= MB_APPLMODAL; {
if (m_lDialogStyle & wxCANCEL)
ulStyle = MB_OKCANCEL;
else else
msStyle |= MB_SYSTEMMODAL; ulStyle = MB_OK;
}
if (m_lDialogStyle & wxICON_EXCLAMATION)
ulStyle |= MB_ICONEXCLAMATION;
else if (m_lDialogStyle & wxICON_HAND)
ulStyle |= MB_ICONHAND;
else if (m_lDialogStyle & wxICON_INFORMATION)
ulStyle |= MB_ICONEXCLAMATION;
else if (m_lDialogStyle & wxICON_QUESTION)
ulStyle |= MB_ICONQUESTION;
int msAns = WinMessageBox(HWND_DESKTOP, hWnd, m_message.c_str(), m_caption.c_str(), 0, msStyle | MB_MOVEABLE); if (hWnd != HWND_DESKTOP)
int ans = wxOK; ulStyle |= MB_APPLMODAL;
switch (msAns) else
ulStyle |= MB_SYSTEMMODAL;
//
// This little line of code is get message boxes under OS/2 to
// behve like the other ports. In OS/2 if the parent is a window
// it displays, clipped, in the window. This centers it on the
// desktop, like the other ports but still allows control over modality
//
hWnd = HWND_DESKTOP;
ULONG ulAns = ::WinMessageBox( hWnd
,hWnd
,(PSZ)m_sMessage.c_str()
,(PSZ)m_sCaption.c_str()
,0L
,ulStyle);
switch (ulAns)
{ {
case MBID_CANCEL: case MBID_CANCEL:
ans = wxID_CANCEL; nAns = wxID_CANCEL;
break; break;
case MBID_OK: case MBID_OK:
ans = wxID_OK; nAns = wxID_OK;
break; break;
case MBID_YES: case MBID_YES:
ans = wxID_YES; nAns = wxID_YES;
break; break;
case MBID_NO: case MBID_NO:
ans = wxID_NO; nAns = wxID_NO;
break; break;
default:
nAns = wxID_CANCEL;
} }
return ans; return nAns;
} } // end of wxMessageDialog::ShowModal