Dialogs and slider updates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2002-07-22 03:29:07 +00:00
parent f1ecc5db54
commit 70a2c6562f
9 changed files with 177 additions and 92 deletions

View File

@@ -303,6 +303,7 @@ wxBitmap::wxBitmap(
LoadFile( nId
,(int)lType
);
SetId(nId);
} // end of wxBitmap::wxBitmap
bool wxBitmap::Create(

View File

@@ -168,6 +168,8 @@ bool wxControl::OS2CreateControl(
// Controls use the same font and colours as their parent dialog by default
//
InheritAttributes();
SetXComp(0);
SetYComp(0);
if (nW == 0 || nH == 0)
SetBestSize(rSize);
return TRUE;

View File

@@ -1038,7 +1038,7 @@ void wxDC::DoDrawRectangle(
if(m_brush.GetStyle() == wxTRANSPARENT)
lControl = DRO_OUTLINE;
::GpiSetColor(m_hPS, lColor);
::GpiSetColor(m_hPS, lBorderColor);
::GpiBox( m_hPS // handle to a presentation space
,lControl // draw the box outline ? or ?
,&vPoint[1] // address of the corner

View File

@@ -421,8 +421,18 @@ bool wxListBox::IsSelected(
LONG lItem;
lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)N, (MPARAM)0));
return (lItem != LIT_NONE);
if (GetWindowStyleFlag() & wxLB_EXTENDED)
{
if (N == 0)
lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
else
lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)(N - 1), (MPARAM)0));
}
else
{
lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
}
return (lItem == (LONG)N && lItem != LIT_NONE);
} // end of wxListBox::IsSelected
wxClientData* wxListBox::DoGetItemClientObject(

View File

@@ -115,13 +115,58 @@ void wxSlider::AdjustSubControls(
,(LONG)nYOffset
,(LONG)nMaxLen
,(LONG)nCy
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
,SWP_ZORDER | SWP_SHOW
);
}
}
else
{
//
// Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
// Now deal with a vertical slider
//
if (m_lWindowStyle & winSL_LABELS )
{
int nMinLen = 0;
int nMaxLen = 0;
::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
GetTextExtent(zBuf, &lMinLen, &nCyf, NULL, NULL, &this->GetFont());
::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
GetTextExtent(zBuf, &lMaxLen, &nCyf, NULL, NULL, &this->GetFont());
if (m_hStaticValue)
{
int nNewWidth = (DAWUTL_MAX(nMinLen, nMaxLen));
::WinSetWindowPos( (HWND)m_hStaticValue
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset + nHeight + nCyf
,(LONG)nNewWidth
,(LONG)nCyf
,SWP_SIZE | SWP_MOVE
);
}
::WinSetWindowPos( (HWND)m_hStaticMax
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset + nHeight
,(LONG)nMaxLen
,(LONG)nCyf
,SWP_SIZE | SWP_MOVE
);
::WinSetWindowPos( (HWND)m_hStaticMin
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset - nCyf
,(LONG)nMinLen
,(LONG)nCyf
,SWP_SIZE | SWP_MOVE
);
}
}
} // end of wxSlider::AdjustSubControls
void wxSlider::ClearSel()
@@ -239,9 +284,9 @@ bool wxSlider::Create(
vSlData.cbSize = sizeof(SLDCDATA);
if (m_windowStyle & wxSL_VERTICAL)
lMsStyle = SLS_VERTICAL | WS_VISIBLE | WS_TABSTOP;
lMsStyle = SLS_VERTICAL | SLS_HOMEBOTTOM | WS_VISIBLE | WS_TABSTOP;
else
lMsStyle = SLS_HORIZONTAL | WS_VISIBLE | WS_TABSTOP;
lMsStyle = SLS_HORIZONTAL | SLS_HOMELEFT| WS_VISIBLE | WS_TABSTOP;
if (m_windowStyle & wxCLIP_SIBLINGS)
lMsStyle |= WS_CLIPSIBLINGS;
@@ -264,6 +309,7 @@ bool wxSlider::Create(
lMsStyle |= SLS_PRIMARYSCALE1 | SLS_PRIMARYSCALE2;
else
lMsStyle |= SLS_PRIMARYSCALE2;
lMsStyle |= SLS_RIBBONSTRIP;
m_nPageSize = ((nMaxValue - nMinValue)/10);
vSlData.usScale1Increments = m_nPageSize;
@@ -288,7 +334,7 @@ bool wxSlider::Create(
//
::WinSendMsg( hScrollBar
,SLM_SETTICKSIZE
,MPFROM2SHORT(SMA_SETALLTICKS, 6)
,MPFROM2SHORT(SMA_SETALLTICKS, (USHORT)12)
,NULL
);
//
@@ -304,12 +350,7 @@ bool wxSlider::Create(
SubclassWin(GetHWND());
::WinSetWindowText((HWND)m_hWnd, "");
wxFont* pTextFont = new wxFont( 10
,wxMODERN
,wxNORMAL
,wxNORMAL
);
SetFont(*pTextFont);
SetFont(*wxSMALL_FONT);
if (m_windowStyle & wxSL_LABELS)
{
//
@@ -412,6 +453,13 @@ bool wxSlider::Create(
,sizeof(LONG)
,(PVOID)&lColor
);
vColour.Set(wxString("BLUE"));
lColor = (LONG)vColour.GetPixel();
::WinSetPresParam( m_hWnd
,PP_HILITEBACKGROUNDCOLOR
,sizeof(LONG)
,(PVOID)&lColor
);
SetValue(nValue);
delete pTextFont;
return TRUE;
@@ -515,7 +563,7 @@ void wxSlider::DoSetSize(
::WinSetWindowPos( (HWND)m_hStaticMin
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset - nCyf
,(LONG)nYOffset - (nCyf * 1.2)
,(LONG)nMinLen
,(LONG)nCy
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -547,7 +595,7 @@ void wxSlider::DoSetSize(
::WinSetWindowPos( (HWND)m_hStaticMax
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset - nCyf
,(LONG)nYOffset - (nCyf * 1.2)
,(LONG)nMaxLen
,(LONG)nCy
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -606,27 +654,24 @@ void wxSlider::DoSetSize(
// The height needs to be a bit bigger under Win95 if using native
// 3D effects.
//
nValueHeight = (int)(nValueHeight * 1.5);
::WinSetWindowPos( (HWND)m_hStaticValue
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset
,(LONG)nYOffset + lHeight
,(LONG)nNewWidth
,(LONG)nValueHeight
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
);
nYOffset -= nValueHeight;
nUsedHeight += nValueHeight;
nUsedHeight += nCy;
}
::WinSetWindowPos( (HWND)m_hStaticMin
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset
,(LONG)nYOffset + lHeight -lCyf
,(LONG)nMinLen
,(LONG)nCy
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
);
nYOffset -= nCy;
nUsedHeight += nCy;
int nSliderLength = nHeight1 - (nUsedHeight + (2 * nCy));
@@ -641,7 +686,7 @@ void wxSlider::DoSetSize(
if (nSliderLength < 100)
nSliderLength = 100;
::WinSetWindowPos( (HWND)m_hStaticMin
::WinSetWindowPos( GetHwnd()
,HWND_TOP
,(LONG)nXOffset
,(LONG)nYOffset
@@ -649,7 +694,6 @@ void wxSlider::DoSetSize(
,(LONG)nSliderLength
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
);
nYOffset -= nSliderLength;
nUsedHeight += nSliderLength;
::WinSetWindowPos( (HWND)m_hStaticMax
,HWND_TOP

View File

@@ -337,8 +337,8 @@ int wxSpinCtrl::GetValue() const
,SPBQ_UPDATEIFVALID
)
);
lVal - atol(zVal);
return lVal;
lVal = atol(zVal);
return (int)lVal;
} // end of wxSpinCtrl::GetValue
void wxSpinCtrl::OnChar (

View File

@@ -32,6 +32,34 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
static wxGDIImage* ConvertImage(
const wxGDIImage& rBitmap
)
{
bool bIsIcon = rBitmap.IsKindOf( CLASSINFO(wxIcon) );
if(!bIsIcon )
{
wxASSERT_MSG( wxDynamicCast(&rBitmap, wxBitmap),
_T("not an icon and not a bitmap?") );
const wxBitmap& rBmp = (const wxBitmap&)rBitmap;
wxMask* pMask = rBmp.GetMask();
if (pMask && pMask->GetMaskBitmap())
{
wxIcon* pIcon = new wxIcon;
pIcon->CopyFromBitmap(rBmp);
return pIcon;
}
return new wxBitmap(rBmp);
}
// copying a bitmap is a cheap operation
return new wxIcon( (const wxIcon&)rBitmap );
} // end of ConvertImage
// ---------------------------------------------------------------------------
// wxStaticBitmap
// ---------------------------------------------------------------------------
@@ -46,15 +74,15 @@ bool wxStaticBitmap::Create(
, const wxString& rName
)
{
ERRORID vError;
wxString sError;
Init();
SetName(rName);
if (pParent)
pParent->AddChild(this);
m_backgroundColour = pParent->GetBackgroundColour() ;
m_foregroundColour = pParent->GetForegroundColour() ;
if (nId == -1)
m_windowId = (int)NewControlId();
else
@@ -66,16 +94,21 @@ bool wxStaticBitmap::Create(
int nY = rPos.y;
int nWidth = rSize.x;
int nHeight = rSize.y;
char zId[16];
m_windowStyle = lStyle;
m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
int nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP;
//
// For now we only support an ICON
//
int nWinstyle = SS_ICON;
sprintf(zId, "#%d", rBitmap.GetId());
m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND()
,WC_STATIC
,rName.c_str()
,zId
,nWinstyle | WS_VISIBLE
,0,0,0,0
,pParent->GetHWND()
@@ -84,17 +117,20 @@ bool wxStaticBitmap::Create(
,NULL
,NULL
);
if (!m_hWnd)
{
vError = ::WinGetLastError(wxGetInstance());
sError = wxPMErrorToStr(vError);
return FALSE;
}
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
SetImage(rBitmap);
m_pImage = ConvertImage(rBitmap);
m_pImage->SetHandle((WXHWND)::WinSendMsg(m_hWnd, SM_QUERYHANDLE, (MPARAM)0, (MPARAM)0));
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
SetFont(*wxSMALL_FONT);
SetSize(nX, nY, nWidth, nHeight);
return(FALSE);
}
return(TRUE);
} // end of wxStaticBitmap::Create
bool wxStaticBitmap::ImageIsOk() const
{
@@ -103,14 +139,17 @@ bool wxStaticBitmap::ImageIsOk() const
void wxStaticBitmap::Free()
{
if (m_pImage)
delete m_pImage;
m_pImage = NULL;
}
} // end of wxStaticBitmap::Free
wxSize wxStaticBitmap::DoGetBestSize() const
{
// reuse the current size (as wxWindow does) instead of using some
//
// Reuse the current size (as wxWindow does) instead of using some
// arbitrary default size (as wxControl, our immediate base class, does)
//
return wxWindow::DoGetBestSize();
}
@@ -118,54 +157,28 @@ void wxStaticBitmap::SetImage(
const wxGDIImage& rBitmap
)
{
int nX = 0;
int nY = 0;
int nWidth = 0;
int nHeight = 0;
Free();
m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
if (m_bIsIcon)
m_pImage = new wxIcon((const wxIcon&)rBitmap);
else
m_pImage = new wxBitmap((const wxBitmap &)rBitmap);
int nX;
int nY;
int nW;
int nH;
GetPosition(&nX, &nY);
GetSize(&nW, &nH);
::WinSendMsg( GetHwnd()
,SM_SETHANDLE
,MPFROMHWND(m_pImage->GetHandle())
,MPFROMHWND(rBitmap.GetHandle())
,NULL
);
if (ImageIsOk())
{
int nWidth = rBitmap.GetWidth();
int nHeight = rBitmap.GetHeight();
m_pImage = ConvertImage(rBitmap);
if (nWidth && nHeight)
{
nW = nWidth;
nW = nHeight;
::WinSetWindowPos( GetHwnd()
,HWND_TOP
,nX
,nY
,nWidth
,nHeight
,SWP_SIZE | SWP_MOVE | SWP_SHOW
);
}
}
GetPosition(&nX, &nY);
GetSize(&nWidth, &nHeight);
RECTL vRect;
vRect.xLeft = nW;
vRect.xLeft = nX;
vRect.yTop = nY;
vRect.xRight = nX + nW;
vRect.yBottom = nY + nH;
vRect.xRight = nX + nWidth;
vRect.yBottom = nY + nHeight;
::WinInvalidateRect(GetHwndOf(GetParent()), &vRect, TRUE);
}

View File

@@ -60,12 +60,26 @@ bool wxStaticLine::Create(
,rsName
))
return FALSE;
return OS2CreateControl( _T("STATIC")
,_T("")
if (!OS2CreateControl( "STATIC"
,SS_FGNDFRAME
,rPos
,vSize
,lStyle
,rSize
,rsName
))
return FALSE;
wxColour vColour;
vColour.Set(wxString("GREY"));
LONG lColor = (LONG)vColour.GetPixel();
::WinSetPresParam( m_hWnd
,PP_FOREGROUNDCOLOR
,sizeof(LONG)
,(PVOID)&lColor
);
return TRUE;
} // end of wxStaticLine::Create
WXDWORD wxStaticLine::OS2GetStyle(

View File

@@ -125,6 +125,7 @@ bool wxTextCtrl::Create(
}
m_windowStyle = lStyle;
m_bIsMLE = FALSE;
long lSstyle = WS_VISIBLE | WS_TABSTOP;
@@ -200,7 +201,7 @@ bool wxTextCtrl::Create(
//
// Set font, position, size and initial value
//
wxFont* pTextFont = new wxFont( 10
wxFont* pTextFont = new wxFont( 8
,wxMODERN
,wxNORMAL
,wxNORMAL
@@ -218,8 +219,8 @@ bool wxTextCtrl::Create(
::WinQueryWindowPos(m_hWnd, &vSwp);
SetXComp(vSwp.x);
SetYComp(vSwp.y);
SetSize( vPos.x
,vPos.y
SetSize( vPos.x - GetXComp()
,vPos.y - GetYComp()
,rSize.x
,rSize.y
);