pwlib.inl
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:31k
- /*
- * pwlib.inl
- *
- * GUI inline function implmentations.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: pwlib.inl,v $
- * Revision 1.39 2000/07/11 18:24:02 robertj
- * Fixed incorrect return value on PComboBox::GetCurrent() when no selection.
- *
- * Revision 1.38 2000/04/13 01:37:14 robertj
- * Added missing implementation of PEditBox::GetSelection() on Win32.
- * Added PEditBox::ReplaceSelection() function.
- *
- * Revision 1.37 2000/03/17 20:32:22 robertj
- * Fixed race conditions in mult-threaded windows (dialogs in particular)
- *
- * Revision 1.36 1999/11/13 14:18:50 robertj
- * Moved scrollBar nudge routines to platform dependent code
- *
- * Revision 1.35 1999/08/17 03:44:30 robertj
- * Fixed WIN32 version of function.
- *
- * Revision 1.34 1999/08/07 07:13:22 robertj
- * Fixed problems with "balloon help" text popup.
- *
- * Revision 1.33 1998/09/24 03:41:37 robertj
- * Added open software license.
- *
- * Revision 1.32 1998/09/21 13:30:57 robertj
- * Changes to support new PListView class. Different call back method.
- *
- * Revision 1.31 1998/03/20 03:13:44 robertj
- * Added function to get physical bounds of canvas. Allows to scale drawing.
- *
- * Revision 1.30 1998/02/06 04:00:17 robertj
- * Fixed colour of controls, again!
- *
- * Revision 1.29 1996/11/04 03:33:14 robertj
- * Fixed bug in background colour of dialogs.
- *
- * Revision 1.28 1996/06/03 09:58:05 robertj
- * Added PInteractor FromScreen/ToScreen for individual ordinates.
- *
- * Revision 1.27 1996/02/15 14:51:57 robertj
- * Fixed bug in choice box get text, could crash heap.
- *
- * Revision 1.26 1996/01/28 03:04:16 robertj
- * Added assert into all Compare functions to assure comparison between compatible objects.
- *
- * Revision 1.25 1996/01/02 12:59:18 robertj
- * Added find interactor function.
- *
- * Revision 1.24 1995/11/09 12:36:23 robertj
- * Fixed bug in control colours.
- *
- * Revision 1.23 1995/10/14 15:16:41 robertj
- * Changed SetChoice to SetSelection for consistencies sake.
- * Added function for getting ssytem colour.
- *
- * Revision 1.22 1995/06/04 12:50:54 robertj
- * Added Add component functions.
- * Added common constructor - Unix implementation requirement.
- *
- * Revision 1.21 1995/04/25 11:41:32 robertj
- * Fixed Borland compiler warnings.
- *
- * Revision 1.20 1995/04/22 01:03:02 robertj
- * Added common construct function for multi-line edit box.
- *
- * Revision 1.19 1995/02/19 04:16:07 robertj
- * Moved PListBox::SetSelection to cxx file.
- * Added callback when PListBox::SetSelection changes selection.
- *
- * Revision 1.18 1995/01/28 07:28:47 robertj
- * Assured all Windows strings have n converted to rn and vice versa.
- *
- * Revision 1.17 1995/01/27 11:22:29 robertj
- * Underscored library variables.
- *
- * Revision 1.16 1995/01/22 07:29:48 robertj
- * Added font & colour standard dialogs.
- *
- * Revision 1.15 1995/01/21 05:19:33 robertj
- * Fixed parameters.
- *
- * Revision 1.14 1995/01/15 04:53:39 robertj
- * Moved function to interact.cxx
- *
- * Revision 1.13 1995/01/06 10:44:03 robertj
- * Changed PRealFont usage from pointer to reference.
- *
- * Revision 1.12 1995/01/03 09:41:59 robertj
- * Removed copy stuff for sub menus.
- *
- * Revision 1.11 1995/01/02 12:26:19 robertj
- * Added update flag to list box select.
- *
- * Revision 1.10 1994/12/21 11:58:26 robertj
- * Documentation and variable normalisation.
- *
- * Revision 1.9 1994/12/14 11:17:23 robertj
- * Changed PDIMENSION to be unsigned causing untold number of changes.
- *
- * Revision 1.8 1994/12/05 11:34:30 robertj
- * Major rewrite of images, pictures and pixmaps.
- * Renamed PPict, PPixels and PImage to make sure all uses are found.
- *
- * Revision 1.7 1994/10/30 11:43:27 robertj
- * Improved DC creation in RedrawCanvas.
- * Added functions to check for in clip region.
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.6 1994/10/23 05:51:04 robertj
- * Shortened OS error assert.
- * Changed windows message handling technique.
- *
- * Revision 1.5 1994/08/21 23:43:02 robertj
- * Moved some destructors from common.
- * Added delayed close of interactors to avoid the "delete this" problem.
- *
- * Revision 1.4 1994/07/27 05:58:07 robertj
- * Synchronisation.
- *
- * Revision 1.3 1994/07/17 10:46:06 robertj
- * Enhancements, bug fixes etc.
- *
- * Revision 1.2 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.1 1994/04/20 12:17:44 robertj
- * Initial revision
- */
- ///////////////////////////////////////////////////////////////////////////////
- // PDim
- PINLINE PDim PDim::FromDWORD(DWORD dw)
- { return PDim(LOWORD(dw), HIWORD(dw)); }
- PINLINE DWORD PDim::ToDWORD() const
- { return MAKELONG(width, height); }
- ///////////////////////////////////////////////////////////////////////////////
- // PPoint
- PINLINE PPoint::PPoint()
- { p.x = p.y = 0; }
- PINLINE PPoint::PPoint(PORDINATE nx, PORDINATE ny)
- { p.x = nx; p.y = ny; }
- PINLINE PPoint::PPoint(const PDim & pt)
- { p.x = pt.Width(); p.y = pt.Height(); }
- PINLINE PPoint::PPoint(const PPoint & pt)
- { p.x = pt.p.x; p.y = pt.p.y; }
- PINLINE PORDINATE PPoint::X() const
- { return (PORDINATE)p.x; }
- PINLINE PORDINATE PPoint::Y() const
- { return (PORDINATE)p.y; }
- PINLINE void PPoint::SetX(PORDINATE nx)
- { p.x = nx; }
- PINLINE void PPoint::SetY(PORDINATE ny)
- { p.y = ny; }
- PINLINE void PPoint::AddX(PORDINATE nx)
- { p.x += nx; }
- PINLINE void PPoint::AddY(PORDINATE ny)
- { p.y += ny; }
- PINLINE PPoint & PPoint::operator+=(const PPoint & pt)
- { p.x += pt.p.x; p.y += pt.p.y; return *this; }
- PINLINE PPoint & PPoint::operator+=(const PDim & dim)
- { p.x += dim.Width(); p.y += dim.Height(); return *this; }
- PINLINE PPoint & PPoint::operator-=(const PPoint & pt)
- { p.x -= pt.p.x; p.y -= pt.p.y; return *this; }
- PINLINE PPoint & PPoint::operator-=(const PDim & dim)
- { p.x -= dim.Width(); p.y -= dim.Height(); return *this; }
- PINLINE PPoint & PPoint::operator*=(const PPoint & pt)
- { p.x *= pt.p.x; p.y *= pt.p.y; return *this; }
- PINLINE PPoint & PPoint::operator*=(const PDim & dim)
- { p.x *= dim.Width(); p.y *= dim.Height(); return *this; }
- PINLINE PPoint & PPoint::operator*=(PORDINATE scale)
- { p.x *= scale; p.y *= scale; return *this; }
- PINLINE PPoint & PPoint::operator/=(const PPoint & pt)
- { p.x /= pt.p.x; p.y /= pt.p.y; return *this; }
- PINLINE PPoint & PPoint::operator/=(const PDim & dim)
- { p.x /= dim.Width(); p.y /= dim.Height(); return *this; }
- PINLINE PPoint & PPoint::operator/=(PORDINATE scale)
- { p.x /= scale; p.y /= scale; return *this; }
- PINLINE BOOL PPoint::InRect(const PRect & rect) const
- { return PtInRect(rect, p); }
- PINLINE DWORD PPoint::ToDWORD() const
- { return MAKELONG(p.x, p.y); }
- PINLINE PPoint::operator POINT() const
- { return p; }
- PINLINE PPoint::operator POINT*()
- { return &p; }
- PINLINE PPoint::operator const POINT*() const
- { return &p; }
- ///////////////////////////////////////////////////////////////////////////////
- // PRect
- PINLINE PRect::PRect(const RECT & rect)
- { CopyRect(&r, &rect); }
- PINLINE PORDINATE PRect::Left() const
- { return (PORDINATE)r.left; }
- PINLINE PORDINATE PRect::Right() const
- { return (PORDINATE)r.right; }
- PINLINE PORDINATE PRect::Top() const
- { return (PORDINATE)r.top; }
- PINLINE PORDINATE PRect::Bottom() const
- { return (PORDINATE)r.bottom; }
- PINLINE PORDINATE PRect::X() const
- { return (PORDINATE)r.left; }
- PINLINE PORDINATE PRect::Y() const
- { return (PORDINATE)r.top; }
- PINLINE PDIMENSION PRect::Width() const
- { return (PDIMENSION)(r.right - r.left); }
- PINLINE PDIMENSION PRect::Height() const
- { return (PDIMENSION)(r.bottom - r.top); }
- PINLINE void PRect::SetWidth(PDIMENSION dx)
- { r.right = r.left + dx; }
- PINLINE void PRect::SetHeight(PDIMENSION dy)
- { r.bottom = r.top + dy; }
- PINLINE BOOL PRect::ContainsPoint(const PPoint & pt) const
- { return PtInRect(&r, pt); }
- PINLINE BOOL PRect::IsEmpty() const
- { return IsRectEmpty(&r); }
- PINLINE void PRect::Inflate(PORDINATE dx, PORDINATE dy)
- { InflateRect(&r, (int)dx, (int)dy); }
- PINLINE void PRect::Offset(PORDINATE dx, PORDINATE dy)
- { OffsetRect(&r, (int)dx, (int)dy); }
- PINLINE PRect::operator RECT*()
- { return &r; }
- PINLINE PRect::operator const RECT*() const
- { return &r; }
- ///////////////////////////////////////////////////////////////////////////////
- // PRegion
- PINLINE PRegion::PRegion()
- { hRegion = CreateRectRgn(0, 0, 0, 0); }
- PINLINE PRegion::PRegion(HRGN hRgn)
- { hRegion = PAssertNULL(hRgn); }
- PINLINE PRegion::~PRegion()
- { DeleteObject(hRegion); }
- PINLINE HRGN PRegion::GetHRGN() const
- { return hRegion; }
- PINLINE BOOL PRegion::ContainsPoint(const PPoint & pt) const
- { return PtInRegion(hRegion, pt.X(), pt.Y()); }
- PINLINE BOOL PRegion::ContainsRect(const PRect & rect) const
- { return RectInRegion(hRegion, rect); }
- PINLINE void PRegion::Offset(PORDINATE dx, PORDINATE dy)
- { OffsetRgn(hRegion, dx, dy); }
- //////////////////////////////////////////////////////////////////////////////
- // PColour
- PINLINE COLORREF PColour::ToCOLORREF() const
- { return RGB(component[RedComponent],
- component[GreenComponent], component[BlueComponent]); }
- PINLINE PColour & PColour::FromSYSCOLOR(int syscol)
- { return FromCOLORREF(GetSysColor(syscol)); }
- //////////////////////////////////////////////////////////////////////////////
- // PRealColour
- PINLINE PObject * PRealColour::Clone() const
- { return new PRealColour(ToCOLORREF()); }
- PINLINE PRealColour::PRealColour(COLORREF col)
- { FromCOLORREF(col); }
- //////////////////////////////////////////////////////////////////////////////
- // PPalette
- PINLINE void PPalette::CopyContents(const PPalette & pal)
- { hPalette = pal.hPalette; }
- PINLINE HPALETTE PPalette::GetHPALETTE() const
- { return hPalette; }
- //////////////////////////////////////////////////////////////////////////////
- // PCanvas
- PINLINE void PCanvas::DrawFocusRect(const PRect & rect)
- { ::DrawFocusRect(GetHDC(), rect); }
- PINLINE void PCanvas::SetCurrentPosition(PORDINATE x, PORDINATE y)
- { MoveToEx(GetHDC(), x, y, NULL); }
- PINLINE BOOL PCanvas::IsInClipRegion(const PPoint & pt) const
- { return PtVisible(GetHDC(), pt.X(), pt.Y()); }
- PINLINE BOOL PCanvas::IsInClipRegion(const PRect & rect) const
- { return RectVisible(GetHDC(), rect); }
- PINLINE HDC PCanvas::GetHDC() const
- { return PAssertNULL(_hDC); }
- PINLINE BOOL PCanvas::NullHDC() const
- { return _hDC == NULL; }
- //////////////////////////////////////////////////////////////////////////////
- // PInteractorCanvas
- PINLINE PInteractorCanvas::PInteractorCanvas(PInteractor * theInteractor,BOOL)
- : interactor(theInteractor) { }
- PINLINE PInteractorCanvas::~PInteractorCanvas()
- { }
- PINLINE void PInteractorCanvas::Scroll(PORDINATE dx,
- PORDINATE dy, const PRect & rect)
- { PAssertOS(ScrollDC(GetHDC(), dx, dy, rect, rect, NULL, NULL)); }
- PINLINE void PInteractorCanvas::Copy(const PRect & srcRect,
- PCanvas & dst, const PPoint & pt)
- { PAssertOS(BitBlt(dst.GetHDC(),
- pt.X(), pt.Y(), srcRect.Width(), srcRect.Height(), GetHDC(),
- srcRect.Left(), srcRect.Top(), SRCCOPY)); }
- PINLINE void PInteractorCanvas::Copy(const PRect & srcRect,
- PCanvas & dst, const PRect & dstRect)
- { PAssertOS(StretchBlt(dst.GetHDC(),
- dstRect.X(), dstRect.Y(), dstRect.Width(), dstRect.Height(), GetHDC(),
- srcRect.X(), srcRect.Y(), srcRect.Width(), srcRect.Height(), SRCCOPY)); }
- //////////////////////////////////////////////////////////////////////////////
- // PPixels
- PINLINE BYTE PPixelBase::GetDepth() const
- { return (BYTE)info.biBitCount; }
- //////////////////////////////////////////////////////////////////////////////
- // PPict
- PINLINE PMETAFILE PPictBase::GetMETAFILE() const
- { return hMetafile; }
- //////////////////////////////////////////////////////////////////////////////
- // PPattern
- PINLINE PDim PPattern::GetDimensions() const
- { return PDim((PDIMENSION)bitmap.bmWidth, (PDIMENSION)bitmap.bmHeight); }
- PINLINE HBITMAP PPattern::GetHBITMAP() const
- { return hBitmap; }
- //////////////////////////////////////////////////////////////////////////////
- // PCursor
- PINLINE PCursor::PCursor()
- { hCursor = LoadCursor(NULL, IDC_ARROW); deleteCursor = FALSE; }
- PINLINE HCURSOR PCursor::GetHCURSOR() const
- { return hCursor; }
- //////////////////////////////////////////////////////////////////////////////
- // PCaret
- PINLINE PCaret::PCaret()
- { activeWindow = NULL; }
- PINLINE PCaret::PCaret(const PDim & dim)
- : caretSize(dim) { activeWindow = NULL; }
- PINLINE PCaret::PCaret(PDIMENSION dx, PDIMENSION dy)
- : caretSize(dx, dy) { activeWindow = NULL; }
- //////////////////////////////////////////////////////////////////////////////
- // PImgIcon
- PINLINE PImgIcon::PImgIcon()
- { hBitmap = NULL; }
- PINLINE PImgIcon::PImgIcon(HBITMAP hBits)
- { hBitmap = hBits; }
- PINLINE HBITMAP PImgIcon::GetHBITMAP() const
- { return hBitmap; }
- PINLINE void PImgIcon::CopyContents(const PImgIcon & icon)
- { hBitmap = icon.hBitmap; }
- //////////////////////////////////////////////////////////////////////////////
- // PIcon
- PINLINE PIcon::PIcon(HICON hIcn)
- : PImgIcon((HBITMAP)NULL), deleteIcon(FALSE) { hIcon = hIcn; }
- PINLINE HICON PIcon::GetHICON() const
- { return hIcon; }
- //////////////////////////////////////////////////////////////////////////////
- // PInteractor
- PINLINE PInteractor::PInteractor()
- { Construct(NULL, NULL, TRUE); }
- PINLINE PInteractor::PInteractor(PInteractor * par, BOOL hiddenChild)
- { Construct(PAssertNULL(par), NULL, hiddenChild); }
- PINLINE PInteractor::PInteractor(PInteractor * par, HWND hWnd)
- { Construct(PAssertNULL(par), hWnd, FALSE); }
- PINLINE void PInteractor::Enable(BOOL enabled)
- { EnableWindow(GetHWND(), enabled); }
- PINLINE BOOL PInteractor::IsEnabled() const
- { return IsWindowEnabled(GetHWND()); }
- PINLINE void PInteractor::Show(BOOL visible)
- { ShowWindow(GetHWND(), visible ? SW_SHOW : SW_HIDE); }
- PINLINE BOOL PInteractor::IsVisible() const
- { return IsWindowVisible(GetHWND()); }
- PINLINE void PInteractor::BringToTop()
- { BringWindowToTop(GetHWND()); }
- PINLINE BOOL PInteractor::IsOnTop() const
- { return GetHWND() == GetActiveWindow(); }
- PINLINE void PInteractor::Update()
- { UpdateWindow(GetHWND()); }
- PINLINE void PInteractor::GrabMouse()
- { SetCapture(GetHWND()); }
- PINLINE BOOL PInteractor::HasMouse() const
- { return GetCapture() == GetHWND(); }
- PINLINE void PInteractor::GrabFocus()
- { SetFocus(GetHWND()); }
- PINLINE BOOL PInteractor::HasFocus() const
- { return GetFocus() == GetHWND(); }
- PINLINE void PInteractor::ShowCursor(BOOL show)
- { ::ShowCursor(show); }
- PINLINE PPoint PInteractor::ToScreen(PORDINATE x, PORDINATE y, CoordinateSystem coords) const
- { return ToScreen(PPoint(x, y), coords); }
- PINLINE PPoint PInteractor::FromScreen(PORDINATE x, PORDINATE y, CoordinateSystem coords) const
- { return FromScreen(PPoint(x, y), coords); }
- PINLINE void PInteractor::SetWndText(const PString & str,
- UINT setMsg, WPARAM wParam)
- { SendMessage(GetHWND(),
- setMsg, wParam, (DWORD)(const char *)PMakeOEMText(str)); }
- //////////////////////////////////////////////////////////////////////////////
- // PNamedControl
- PINLINE PNamedControl::PNamedControl(PInteractorLayout * parent,
- PRESOURCE_ID ctlID, const PNotifier & notify, void * valuePtr)
- : PControl(parent, ctlID, notify, valuePtr) { }
- PINLINE PString PNamedControl::GetName() const
- { return GetWndText(); }
- //////////////////////////////////////////////////////////////////////////////
- // PEditBox
- PINLINE PEditBox::PEditBox(PInteractorLayout * parent,
- PRESOURCE_ID ctlID, const PNotifier & notify, PString * valuePtr)
- : PControl(parent, ctlID, notify, valuePtr) { }
- PINLINE PEditBox::~PEditBox()
- { }
- PINLINE void PEditBox::Construct()
- { }
- PINLINE PString PEditBox::GetText() const
- { return GetWndText(); }
- PINLINE void PEditBox::SetMaxText(PINDEX max)
- { SendMessage(GetHWND(), EM_LIMITTEXT, max, 0L); }
- PINLINE PINDEX PEditBox::GetLength() const
- { return (PINDEX)SendMessage(GetHWND(), WM_GETTEXTLENGTH, 0, 0L); }
- PINLINE BOOL PEditBox::IsModified() const
- { return (BOOL)SendMessage(GetHWND(), EM_GETMODIFY, 0, 0L); }
- PINLINE void PEditBox::SetSelection(PINDEX start, PINDEX finish)
- #ifdef _WIN32
- { SendMessage(GetHWND(), EM_SETSEL, start, finish); }
- #else
- { SendMessage(GetHWND(), EM_SETSEL, 0, MAKELPARAM(start, finish)); }
- #endif
- PINLINE void PEditBox::ReplaceSelection(const PString & text, BOOL canUndo)
- { SendMessage(GetHWND(), EM_REPLACESEL, canUndo, (LPARAM)(const char *)text); }
- PINLINE BOOL PEditBox::CanUndo() const
- { return (BOOL)SendMessage(GetHWND(), EM_CANUNDO, 0, 0L); }
- PINLINE void PEditBox::Undo()
- { SendMessage(GetHWND(), EM_UNDO, 0, 0L); }
- PINLINE void PEditBox::Cut()
- { SendMessage(GetHWND(), WM_CUT, 0, 0L); }
- PINLINE void PEditBox::Copy() const
- { SendMessage(GetHWND(), WM_COPY, 0, 0L); }
- PINLINE void PEditBox::Paste()
- { SendMessage(GetHWND(), WM_PASTE, 0, 0L); }
- PINLINE void PEditBox::Clear()
- { SendMessage(GetHWND(), WM_CLEAR, 0, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PPasswordEditBox
- PINLINE void PPasswordEditBox::Construct()
- { }
- PINLINE void PPasswordEditBox::SetPasswordCharacter(char c)
- { SendMessage(GetHWND(), EM_SETPASSWORDCHAR, c, 0); }
- PINLINE char PPasswordEditBox::GetPasswordCharacter()
- { return (char)SendMessage(GetHWND(), EM_GETPASSWORDCHAR, 0, 0);}
- //////////////////////////////////////////////////////////////////////////////
- // PMultiLineEditBox
- PINLINE void PMultiLineEditBox::Construct()
- { }
- PINLINE PINDEX PMultiLineEditBox::GetLineCount()
- { return (PINDEX)SendMessage(GetHWND(), EM_GETLINECOUNT, 0, 0L); }
- PINLINE PString PMultiLineEditBox::GetLine(PINDEX linenum)
- { return GetWndText(EM_LINELENGTH, EM_GETLINE,
- linenum, GetOffsetFromLine(linenum)); }
- PINLINE PINDEX PMultiLineEditBox::GetLineFromOffset(PINDEX offset)
- { return (PINDEX)SendMessage(GetHWND(), EM_LINEFROMCHAR, offset, 0L); }
- PINLINE PINDEX PMultiLineEditBox::GetOffsetFromLine(PINDEX linenum)
- { return (PINDEX)SendMessage(GetHWND(), EM_LINEINDEX, linenum, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PNumberEditBox
- PINLINE PNumberEditBox::PNumberEditBox(PInteractorLayout * parent,
- PRESOURCE_ID ctlID, const PNotifier & notify, void * valuePtr)
- : PEditBox(parent, ctlID, notify, (PString *)valuePtr) { }
- //////////////////////////////////////////////////////////////////////////////
- // PPushButton
- PINLINE void PPushButton::Construct()
- { }
- PINLINE BOOL PPushButton::IsOwnerDraw() const
- { return TRUE; }
- //////////////////////////////////////////////////////////////////////////////
- // PTextButton
- PINLINE PTextButton::PTextButton(PInteractorLayout * parent,
- PRESOURCE_ID ctlID, const PNotifier & notify, void * valuePtr)
- : PPushButton(parent, ctlID, notify, valuePtr) { }
- //////////////////////////////////////////////////////////////////////////////
- // PCheck3WayBox
- PINLINE PCheck3WayBox::CheckValues PCheck3WayBox::GetValue() const
- { return (CheckValues)SendMessage(GetHWND(), BM_GETCHECK, 0, 0L); }
- PINLINE void PCheck3WayBox::SetValue(CheckValues newVal)
- { SendMessage(GetHWND(), BM_SETCHECK, newVal, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PChoiceBox
- PINLINE PChoiceBox::~PChoiceBox()
- { }
- PINLINE void PChoiceBox::Construct()
- { }
- PINLINE PINDEX PChoiceBox::GetSelection() const
- { return (PINDEX)SendMessage(GetHWND(), CB_GETCURSEL, 0, 0L); }
- PINLINE void PChoiceBox::SetSelection(PINDEX newVal)
- { SendMessage(GetHWND(), CB_SETCURSEL, newVal, 0L); }
- PINLINE PINDEX PChoiceBox::AddString(const PString & str)
- { return (PINDEX)SendMessage(GetHWND(), CB_ADDSTRING, 0, (DWORD)(LPCSTR)str); }
- PINLINE void PChoiceBox::InsertString(const PString & str, PINDEX index)
- { SendMessage(GetHWND(), CB_INSERTSTRING, index, (DWORD)(LPCSTR)str); }
- PINLINE void PChoiceBox::DeleteString(PINDEX index)
- { SendMessage(GetHWND(), CB_DELETESTRING, index, 0L); }
- PINLINE void PChoiceBox::DeleteAllStrings()
- { SendMessage(GetHWND(), CB_RESETCONTENT, 0, 0L); }
- PINLINE PINDEX PChoiceBox::FindString(const PString & str,
- PINDEX startIndex, BOOL exact) const
- { return (PINDEX)SendMessage(GetHWND(),
- exact ? CB_FINDSTRINGEXACT : CB_FINDSTRING,
- startIndex == P_MAX_INDEX ? -1 : startIndex, (DWORD)(LPCSTR)str); }
- PINLINE void PChoiceBox::SetString(const PString & str, PINDEX index)
- { DeleteString(index); InsertString(str, index); }
- PINLINE PString PChoiceBox::GetString(PINDEX index) const
- { return GetWndText(CB_GETLBTEXTLEN, CB_GETLBTEXT, index, index); }
- PINLINE PINDEX PChoiceBox::GetCount() const
- { return (PINDEX)SendMessage(GetHWND(), CB_GETCOUNT, 0, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PListBox
- PINLINE PListBox::~PListBox()
- { }
- PINLINE PINDEX PListBox::GetCount() const
- { return (PINDEX)SendMessage(GetHWND(), LB_GETCOUNT, 0, 0L); }
- PINLINE PINDEX PListBox::GetTopIndex() const
- { return (PINDEX)SendMessage(GetHWND(), LB_GETTOPINDEX, 0, 0L); }
- PINLINE BOOL PListBox::IsSelected(PINDEX index) const
- { return SendMessage(GetHWND(), LB_GETSEL, index, 0L) > 0; }
- PINLINE PINDEX PListBox::GetSelCount() const
- { return (PINDEX)SendMessage(GetHWND(), LB_GETSELCOUNT, 0, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PStringListBox
- PINLINE PStringListBox::PStringListBox(PInteractorLayout * parent,
- PRESOURCE_ID ctlID, const PNotifier & notify, PINDEX * valuePtr)
- : PListBox(parent, ctlID, notify, valuePtr) { AllowDeleteObjects(); }
- //////////////////////////////////////////////////////////////////////////////
- // PComboBox
- PINLINE PComboBox::~PComboBox()
- { }
- PINLINE void PComboBox::Construct()
- { }
- PINLINE PString PComboBox::GetText() const
- { return GetWndText(); }
- PINLINE void PComboBox::SetText(const PString & name)
- { SetWndText(name); }
- PINLINE void PComboBox::SetMaxText(PINDEX max)
- { SendMessage(GetHWND(), CB_LIMITTEXT, max, 0L); }
- PINLINE PINDEX PComboBox::GetLength() const
- { return (PINDEX)SendMessage(GetHWND(), WM_GETTEXTLENGTH, 0, 0L); }
- PINLINE void PComboBox::SetSelection(PINDEX start, PINDEX finish)
- { SendMessage(GetHWND(), CB_SETEDITSEL, 0, MAKELPARAM(start, finish)); }
- PINLINE void PComboBox::Cut()
- { SendMessage(GetHWND(), WM_CUT, 0, 0L); }
- PINLINE void PComboBox::Copy() const
- { SendMessage(GetHWND(), WM_COPY, 0, 0L); }
- PINLINE void PComboBox::Paste()
- { SendMessage(GetHWND(), WM_PASTE, 0, 0L); }
- PINLINE void PComboBox::Clear()
- { SendMessage(GetHWND(), WM_CLEAR, 0, 0L); }
- PINLINE PINDEX PComboBox::AddString(const PString & str)
- { return (PINDEX)SendMessage(GetHWND(), CB_ADDSTRING, 0, (DWORD)(LPCSTR)str); }
- PINLINE void PComboBox::InsertString(const PString & str, PINDEX index)
- { SendMessage(GetHWND(), CB_INSERTSTRING, index, (DWORD)(LPCSTR)str); }
- PINLINE void PComboBox::DeleteString(PINDEX index)
- { SendMessage(GetHWND(), CB_DELETESTRING, index, 0L); }
- PINLINE void PComboBox::DeleteAllStrings()
- { SendMessage(GetHWND(), CB_RESETCONTENT, 0, 0L); }
- PINLINE PINDEX PComboBox::FindString(const PString & str,
- PINDEX startIndex, BOOL exact) const
- { return (PINDEX)SendMessage(GetHWND(),
- exact ? CB_FINDSTRINGEXACT : CB_FINDSTRING,
- startIndex == P_MAX_INDEX ? -1 : startIndex, (DWORD)(LPCSTR)str); }
- PINLINE void PComboBox::SetString(const PString & str, PINDEX index)
- { DeleteString(index); InsertString(str, index); }
- PINLINE PString PComboBox::GetString(PINDEX index) const
- { return GetWndText(CB_GETLBTEXTLEN, CB_GETLBTEXT, index, index); }
- PINLINE PINDEX PComboBox::GetCount() const
- { return (PINDEX)SendMessage(GetHWND(), CB_GETCOUNT, 0, 0L); }
- PINLINE void PComboBox::SetCurrent(PINDEX index)
- { SendMessage(GetHWND(), CB_SETCURSEL, index, 0L); }
- //////////////////////////////////////////////////////////////////////////////
- // PScrollBar
- PINLINE void PScrollBar::Construct()
- { }
- PINLINE void PScrollBar::SetSmallNudge(PSCROLLBAR_VALUE val)
- { smallNudge = val; }
- PINLINE void PScrollBar::SetLargeNudge(PSCROLLBAR_VALUE val)
- { largeNudge = val; }
- /////////////////////////////////////////////////////////////////////////////
- // PDialog
- PINLINE PDialog::~PDialog()
- { }
- PINLINE PString PDialog::GetTitle() const
- { return GetWndText(); }
- PINLINE void PDialog::SetTitle(const PString & title)
- { SetWndText(title); }
- /////////////////////////////////////////////////////////////////////////////
- // PTitledWindow
- PINLINE PTitledWindow::~PTitledWindow()
- { }
- PINLINE PString PTitledWindow::GetTitle() const
- { return GetWndText(); }
- PINLINE void PTitledWindow::SetTitle(const PString & title)
- { SetWndText(title); }
- PINLINE void PTitledWindow::Activate()
- { SetActiveWindow(GetHWND()); }
- PINLINE void PTitledWindow::MakeIconic()
- { ShowWindow(GetHWND(), SW_MINIMIZE); }
- PINLINE void PTitledWindow::Zoom()
- { ShowWindow(GetHWND(), SW_MAXIMIZE); }
- PINLINE void PTitledWindow::Normalise()
- { ShowWindow(GetHWND(), SW_RESTORE); }
- /////////////////////////////////////////////////////////////////////////////
- // PTopLevelWindow
- PINLINE PSubMenu & PTopLevelWindow::GetHelpMenu()
- { return helpMenu; }
- /////////////////////////////////////////////////////////////////////////////
- // PMDIFrameWindow
- PINLINE void PMDIFrameWindow::CascadeDocuments()
- { SendMessage(mdiClient, WM_MDICASCADE, 0, 0L); }
- PINLINE void PMDIFrameWindow::TileDocuments(BOOL vertically)
- { SendMessage(mdiClient, WM_MDITILE,
- vertically ? MDITILE_VERTICAL : MDITILE_HORIZONTAL, 0L); }
- PINLINE void PMDIFrameWindow::ArrangeIcons()
- { SendMessage(mdiClient, WM_MDIICONARRANGE, 0, 0L); }
- PINLINE PSubMenu & PMDIFrameWindow::GetWindowMenu()
- { return windowMenu; }
- /////////////////////////////////////////////////////////////////////////////
- // PMDIDocWindow
- PINLINE PMDIDocWindow::PMDIDocWindow(PMDIFrameWindow * parent,
- const PString & newTitle, int CanDo)
- : PTitledWindow(parent, CanDo), initialTitle(newTitle) { }
- //////////////////////////////////////////////////////////////////////////////
- // PMenuItem
- PINLINE void PMenuItem::Enable(BOOL enabled)
- { EnableMenuItem(itsMenu->GetHMENU(), menuID,
- (UINT)(enabled ? MF_ENABLED : MF_GRAYED)); }
- PINLINE BOOL PMenuItem::IsEnabled() const
- { return (GetMenuState(itsMenu->GetHMENU(), menuID,
- MF_BYCOMMAND)&MF_GRAYED) == 0; }
- PINLINE void PMenuItem::Check(BOOL checked)
- { CheckMenuItem(itsMenu->GetHMENU(), menuID,
- (UINT)(checked ? MF_CHECKED : MF_UNCHECKED)); }
- PINLINE BOOL PMenuItem::IsChecked() const
- { return (GetMenuState(itsMenu->GetHMENU(), menuID,
- MF_BYCOMMAND)&MF_CHECKED) != 0; }
- //////////////////////////////////////////////////////////////////////////////
- // PMenuSeparator
- PINLINE PMenuSeparator::PMenuSeparator(int, PSubMenu & menu)
- : PMenuEntry(menu, NULL) { }
- //////////////////////////////////////////////////////////////////////////////
- // PSubMenu
- PINLINE PString PSubMenu::GetString() const
- { return title; }
- PINLINE HMENU PSubMenu::GetHMENU() const
- { return PAssertNULL(hMenu); }
- //////////////////////////////////////////////////////////////////////////////
- // PRootMenu
- PINLINE PRootMenu::~PRootMenu()
- { entries.RemoveAll(); }
- PINLINE HACCEL PRootMenu::GetHACCEL() const
- { return accelerators; }
- ///////////////////////////////////////////////////////////////////////////////
- // PSound
- PINLINE void PSound::Beep()
- { MessageBeep(0); }
- ///////////////////////////////////////////////////////////////////////////////
- // PResourceData
- PINLINE BYTE PResourceData::operator[](PINDEX offset) const
- { return lpResource[offset]; }
- PINLINE PResourceData::operator const BYTE *() const
- { return (const BYTE *)lpResource; }
- ///////////////////////////////////////////////////////////////////////////////
- // PClipboard
- PINLINE BOOL PClipboard::InUse()
- { return !opened; }
- ///////////////////////////////////////////////////////////////////////////////
- // PApplication
- PINLINE HINSTANCE PApplication::GetInstance() const
- { return hInstance; }
- PINLINE WNDPROC PApplication::GetWndProcPtr(WndProcTypes proc) const
- { return wndProcPtr[proc]; }
- PINLINE void PApplication::AddWindowHandle(HWND hWnd, PInteractor * pWnd)
- { createdWindows.SetAt((HWNDKey)hWnd, pWnd); }
- PINLINE void PApplication::RemoveWindowHandle(HWND hWnd)
- { createdWindows.SetAt((HWNDKey)hWnd, NULL); }
- PINLINE PInteractor * PApplication::GetWindowObject(HWND hWnd) const
- { return (PInteractor *)createdWindows.GetAt((HWNDKey)hWnd); }
- PINLINE PInteractor * PApplication::FindInteractor(const PPoint & pt) const
- { return GetWindowObject(WindowFromPoint(pt)); }
- // End Of File ///////////////////////////////////////////////////////////////