More OS/2 stuff
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -333,6 +333,16 @@ OS2OBJS = \
|
||||
..\os2\$D\menuitem.obj \
|
||||
..\os2\$D\metafile.obj \
|
||||
..\os2\$D\minifram.obj \
|
||||
..\os2\$D\msgdlg.obj \
|
||||
..\os2\$D\nativdlg.obj \
|
||||
..\os2\$D\notebook.obj \
|
||||
..\os2\$D\ownerdrw.obj \
|
||||
..\os2\$D\palette.obj \
|
||||
..\os2\$D\pen.obj \
|
||||
..\os2\$D\pngread.obj \
|
||||
..\os2\$D\print.obj \
|
||||
..\os2\$D\radiobox.obj \
|
||||
..\os2\$D\radiobut.obj \
|
||||
..\os2\$D\window.obj
|
||||
|
||||
OS2LIBOBJS = \
|
||||
@@ -380,6 +390,16 @@ OS2LIBOBJS = \
|
||||
menuitem.obj \
|
||||
metafile.obj \
|
||||
minifram.obj \
|
||||
msgdlg.obj \
|
||||
nativdlg.obj \
|
||||
notebook.obj \
|
||||
ownerdrw.obj \
|
||||
palette.obj \
|
||||
pen.obj \
|
||||
pngread.obj \
|
||||
print.obj \
|
||||
radiobox.obj \
|
||||
radiobut.obj \
|
||||
window.obj
|
||||
|
||||
HTMLOBJS = \
|
||||
@@ -571,6 +591,16 @@ $(OS2LIBOBJS):
|
||||
copy ..\os2\$D\menuitem.obj
|
||||
copy ..\os2\$D\metafile.obj
|
||||
copy ..\os2\$D\minifram.obj
|
||||
copy ..\os2\$D\msgdlg.obj
|
||||
copy ..\os2\$D\nativdlg.obj
|
||||
copy ..\os2\$D\notebook.obj
|
||||
copy ..\os2\$D\ownerdrw.obj
|
||||
copy ..\os2\$D\pallet.obj
|
||||
copy ..\os2\$D\pen.obj
|
||||
copy ..\os2\$D\pngread.obj
|
||||
copy ..\os2\$D\print.obj
|
||||
copy ..\os2\$D\radiobox.obj
|
||||
copy ..\os2\$D\radiobut.obj
|
||||
copy ..\os2\$D\window.obj
|
||||
|
||||
# wxWindows library as DLL
|
||||
|
@@ -1,19 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msgdlg.cpp
|
||||
// Purpose: wxMessageDialog
|
||||
// Author: AUTHOR
|
||||
// Author: David Webster
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// Created: 10/10/99
|
||||
// RCS-ID: $$
|
||||
// Copyright: (c) AUTHOR
|
||||
// Licence: wxWindows licence
|
||||
// Copyright: (c) David Webster
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "msgdlg.h"
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/defs.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/stubs/msgdlg.h"
|
||||
#include "wx/os2/private.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define wxDIALOG_DEFAULT_X 300
|
||||
#define wxDIALOG_DEFAULT_Y 300
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||
|
@@ -1,52 +1,71 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: notebook.cpp
|
||||
// Purpose: implementation of wxNotebook
|
||||
// Author: AUTHOR
|
||||
// Author: David Webster
|
||||
// Modified by:
|
||||
// Created: ??/??/98
|
||||
// Created: 10/12/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) AUTHOR
|
||||
// Copyright: (c) David Webster
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "notebook.h"
|
||||
#endif
|
||||
// wxWindows
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/string.h>
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/control.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
#include <wx/os2/private.h>
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// check that the page index is valid
|
||||
#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
|
||||
|
||||
// hide the ugly cast
|
||||
#define m_hwnd (HWND)GetHWND()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This is a work-around for missing defines in gcc-2.95 headers
|
||||
#ifndef TCS_RIGHT
|
||||
#define TCS_RIGHT 0x0002
|
||||
#endif
|
||||
|
||||
#ifndef TCS_VERTICAL
|
||||
#define TCS_VERTICAL 0x0080
|
||||
#endif
|
||||
|
||||
#ifndef TCS_BOTTOM
|
||||
#define TCS_BOTTOM TCS_RIGHT
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
|
||||
|
||||
EVT_SIZE(wxNotebook::OnSize)
|
||||
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
|
||||
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||
END_EVENT_TABLE()
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
@@ -91,19 +110,53 @@ bool wxNotebook::Create(wxWindow *parent,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
// base init
|
||||
SetName(name);
|
||||
SetParent(parent);
|
||||
// base init
|
||||
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return FALSE;
|
||||
|
||||
m_windowId = id == -1 ? NewControlId() : id;
|
||||
// colors and font
|
||||
m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE));
|
||||
m_foregroundColour = *wxBLACK ;
|
||||
|
||||
// style
|
||||
m_windowStyle = style;
|
||||
// TODO:
|
||||
/*
|
||||
// style
|
||||
m_windowStyle = style | wxTAB_TRAVERSAL;
|
||||
|
||||
if ( parent != NULL )
|
||||
parent->AddChild(this);
|
||||
long tabStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TABS;
|
||||
|
||||
// TODO
|
||||
if (m_windowStyle & wxCLIP_CHILDREN)
|
||||
tabStyle |= WS_CLIPCHILDREN;
|
||||
if ( m_windowStyle & wxTC_MULTILINE )
|
||||
tabStyle |= TCS_MULTILINE;
|
||||
if ( m_windowStyle & wxBORDER )
|
||||
tabStyle &= WS_BORDER;
|
||||
if (m_windowStyle & wxNB_FIXEDWIDTH)
|
||||
tabStyle |= TCS_FIXEDWIDTH ;
|
||||
if (m_windowStyle & wxNB_BOTTOM)
|
||||
tabStyle |= TCS_RIGHT;
|
||||
if (m_windowStyle & wxNB_LEFT)
|
||||
tabStyle |= TCS_VERTICAL;
|
||||
if (m_windowStyle & wxNB_RIGHT)
|
||||
tabStyle |= TCS_VERTICAL|TCS_RIGHT;
|
||||
|
||||
|
||||
if ( !MSWCreate(GetId(), GetParent(), WC_TABCONTROL,
|
||||
this, NULL, pos.x, pos.y, size.x, size.y,
|
||||
tabStyle, NULL, 0) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Not all compilers recognise SetWindowFont
|
||||
::SendMessage(GetHwnd(), WM_SETFONT,
|
||||
(WPARAM)::GetStockObject(DEFAULT_GUI_FONT), TRUE);
|
||||
|
||||
|
||||
if ( parent != NULL )
|
||||
parent->AddChild(this);
|
||||
*/
|
||||
SubclassWin(m_hWnd);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -129,7 +182,7 @@ int wxNotebook::GetRowCount() const
|
||||
|
||||
int wxNotebook::SetSelection(int nPage)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
|
||||
|
||||
ChangePage(m_nSelection, nPage);
|
||||
|
||||
@@ -149,7 +202,7 @@ void wxNotebook::AdvanceSelection(bool bForward)
|
||||
|
||||
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
@@ -157,7 +210,7 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
||||
|
||||
wxString wxNotebook::GetPageText(int nPage) const
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
|
||||
|
||||
// TODO
|
||||
return wxString("");
|
||||
@@ -165,7 +218,7 @@ wxString wxNotebook::GetPageText(int nPage) const
|
||||
|
||||
int wxNotebook::GetPageImage(int nPage) const
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
|
||||
|
||||
// TODO
|
||||
return 0;
|
||||
@@ -173,7 +226,7 @@ int wxNotebook::GetPageImage(int nPage) const
|
||||
|
||||
bool wxNotebook::SetPageImage(int nPage, int nImage)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
@@ -185,6 +238,11 @@ void wxNotebook::SetImageList(wxImageList* imageList)
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxNotebook::SetTabSize(const wxSize& sz)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNotebook operations
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -192,7 +250,7 @@ void wxNotebook::SetImageList(wxImageList* imageList)
|
||||
// remove one page from the notebook
|
||||
bool wxNotebook::DeletePage(int nPage)
|
||||
{
|
||||
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
|
||||
|
||||
// TODO: delete native widget page
|
||||
|
||||
@@ -205,7 +263,7 @@ bool wxNotebook::DeletePage(int nPage)
|
||||
// remove one page from the notebook, without deleting the window
|
||||
bool wxNotebook::RemovePage(int nPage)
|
||||
{
|
||||
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
|
||||
|
||||
m_aPages.Remove(nPage);
|
||||
|
||||
@@ -303,8 +361,21 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
|
||||
{
|
||||
// is it our tab control?
|
||||
if ( event.GetEventObject() == this )
|
||||
ChangePage(event.GetOldSelection(), event.GetSelection());
|
||||
|
||||
{
|
||||
int sel = event.GetOldSelection();
|
||||
if ( sel != -1 )
|
||||
m_aPages[sel]->Show(FALSE);
|
||||
|
||||
sel = event.GetSelection();
|
||||
if ( sel != -1 )
|
||||
{
|
||||
wxNotebookPage *pPage = m_aPages[sel];
|
||||
pPage->Show(TRUE);
|
||||
pPage->SetFocus();
|
||||
}
|
||||
|
||||
m_nSelection = sel;
|
||||
}
|
||||
// we want to give others a chance to process this message as well
|
||||
event.Skip();
|
||||
}
|
||||
@@ -350,9 +421,33 @@ bool wxNotebook::DoPhase(int /* nPhase */)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxNotebook::Command(wxCommandEvent& event)
|
||||
bool wxNotebook::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
|
||||
{
|
||||
wxFAIL_MSG("wxNotebook::Command not implemented");
|
||||
wxNotebookEvent event(wxEVT_NULL, m_windowId);
|
||||
//TODO:
|
||||
/*
|
||||
NMHDR* hdr = (NMHDR *)lParam;
|
||||
switch ( hdr->code ) {
|
||||
case TCN_SELCHANGE:
|
||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
||||
break;
|
||||
|
||||
case TCN_SELCHANGING:
|
||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING);
|
||||
break;
|
||||
|
||||
default:
|
||||
return wxControl::MSWOnNotify(idCtrl, lParam, result);
|
||||
}
|
||||
*/
|
||||
event.SetSelection(TabCtrl_GetCurSel(m_hwnd));
|
||||
event.SetOldSelection(m_nSelection);
|
||||
event.SetEventObject(this);
|
||||
event.SetInt(idCtrl);
|
||||
|
||||
bool processed = GetEventHandler()->ProcessEvent(event);
|
||||
*result = !event.IsAllowed();
|
||||
return processed;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -362,21 +457,35 @@ void wxNotebook::Command(wxCommandEvent& event)
|
||||
// hide the currently active panel and show the new one
|
||||
void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
{
|
||||
wxASSERT( nOldSel != nSel ); // impossible
|
||||
// MT-FIXME should use a real semaphore
|
||||
static bool s_bInsideChangePage = FALSE;
|
||||
|
||||
if ( nOldSel != -1 ) {
|
||||
m_aPages[nOldSel]->Show(FALSE);
|
||||
// when we call ProcessEvent(), our own OnSelChange() is called which calls
|
||||
// this function - break the infinite loop
|
||||
if ( s_bInsideChangePage )
|
||||
return;
|
||||
|
||||
// it's not an error (the message may be generated by the tab control itself)
|
||||
// and it may happen - just do nothing
|
||||
if ( nSel == nOldSel )
|
||||
return;
|
||||
|
||||
s_bInsideChangePage = TRUE;
|
||||
|
||||
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
|
||||
event.SetSelection(nSel);
|
||||
event.SetOldSelection(nOldSel);
|
||||
event.SetEventObject(this);
|
||||
if ( ProcessEvent(event) && !event.IsAllowed() )
|
||||
{
|
||||
// program doesn't allow the page change
|
||||
s_bInsideChangePage = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
wxNotebookPage *pPage = m_aPages[nSel];
|
||||
pPage->Show(TRUE);
|
||||
pPage->SetFocus();
|
||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
||||
ProcessEvent(event);
|
||||
|
||||
m_nSelection = nSel;
|
||||
}
|
||||
|
||||
void wxNotebook::SetTabSize(const wxSize& sz)
|
||||
{
|
||||
// TODO
|
||||
s_bInsideChangePage = FALSE;
|
||||
}
|
||||
|
||||
|
@@ -9,16 +9,22 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "palette.h"
|
||||
#endif
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/palette.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
||||
#endif
|
||||
|
||||
#define INCL_PM
|
||||
#define INCL_GPI
|
||||
#include <os2.h>
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
|
||||
/*
|
||||
* Palette
|
||||
*
|
||||
@@ -26,12 +32,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
|
||||
|
||||
wxPaletteRefData::wxPaletteRefData()
|
||||
{
|
||||
// TODO
|
||||
m_hPalette = 0;
|
||||
}
|
||||
|
||||
wxPaletteRefData::~wxPaletteRefData()
|
||||
{
|
||||
// TODO
|
||||
if ( m_hPalette )
|
||||
return;
|
||||
// TODO: ::DeleteObject((HPALETTE) m_hPalette);
|
||||
}
|
||||
|
||||
wxPalette::wxPalette()
|
||||
@@ -47,6 +55,15 @@ wxPalette::~wxPalette()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxPalette::FreeResource(bool force)
|
||||
{
|
||||
if ( M_PALETTEDATA && M_PALETTEDATA->m_hPalette)
|
||||
{
|
||||
// TODO: DeleteObject((HPALETTE)M_PALETTEDATA->m_hPalette);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
|
||||
{
|
||||
UnRef();
|
||||
@@ -54,8 +71,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
// TODO
|
||||
/*
|
||||
NPLOGPALETTE npPal = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
|
||||
(WORD)n * sizeof(PALETTEENTRY));
|
||||
if (!npPal)
|
||||
return(FALSE);
|
||||
|
||||
return FALSE;
|
||||
npPal->palVersion = 0x300;
|
||||
npPal->palNumEntries = n;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < n; i ++)
|
||||
{
|
||||
npPal->palPalEntry[i].peRed = red[i];
|
||||
npPal->palPalEntry[i].peGreen = green[i];
|
||||
npPal->palPalEntry[i].peBlue = blue[i];
|
||||
npPal->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
M_PALETTEDATA->m_hPalette = (WXHPALETTE) CreatePalette((LPLOGPALETTE)npPal);
|
||||
LocalFree((HANDLE)npPal);
|
||||
*/
|
||||
}
|
||||
|
||||
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
|
||||
@@ -74,9 +109,27 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
|
||||
|
||||
if (index < 0 || index > 255)
|
||||
return FALSE;
|
||||
// TODO
|
||||
/*
|
||||
PALETTEENTRY entry;
|
||||
if (::GetPaletteEntries((HPALETTE) M_PALETTEDATA->m_hPalette, index, 1, &entry))
|
||||
{
|
||||
*red = entry.peRed;
|
||||
*green = entry.peGreen;
|
||||
*blue = entry.peBlue;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
void wxPalette::SetHPALETTE(WXHPALETTE pal)
|
||||
{
|
||||
if ( !m_refData )
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
M_PALETTEDATA->m_hPalette = pal;
|
||||
}
|
||||
|
||||
|
||||
|
129
src/os2/pen.cpp
129
src/os2/pen.cpp
@@ -1,26 +1,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: pen.cpp
|
||||
// Purpose: wxPen
|
||||
// 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 "pen.h"
|
||||
#endif
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/pen.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
||||
#endif
|
||||
|
||||
#include "wx/os2/private.h"
|
||||
#include "assert.h"
|
||||
|
||||
wxPenRefData::wxPenRefData()
|
||||
{
|
||||
m_style = wxSOLID;
|
||||
@@ -29,9 +32,7 @@ wxPenRefData::wxPenRefData()
|
||||
m_cap = wxCAP_ROUND ;
|
||||
m_nbDash = 0 ;
|
||||
m_dash = 0 ;
|
||||
/* TODO: null data
|
||||
m_hPen = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
wxPenRefData::wxPenRefData(const wxPenRefData& data)
|
||||
@@ -73,13 +74,22 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
|
||||
m_refData = new wxPenRefData;
|
||||
|
||||
M_PENDATA->m_colour = col;
|
||||
// M_PENDATA->m_stipple = NULL;
|
||||
M_PENDATA->m_width = Width;
|
||||
M_PENDATA->m_style = Style;
|
||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
M_PENDATA->m_hPen = 0 ;
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
|
||||
(Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
|
||||
(Style == wxUSER_DASH))
|
||||
M_PENDATA->m_width = 1;
|
||||
*/
|
||||
RealizeResource();
|
||||
|
||||
if ( wxThePenList )
|
||||
@@ -97,6 +107,7 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
|
||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
M_PENDATA->m_hPen = 0 ;
|
||||
|
||||
RealizeResource();
|
||||
|
||||
@@ -104,19 +115,44 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
|
||||
wxThePenList->AddPen(this);
|
||||
}
|
||||
|
||||
bool wxPen::RealizeResource()
|
||||
{
|
||||
// TODO: create actual pen
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WXHANDLE wxPen::GetResourceHandle()
|
||||
{
|
||||
if ( !M_PENDATA )
|
||||
return 0;
|
||||
else
|
||||
return (WXHANDLE)M_PENDATA->m_hPen;
|
||||
}
|
||||
|
||||
bool wxPen::FreeResource(bool force)
|
||||
{
|
||||
if (M_PENDATA && (M_PENDATA->m_hPen != 0))
|
||||
{
|
||||
DeleteObject((HPEN) M_PENDATA->m_hPen);
|
||||
M_PENDATA->m_hPen = 0;
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
void wxPen::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxPenRefData();
|
||||
}
|
||||
m_refData = new wxPenRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxPen::SetColour(const wxColour& col)
|
||||
@@ -193,10 +229,57 @@ void wxPen::SetCap(int Cap)
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
bool wxPen::RealizeResource()
|
||||
void wxPen::SetCap(int Cap)
|
||||
{
|
||||
// TODO: create actual pen
|
||||
return FALSE;
|
||||
Unshare();
|
||||
|
||||
M_PENDATA->m_cap = Cap;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
int wx2os2PenStyle(int wx_style)
|
||||
{
|
||||
int cstyle;
|
||||
// TODO:
|
||||
/*
|
||||
switch (wx_style)
|
||||
{
|
||||
case wxDOT:
|
||||
cstyle = PS_DOT;
|
||||
break;
|
||||
|
||||
case wxDOT_DASH:
|
||||
cstyle = PS_DASHDOT;
|
||||
break;
|
||||
|
||||
case wxSHORT_DASH:
|
||||
case wxLONG_DASH:
|
||||
cstyle = PS_DASH;
|
||||
break;
|
||||
|
||||
case wxTRANSPARENT:
|
||||
cstyle = PS_NULL;
|
||||
break;
|
||||
|
||||
case wxUSER_DASH:
|
||||
#ifdef __WIN32__
|
||||
// Win32s doesn't have PS_USERSTYLE
|
||||
if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
|
||||
cstyle = PS_USERSTYLE;
|
||||
else
|
||||
cstyle = PS_DOT; // We must make a choice... This is mine!
|
||||
#else
|
||||
cstyle = PS_DASH;
|
||||
#endif
|
||||
break;
|
||||
case wxSOLID:
|
||||
default:
|
||||
cstyle = PS_SOLID;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
return cstyle;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -9,12 +9,20 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "print.h"
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/stubs/print.h"
|
||||
#include "wx/stubs/printdlg.h"
|
||||
|
||||
#include "wx/os2/print.h"
|
||||
#include "wx/print.h"
|
||||
#include "wx/generic/printdlg.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase)
|
||||
|
@@ -1,38 +1,149 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: radiobox.cpp
|
||||
// Purpose: wxRadioBox
|
||||
// Author: AUTHOR
|
||||
// Author: David Webster
|
||||
// Modified by:
|
||||
// Created: ??/??/98
|
||||
// Created: 10/12/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) AUTHOR
|
||||
// Licence: wxWindows licence
|
||||
// Copyright: (c) David Webster
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "radiobox.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/bitmap.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/radiobox.h"
|
||||
#endif
|
||||
|
||||
#include "wx/radiobox.h"
|
||||
#include "wx/os2/private.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// private functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// wnd proc for radio buttons
|
||||
MRESULT _EXPORT wxRadioBtnWndProc(HWND hWnd,
|
||||
UINT message,
|
||||
MPARAM wParam,
|
||||
MPARAM lParam);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global vars
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// the pointer to standard radio button wnd proc
|
||||
static s_wndprocRadioBtn = NULL;
|
||||
|
||||
// ===========================================================================
|
||||
// implementation
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxRadioBox
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
int wxRadioBox::GetNumVer() const
|
||||
{
|
||||
if ( m_windowStyle & wxRA_SPECIFY_ROWS )
|
||||
{
|
||||
return m_majorDim;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (m_noItems + m_majorDim - 1)/m_majorDim;
|
||||
}
|
||||
}
|
||||
|
||||
int wxRadioBox::GetNumHor() const
|
||||
{
|
||||
if ( m_windowStyle & wxRA_SPECIFY_ROWS )
|
||||
{
|
||||
return (m_noItems + m_majorDim - 1)/m_majorDim;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_majorDim;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxRadioBox::OS2Command(WXUINT cmd, WXWORD id)
|
||||
{
|
||||
// TODO:
|
||||
/*
|
||||
if ( cmd == BN_CLICKED )
|
||||
{
|
||||
int selectedButton = -1;
|
||||
|
||||
for ( int i = 0; i < m_noItems; i++ )
|
||||
{
|
||||
if ( id == wxGetWindowId(m_radioButtons[i]) )
|
||||
{
|
||||
selectedButton = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wxASSERT_MSG( selectedButton != -1, wxT("click from alien button?") );
|
||||
|
||||
if ( selectedButton != m_selectedButton )
|
||||
{
|
||||
m_selectedButton = selectedButton;
|
||||
|
||||
SendNotificationEvent();
|
||||
}
|
||||
//else: don't generate events when the selection doesn't change
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
|
||||
int x, int y, int width, int height,
|
||||
int n, char **choices,
|
||||
int majorDim, long style, const char *name)
|
||||
{
|
||||
wxString *choices2 = new wxString[n];
|
||||
for ( int i = 0; i < n; i ++) choices2[i] = choices[i];
|
||||
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), n, choices2, majorDim, style,
|
||||
wxDefaultValidator, name);
|
||||
Callback(func);
|
||||
delete choices2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Radio box item
|
||||
wxRadioBox::wxRadioBox()
|
||||
{
|
||||
m_selectedButton = -1;
|
||||
m_noItems = 0;
|
||||
m_noRowsOrCols = 0;
|
||||
m_majorDim = 0 ;
|
||||
m_radioButtons = NULL;
|
||||
m_majorDim = 0;
|
||||
m_radioWidth = NULL;
|
||||
m_radioHeight = NULL;
|
||||
}
|
||||
|
||||
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
int majorDim, long style,
|
||||
const wxValidator& val, const wxString& name)
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
int majorDim, long style,
|
||||
const wxValidator& val, const wxString& name)
|
||||
{
|
||||
m_selectedButton = -1;
|
||||
m_noItems = n;
|
||||
@@ -41,56 +152,181 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
SetValidator(val);
|
||||
|
||||
parent->AddChild(this);
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
m_windowStyle = (long&)style;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
if (id == -1)
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
if ( majorDim == 0 )
|
||||
m_majorDim = n;
|
||||
else
|
||||
m_majorDim = majorDim;
|
||||
m_noRowsOrCols = majorDim;
|
||||
|
||||
if (majorDim==0)
|
||||
m_majorDim = n ;
|
||||
else
|
||||
m_majorDim = majorDim ;
|
||||
long msStyle = GROUP_FLAGS;
|
||||
|
||||
bool want3D;
|
||||
WXDWORD exStyle = Determine3DEffects(0, &want3D);
|
||||
|
||||
// TODO create radiobox
|
||||
return FALSE;
|
||||
HWND hwndParent = (HWND)parent->GetHWND();
|
||||
/*
|
||||
m_hWnd = (WXHWND)::CreateWindowEx
|
||||
(
|
||||
(DWORD)exStyle,
|
||||
GROUP_CLASS,
|
||||
title,
|
||||
msStyle,
|
||||
0, 0, 0, 0,
|
||||
hwndParent,
|
||||
(HMENU)m_windowId,
|
||||
wxGetInstance(),
|
||||
NULL
|
||||
);
|
||||
|
||||
#if wxUSE_CTL3D
|
||||
if (want3D)
|
||||
{
|
||||
Ctl3dSubclassCtl((HWND)m_hWnd);
|
||||
m_useCtl3D = TRUE;
|
||||
}
|
||||
#endif // wxUSE_CTL3D
|
||||
*/
|
||||
SetFont(parent->GetFont());
|
||||
|
||||
SubclassWin(m_hWnd);
|
||||
|
||||
// Some radio boxes test consecutive id.
|
||||
(void)NewControlId();
|
||||
m_radioButtons = new WXHWND[n];
|
||||
m_radioWidth = new int[n];
|
||||
m_radioHeight = new int[n];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// TODO:
|
||||
/*
|
||||
m_radioWidth[i] = m_radioHeight[i] = -1;
|
||||
long groupStyle = 0;
|
||||
if ( i == 0 && style == 0 )
|
||||
groupStyle = WS_GROUP;
|
||||
long newId = NewControlId();
|
||||
long msStyle = groupStyle | RADIO_FLAGS;
|
||||
|
||||
HWND hwndBtn = CreateWindowEx(exStyle, RADIO_CLASS,
|
||||
choices[i], msStyle,
|
||||
0,0,0,0,
|
||||
hwndParent,
|
||||
(HMENU)newId, wxGetInstance(),
|
||||
NULL);
|
||||
|
||||
m_radioButtons[i] = (WXHWND)hwndBtn;
|
||||
|
||||
SubclassRadioButton((WXHWND)hwndBtn);
|
||||
|
||||
wxFont& font = GetFont();
|
||||
if ( font.Ok() )
|
||||
{
|
||||
SendMessage(hwndBtn, WM_SETFONT,
|
||||
(WPARAM)font.GetResourceHandle(), 0L);
|
||||
}
|
||||
|
||||
m_subControls.Append((wxObject *)(WXDWORD)(WXWORD)newId);
|
||||
*/
|
||||
}
|
||||
|
||||
// Create a dummy radio control to end the group.
|
||||
(void)CreateWindowEx(0, RADIO_CLASS, wxT(""), WS_GROUP | RADIO_FLAGS,
|
||||
0, 0, 0, 0, hwndParent,
|
||||
(HMENU)NewControlId(), wxGetInstance(), NULL);
|
||||
|
||||
SetSelection(0);
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
wxRadioBox::~wxRadioBox()
|
||||
{
|
||||
// TODO
|
||||
m_isBeingDeleted = TRUE;
|
||||
|
||||
if (m_radioButtons)
|
||||
{
|
||||
int i;
|
||||
// TODO:
|
||||
/*
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
::DestroyWindow((HWND)m_radioButtons[i]);
|
||||
delete[] m_radioButtons;
|
||||
*/
|
||||
}
|
||||
|
||||
if (m_radioWidth)
|
||||
delete[] m_radioWidth;
|
||||
if (m_radioHeight)
|
||||
delete[] m_radioHeight;
|
||||
|
||||
}
|
||||
|
||||
wxString wxRadioBox::GetLabel(int item) const
|
||||
{
|
||||
// TODO
|
||||
return wxString("");
|
||||
wxCHECK_MSG( item >= 0 && item < m_noItems, wxT(""), wxT("invalid radiobox index") );
|
||||
|
||||
return wxGetWindowText(m_radioButtons[item]);
|
||||
}
|
||||
|
||||
void wxRadioBox::SetLabel(int item, const wxString& label)
|
||||
{
|
||||
// TODO
|
||||
wxCHECK_RET( item >= 0 && item < m_noItems, wxT("invalid radiobox index") );
|
||||
|
||||
m_radioWidth[item] = m_radioHeight[item] = -1;
|
||||
// TODO: SetWindowText((HWND)m_radioButtons[item], label.c_str());
|
||||
}
|
||||
|
||||
void wxRadioBox::SetLabel(int item, wxBitmap *bitmap)
|
||||
{
|
||||
/*
|
||||
m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN;
|
||||
m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN;
|
||||
*/
|
||||
wxFAIL_MSG(wxT("not implemented"));
|
||||
}
|
||||
|
||||
int wxRadioBox::FindString(const wxString& s) const
|
||||
{
|
||||
// TODO
|
||||
return -1;
|
||||
for (int i = 0; i < m_noItems; i++)
|
||||
{
|
||||
if ( s == wxGetWindowText(m_radioButtons[i]) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return wxNOT_FOUND;
|
||||
}
|
||||
|
||||
void wxRadioBox::SetSelection(int n)
|
||||
void wxRadioBox::SetSelection(int N)
|
||||
{
|
||||
if ((n < 0) || (n >= m_noItems))
|
||||
return;
|
||||
// TODO
|
||||
wxCHECK_RET( (N >= 0) && (N < m_noItems), wxT("invalid radiobox index") );
|
||||
|
||||
m_selectedButton = n;
|
||||
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
|
||||
// TODO:
|
||||
/*
|
||||
if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
|
||||
::SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
|
||||
|
||||
::SendMessage((HWND)m_radioButtons[N], BM_SETCHECK, 1, 0L);
|
||||
::SetFocus((HWND)m_radioButtons[N]);
|
||||
*/
|
||||
m_selectedButton = N;
|
||||
}
|
||||
|
||||
// Get single selection, for single choice list items
|
||||
@@ -100,80 +336,309 @@ int wxRadioBox::GetSelection() const
|
||||
}
|
||||
|
||||
// Find string for position
|
||||
wxString wxRadioBox::GetString(int n) const
|
||||
wxString wxRadioBox::GetString(int N) const
|
||||
{
|
||||
// TODO
|
||||
return wxString("");
|
||||
return wxGetWindowText(m_radioButtons[N]);
|
||||
}
|
||||
|
||||
void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
// Restored old code.
|
||||
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
// TODO
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int widthOld, heightOld;
|
||||
GetSize(&widthOld, &heightOld);
|
||||
|
||||
int xx = x;
|
||||
int yy = y;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
xx = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
yy = currentY;
|
||||
|
||||
wxString buf;
|
||||
|
||||
int y_offset = yy;
|
||||
int x_offset = xx;
|
||||
int current_width, cyf;
|
||||
|
||||
int cx1,cy1;
|
||||
wxGetCharSize(m_hWnd, &cx1, &cy1, & GetFont());
|
||||
|
||||
// Attempt to have a look coherent with other platforms: We compute the
|
||||
// biggest toggle dim, then we align all items according this value.
|
||||
int maxWidth = -1;
|
||||
int maxHeight = -1;
|
||||
|
||||
int i;
|
||||
for (i = 0 ; i < m_noItems; i++)
|
||||
{
|
||||
int eachWidth;
|
||||
int eachHeight;
|
||||
if (m_radioWidth[i]<0)
|
||||
{
|
||||
// It's a labelled toggle
|
||||
buf = wxGetWindowText(m_radioButtons[i]);
|
||||
GetTextExtent(buf, ¤t_width, &cyf);
|
||||
eachWidth = (int)(current_width + RADIO_SIZE);
|
||||
eachHeight = (int)((3*cyf)/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
eachWidth = m_radioWidth[i];
|
||||
eachHeight = m_radioHeight[i];
|
||||
}
|
||||
|
||||
if (maxWidth<eachWidth)
|
||||
maxWidth = eachWidth;
|
||||
if (maxHeight<eachHeight)
|
||||
maxHeight = eachHeight;
|
||||
}
|
||||
|
||||
if (m_hWnd)
|
||||
{
|
||||
int totWidth;
|
||||
int totHeight;
|
||||
|
||||
int nbHor = GetNumHor(),
|
||||
nbVer = GetNumVer();
|
||||
|
||||
// this formula works, but I don't know why.
|
||||
// Please, be sure what you do if you modify it!!
|
||||
if (m_radioWidth[0]<0)
|
||||
totHeight = (nbVer * maxHeight) + cy1/2;
|
||||
else
|
||||
totHeight = nbVer * (maxHeight+cy1/2);
|
||||
totWidth = nbHor * (maxWidth+cx1);
|
||||
|
||||
int extraHeight = cy1;
|
||||
|
||||
// only change our width/height if asked for
|
||||
if ( width == -1 )
|
||||
{
|
||||
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
|
||||
width = totWidth + cx1;
|
||||
else
|
||||
width = widthOld;
|
||||
}
|
||||
|
||||
if ( height == -1 )
|
||||
{
|
||||
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
|
||||
height = totHeight + extraHeight;
|
||||
else
|
||||
height = heightOld;
|
||||
}
|
||||
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset, width, height, TRUE);
|
||||
|
||||
x_offset += cx1;
|
||||
y_offset += cy1;
|
||||
}
|
||||
|
||||
int startX = x_offset;
|
||||
int startY = y_offset;
|
||||
|
||||
for ( i = 0 ; i < m_noItems; i++)
|
||||
{
|
||||
// Bidimensional radio adjustment
|
||||
if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
|
||||
{
|
||||
if (m_windowStyle & wxRA_VERTICAL)
|
||||
{
|
||||
y_offset = startY;
|
||||
x_offset += maxWidth + cx1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_offset = startX;
|
||||
y_offset += maxHeight;
|
||||
if (m_radioWidth[0]>0)
|
||||
y_offset += cy1/2;
|
||||
}
|
||||
}
|
||||
int eachWidth;
|
||||
int eachHeight;
|
||||
if (m_radioWidth[i]<0)
|
||||
{
|
||||
// It's a labeled item
|
||||
buf = wxGetWindowText(m_radioButtons[i]);
|
||||
GetTextExtent(buf, ¤t_width, &cyf);
|
||||
|
||||
// How do we find out radio button bitmap size!!
|
||||
// By adjusting them carefully, manually :-)
|
||||
eachWidth = (int)(current_width + RADIO_SIZE);
|
||||
eachHeight = (int)((3*cyf)/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
eachWidth = m_radioWidth[i];
|
||||
eachHeight = m_radioHeight[i];
|
||||
}
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
MoveWindow((HWND)m_radioButtons[i], x_offset, y_offset,
|
||||
eachWidth, eachHeight,
|
||||
TRUE);
|
||||
*/
|
||||
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
||||
{
|
||||
y_offset += maxHeight;
|
||||
if (m_radioWidth[0]>0)
|
||||
y_offset += cy1/2;
|
||||
}
|
||||
else
|
||||
x_offset += maxWidth + cx1;
|
||||
}
|
||||
}
|
||||
|
||||
void wxRadioBox::GetSize(int *width, int *height) const
|
||||
{
|
||||
// TODO
|
||||
RECT rect;
|
||||
rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
|
||||
|
||||
if (m_hWnd)
|
||||
wxFindMaxSize(m_hWnd, &rect);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
wxFindMaxSize(m_radioButtons[i], &rect);
|
||||
|
||||
*width = rect.right - rect.left;
|
||||
*height = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
void wxRadioBox::GetPosition(int *x, int *y) const
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
wxWindow *parent = GetParent();
|
||||
RECT rect;
|
||||
rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
|
||||
|
||||
wxString wxRadioBox::GetLabel() const
|
||||
{
|
||||
// TODO
|
||||
return wxString("");
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
wxFindMaxSize(m_radioButtons[i], &rect);
|
||||
|
||||
void wxRadioBox::SetLabel(const wxString& label)
|
||||
{
|
||||
// TODO
|
||||
if (m_hWnd)
|
||||
wxFindMaxSize(m_hWnd, &rect);
|
||||
|
||||
// Since we now have the absolute screen coords,
|
||||
// if there's a parent we must subtract its top left corner
|
||||
POINT point;
|
||||
point.x = rect.left;
|
||||
point.y = rect.top;
|
||||
// TODO:
|
||||
/*
|
||||
if (parent)
|
||||
{
|
||||
::ScreenToClient((HWND) parent->GetHWND(), &point);
|
||||
}
|
||||
*/
|
||||
// We may be faking the client origin.
|
||||
// So a window that's really at (0, 30) may appear
|
||||
// (to wxWin apps) to be at (0, 0).
|
||||
if (GetParent())
|
||||
{
|
||||
wxPoint pt(GetParent()->GetClientAreaOrigin());
|
||||
point.x -= pt.x;
|
||||
point.y -= pt.y;
|
||||
}
|
||||
|
||||
*x = point.x;
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
void wxRadioBox::SetFocus()
|
||||
{
|
||||
// TODO
|
||||
// TODO:
|
||||
/*
|
||||
if (m_noItems > 0)
|
||||
{
|
||||
if (m_selectedButton == -1)
|
||||
::SetFocus((HWND) m_radioButtons[0]);
|
||||
else
|
||||
::SetFocus((HWND) m_radioButtons[m_selectedButton]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool wxRadioBox::Show(bool show)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
if ( !wxControl::Show(show) )
|
||||
return FALSE;
|
||||
|
||||
int nCmdShow = show ? SW_SHOW : SW_HIDE;
|
||||
for ( int i = 0; i < m_noItems; i++ )
|
||||
{
|
||||
// TODO: ::ShowWindow((HWND)m_radioButtons[i], nCmdShow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Enable a specific button
|
||||
void wxRadioBox::Enable(int item, bool enable)
|
||||
{
|
||||
// TODO
|
||||
wxCHECK_RET( item >= 0 && item < m_noItems,
|
||||
wxT("invalid item in wxRadioBox::Enable()") );
|
||||
|
||||
// TODO: ::EnableWindow((HWND) m_radioButtons[item], enable);
|
||||
}
|
||||
|
||||
// Enable all controls
|
||||
void wxRadioBox::Enable(bool enable)
|
||||
bool wxRadioBox::Enable(bool enable)
|
||||
{
|
||||
wxControl::Enable(enable);
|
||||
if ( !wxControl::Enable(enable) )
|
||||
return FALSE;
|
||||
|
||||
// TODO
|
||||
// TODO:
|
||||
/*
|
||||
for (int i = 0; i < m_noItems; i++)
|
||||
::EnableWindow((HWND) m_radioButtons[i], enable);
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Show a specific button
|
||||
void wxRadioBox::Show(int item, bool show)
|
||||
{
|
||||
// TODO
|
||||
wxCHECK_RET( item >= 0 && item < m_noItems,
|
||||
wxT("invalid item in wxRadioBox::Show()") );
|
||||
|
||||
// TODO: ::ShowWindow((HWND)m_radioButtons[item], show ? SW_SHOW : SW_HIDE);
|
||||
}
|
||||
|
||||
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
// TODO:
|
||||
/*
|
||||
if (GetParent()->GetTransparentBackground())
|
||||
SetBkMode((HDC) pDC, TRANSPARENT);
|
||||
else
|
||||
SetBkMode((HDC) pDC, OPAQUE);
|
||||
|
||||
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
|
||||
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
|
||||
*/
|
||||
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
|
||||
|
||||
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
|
||||
}
|
||||
|
||||
// For single selection items only
|
||||
wxString wxRadioBox::GetStringSelection () const
|
||||
wxString wxRadioBox::GetStringSelection() const
|
||||
{
|
||||
int sel = GetSelection ();
|
||||
wxString result;
|
||||
int sel = GetSelection();
|
||||
if (sel > -1)
|
||||
return this->GetString (sel);
|
||||
else
|
||||
return wxString("");
|
||||
result = GetString(sel);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool wxRadioBox::SetStringSelection (const wxString& s)
|
||||
bool wxRadioBox::SetStringSelection(const wxString& s)
|
||||
{
|
||||
int sel = FindString (s);
|
||||
if (sel > -1)
|
||||
@@ -185,10 +650,124 @@ bool wxRadioBox::SetStringSelection (const wxString& s)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < Number(); i++)
|
||||
{
|
||||
if (GetRadioButtons()[i] == hWnd)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxRadioBox::Command (wxCommandEvent & event)
|
||||
{
|
||||
SetSelection (event.m_commandInt);
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
|
||||
{
|
||||
HWND hwndBtn = (HWND)hWndBtn;
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
if ( !s_wndprocRadioBtn )
|
||||
s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC);
|
||||
|
||||
// No GWL_USERDATA in Win16, so omit this subclassing.
|
||||
::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
|
||||
::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
|
||||
*/
|
||||
}
|
||||
|
||||
void wxRadioBox::SendNotificationEvent()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
|
||||
event.SetInt( m_selectedButton );
|
||||
event.SetString( GetString(m_selectedButton) );
|
||||
event.SetEventObject( this );
|
||||
ProcessCommand(event);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// window proc for radio buttons
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
|
||||
UINT msg,
|
||||
MPARAM wParam,
|
||||
MPARAM lParam)
|
||||
{
|
||||
bool processed = TRUE;
|
||||
if ( msg != WM_KEYDOWN )
|
||||
processed = FALSE;
|
||||
|
||||
if ( processed )
|
||||
{
|
||||
wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA);
|
||||
|
||||
wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
|
||||
|
||||
int sel = radiobox->GetSelection();
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_UP:
|
||||
sel--;
|
||||
break;
|
||||
|
||||
case VK_LEFT:
|
||||
sel -= radiobox->GetNumVer();
|
||||
break;
|
||||
|
||||
case VK_DOWN:
|
||||
sel++;
|
||||
break;
|
||||
|
||||
case VK_RIGHT:
|
||||
sel += radiobox->GetNumVer();
|
||||
break;
|
||||
|
||||
case VK_TAB:
|
||||
{
|
||||
wxNavigationKeyEvent event;
|
||||
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
|
||||
event.SetWindowChange(FALSE);
|
||||
event.SetEventObject(radiobox);
|
||||
|
||||
if ( radiobox->GetEventHandler()->ProcessEvent(event) )
|
||||
return 0;
|
||||
}
|
||||
// fall through
|
||||
|
||||
default:
|
||||
processed = FALSE;
|
||||
}
|
||||
*/
|
||||
if ( processed )
|
||||
{
|
||||
if ( sel >= 0 && sel < radiobox->Number() )
|
||||
{
|
||||
radiobox->SetSelection(sel);
|
||||
|
||||
// emulate the button click
|
||||
radiobox->SendNotificationEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
if ( !processed )
|
||||
return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, msg, wParam, lParam);
|
||||
else
|
||||
return 0;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,26 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: radiobut.cpp
|
||||
// Purpose: wxRadioButton
|
||||
// Author: AUTHOR
|
||||
// Author: David Webster
|
||||
// Modified by:
|
||||
// Created: ??/??/98
|
||||
// Created: 10/12/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) AUTHOR
|
||||
// Licence: wxWindows licence
|
||||
// Copyright: (c) David Webster
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "radiobut.h"
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/radiobut.h"
|
||||
#include "wx/brush.h"
|
||||
#endif
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
||||
#endif
|
||||
|
||||
bool wxRadioButton::OS2Command(WXUINT param, WXWORD id)
|
||||
{
|
||||
if (param == BN_CLICKED)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId);
|
||||
event.SetEventObject( this );
|
||||
ProcessCommand(event);
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
@@ -31,15 +53,73 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
SetBackgroundColour(parent->GetBackgroundColour());
|
||||
SetForegroundColour(parent->GetForegroundColour());
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
m_windowId = id;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
m_windowStyle = style ;
|
||||
|
||||
// TODO create radiobutton
|
||||
return FALSE;
|
||||
// TODO create radiobutton
|
||||
/*
|
||||
long groupStyle = 0;
|
||||
if (m_windowStyle & wxRB_GROUP)
|
||||
groupStyle = WS_GROUP;
|
||||
|
||||
// long msStyle = groupStyle | RADIO_FLAGS;
|
||||
long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
|
||||
|
||||
bool want3D;
|
||||
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
|
||||
|
||||
m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
|
||||
msStyle,0,0,0,0,
|
||||
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
|
||||
|
||||
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
|
||||
|
||||
|
||||
SetFont(parent->GetFont());
|
||||
|
||||
// Subclass again for purposes of dialog editing mode
|
||||
SubclassWin((WXHWND)m_hWnd);
|
||||
|
||||
// SetValue(value);
|
||||
*/
|
||||
|
||||
// start GRW fix
|
||||
if (label != wxT(""))
|
||||
{
|
||||
int label_width, label_height;
|
||||
GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont());
|
||||
if (width < 0)
|
||||
width = (int)(label_width + RADIO_SIZE);
|
||||
if (height<0)
|
||||
{
|
||||
height = (int)(label_height);
|
||||
if (height < RADIO_SIZE)
|
||||
height = RADIO_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width < 0)
|
||||
width = RADIO_SIZE;
|
||||
if (height < 0)
|
||||
height = RADIO_SIZE;
|
||||
}
|
||||
// end GRW fix
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxRadioButton::SetLabel(const wxString& label)
|
||||
@@ -65,4 +145,69 @@ void wxRadioButton::Command (wxCommandEvent & event)
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxBitmap *bitmap,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
SetBackgroundColour(parent->GetBackgroundColour());
|
||||
SetForegroundColour(parent->GetForegroundColour());
|
||||
|
||||
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;
|
||||
m_windowStyle = style ;
|
||||
|
||||
long groupStyle = 0;
|
||||
if (m_windowStyle & wxRB_GROUP)
|
||||
groupStyle = WS_GROUP;
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
// long msStyle = groupStyle | RADIO_FLAGS;
|
||||
// long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
|
||||
|
||||
m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
|
||||
msStyle,0,0,0,0,
|
||||
(HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
|
||||
|
||||
wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
|
||||
|
||||
*/
|
||||
// Subclass again for purposes of dialog editing mode
|
||||
SubclassWin(GetHWND());
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
void wxBitmapRadioButton::SetValue(bool value)
|
||||
{
|
||||
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
|
||||
// SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
|
||||
}
|
||||
|
||||
// Get single selection, for single choice list items
|
||||
bool wxBitmapRadioButton::GetValue(void) const
|
||||
{
|
||||
// return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
2750
src/os2/window.cpp
2750
src/os2/window.cpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user