added modeless dlg test to dialogs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-01-30 01:33:02 +00:00
parent b6c588e1a6
commit 4c45f240f6
5 changed files with 95 additions and 180 deletions

View File

@@ -43,10 +43,37 @@
IMPLEMENT_APP(MyApp)
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_PAINT(MyCanvas::OnPaint)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
EVT_MENU(DIALOGS_MODELESS, MyFrame::ModelessDlg)
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
#endif
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_BUTTON(DIALOGS_MODELESS_BTN, MyFrame::OnButton)
END_EVENT_TABLE()
MyCanvas *myCanvas = (MyCanvas *) NULL;
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit(void)
bool MyApp::OnInit()
{
#if defined(__WXGTK__) && defined(wxUSE_UNICODE)
wxConvCurrent = &wxConvLibc;
@@ -80,15 +107,17 @@ bool MyApp::OnInit(void)
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E");
file_menu->Append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P");
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-S");
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C");
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_TIP, "&Tip of the day\tCtrl-T");
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O");
file_menu->Append(DIALOGS_FILES_OPEN, "Open &files\tCtrl-Q");
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file");
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S");
file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", TRUE);
file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT, "E&xit\tAlt-X");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
@@ -108,9 +137,14 @@ bool MyApp::OnInit(void)
}
// My frame constructor
MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size):
wxFrame(parent, -1, title, pos, size)
{}
MyFrame::MyFrame(wxWindow *parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size)
: wxFrame(parent, -1, title, pos, size)
{
m_dialog = (MyModelessDialog *)NULL;
}
void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
{
@@ -360,6 +394,31 @@ void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
}
}
void MyFrame::ModelessDlg(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetInt());
if ( show )
{
if ( !m_dialog )
{
m_dialog = new MyModelessDialog(this);
}
m_dialog->Show(TRUE);
}
else // hide
{
m_dialog->Hide();
}
}
void MyFrame::OnButton(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox("Button pressed in modeless dialog", "Info",
wxOK | wxICON_INFORMATION, this);
}
void MyFrame::ShowTip(wxCommandEvent& event)
{
#if wxUSE_STARTUP_TIPS
@@ -403,28 +462,14 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
dc.DrawText("wxWindows common dialogs test application", 10, 10);
}
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_PAINT(MyCanvas::OnPaint)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
#endif
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// MyModelessDialog
// ----------------------------------------------------------------------------
MyModelessDialog::MyModelessDialog(wxWindow *parent)
: wxDialog(parent, -1, wxString("Modeless dialog"))
{
(void)new wxButton(this, DIALOGS_MODELESS_BTN, "Press me");
Fit();
Centre();
}

View File

@@ -22,6 +22,13 @@ public:
wxColour m_canvasTextColour;
};
// A modeless dialog
class MyModelessDialog : public wxDialog
{
public:
MyModelessDialog(wxWindow *parent);
};
// Define a new frame type
class MyFrame: public wxFrame
{
@@ -42,6 +49,7 @@ public:
void FileSave(wxCommandEvent& event);
void DirChoose(wxCommandEvent& event);
void ShowTip(wxCommandEvent& event);
void ModelessDlg(wxCommandEvent& event);
#if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW
void ChooseColourGeneric(wxCommandEvent& event);
@@ -50,6 +58,11 @@ public:
void OnExit(wxCommandEvent& event);
void OnButton(wxCommandEvent& event);
private:
MyModelessDialog *m_dialog;
DECLARE_EVENT_TABLE()
};
@@ -81,7 +94,9 @@ enum
DIALOGS_DIR_CHOOSE,
DIALOGS_TIP,
DIALOGS_NUM_ENTRY,
DIALOGS_LOG_DIALOG
DIALOGS_LOG_DIALOG,
DIALOGS_MODELESS,
DIALOGS_MODELESS_BTN
};
#endif

View File

@@ -585,7 +585,9 @@ void MyCanvas::DrawDefault(wxDC& dc)
memdc.DrawLine( 10,0,10,70 );
// to the right
memdc.SetPen(*wxRED_PEN);
wxPen pen = *wxRED_PEN;
pen.SetWidth(2);
memdc.SetPen(pen);
memdc.DrawLine( 10, 5,10, 5 );
memdc.DrawLine( 10,10,11,10 );
memdc.DrawLine( 10,15,12,15 );

View File

@@ -1,118 +0,0 @@
# Microsoft Developer Studio Project File - Name="test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=test - Win32 Release
!MESSAGE Dies ist kein g<>ltiges Makefile. Zum Erstellen dieses Projekts mit\
NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und f<>hren Sie den\
Befehl
!MESSAGE
!MESSAGE NMAKE /f "test.mak".
!MESSAGE
!MESSAGE Sie k<>nnen beim Ausf<73>hren von NMAKE eine Konfiguration angeben
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 Release"
!MESSAGE
!MESSAGE F<>r die Konfiguration stehen zur Auswahl:
!MESSAGE
!MESSAGE "test - Win32 Release" (basierend auf "Win32 (x86) Application")
!MESSAGE "test - Win32 Debug" (basierend auf "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /w /W0 /GX /O2 /I "..\..\include" /D "__WXDEBUG__" /D "__WIN32__" /D "__WXMSW__" /D "__WIN95__" /D "STRICT" /D "__WINDOWS__" /YX /FD /D /c
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /i "..\..\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ..\..\debug\wxwin.lib ctl3d32.lib /nologo /subsystem:windows /incremental:yes /pdb:".\Debug/santis.pdb" /debug /machine:I386 /out:".\Debug/santis.exe"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\Debug"
# PROP BASE Intermediate_Dir ".\Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\Debug"
# PROP Intermediate_Dir ".\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /w /W0 /GX /Z7 /Od /I "..\..\include" /D "__WXDEBUG__" /D "__WIN32__" /D "__WXMSW__" /D "__WIN95__" /D "STRICT" /D "__WINDOWS__" /YX /FD /D /c
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /i "..\..\include" /d "WXDEBUG" /d "__WXMSW__"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib oldnames.lib comctl32.lib ctl3d32.lib odbc32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ..\..\debug\wxwin.lib ctl3d32.lib /nologo /subsystem:windows /debug /machine:I386
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "test - Win32 Release"
# Name "test - Win32 Debug"
# Begin Group "Quellcodedateien"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\printing.cpp
# End Source File
# End Group
# Begin Group "Header-Dateien"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\printing.h
# End Source File
# End Group
# Begin Group "Ressourcendateien"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\printing.rc
# End Source File
# End Group
# End Target
# End Project

View File

@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GEL<45>SCHT WERDEN!
###############################################################################
Project: "test"=.\test.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################