⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.cxx

📁 windows mobile phone source code
💻 CXX
📖 第 1 页 / 共 3 页
字号:
/*
 * control.cxx
 *
 * Control interactor 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: control.cxx,v $
 * Revision 1.55  1999/11/23 05:24:32  robertj
 * Moved function from platform independent to platform dependent files.
 *
 * Revision 1.54  1999/11/23 05:08:47  craigs
 * Moved PTextButton::DefaultDimensions to platform dependent code
 *
 * Revision 1.53  1999/11/16 06:51:41  robertj
 * Created PCustomListBox to allow motif native code PStringListBox implementation
 *
 * Revision 1.52  1999/11/16 05:23:22  craigs
 * Changed for creation of PCustomListBox class
 *
 * Revision 1.51  1999/09/05 14:39:22  robertj
 * GNU 2.95 compatibility
 *
 * Revision 1.50  1999/08/07 07:13:23  robertj
 * Fixed problems with "balloon help" text popup.
 *
 * Revision 1.49  1998/09/23 06:29:37  robertj
 * Added open source copyright license.
 *
 * Revision 1.48  1998/09/14 12:41:52  robertj
 * Added tab stops to string output in list box.
 *
 * Revision 1.47  1998/02/24 23:07:27  robertj
 * Fixed background colour for static text (another constructor) on simple dialogs
 *
 * Revision 1.46  1998/02/06 04:00:16  robertj
 * Fixed colour of controls, again!
 *
 * Revision 1.45  1996/11/04 03:39:56  robertj
 * Fixed default dimensions of check box and radio button.
 *
 * Revision 1.44  1996/04/30 12:33:50  robertj
 * Changed "inPixels" boolean to enum for three coordinate systems.
 *
 * Revision 1.43  1995/11/09 12:20:34  robertj
 * Added static (filled) rectange control.
 *
 * Revision 1.42  1995/10/14 15:08:24  robertj
 * Added addition of colection as strings to box.
 *
 * Revision 1.41  1995/08/12 22:33:12  robertj
 * Moved OnEndInput() function to platform dependent code.
 *
 * Revision 1.40  1995/06/17 00:46:42  robertj
 * Added missing constructor for PTextButton.
 *
 * Revision 1.39  1995/06/04 12:40:18  robertj
 * Removed non-portable function ltoa.
 *
 * Revision 1.38  1995/04/25 11:29:19  robertj
 * Fixed Borland compiler warnings.
 *
 * Revision 1.37  1995/04/02 09:27:29  robertj
 * Added "balloon" help.
 *
 * Revision 1.36  1995/02/19 04:19:20  robertj
 * Added dynamically linked command processing.
 *
 * Revision 1.35  1995/02/05  00:50:42  robertj
 * Had to change variable name "small" for MSVC 2.0
 * Added notification of end input.
 *
 * Revision 1.34  1995/01/27  11:13:18  robertj
 * Changed alignment mask from enum to int.
 * Changed state of checkbox from CheckValue to BOOL.
 *
 * Revision 1.33  1995/01/18  10:58:15  robertj
 * No need for constructors of images.
 *
 * Revision 1.32  1995/01/18  09:02:23  robertj
 * Added separate image icon for enabled and disabled button.
 *
 * Revision 1.31  1995/01/06  10:43:56  robertj
 * Changed PRealFont usage from pointer to reference.
 *
 * Revision 1.30  1995/01/01  01:06:18  robertj
 * Incorrect position of text in list boxes
 *
 * Revision 1.29  1994/12/21  11:58:24  robertj
 * Documentation and variable normalisation.
 *
 * Revision 1.28  1994/12/14  11:17:15  robertj
 * Changed PDIMENSION to be unsigned causing untold number of changes.
 *
 * Revision 1.27  1994/12/05  11:27:16  robertj
 * Changed 3 way check box constructor to be similar to other constructors.
 *
 * Revision 1.26  1994/11/19  00:01:04  robertj
 * Added notifier & value to main PControl constructor
 *
 * Revision 1.25  1994/10/30  11:47:11  robertj
 * Changed mechanism for doing notification callback functions.
 *
 * Revision 1.24  1994/08/21  23:43:02  robertj
 * Added undef of new for Unix build system.
 *
 * Revision 1.23  1994/07/27  05:58:07  robertj
 * Synchronisation.
 *
 * Revision 1.22  1994/07/02  03:03:49  robertj
 * Fixed bug in list box construction.
 *
 * Revision 1.21  1994/06/25  11:55:15  robertj
 * Unix version synchronisation.
 *
 * Revision 1.20  1994/04/20  12:17:44  robertj
 * assert changes
 *
 * Revision 1.19  1994/04/11  14:09:03  robertj
 * Fixed bug in static icon, not being set on windows platforms.
 *
 * Revision 1.18  1994/04/03  08:34:18  robertj
 * Added help and focus functionality.
 *
 * Revision 1.17  1994/04/01  14:01:49  robertj
 * Added PControl level DefaultDimensions.
 * Moved PStringListBox constructor to  platform specific sections.
 *
 * Revision 1.16  1994/03/07  07:47:00  robertj
 * Major upgrade
 *
 * Revision 1.15  1994/01/15  02:53:45  robertj
 * Moved control constructors to common code and added platform dependent Construct() function.
 *
 * Revision 1.14  1993/12/31  06:53:48  robertj
 * Added PImgIcon class.
 *
 * Revision 1.13  1993/12/16  06:21:00  robertj
 * Cannot do triadic conditionals with objects in GCC.
 *
 * Revision 1.12  1993/12/16  06:20:57  robertj
 * Changes to callback function definition due to GCC.
 *
 * Revision 1.11  1993/12/15  21:10:10  robertj
 * Changed group in radio buttons to use containers reference system.
 * Added optional deletion of objects in a list box.
 *
 * Revision 1.10  1993/12/04  05:23:06  robertj
 * Moved code from pwlib.inl
 *
 * Revision 1.9  1993/12/01  16:09:05  robertj
 * Windows NT port.
 *
 * Revision 1.8  1993/11/20  17:26:28  robertj
 * Change of PImage to PPixels in picture buttons.
 *
 * Revision 1.7  1993/09/29  03:06:30  robertj
 * Moved PListBox contructor to platform specific modules.
 * Removed cursor setting for PComboBoxes
 *
 * Revision 1.6  1993/09/27  16:35:25  robertj
 * Removed special constructor for dialog resource loading.
 * Fixed standard string list item draw function colour setting.
 * Fixed graying of standard push buttons.
 *
 * Revision 1.5  1993/08/31  03:38:02  robertj
 * Added #if protection for platforms that haven't implemented everything yet.
 *
 * Revision 1.4  1993/08/24  00:27:59  robertj
 * Rearranged push button classes and reimplemented text/image buttons.
 *
 * Revision 1.3  1993/08/21  17:09:50  robertj
 * Fixed cursor setting in text editing controls
 *
 * Revision 1.2  1993/08/21  01:50:33  robertj
 * Made Clone() function optional, default will assert if called.
 *
 * Revision 1.1  1993/08/21  01:07:35  robertj
 * Initial revision
 *
 */

#include <pwlib.h>
#include <ctype.h>

#define new PNEW

//////////////////////////////////////////////////////////////////////////////
// PControl

#if defined (_PCONTROL)

void PControl::DefaultDimensions()
{
}


void PControl::TransferValue(int)
{
}


void PControl::UpdateMyCommandSources()
{
  if (notifyForStateUpdate && !callback.IsNULL())
    callback(*this, NotifyEnable);
}


PBalloon * PControl::OnBalloonHelp()
{
  if (balloonHelpText.IsEmpty())
    return parent->OnBalloonHelp();
  return new PBalloon(this, balloonHelpText);
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PStaticText

#if defined (_PSTATICTEXT)

PStaticText::PStaticText(PInteractor * parent, int align)
  : PNamedControl(parent)
{
  alignment = align;

  foregroundColour = parent->GetForegroundColour();
  backgroundColour = parent->GetBackgroundColour();
}


PStaticText::PStaticText(PInteractor * parent, const PString & str, int align)
  : PNamedControl(parent)
{
  alignment = align;

  foregroundColour = parent->GetForegroundColour();
  backgroundColour = parent->GetBackgroundColour();

  SetName(str);
  DefaultDimensions();
}


void PStaticText::DefaultDimensions()
{
  PDrawCanvas canvas(this);
  PDim dim = canvas.MeasureString(GetName());
  dim += PDim(1,1);

  PDIMENSION maxX = owner->GetScreenRect().Width()*4/5;
  if (dim.Width() > maxX)
    dim.SetWidth(maxX);

  SetDimensions(dim, LocalCoords);
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PStaticBox

#if defined (_PSTATICBOX)

PStaticBox::PStaticBox(PInteractor * parent)
  : PNamedControl(parent)
{
  foregroundColour = parent->GetForegroundColour();
  backgroundColour = parent->GetBackgroundColour();
}


PStaticBox::PStaticBox(PInteractor * parent, const PString & str)
  : PNamedControl(parent, str, PNotifier(), NULL)
{
  foregroundColour = parent->GetForegroundColour();
  backgroundColour = parent->GetBackgroundColour();
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PStaticIcon

#if defined (_PSTATICICON)

PStaticIcon::PStaticIcon(PInteractor * parent, const PIcon & icn)
  : PControl(parent, PNotifier(), NULL), icon(icn)
{
  SetIcon(icon);
  DefaultDimensions();

  foregroundColour = parent->GetForegroundColour();
  backgroundColour = parent->GetBackgroundColour();
}


void PStaticIcon::DefaultDimensions()
{
  SetDimensions(icon.GetDimensions(), PixelCoords);
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PStaticRect

#if defined (_PSTATICRECT)

PStaticRect::PStaticRect(PInteractor * parent)
  : PControl(parent, PNotifier(), NULL)
{
  SetBackgroundColour(owner->GetWindowFgColour());
}


PStaticRect::PStaticRect(PInteractor * parent, const PColour & colour)
  : PControl(parent, PNotifier(), NULL)
{
  SetBackgroundColour(colour);
}


PStaticRect::PStaticRect(PInteractorLayout * parent,
                PRESOURCE_ID ctlID, const PNotifier & notify, void * valuePtr)
  : PControl(parent, ctlID, notify, valuePtr)
{
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PEditBox

#if defined(_PEDITBOX)

BOOL PEditBox::OnEndInput()
{
  parent->OnControlNotify(*this, PEditBox::EndEdit);
  return TRUE;
}


void PEditBox::TransferValue(int option)
{
  if (valuePointer != NULL)
    if (option == NotifyUpdate)
      SetText(*(PString *)valuePointer);
    else
      *(PString *)valuePointer = GetText();
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PNumberEditBox

#if defined(_PNUMBEREDITBOX)

PNumberEditBox::PNumberEditBox(PInteractor * parent)
  : PEditBox(parent)
{
  nudgeUp = new NudgeButton(this, TRUE);
  nudgeUp->SetNotifier(PCREATE_NOTIFIER(Nudged));
  nudgeDown = new NudgeButton(this, FALSE);
  nudgeDown->SetNotifier(PCREATE_NOTIFIER(Nudged));
}


void PNumberEditBox::Nudged(NudgeButton & control, INT)
{
  if (&control == nudgeUp)
    AddNudge();
  else
    SubtractNudge();
}


PNumberEditBox::NudgeButton::NudgeButton(PNumberEditBox * parent, BOOL isUp)
  : PPushButton(parent),
    up(isUp)
{
}


void PNumberEditBox::NudgeButton::OnDrawFace(PCanvas & canvas,
                                       const PRect & rect, BOOL hasFocus, BOOL)
{
  if (up) {
    canvas.SetCurrentPosition(rect.Left(), rect.Bottom());
    canvas.DrawLine((rect.Left() + rect.Right())/2, rect.Top());
    canvas.DrawLine(rect.Right(), rect.Bottom());
    canvas.DrawLine(rect.Left(), rect.Bottom());
  }
  else {
    canvas.SetCurrentPosition(rect.Left(), rect.Top());
    canvas.DrawLine((rect.Left() + rect.Right())/2, rect.Bottom());
    canvas.DrawLine(rect.Right(), rect.Top());
    canvas.DrawLine(rect.Left(), rect.Top());
  }
  if (hasFocus)
    canvas.DrawFocusRect(rect);
}


#endif


//////////////////////////////////////////////////////////////////////////////
// PIntegerEditBox

#if defined(_PINTEGEREDITBOX)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -