pwmisc.inl
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:21k
- /*
- * pwmisc.inl
- *
- * Miscellaneous inline functions for GUI classes.
- *
- * 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: pwmisc.inl,v $
- * Revision 1.56 1999/08/07 07:13:22 robertj
- * Fixed problems with "balloon help" text popup.
- *
- * Revision 1.55 1998/12/16 12:56:04 robertj
- * Moved SetAccelerator to platform dependent code.
- *
- * Revision 1.54 1998/10/16 02:08:05 robertj
- * Fixed problem with changing first tier menus when have maximised MDI child.
- *
- * Revision 1.53 1998/09/23 06:28:30 robertj
- * Added open source copyright license.
- *
- * Revision 1.52 1997/04/27 05:50:18 robertj
- * DLL support.
- *
- * Revision 1.51 1996/01/28 02:52:01 robertj
- * Added assert into all Compare functions to assure comparison between compatible objects.
- *
- * Revision 1.50 1995/12/10 11:34:01 robertj
- * Changed default default OnAbout() function to have user specified dialog.
- *
- * Revision 1.49 1995/10/14 15:03:49 robertj
- * Changed return values to references for efficency.
- *
- * Revision 1.48 1995/08/24 12:35:26 robertj
- * Added standard colours for balloon help windows.
- *
- * Revision 1.47 1995/07/02 01:20:26 robertj
- * Moved function to .cxx file when fixed bug.
- *
- * Revision 1.46 1995/06/04 12:35:36 robertj
- * Added Add component functions.
- *
- * Revision 1.45 1995/02/19 04:12:25 robertj
- * Changed font constructor to se more gener PString.
- * Added dynamically linked command processing.
- *
- * Revision 1.44 1995/01/27 11:12:09 robertj
- * Changed face name strings to be caseless.
- *
- * Revision 1.43 1995/01/22 07:29:40 robertj
- * Added font & colour standard dialogs.
- *
- * Revision 1.42 1995/01/07 04:39:40 robertj
- * Redesigned font enumeration code and changed font styles.
- *
- * Revision 1.41 1995/01/06 10:32:38 robertj
- * Changed GetColourCount() to GetSize() and SetSize().
- *
- * Revision 1.40 1994/12/14 11:17:10 robertj
- * Changed PDIMENSION to be unsigned causing untold number of changes.
- *
- * Revision 1.39 1994/12/05 11:34:21 robertj
- * Major rewrite of images, pictures and pixmaps.
- * Renamed PPict, PPixels and PImage to make sure all uses are found.
- *
- * Revision 1.38 1994/11/26 03:40:08 robertj
- * Added DoContextHelp versions using default help file (MSC bug).
- *
- * Revision 1.37 1994/10/30 11:46:59 robertj
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.36 1994/10/23 04:53:45 robertj
- * Changed colour components to 8 bit.
- *
- * Revision 1.35 1994/08/21 23:43:02 robertj
- * Moved root menu destructor to platform dependent files.
- * Added delayed close of interactors to avoid the "delete this" problem.
- *
- * Revision 1.34 1994/07/02 03:03:49 robertj
- * Time interval and timer redesign.
- *
- * Revision 1.33 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.32 1994/04/20 12:17:44 robertj
- * assert stuff
- *
- * Revision 1.31 1994/04/11 14:18:15 robertj
- * Added password entry edit box.
- *
- * Revision 1.30 1994/04/03 08:34:18 robertj
- * Added help and focus functionality.
- *
- * Revision 1.29 1994/04/01 14:07:14 robertj
- * Elimination of PDECLARE_ABSTRACT_CONTAINER.
- *
- * Revision 1.28 1994/03/07 07:45:40 robertj
- * Major upgrade
- *
- * Revision 1.27 1994/01/15 02:50:29 robertj
- * Moved control contructors to common and added a platform dependent Construct() function.
- *
- * Revision 1.26 1994/01/13 11:30:39 robertj
- * Added private PInteractor copy constructor and assignment operator.
- * Moved list box destructor to platform dependent files.
- *
- * Revision 1.25 1994/01/13 03:36:48 robertj
- * Created intermediate class PInteractorLayout for dialog-ish windows.
- *
- * Revision 1.24 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.23 1993/12/31 06:48:46 robertj
- * Made inlines optional for debugging purposes.
- * Added PImgIcon class.
- *
- * Revision 1.22 1993/12/29 04:40:47 robertj
- * Mac port.
- *
- * Revision 1.21 1993/12/16 06:21:00 robertj
- * Removed usage of enum as bitmask as GCC does not like it.
- *
- * Revision 1.20 1993/12/16 06:20:57 robertj
- * Changes to callback function definition due to GCC.
- *
- * Revision 1.19 1993/12/15 21:11:00 robertj
- * Moved simple dialogs from inline to cxx file.
- *
- * Revision 1.18 1993/12/15 21:10:10 robertj
- * Added optional deletion of objects in a list box.
- *
- * Revision 1.17 1993/12/14 18:44:56 robertj
- * Fixed multiple deletion of menu entries.
- *
- * Revision 1.16 1993/12/04 05:24:46 robertj
- * Split up file and moved some code to cxx files
- *
- * Revision 1.15 1993/12/01 16:09:05 robertj
- * Windows NT port.
- *
- * Revision 1.14 1993/11/30 18:34:11 robertj
- * Added missing PImage constructor.
- * Added missing PCanvas::GetFont() function.
- *
- * Revision 1.13 1993/11/20 17:26:28 robertj
- * Shape classes implementation
- * Added + and - operators to PDim for PPoints.
- * Made ancestor to PPoint and PRect private with operators to get pointers.
- *
- * Revision 1.12 1993/10/16 20:33:20 robertj
- * Changed pixmap class to be descendent of PImage.
- * Added picture type image class.
- * Moved PCanvasState out of PCanvas.
- *
- * Revision 1.11 1993/09/27 16:35:25 robertj
- * Added Construct() function to push buttons.
- * Added clipboard support class.
- *
- * Revision 1.10 1993/08/27 18:17:47 robertj
- * Added interactor background colour manipulation functions.
- * Added timer support.
- *
- * Revision 1.9 1993/08/24 00:27:59 robertj
- * Rearranged push button and descendent classes.
- * Added inPixels parameter to invalidate/validate functions.
- *
- * Revision 1.8 1993/08/21 17:09:50 robertj
- * Added function to allow setting of menus whenever it is selected.
- *
- * Revision 1.7 1993/08/21 01:07:35 robertj
- * Added nudge buttons
- *
- * Revision 1.6 1993/08/19 18:02:29 robertj
- * Moved horizontal and vertical scroll bar constructors to platform specific
- * implementation files.
- * ./
- *
- * Revision 1.5 1993/07/15 04:23:39 robertj
- * Added non-printf style function for setting status bar section text.
- *
- * Revision 1.4 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- ///////////////////////////////////////////////////////////////////////////////
- // PDim
- #if defined(_PDIM)
- PINLINE PDim ::PDim()
- { width = height = 0; }
- PINLINE PDim ::PDim(PDIMENSION w, PDIMENSION h)
- { width = w; height = h; }
- PINLINE PDim::PDim(const PDim & dim)
- { width = dim.width; height = dim.height; }
- PINLINE PDIMENSION PDim::Width() const
- { return width; }
- PINLINE PDIMENSION PDim::Height() const
- { return height; }
- PINLINE void PDim::SetWidth(PDIMENSION w)
- { width = w; }
- PINLINE void PDim::SetHeight(PDIMENSION h)
- { height = h; }
- PINLINE void PDim::AddWidth(PORDINATE w)
- { width += w; }
- PINLINE void PDim::AddHeight(PORDINATE h)
- { height += h; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PRect
- #if defined(_PRECT)
- PINLINE PPoint PRect::Origin() const
- { return PPoint(X(), Y()); }
- PINLINE PPoint PRect::Corner() const
- { return PPoint(Right(), Bottom()); }
- PINLINE PDim PRect::Dimensions() const
- { return PDim(Width(), Height()); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PKeyCode
- #if defined(_PKEYCODE)
- PINLINE PKeyCode::PKeyCode(Value theValue, int theMods)
- { value = theValue; modifiers = theMods; }
- PINLINE PKeyCode::Value PKeyCode::GetValue() const
- { return value; }
- PINLINE int PKeyCode::GetModifiers() const
- { return modifiers; }
- PINLINE BOOL PKeyCode::IsModifier(int modmask) const
- { return (modifiers&modmask) != 0; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PColour
- #if defined(_PCOLOUR)
- PINLINE BYTE PColour::GetRed() const
- { return component[RedComponent]; }
- PINLINE BYTE PColour::GetGreen() const
- { return component[GreenComponent]; }
- PINLINE BYTE PColour::GetBlue() const
- { return component[BlueComponent]; }
- PINLINE BYTE PColour::GetAlpha() const
- { return component[AlphaComponent]; }
- PINLINE BYTE PColour::operator[](PINDEX c) const
- { PASSERTINDEX(c);
- PAssert(c < NumComponents, PInvalidArrayIndex);
- return component[c]; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPalette
- #if defined(_PPALETTE)
- PINLINE void PPalette::CloneContents(const PPalette * p)
- { CopyContents(*p); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PFont
- #if defined(_PFONT)
- PINLINE PFont::PFont(const char * fontDescriptionPtr)
- { Construct(fontDescriptionPtr); }
- PINLINE PFont::PFont(const PString & fontDescriptionStr)
- { Construct(fontDescriptionStr); }
- PINLINE PCaselessString PFont::GetFacename() const
- { return facename; }
- PINLINE PDIMENSION PFont::GetSize() const
- { return size; }
- PINLINE WORD PFont::GetStyles() const
- { return styles; }
- PINLINE BOOL PFont::IsBold() const
- { return (styles&Bold) != 0; }
- PINLINE BOOL PFont::IsItalic() const
- { return (styles&Italic) != 0; }
- PINLINE BOOL PFont::IsUnderlined() const
- { return (styles&Underline) != 0; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PRealFont
- #if defined(_PREALFONT)
- PINLINE PDIMENSION PRealFont::PointsToPixelsX(PDIMENSION x) const
- { return (PDIMENSION)(((DWORD)x*deviceResX+36)/72); }
-
- PINLINE PDIMENSION PRealFont::PointsToPixelsY(PDIMENSION y) const
- { return (PDIMENSION)(((DWORD)y*deviceResY+36)/72); }
-
- PINLINE PDIMENSION PRealFont::PixelsToPointsX(PDIMENSION x) const
- { return (PDIMENSION)(((DWORD)x*72+deviceResX/2)/deviceResX); }
- PINLINE PDIMENSION PRealFont::PixelsToPointsY(PDIMENSION y) const
- { return (PDIMENSION)(((DWORD)y*72+deviceResY/2)/deviceResY); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PFontFamily
- #if defined(_PFONTFAMILY)
- PINLINE PFontFamily::PFontFamily(const PCaselessString & face)
- : facename(face) { scalable = FALSE; }
- PINLINE const PCaselessString & PFontFamily::GetFacename() const
- { return facename; }
- PINLINE BOOL PFontFamily::IsScalable() const
- { return scalable; }
- PINLINE const PWORDArray & PFontFamily::GetSizes() const
- { return sizes; }
- PINLINE const PWORDArray & PFontFamily::GetStyles() const
- { return styles; }
- PINLINE const PStringArray & PFontFamily::GetStyleNames() const
- { return styleNames; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPattern
- #if defined(_PPATTERN)
- PINLINE void PPattern::CloneContents(const PPattern * p)
- { CopyContents(*p); }
- PINLINE BOOL PPattern::SetSize(PINDEX)
- { return TRUE; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PImage
- #if defined(_PIMAGE)
- PINLINE PImageBase::PImageBase(PDIMENSION dx, PDIMENSION dy)
- : size(dx, dy) { }
- PINLINE PImageBase::PImageBase(const PDim & sz)
- : size(sz) { }
- PINLINE PDIMENSION PImageBase::Width() const
- { return size.Width(); }
- PINLINE PDIMENSION PImageBase::Height() const
- { return size.Height(); }
- PINLINE PDim PImageBase::GetDimensions() const
- { return size; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPixels
- #if defined(_PPIXELS)
- PINLINE PPalette PPixelBase::GetPalette() const
- { return palette; }
- PINLINE void PPixelBase::SetPalette(const PPalette & pal)
- { palette = pal; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PPict
- #if defined(_PPICT)
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PImgIcon
- #if defined(_PIMGICON)
- PINLINE void PImgIcon::CloneContents(const PImgIcon * i)
- { CopyContents(*i); }
- PINLINE BOOL PImgIcon::SetSize(PINDEX)
- { return TRUE; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PIcon
- #if defined(_PICON)
- PINLINE void PIcon::CloneContents(const PIcon * i)
- { CopyContents(*i); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PCursor
- #if defined(_PCURSOR)
- PINLINE void PCursor::CloneContents(const PCursor * c)
- { CopyContents(*c); }
- PINLINE BOOL PCursor::SetSize(PINDEX)
- { return TRUE; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PCaret
- #if defined(_PCARET)
- PINLINE void PCaret::CloneContents(const PCaret * c)
- { CopyContents(*c); }
- PINLINE BOOL PCaret::SetSize(PINDEX)
- { return TRUE; }
- PINLINE void PCaret::SetDimensions(const PDim & dim)
- { SetDimensions(dim.Width(), dim.Height()); }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PMenuEntry
- #if defined(_PMENUENTRY)
- PINLINE PSubMenu * PMenuEntry::GetMenu() const
- { return itsMenu; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PMenuItem
- #if defined(_PMENUITEM)
- PINLINE PKeyCode PMenuItem::GetAccelerator() const
- { return accelerator; }
- PINLINE void PMenuItem::SetNotifier(const PNotifier & func, BOOL update)
- { callback = func; notifyForStateUpdate = update; }
- PINLINE const PNotifier & PMenuItem::GetNotifier() const
- { return callback; }
- PINLINE BOOL PMenuItem::WillNotifyOnStateUpdate() const
- { return notifyForStateUpdate; }
- PINLINE void PMenuItem::Disable()
- { Enable(FALSE); }
- PINLINE void PMenuItem::Uncheck()
- { Check(FALSE); }
- PINLINE BOOL * PMenuItem::GetCheckPointer() const
- { return checkPointer; }
- PINLINE void PMenuItem::SetCheckPointer(BOOL * ptr)
- { checkPointer = ptr; }
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PSubMenu
- #if defined(_PSUBMENU)
- PINLINE PSubMenu::PSubMenu()
- : PMenuEntry() { }
-
- PINLINE PINDEX PSubMenu::GetSize() const
- { return entries.GetSize(); }
-
- PINLINE PMenuEntry & PSubMenu::operator[](PINDEX index)
- { return entries[index]; }
-
-
- #endif
- //////////////////////////////////////////////////////////////////////////////
- // PRootMenu
- #if defined(_PROOTMENU)
- PINLINE PMenuItem * PRootMenu::GetItemFromKey(PRESOURCE_ID key)
- { return (PMenuItem *)keyedItems.GetAt(key); }
- #endif
- ///////////////////////////////////////////////////////////////////////////////
- // PCommandSource
- #if defined(_PCOMMANDS)
- PINLINE PCommandSource::PCommandSource(const char * cmdName)
- : PNotifierFunction(PApplication::Current().GetWindow()), name(cmdName) { }
- #endif
- ///////////////////////////////////////////////////////////////////////////////
- // PResourceData
- #if defined(_PRESOURCEDATA)
- PINLINE void PResourceData::CloneContents(const PResourceData * r)
- { CopyContents(*r); }
- #endif
- ///////////////////////////////////////////////////////////////////////////////
- // PApplication
- #if defined(_PAPPLICATION)
- PINLINE PApplication::~PApplication()
- { }
- PINLINE PTopLevelWindow * PApplication::GetWindow() const
- { return mainWindow; }
- PINLINE PApplication::ParameterTypes PApplication::GetParameterType() const
- { return parameterType; }
- PINLINE PString PApplication::GetAboutMenuItemString() const
- { return aboutMenuItemString; }
- PINLINE void PApplication::SetAboutMenuItemString(const PString & newName)
- { aboutMenuItemString = newName; }
- PINLINE PRESOURCE_ID PApplication::GetAboutDialogID() const
- { return aboutDialogID; }
- PINLINE void PApplication::SetAboutDialogID(PRESOURCE_ID newID)
- { aboutDialogID = newID; }
- PINLINE PFilePath PApplication::GetDefaultHelpFile() const
- { return defaultHelpFile; }
- PINLINE void PApplication::SetDefaultHelpFile(const PFilePath & name)
- { defaultHelpFile = name; }
- PINLINE void PApplication::DoContextHelp(const PString & context)
- { DoContextHelp(context, defaultHelpFile); }
- PINLINE void PApplication::DoContextHelp(PINDEX contextId)
- { DoContextHelp(contextId, defaultHelpFile); }
- PINLINE const PRect & PApplication::GetScreenRect() const
- { return screenRect; }
- PINLINE const PDim & PApplication::GetPrimaryScreenSize() const
- { return primaryScreenSize; }
- PINLINE const PDim & PApplication::GetScreenResolution(BOOL imperial) const
- { return imperial ? screenResImperial : screenResMetric; }
- PINLINE long PApplication::GetScreenColours() const
- { return screenColours; }
- PINLINE PDIMENSION PApplication::GetScreenDepth() const
- { return screenDepth; }
- PINLINE const PDim & PApplication::GetCursorSize() const
- { return cursorSize;}
- PINLINE const PDim & PApplication::GetIconSize() const
- { return iconSize; }
- PINLINE PDIMENSION PApplication::GetTitleHeight() const
- { return heightTitle; }
- PINLINE PDIMENSION PApplication::GetMenuHeight() const
- { return heightMenu; }
- PINLINE const PDim & PApplication::GetTitledBorderSize() const
- { return titledBorder; }
- PINLINE const PDim & PApplication::GetDlgBorderSize() const
- { return dlgBorder; }
- PINLINE const PDim & PApplication::GetBorderSize() const
- { return border; }
- PINLINE const PDim & PApplication::GetMainWindowSize() const
- { return defMainWindow; }
- PINLINE const PDim & PApplication::GetTitledWindowSize() const
- { return defTitledWindow; }
- PINLINE PDIMENSION PApplication::GetHScrollHeight() const
- { return heightHScroll; }
- PINLINE PDIMENSION PApplication::GetVScrollWidth() const
- { return widthVScroll; }
- PINLINE const PFont & PApplication::GetSystemFont() const
- { return systemFont; }
- PINLINE const PFont & PApplication::GetBalloonFont() const
- { return balloonFont; }
- PINLINE const PRect & PApplication::GetDoubleClickRect() const
- { return dblClkRect; }
- PINLINE const PTimeInterval & PApplication::GetDoubleClickTime() const
- { return doubleClick; }
- PINLINE const PColour & PApplication::GetWindowFgColour() const
- { return windowFg; }
- PINLINE const PColour & PApplication::GetWindowBkColour() const
- { return windowBk; }
- PINLINE const PColour & PApplication::GetActiveBorderColour() const
- { return activeBorder; }
- PINLINE const PColour & PApplication::GetInactiveBorderColour() const
- { return inactiveBorder; }
- PINLINE const PColour & PApplication::GetActiveTitleFgColour() const
- { return activeTitleFg; }
- PINLINE const PColour & PApplication::GetActiveTitleBkColour() const
- { return activeTitleBk; }
- PINLINE const PColour & PApplication::GetInactiveTitleFgColour() const
- { return inactiveTitleFg; }
- PINLINE const PColour & PApplication::GetInactiveTitleBkColour() const
- { return inactiveTitleBk; }
- PINLINE const PColour & PApplication::GetMenuFgColour() const
- { return menuFg; }
- PINLINE const PColour & PApplication::GetMenuBkColour() const
- { return menuBk; }
- PINLINE const PColour & PApplication::GetBalloonFgColour() const
- { return balloonFg; }
- PINLINE const PColour & PApplication::GetBalloonBkColour() const
- { return balloonBk; }
- PINLINE const PColour & PApplication::GetButtonFgColour() const
- { return buttonFg; }
- PINLINE const PColour & PApplication::GetButtonBkColour() const
- { return buttonBk; }
- PINLINE const PColour & PApplication::GetButtonLightingColour() const
- { return buttonLighting; }
- PINLINE const PColour & PApplication::GetButtonShadowColour() const
- { return buttonShadow; }
- PINLINE const PColour & PApplication::GetScrollBarColour() const
- { return scrollBar; }
- PINLINE const PColour & PApplication::GetHighlightFgColour() const
- { return highlightFg; }
- PINLINE const PColour & PApplication::GetHighlightBkColour() const
- { return highlightBk; }
- PINLINE const PColour & PApplication::GetGrayTextColour() const
- { return grayText; }
- #endif
- // End Of File ///////////////////////////////////////////////////////////////