本文整理汇总了C++中GetSelection函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSelection函数的具体用法?C++ GetSelection怎么用?C++ GetSelection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSelection函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetSelection
const tmAction* FindCmdDlg::ActionList::GetSelectedAction() {
const int sel = GetSelection();
return sel == -1 ? NULL : m_items[sel].action;
}
开发者ID:khmerlovers,项目名称:e,代码行数:4,代码来源:FindCmdDlg.cpp
示例2: GetSelection
void wxFlatNotebook::SetSelection(size_t page)
{
if(page >= m_windows.GetCount())
return;
// Support for disabed tabs
if(!m_pages->GetEnabled(page) && m_windows.GetCount() > 1 && !m_bForceSelection)
return;
if( m_sendPageChangeEvent )
{
// Allow the user to veto the selection
int oldSelection = GetSelection();
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING, GetId());
event.SetSelection( (int)page );
event.SetOldSelection( oldSelection );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
if( !event.IsAllowed() )
{
return;
}
}
int curSel = m_pages->GetSelection();
// program allows the page change
Freeze();
if(curSel >= 0)
{
// Remove the window from the main sizer
m_mainSizer->Detach(m_windows[curSel]);
m_windows[curSel]->Hide();
}
if(m_windowStyle & wxFNB_BOTTOM)
{
m_mainSizer->Insert(0, m_windows[page], 1, wxEXPAND);
}
else
{
// We leave a space of 1 pixel around the window
m_mainSizer->Add(m_windows[page], 1, wxEXPAND);
}
m_windows[page]->Show();
Thaw();
m_mainSizer->Layout();
if( page != (size_t)m_pages->m_iActivePage )
//there is a real poge changing
m_pages->m_iPreviousActivePage = m_pages->m_iActivePage;
m_pages->m_iActivePage = (int)page;
m_pages->DoSetSelection(page);
if( m_sendPageChangeEvent )
{
// Fire event 'Page Changed'
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED, GetId());
event.SetSelection( (int)page );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
}
开发者ID:yasriady,项目名称:wxProjects,代码行数:67,代码来源:wxFlatNotebook.cpp
示例3: SourceSelectionDialog
void P3DPlantModelTreeCtrl::OnAppendBranchCopyClick
(wxCommandEvent &event)
{
P3DListDialog SourceSelectionDialog(NULL,wxID_ANY,wxT("Select group to copy"));
bool Done;
P3DPlantModel *PlantModel;
P3DBranchModel *BranchModel;
unsigned int BranchIndex;
PlantModel = P3DApp::GetApp()->GetModel();
BranchIndex = 0;
BranchModel = P3DPlantModel::GetBranchModelByIndex(PlantModel,BranchIndex);
while (BranchModel != 0)
{
SourceSelectionDialog.AddChoice(BranchModel->GetName());
BranchModel = P3DPlantModel::GetBranchModelByIndex(PlantModel,++BranchIndex);
}
SourceSelectionDialog.SetSelection(0);
if (SourceSelectionDialog.ShowModal() == wxID_OK)
{
int SourceBranchIndex;
SourceBranchIndex = SourceSelectionDialog.GetSelection();
if (SourceBranchIndex >= 0)
{
const P3DBranchModel *SourceBranchModel;
P3DBranchModel *ParentBranchModel;
P3DBranchModel *ChildBranchModel;
P3DStemModelWings *WingsStemModel;
const P3DBranchingAlg *SourceBranchingAlg;
P3DStemModel *NewStemModel;
P3DBranchingAlg *NewBranchingAlg;
P3DVisRangeState *NewVisRange;
float MinRange,MaxRange;
SourceBranchModel = P3DPlantModel::GetBranchModelByIndex(PlantModel,SourceBranchIndex);
ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel();
if (dynamic_cast<const P3DStemModelWings*>(SourceBranchModel->GetStemModel()) != 0)
{
if (ParentBranchModel->GetStemModel() == 0) /* trunk */
{
::wxMessageBox(wxT("\"Wings\" stem can be added to \"Tube\" stems only"),
wxT("Error"),
wxICON_ERROR | wxOK);
return;
}
}
ChildBranchModel = new P3DBranchModel();
ChildBranchModel->SetName
(GenerateClonedBranchName
(P3DApp::GetApp()->GetModel(),SourceBranchModel).c_str());
NewStemModel = SourceBranchModel->GetStemModel()->CreateCopy();
WingsStemModel = dynamic_cast<P3DStemModelWings*>(NewStemModel);
if (WingsStemModel != 0)
{
WingsStemModel->SetParent((P3DStemModelTube*)ParentBranchModel->GetStemModel());
}
ChildBranchModel->SetStemModel(NewStemModel);
if ((dynamic_cast<const P3DBranchingAlgBase*>(SourceBranchModel->GetBranchingAlg())) != 0)
{
if (ParentBranchModel->GetStemModel() == 0)
{
NewBranchingAlg = SourceBranchModel->GetBranchingAlg()->CreateCopy();
}
else
{
NewBranchingAlg = P3DApp::GetApp()->CreateBranchingAlgStd();
}
}
else
{
if (ParentBranchModel->GetStemModel() == 0)
{
NewBranchingAlg = new P3DBranchingAlgBase();
}
else
{
NewBranchingAlg = SourceBranchModel->GetBranchingAlg()->CreateCopy();
}
}
ChildBranchModel->SetBranchingAlg(NewBranchingAlg);
ChildBranchModel->SetMaterialInstance(SourceBranchModel->GetMaterialInstance()->CreateCopy());
//.........这里部分代码省略.........
开发者ID:Benjamin-L,项目名称:Dinosauria,代码行数:101,代码来源:p3dmedit.cpp
示例4: GetSelection
void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
COMPONENT* aComponent, int aFilterType )
{
wxArrayString newList;
wxString msg;
wxString oldSelection;
if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
oldSelection = m_footprintList[ GetSelection() ];
for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
{
if( aFilterType == UNFILTERED )
{
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetNickname() ),
GetChars( aList.GetItem( ii ).GetFootprintName() ) );
newList.Add( msg );
continue;
}
if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty()
&& !aList.GetItem( ii ).InLibrary( aLibName ) )
continue;
if( (aFilterType & BY_COMPONENT) && aComponent
&& !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetFootprintName() ) )
continue;
if( (aFilterType & BY_PIN_COUNT) && aComponent
&& aComponent->GetNetCount() != aList.GetItem( ii ).GetPadCount() )
continue;
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetNickname() ),
GetChars( aList.GetItem( ii ).GetFootprintName() ) );
newList.Add( msg );
}
if( newList == m_footprintList )
return;
m_footprintList = newList;
int selection = m_footprintList.Index( oldSelection );
if( selection == wxNOT_FOUND )
selection = 0;
DeleteAllItems();
if( m_footprintList.GetCount() )
{
SetItemCount( m_footprintList.GetCount() );
SetSelection( selection, true );
RefreshItems( 0L, m_footprintList.GetCount()-1 );
#if defined (__WXGTK__ ) //&& wxMINOR_VERSION == 8
// @bug On GTK and wxWidgets 2.8.x, this will assert in debug builds because the
// column parameter is -1. This was the only way to prevent GTK3 from
// ellipsizing long strings down to a few characters. It still doesn't set
// the scroll bars correctly (too short) but it's better than any of the
// other alternatives. If someone knows how to fix this, please do.
SetColumnWidth( -1, wxLIST_AUTOSIZE );
#else
SetColumnWidth( 0, wxLIST_AUTOSIZE );
#endif
}
}
开发者ID:Th0rN13,项目名称:kicad-source-mirror,代码行数:70,代码来源:class_footprints_listbox.cpp
示例5: Mark
void thBarViewCtrl::OnMouseLeave(wxMouseEvent &event)
{
Mark(GetSelection());
}
开发者ID:pulsa,项目名称:t.hex,代码行数:4,代码来源:BarViewCtrl.cpp
示例6: dc
void wxTabbedCtrl::OnPaint(wxPaintEvent &) {
wxPaintDC dc(this);
wxSize size = GetSize();
wxBrush back_brush = wxBrush(GetBackgroundColour());
wxBrush nosel_brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
wxBrush sel_brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
wxPen border_pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
wxPen sel_pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
wxPen back_pen = wxPen(GetBackgroundColour());
wxFont normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont bold_font = normal_font;
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
bool mirror = style & wxTB_BOTTOM;
bool fullborder = !(style & wxNO_BORDER);
dc.BeginDrawing();
//background
dc.SetTextBackground(GetBackgroundColour());
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
dc.SetBrush(back_brush);
if(fullborder) {
dc.SetPen(border_pen);
dc.DrawRectangle(0, 0, size.x, size.y);
}
else {
dc.SetPen(back_pen);
dc.DrawRectangle(0, 0, size.x, size.y);
dc.SetPen(border_pen);
dc.DrawLine(0, mirror ? 0 : size.y-1, size.x, mirror ? 0 : size.y-1);
}
int height, width, pom;
dc.SetFont(bold_font);
dc.GetTextExtent("Aq", &pom, &height);
int posx = 3;
//and tabs
int i = m_intStartPage;
for( ; i < GetPageCount(); i++) {
dc.SetPen(border_pen);
dc.SetFont((i==GetSelection()) ? bold_font : normal_font);
dc.SetBrush((i==GetSelection()) ? sel_brush : nosel_brush);
dc.GetTextExtent(GetPageText(i), &width, &pom);
int space = padding.x;
if( ( posx + width+space+padding.x + BUTTON_BAR_SIZE ) > size.x ) {
break;
}
dc.DrawRoundedRectangle(posx, size.y-height-padding.y*2, width+space+padding.x, height+padding.y*2+3, 3);
dc.DrawText(GetPageText(i), posx+space, size.y-height-padding.y);
if(i!=GetSelection())
dc.DrawLine(posx, size.y-1, posx+width+space+padding.x, size.y-1);
posx += width+space+padding.x;
}
m_intLastPage = i - 1;
//X
DrawX(hover, dc);
DrawNext( hover_next, dc );
DrawPrev( hover_prev, dc );
DrawMenu( hover_menu, dc );
dc.EndDrawing();
}
开发者ID:bihai,项目名称:fbide,代码行数:68,代码来源:wxmynotebook.cpp
示例7: GetPage
void CQueue::SetFocus()
{
GetPage(GetSelection())->SetFocus();
}
开发者ID:ErichKrause,项目名称:filezilla,代码行数:4,代码来源:queue.cpp
示例8: startingPresShell
nsresult
nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, PRBool aIsLinksOnly,
PRBool aIsFirstVisiblePreferred, PRBool aFindPrev,
PRUint16* aResult)
{
*aResult = FIND_NOTFOUND;
mFoundLink = nsnull;
mFoundEditable = nsnull;
mCurrentWindow = nsnull;
nsCOMPtr<nsIPresShell> startingPresShell (GetPresShell());
if (!startingPresShell) {
nsCOMPtr<nsIDocShell> ds = do_QueryReferent(mDocShell);
NS_ENSURE_TRUE(ds, NS_ERROR_FAILURE);
ds->GetPresShell(getter_AddRefs(startingPresShell));
mPresShell = do_GetWeakReference(startingPresShell);
}
nsCOMPtr<nsIPresShell> presShell(aPresShell);
if (!presShell) {
presShell = startingPresShell; // this is the current document
if (!presShell)
return NS_ERROR_FAILURE;
}
nsRefPtr<nsPresContext> presContext = presShell->GetPresContext();
if (!presContext)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> selection;
nsCOMPtr<nsISelectionController> selectionController =
do_QueryReferent(mSelectionController);
if (!selectionController) {
GetSelection(presShell, getter_AddRefs(selectionController),
getter_AddRefs(selection)); // cache for reuse
mSelectionController = do_GetWeakReference(selectionController);
} else {
selectionController->GetSelection(
nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
}
nsCOMPtr<nsISupports> startingContainer = presContext->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(startingContainer));
NS_ASSERTION(treeItem, "Bug 175321 Crashes with Type Ahead Find [@ nsTypeAheadFind::FindItNow]");
if (!treeItem)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShellTreeItem> rootContentTreeItem;
nsCOMPtr<nsIDocShell> currentDocShell;
nsCOMPtr<nsIDocShell> startingDocShell(do_QueryInterface(startingContainer));
treeItem->GetSameTypeRootTreeItem(getter_AddRefs(rootContentTreeItem));
nsCOMPtr<nsIDocShell> rootContentDocShell =
do_QueryInterface(rootContentTreeItem);
if (!rootContentDocShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISimpleEnumerator> docShellEnumerator;
rootContentDocShell->GetDocShellEnumerator(nsIDocShellTreeItem::typeContent,
nsIDocShell::ENUMERATE_FORWARDS,
getter_AddRefs(docShellEnumerator));
// Default: can start at the current document
nsCOMPtr<nsISupports> currentContainer = startingContainer =
do_QueryInterface(rootContentDocShell);
// Iterate up to current shell, if there's more than 1 that we're
// dealing with
PRBool hasMoreDocShells;
while (NS_SUCCEEDED(docShellEnumerator->HasMoreElements(&hasMoreDocShells)) && hasMoreDocShells) {
docShellEnumerator->GetNext(getter_AddRefs(currentContainer));
currentDocShell = do_QueryInterface(currentContainer);
if (!currentDocShell || currentDocShell == startingDocShell || aIsFirstVisiblePreferred)
break;
}
// ------------ Get ranges ready ----------------
nsCOMPtr<nsIDOMRange> returnRange;
nsCOMPtr<nsIPresShell> focusedPS;
if (NS_FAILED(GetSearchContainers(currentContainer,
(!aIsFirstVisiblePreferred ||
mStartFindRange) ?
selectionController.get() : nsnull,
aIsFirstVisiblePreferred, aFindPrev,
getter_AddRefs(presShell),
getter_AddRefs(presContext)))) {
return NS_ERROR_FAILURE;
}
PRInt16 rangeCompareResult = 0;
mStartPointRange->CompareBoundaryPoints(nsIDOMRange::START_TO_START, mSearchRange, &rangeCompareResult);
// No need to wrap find in doc if starting at beginning
PRBool hasWrapped = (rangeCompareResult < 0);
if (mTypeAheadBuffer.IsEmpty())
//.........这里部分代码省略.........
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:101,代码来源:nsTypeAheadFind.cpp
示例9: presShell
NS_IMETHODIMP
nsTypeAheadFind::Find(const nsAString& aSearchString, PRBool aLinksOnly,
PRUint16* aResult)
{
*aResult = FIND_NOTFOUND;
nsCOMPtr<nsIPresShell> presShell (GetPresShell());
if (!presShell) {
nsCOMPtr<nsIDocShell> ds (do_QueryReferent(mDocShell));
NS_ENSURE_TRUE(ds, NS_ERROR_FAILURE);
ds->GetPresShell(getter_AddRefs(presShell));
mPresShell = do_GetWeakReference(presShell);
}
nsCOMPtr<nsISelection> selection;
nsCOMPtr<nsISelectionController> selectionController =
do_QueryReferent(mSelectionController);
if (!selectionController) {
GetSelection(presShell, getter_AddRefs(selectionController),
getter_AddRefs(selection)); // cache for reuse
mSelectionController = do_GetWeakReference(selectionController);
} else {
selectionController->GetSelection(
nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
}
if (selection)
selection->CollapseToStart();
if (aSearchString.IsEmpty()) {
mTypeAheadBuffer.Truncate();
// These will be initialized to their true values after the first character
// is typed
mStartFindRange = nsnull;
mSelectionController = nsnull;
*aResult = FIND_FOUND;
return NS_OK;
}
PRBool atEnd = PR_FALSE;
if (mTypeAheadBuffer.Length()) {
const nsAString& oldStr = Substring(mTypeAheadBuffer, 0, mTypeAheadBuffer.Length());
const nsAString& newStr = Substring(aSearchString, 0, mTypeAheadBuffer.Length());
if (oldStr.Equals(newStr))
atEnd = PR_TRUE;
const nsAString& newStr2 = Substring(aSearchString, 0, aSearchString.Length());
const nsAString& oldStr2 = Substring(mTypeAheadBuffer, 0, aSearchString.Length());
if (oldStr2.Equals(newStr2))
atEnd = PR_TRUE;
if (!atEnd)
mStartFindRange = nsnull;
}
if (!mIsSoundInitialized && !mNotFoundSoundURL.IsEmpty()) {
// This makes sure system sound library is loaded so that
// there's no lag before the first sound is played
// by waiting for the first keystroke, we still get the startup time benefits.
mIsSoundInitialized = PR_TRUE;
mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
if (mSoundInterface && !mNotFoundSoundURL.Equals(NS_LITERAL_CSTRING("beep"))) {
mSoundInterface->Init();
}
}
#ifdef XP_WIN
// After each keystroke, ensure sound object is destroyed, to free up memory
// allocated for error sound, otherwise Windows' nsISound impl
// holds onto the last played sound, using up memory.
mSoundInterface = nsnull;
#endif
PRInt32 bufferLength = mTypeAheadBuffer.Length();
mTypeAheadBuffer = aSearchString;
PRBool isFirstVisiblePreferred = PR_FALSE;
// --------- Initialize find if 1st char ----------
if (bufferLength == 0) {
// If you can see the selection (not collapsed or thru caret browsing),
// or if already focused on a page element, start there.
// Otherwise we're going to start at the first visible element
PRBool isSelectionCollapsed = PR_TRUE;
if (selection)
selection->GetIsCollapsed(&isSelectionCollapsed);
// If true, we will scan from top left of visible area
// If false, we will scan from start of selection
isFirstVisiblePreferred = !atEnd && !mCaretBrowsingOn && isSelectionCollapsed;
if (isFirstVisiblePreferred) {
// Get the focused content. If there is a focused node, ensure the
// selection is at that point. Otherwise, we will just want to start
// from the caret position or the beginning of the document.
nsPresContext* presContext = presShell->GetPresContext();
NS_ENSURE_TRUE(presContext, NS_OK);
//.........这里部分代码省略.........
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:101,代码来源:nsTypeAheadFind.cpp
示例10: GetSelection
// Create a command list node.
void KeyboardPage::CreateNode( int nType, LPVOID lpvData )
{
// Get the currently selected keyboard hash.
LPHASH pHash = GetSelection();
LPCNODE pCNode = NULL;
if ( pHash )
{
// Allocate node.
pCNode = ( LPCNODE )::AllocPooled( pParserPool, sizeof( CNODE ));
if ( pCNode != NULL )
{
// Setup type.
pCNode->nType = nType;
// Hardcoded?
if ( nType == CTYPE_HARDCODED )
// Setup function.
pCNode->lpFunc = ::FindCommand(( int )lpvData );
else
{
// Allocate string copy.
pCNode->pcStr = ::CopyStringPool( pParserPool, ( LPCTSTR )lpvData );
if ( pCNode->pcStr == NULL )
{
// Failure.
MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
::FreePooled( pParserPool, pCNode );
pCNode = NULL;
}
}
}
else
MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
}
// Still there?
if ( pCNode )
{
// Add the node to the list.
AddTail(( LPLIST )pHash->lpCommands, ( LPNODE )pCNode );
// Add it to the listview.
int nSel = m_Commands.AddString(( LPCTSTR )pCNode );
if ( nSel != LB_ERR )
{
// Select the entry.
m_Commands.SetCurSel( nSel );
// Edit the node.
SendMessage( WM_COMMAND, MAKEWPARAM( IDC_COMMANDS, LBN_DBLCLK ), ( LPARAM )m_Commands.GetSafeHWND());
// Changes have been made.
pSettings->Changed( m_pParser );
SetupControls();
}
else
{
// Show out of memory error. Guess this should be the
// only reason this could fail.
MessageBox( ClsString( MAKEINTRESOURCE( IDS_NO_MEMORY )), ClsGetApp()->GetAppTitle(), MB_ICONERROR | MB_OK );
// Free the node and
// it's string.
if ( nType != CTYPE_HARDCODED ) ::FreePooled( pParserPool, pCNode->pcStr );
::FreePooled( pParserPool, pCNode );
}
}
}
开发者ID:jcbaar,项目名称:BCC,代码行数:69,代码来源:KEYBOARD.CPP
示例11: switch
//.........这里部分代码省略.........
pCNode->nType = cTemp.nType;
pCNode->uCommand = cTemp.uCommand;
// Select the next item which
// in fact is the already selected
// item.
m_Commands.SetCurSel( m_Commands.GetCurSel() + 1 );
SetupControls();
pSettings->Changed( m_pParser );
return 0;
}
}
case IDS_INSERT:
CreateNode( CTYPE_TEXT, ( LPVOID )( LPCTSTR )ClsString( MAKEINTRESOURCE( IDS_NEWINSERT )));
return 0;
case IDS_HARDCODED:
CreateNode( CTYPE_HARDCODED, ( LPVOID )( ::GetCommandTable()->nCommandID ));
return 0;
case IDS_RUN:
CreateNode( CTYPE_RUN, ( LPVOID )( _T( "Calc.exe" )));
return 0;
case IDS_OPEN:
CreateNode( CTYPE_SHELLOPEN, ( LPVOID )( _T( "ReadMe.txt" )));
return 0;
case IDC_KEYS:
if ( nNotifyCode == LBN_SELCHANGE )
{
// Get the current selection.
LPHASH pSel = GetSelection();
if ( pSel )
{
// Clear the contents of the command list.
m_Commands.ResetContent();
// Add commands.
LPCNODE pNode;
for ( pNode = pSel->lpCommands->lpFirst; pNode->lpNext; pNode = pNode->lpNext )
m_Commands.AddString(( LPCTSTR )pNode );
}
}
// Setup controls.
SetupControls();
return 0;
case IDC_COMMANDS:
// Double-click?
if ( nNotifyCode == LBN_DBLCLK )
{
// Find the command node.
LPCNODE pCNode = ( LPCNODE )m_Commands.GetItemData( m_Commands.GetCurSel());
if ( pCNode != ( LPCNODE )LB_ERR )
{
// What's the type?
switch ( pCNode->nType )
{
case CTYPE_HARDCODED:
{
// Open the editor.
Hardcoded h;
if ( h.Select( *GetParent(), pCNode ))
{
开发者ID:jcbaar,项目名称:BCC,代码行数:67,代码来源:KEYBOARD.CPP
示例12: SetInputFocus
int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y)
{
static int startSelection = -1;
int textWidth;
string displayValue, originalValue;
void* fontResource = NULL;
if (mFont) fontResource = mFont->GetResource();
if (!isConditionTrue())
return -1;
if (!HasInputFocus) {
if (state != TOUCH_RELEASE)
return 0; // Only change focus if touch releases within the input box
if (GetSelection(x, y) >= 0) {
// When changing focus, we don't scroll or change the cursor location
PageManager::SetKeyBoardFocus(0);
PageManager::NotifyKeyboard(0);
SetInputFocus(1);
DrawCursor = true;
mRendered = false;
}
} else {
switch (state) {
case TOUCH_HOLD:
case TOUCH_REPEAT:
break;
case TOUCH_START:
startSelection = GetSelection(x,y);
lastX = x;
DrawCursor = false;
mRendered = false;
break;
case TOUCH_DRAG:
// Check if we dragged out of the selection window
if (GetSelection(x, y) == -1) {
lastX = 0;
break;
}
DrawCursor = false;
// Provide some debounce on initial touches
if (startSelection != -1 && abs(x - lastX) < 6) {
break;
}
startSelection = -1;
if (lastX != x)
HandleTextLocation(x);
break;
case TOUCH_RELEASE:
// We've moved the cursor location
int relativeX = x - mRenderX;
mRendered = false;
DrawCursor = true;
DataManager::GetValue(mVariable, displayValue);
if (HasMask) {
int index, string_size = displayValue.size();
string maskedValue;
for (index=0; index<string_size; index++)
maskedValue += mMask;
displayValue = maskedValue;
}
if (displayValue.size() == 0) {
skipChars = 0;
mCursorLocation = -1;
return 0;
} else if (skipChars && skipChars < displayValue.size()) {
displayValue.erase(0, skipChars);
}
string cursorString;
int cursorX = 0;
unsigned index = 0;
for(index=0; index<displayValue.size(); index++)
{
cursorString = displayValue.substr(0, index);
cursorX = gr_measureEx(cursorString.c_str(), fontResource) + mRenderX;
if (cursorX > x) {
if (index > 0)
mCursorLocation = index - 1;
else
mCursorLocation = index;
return 0;
}
}
mCursorLocation = -1;
break;
}
}
return 0;
}
开发者ID:Thunder07,项目名称:Team-Win-Recovery-Project,代码行数:98,代码来源:input.cpp
示例13: switch
int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y)
{
static int lastY = 0, last2Y = 0;
int selection = 0;
switch (state)
{
case TOUCH_START:
if (scrollingSpeed != 0)
startSelection = -1;
else
startSelection = GetSelection(x,y);
isHighlighted = (startSelection > -1);
if (isHighlighted)
mUpdate = 1;
startY = lastY = last2Y = y;
scrollingSpeed = 0;
break;
case TOUCH_DRAG:
// Check if we dragged out of the selection window
if (GetSelection(x, y) == -1) {
last2Y = lastY = 0;
if (isHighlighted) {
isHighlighted = false;
mUpdate = 1;
}
break;
}
// Fast scroll
if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
{
int pct = ((y-mRenderY-mHeaderH)*100)/(mRenderH-mHeaderH);
int totalSize = mList.size();
int lines = (mRenderH - mHeaderH) / (actualLineHeight);
float l = float((totalSize-lines)*pct)/100;
if(l + lines >= totalSize)
{
mStart = totalSize - lines;
scrollingY = 0;
}
else
{
mStart = l;
scrollingY = -(l - int(l))*actualLineHeight;
}
startSelection = -1;
mUpdate = 1;
scrollingSpeed = 0;
isHighlighted = false;
break;
}
// Provide some debounce on initial touches
if (startSelection != -1 && abs(y - startY) < touchDebounce) {
isHighlighted = true;
mUpdate = 1;
break;
}
isHighlighted = false;
last2Y = lastY;
lastY = y;
startSelection = -1;
// Handle scrolling
scrollingY += y - startY;
startY = y;
while(mStart && scrollingY > 0) {
mStart--;
scrollingY -= actualLineHeight;
}
if (mStart == 0 && scrollingY > 0)
scrollingY = 0;
{
int totalSize = mList.size();
int lines = (mRenderH - mHeaderH) / (actualLineHeight);
if (totalSize > lines) {
int bottom_offset = ((int)(mRenderH) - mHeaderH) - (lines * actualLineHeight);
bottom_offset -= actualLineHeight;
while (mStart + lines + (bottom_offset ? 1 : 0) < totalSize && abs(scrollingY) > actualLineHeight) {
mStart++;
scrollingY += actualLineHeight;
}
if (bottom_offset != 0 && mStart + lines + 1 >= totalSize && scrollingY <= bottom_offset) {
mStart = totalSize - lines - 1;
scrollingY = bottom_offset;
} else if (mStart + lines >= totalSize && scrollingY < 0) {
mStart = totalSize - lines;
scrollingY = 0;
}
} else
scrollingY = 0;
}
//.........这里部分代码省略.........
开发者ID:Diconal,项目名称:android_bootable_recovery-twrp,代码行数:101,代码来源:listbox.cpp
示例14: LayerChanged
bool LayerChanged() { return GetSelection() != 0; }
开发者ID:FlyingJester,项目名称:sphere,代码行数:1,代码来源:MoveLayerDialog.hpp
示例15: switch
void WrappingTextView::KeyDown(const char *bytes, int32 numBytes)
{
if (IsEditable() && numBytes==1) {
m_last_key_was_del = (bytes[0]==B_DELETE);
switch( bytes[0]) {
case B_RIGHT_ARROW: {
// implement word-wise movement:
int32 mods = Window()->CurrentMessage()->FindInt32("modifiers");
if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) {
int32 len=TextLength();
int32 startPos, endPos;
GetSelection( &startPos, &endPos);
if (endPos==len)
break;
if (startPos==endPos && (mods & B_SHIFT_KEY))
m_selection_start=B_RIGHT_ARROW;
int32 wordStart, wordEnd;
if (mods & B_SHIFT_KEY && m_selection_start==B_LEFT_ARROW) {
do {
FindWord( startPos, &wordStart, &wordEnd);
if (wordEnd > wordStart+1)
break;
if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
break;
} while( ++startPos < len);
Select( MIN(endPos, wordEnd), endPos);
} else {
do {
FindWord( endPos, &wordStart, &wordEnd);
if (wordEnd > wordStart+1)
break;
if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
break;
} while( ++endPos < len);
if (mods & B_SHIFT_KEY) {
Select( startPos, wordEnd);
} else
Select( wordEnd, wordEnd);
}
ScrollToSelection();
} else
inherited::KeyDown( bytes, numBytes);
break;
}
case B_LEFT_ARROW: {
// implement word-wise movement:
int32 mods = Window()->CurrentMessage()->FindInt32("modifiers");
if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) {
int32 startPos, endPos;
GetSelection( &startPos, &endPos);
if (!startPos)
break;
if (startPos==endPos && (mods & B_SHIFT_KEY))
m_selection_start=B_LEFT_ARROW;
int32 wordStart, wordEnd;
if (mods & B_SHIFT_KEY && m_selection_start==B_RIGHT_ARROW) {
--endPos;
do {
FindWord( endPos, &wordStart, &wordEnd);
if (wordEnd > wordStart+1)
break;
if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
break;
} while( --endPos > 0);
Select( startPos, MAX( startPos, wordStart));
} else {
--startPos;
do {
FindWord( startPos, &wordStart, &wordEnd);
if (wordEnd > wordStart+1)
break;
if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
break;
} while( --startPos > 0);
if (mods & B_SHIFT_KEY)
Select( wordStart, endPos);
else
Select( wordStart, wordStart);
}
ScrollToSelection();
} else
inherited::KeyDown( bytes, numBytes);
break;
}
default:
inherited::KeyDown( bytes, numBytes);
break;
}
} else if ( numBytes == 1 ) {
// in read-only mode, we use cursor-keys to move scrollbar, and
// we remap HOME / END to the vertical scrollbar (not the horizontal,
// which is default).
switch( bytes[0]) {
case B_PAGE_UP:
case B_PAGE_DOWN:
case B_UP_ARROW:
case B_DOWN_ARROW:
case B_HOME:
case B_END: {
// move vertical scrollbar:
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Beam,代码行数:101,代码来源:WrappingTextView.cpp
示例16: GetSelection
bool CppSymbolTree::ActivateSelectedItem()
{
wxTreeItemId item = GetSelection();
wxTreeEvent dummy;
return DoItemActivated(item, dummy, true);
}
开发者ID:05storm26,项目名称:codelite,代码行数:6,代码来源:cpp_symbol_tree.cpp
示例17: GetPageIndexByWindow
void InfoPane::OnClear(wxCommandEvent& event)
{
int i = GetPageIndexByWindow(GetPage(GetSelection()));
if (page[i].islogger)
page[i].logger->Clear();
}
开发者ID:469306621,项目名称:Languages,代码行数:6,代码来源:infopane.cpp
示例18: switch
//.........这里部分代码省略.........
// cb = dynamic_cast<BComboBox*>Parent());
// ASSERT(cb);
// if (cb->fAutoComplete && cb->fCompletionIndex >= 0) {
// int32 from, to;
// cb->fText->GetSelection(&from, &to);
// if (from == to) {
// // HACK: this should never happen. The rest of the class
// // should be fixed so that fCompletionIndex is set to -1 if the
// // text is modified
// printf("BComboBox::TextInput::KeyDown() -- HACK! this shouldn't happen!");
// cb->fCompletionIndex = -1;
// }
//
// const char *text = cb->fText->Text();
// BString prefix;
// prefix.Append(text, from);
//
// int32 match;
// const char *completion;
// if (cb->fChoiceList->GetMatch( prefix.String(),
// cb->fCompletionIndex + 1,
// &match,
// &completion) == B_OK)
// {
// cb->fText->Delete(); // delete the selection
// cb->fText->Insert(completion);
// cb->fText->Select(from, from + strlen(completion));
// cb->fCompletionIndex = match;
// cb->Select(cb->fCompletionIndex);
// } else {
// //system_beep();
// }
// } else {
BView::KeyDown(bytes, numBytes);
// }
break;
#if 0
case B_UP_ARROW: // fall through
case B_DOWN_ARROW:
cb = dynamic_cast<BComboBox*>(Parent());
ASSERT(cb);
if (cb->fChoiceList) {
cb = dynamic_cast<BComboBox*>(Parent());
ASSERT(cb);
if (!(cb->fPopupWindow)) {
cb->fPopupWindow = cb->CreatePopupWindow();
}
if (cb->fPopupWindow->Lock()) {
// show popup window, if needed
if (cb->fPopupWindow->IsHidden()) {
cb->ShowPopupWindow();
} else {
printf("Whoa!!! Erroneously got up/down arrow key down in TextInput::KeyDown()!\n");
}
int32 index = cb->CurrentSelection();
int32 choices = cb->fChoiceList->CountChoices();
// select something, if no selection
if (index < 0 && choices > 0) {
if (aKey == B_UP_ARROW) {
cb->Select(choices - 1);
} else {
cb->Select(0);
}
}
cb->fPopupWindow->Unlock();
}
}
break;
#endif
case B_ESCAPE:
cb = dynamic_cast<BComboBox*>(Parent());
ASSERT(cb);
if (cb->fChoiceList)
{
cb = dynamic_cast<BComboBox*>(Parent());
ASSERT(cb);
if (cb->fPopupWindow && cb->fPopupWindow->Lock())
{
if (!cb->fPopupWindow->IsHidden())
cb->HidePopupWindow();
cb->fPopupWindow->Unlock();
}
}
break;
case ',':
{
int32 startSel, endSel;
GetSelection(&startSel, &endSel);
int32 length = TextLength();
if (endSel == length)
Select(endSel, endSel);
BTextView::KeyDown(bytes, numBytes);
}
break;
default:
BTextView::KeyDown(bytes, numBytes);
break;
}
}
开发者ID:anevilyak,项目名称:haiku,代码行数:101,代码来源:ComboBox.cpp
示例19: RefreshItem
void CDirstatDoc::OnRefreshselected()
{
// FIXME: Multi-select
RefreshItem(GetSelection(0));
}
开发者ID:JDuverge,项目名称:windirstat,代码行数:5,代码来源:dirstatdoc.cpp
示例20: GetHKClientData
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetSelHKClientData()
{
return GetHKClientData( GetSelection() );
}
开发者ID:Lotharyx,项目名称:kicad-source-mirror,代码行数:4,代码来源:widget_hotkey_list.cpp
注:本文中的GetSelection函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论