зеркало из https://github.com/mozilla/gecko-dev.git
208 строки
5.5 KiB
C++
208 строки
5.5 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (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/NPL/
|
|
*
|
|
* 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 mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
|
|
#include "CSelectionBroadcastingList.h"
|
|
|
|
#include <LStream.h>
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ CreateFromStream [static]
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void*
|
|
CSelectionBroadcastingList::CreateFromStream(
|
|
LStream *inStream)
|
|
{
|
|
return (new CSelectionBroadcastingList(inStream));
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ CSelectionBroadcastingList
|
|
// ---------------------------------------------------------------------------
|
|
|
|
CSelectionBroadcastingList::CSelectionBroadcastingList(
|
|
LStream *inStream)
|
|
: fAllowSelectionChange(true),
|
|
|
|
super(inStream)
|
|
{
|
|
inStream->ReadData(&fMessage, sizeof(fMessage));
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ ~CSelectionBroadcastingList
|
|
// ---------------------------------------------------------------------------
|
|
|
|
CSelectionBroadcastingList::~CSelectionBroadcastingList()
|
|
{
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ SetBroadcastMessage
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::SetBroadcastMessage(MessageT inMessage)
|
|
{
|
|
fMessage = inMessage;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ GetBroadcastMessage
|
|
// ---------------------------------------------------------------------------
|
|
|
|
MessageT
|
|
CSelectionBroadcastingList::GetBroadcastMessage()
|
|
{
|
|
return fMessage;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ SetValue
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::SetValue(Int32 inValue)
|
|
{
|
|
if (fAllowSelectionChange)
|
|
{
|
|
super::SetValue(inValue);
|
|
|
|
BroadcastMessage(fMessage, this);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ DoNavigationKey
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::DoNavigationKey(
|
|
const EventRecord &inKeyEvent)
|
|
{
|
|
int before = NumCellsSelected();
|
|
|
|
if (fAllowSelectionChange)
|
|
{
|
|
super::DoNavigationKey(inKeyEvent);
|
|
|
|
// if num selected hasn't changed, then don't send message
|
|
if (NumCellsSelected() != before)
|
|
BroadcastMessage(fMessage, this);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ DoTypeSelection
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::DoTypeSelection(
|
|
const EventRecord& inKeyEvent)
|
|
{
|
|
if (fAllowSelectionChange)
|
|
{
|
|
super::DoTypeSelection(inKeyEvent);
|
|
|
|
BroadcastMessage(fMessage, this);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ SelectOneCell
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::SelectOneCell(
|
|
Cell inCell)
|
|
{
|
|
if (fAllowSelectionChange)
|
|
{
|
|
super::SelectOneCell(inCell);
|
|
|
|
BroadcastMessage(fMessage, this);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ ClickSelf
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::ClickSelf(
|
|
const SMouseDownEvent &inMouseDown)
|
|
{
|
|
int before = NumCellsSelected();
|
|
|
|
if (fAllowSelectionChange)
|
|
{
|
|
super::ClickSelf(inMouseDown);
|
|
|
|
// if num selected hasn't changed, then don't send message
|
|
if (NumCellsSelected() != before)
|
|
BroadcastMessage(fMessage, this);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ DontAllowSelectionChange
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::DontAllowSelectionChange()
|
|
{
|
|
fAllowSelectionChange = false;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ AllowSelectionChange
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void
|
|
CSelectionBroadcastingList::AllowSelectionChange()
|
|
{
|
|
fAllowSelectionChange = true;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ¥ NumCellsSelected
|
|
// ---------------------------------------------------------------------------
|
|
|
|
int
|
|
CSelectionBroadcastingList::NumCellsSelected()
|
|
{
|
|
int numSelected = 0;
|
|
Cell currentCell = {0, 0};
|
|
Boolean hasSelection = ::LGetSelect(true, ¤tCell, mMacListH);
|
|
|
|
if (hasSelection)
|
|
{
|
|
do
|
|
{
|
|
if (::LGetSelect(true, ¤tCell, mMacListH))
|
|
numSelected++;
|
|
} while (::LNextCell(true, true, ¤tCell, mMacListH));
|
|
}
|
|
|
|
return numSelected;
|
|
}
|