Exemplo n.º 1
0
//__________________________________________________________________
void		_HYSequencePane::SelectAll (bool flag)
{
	if (flag)
	{
		if (selection.lLength!=columnStrings.lLength)
		{
			selection.Clear();
			vselection.Clear();
			selection.RequestSpace (columnStrings.lLength);
			for (long k=0;k<columnStrings.lLength;k++)
				selection<<k;
			BuildPane();
			_MarkForUpdate();
			SendSelectionChange();
		}
	}
	else
	{
		if (selection.lLength)
		{
			selection.Clear();
			BuildPane();
			_MarkForUpdate();
			SendSelectionChange();
		}
	}
}
Exemplo n.º 2
0
void            _HYPullDown::Deactivate  (void)
{
    _HYComponent::Deactivate();
    if (IsEnabled()) {
        _MarkForUpdate();
    }
}
Exemplo n.º 3
0
//__________________________________________________________________
void        _HYPullDown::EnableMenu      (bool flag)
{
    if (flag!=enabledFlag) {
        enabledFlag = flag;
        _EnableMenu    (flag);
        _MarkForUpdate ();
    }
}
Exemplo n.º 4
0
//__________________________________________________________________
void        _HYPullDown::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}
Exemplo n.º 5
0
//__________________________________________________________________
void		_HYSequencePane::CleanUpSequenceNames (void)
{
	bool	doSomething = false;
	
	_List		namesl;
	_AVLList	names (&namesl);	
	
	for    (long k=0; k<speciesIndex.lLength; k++)
	{
		_String * thisString = (_String*)rowHeaders (speciesIndex.lData[k]);
		if (!thisString->IsValidIdentifier(false))
		{
			BufferToConsole ("Changed ");
			StringToConsole(*thisString);
			thisString->ConvertToAnIdent(false);
			BufferToConsole (" to ");
			StringToConsole(*thisString);
			NLToConsole();
			doSomething = true;
		}
		
		_String * testString = new _String (*thisString);
		
		if (!testString)
			checkPointer (testString);
		
		long	tryThisSuffix = 2;
		
		while (names.Find (testString)>=0)
		{
			*testString = *thisString & '_' & tryThisSuffix;
			tryThisSuffix++;
		}
		
		if (tryThisSuffix>2)
		{
			BufferToConsole ("Changed ");
			StringToConsole(*thisString);
			BufferToConsole (" to ");
			StringToConsole(*testString);
			BufferToConsole (" to avoid duplicate identifiers\n");
			doSomething  = true;
			thisString->CopyDynamicString (testString,true);
		}
		else
			DeleteObject (testString);
		
		names.Insert(thisString);
		thisString->nInstances++;
	}
	
	if (doSomething)
	{
		SetHeaders (nil,true);
		_MarkForUpdate();
	}
}
Exemplo n.º 6
0
//__________________________________________________________________
void		_HYPullDown::ChangeSelection	 (long newSel, bool eventSend)
{
	if ((newSel>=0)&&(newSel<menuSelections.lLength))
	{
		selection = newSel;
		if (eventSend)
			SendSelectionChange();
		_MarkForUpdate();
	}
}
Exemplo n.º 7
0
void		_HYButtonBar::DeleteButton (long index)
{	
	long f = enabledButtons.BinaryFind(index);
	if (f>=0)
		enabledButtons.Delete(f);
	f = pullDownButtons.Find (index);
	if (f>=0)
		pullDownButtons.Delete (f);
	buttons.Delete(index);
	toolTips.Delete (index);
	_MarkForUpdate();
}	
Exemplo n.º 8
0
//__________________________________________________________________
void		_HYSequencePane::AlphabetizeSpecies (void)
{
	_List currentActiveNames;
	long  k;
	
	for (k=0; k<speciesIndex.lLength; k++)
		currentActiveNames << rowHeaders (speciesIndex.lData[k]);
		
	SortLists (&currentActiveNames,&speciesIndex);
	
	BuildPane ();
	_MarkForUpdate();
}
Exemplo n.º 9
0
void		_HYButtonBar::AddButton (Ptr p, _String* toolTip)
{
	if (p)
	{
		enabledButtons<<buttons.lLength;
		buttons<<(long)p;
		if (toolTip)
			toolTips && toolTip;
		else
			toolTips && & empty;
		_MarkForUpdate();
	}
}	
Exemplo n.º 10
0
//__________________________________________________________________
void		_HYSequencePane::MoveSpecies (long oldIndex, long newIndex)
{
	if ((newIndex!=oldIndex)&&(newIndex>=-1))
	{
		long c = speciesIndex.lData[oldIndex];
		speciesIndex.InsertElement ((BaseRef)c,newIndex+1,false,false);
		if (oldIndex>newIndex)
		{
			oldIndex++;
			newIndex++;
		}
		vselection.lData[0] = newIndex;
		speciesIndex.Delete(oldIndex);
		BuildPane();
		_MarkForUpdate();
	}
}
Exemplo n.º 11
0
//__________________________________________________________________
void		_HYSequencePane::SelectSequenceNames (_List& list, bool send)
{
	selection.Clear();
	vselection.Clear();
	
	for (long k=0; k<rowHeaders.lLength; k++)
	{
		_String * aSeq = (_String*)rowHeaders(speciesIndex.lData[k]);
		if (list.BinaryFind (aSeq) >= 0)
			vselection << k;
	}
	
	BuildPane();
	_MarkForUpdate();
	if (send)
		SendSelectionChange (true);
}
Exemplo n.º 12
0
//__________________________________________________________________
void		_HYSequencePane::BatchRenameSequences (_List& oldNames,_List& newNames)
{
	bool touched = false;
	for (long k=0; k<oldNames.lLength; k++)
	{
		long nID = rowHeaders.Find (oldNames(k));
		if (nID >= 0 && rowHeaders.Find (newNames(k)) < 0)
		{
			rowHeaders (nID)->Duplicate (newNames(k));
			touched = true;
		}
	}
	if (touched)
	{
		SetHeaders (nil,true);
		_MarkForUpdate();
	}
}
Exemplo n.º 13
0
//__________________________________________________________________
void		_HYSequencePane::SelectRange (_SimpleList& range, bool vert)
{
	if (vert)
	{
		selection.Clear();
		vselection.Clear();
		vselection.Duplicate(&range);
		vselection.Sort();	
	}	
	else
	{
		vselection.Clear();
		selection.Clear();
		selection.Duplicate(&range);
		selection.Sort();	
	}
	BuildPane();
	_MarkForUpdate();
}
Exemplo n.º 14
0
void		_HYSequencePane::SetNameDisplayMode (unsigned char newMode, bool update)
{
	if (nameDisplayFlags!=newMode)
	{
		nameDisplayFlags = newMode;
		if (newMode&HY_SEQUENCE_PANE_NAMES_SHORT)
			headerWidth = shortHeaderWidth;
		else
		if (newMode&HY_SEQUENCE_PANE_NAMES_ALL)
			headerWidth = fullHeaderWidth;
		else
			headerWidth = 0;

		if (update)
		{
			BuildPane();
			_MarkForUpdate();
		}
	}
}
Exemplo n.º 15
0
//__________________________________________________________________
void		_HYSequencePane::EditSequenceName (long k)
{
	_String prompt ("Edit Sequence Name"),
			*present = ((_String*)rowHeaders (speciesIndex.lData[k])),
			edited = *present;
						
	if (EnterStringDialog ( edited, prompt,(Ptr)messageRecipient))
	{
		if (!edited.Equal (present))
		{
			if (rowHeaders.Find (&edited)>=0)
			{
				prompt = _String("Another sequence is already named ") & edited & ". Please choose another name.";
				ProblemReport (prompt, (Ptr)messageRecipient);	
				return;
			}
			present->Duplicate (&edited);
			SetHeaders (nil,true);
			_MarkForUpdate();
		}
	}
}
Exemplo n.º 16
0
bool _HYSequencePane::_ProcessOSEvent (Ptr vEvent)
{
    static  bool    amScrolling = false,
                    vertical;

    static  POINT   localPt;

    static  long    originalStart,
            originalSpan,
            lastClick,
            firstClick;

    if (_HYPlatformComponent::_ProcessOSEvent (vEvent)) {
        return true;
    }
    if (!active) {
        return false;
    }

    short lastH, lastV;
    POINT globalPt;

    _HYWindowsUIMessage*    theEvent = (_HYWindowsUIMessage*)vEvent;

    switch (theEvent->iMsg) {
    case WM_RBUTTONDOWN:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
        {

            lastH = (short)LOWORD (theEvent->lParam),
            lastV = (short)HIWORD (theEvent->lParam);

            globalPt = (POINT) {
                lastH, lastV
            };

            localPt  = (POINT) {
                lastH - rel.left , lastV - rel.top
            };

            vertical = (localPt.x<headerWidth)&&(localPt.y>=(GetSlotHeight()+1));


            if ((theEvent->iMsg == WM_LBUTTONDOWN)||(theEvent->iMsg == WM_LBUTTONDBLCLK)) {
                forceUpdateForScrolling = true;
                if (vertical)
                    ProcessVSelectionChange (localPt.x,localPt.y,GetAsyncKeyState (VK_SHIFT) & 0x8000,
                                             GetAsyncKeyState (VK_CONTROL) & 0x8000, false, theEvent->iMsg == WM_LBUTTONDBLCLK);
                else
                    ProcessSelectionChange  (localPt.x,localPt.y,GetAsyncKeyState (VK_SHIFT) & 0x8000,
                                             GetAsyncKeyState (VK_CONTROL) & 0x8000);
                forceUpdateForScrolling = false;

                ClientToScreen (parentWindow, &globalPt);

                if (DragDetect (parentWindow, globalPt)) {
                    if (messageRecipient) {
                        SetCapture (parentWindow);
                        ((_HYTWindow*)messageRecipient)->trackMouseComponent = this;
                    }
                    amScrolling = true;
                    if (vertical) {
                        originalStart = startRow,
                        originalSpan  = endRow-startRow;
                        lastClick = -2;
                        firstClick = (localPt.y-(GetSlotHeight()+1))/GetSlotHeight();
                    }
                }

                return true;
            }

            if ((theEvent->iMsg == WM_RBUTTONDOWN)&&(vertical&&vselection.lLength)||((!vertical)&&selection.lLength)) {
                ClientToScreen (parentWindow, &globalPt);
                ProcessContextualPopUp (globalPt.x, globalPt.y);
                return true;
            }
        }
        break;

    case WM_LBUTTONUP:
        if (amScrolling) {
            amScrolling = false;
            if (messageRecipient) {
                ReleaseCapture ();
                ((_HYTWindow*)messageRecipient)->trackMouseComponent = nil;
            }
            if  (vertical) {
                RECT invalRect = {rel.left,rel.top+(GetSlotHeight()+1)+1,rel.left+headerWidth,rel.bottom-HY_SCROLLER_WIDTH};
                InvalidateRect (parentWindow,&invalRect,false);
                if ((localPt.x<headerWidth)&&(localPt.x>0)&&(lastClick>-2)) {
                    MoveSpecies (firstClick+originalStart,lastClick+startRow);
                }
            }
        }
        return true;
        break;

    case WM_MOUSEMOVE:
        if ((theEvent->wParam & MK_LBUTTON)&&(amScrolling)) {
            POINT mousePt = {((short)LOWORD (theEvent->lParam))-rel.left,
                             ((short)HIWORD (theEvent->lParam))-rel.top
                            };
            if (vertical) {

                long  wHeight = rel.bottom-rel.top-HY_SCROLLER_WIDTH,
                      slotHeight = GetSlotHeight();


                forceUpdateForScrolling = true;
                if ((mousePt.y<(GetSlotHeight()+1))||(localPt.y!=mousePt.y)||(mousePt.y>wHeight)) {
                    localPt = mousePt;
                    if (mousePt.y>wHeight) {
                        // scroll down
                        if ((endRow<=speciesIndex.lLength)&&(vselection.lData[0]!=speciesIndex.lLength-1)) {
                            if (endRow-startRow<originalSpan) {
                                break;
                            }
                            startRow++;
                            endRow++;
                            _SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/
                                             (speciesIndex.lLength-endRow+startRow+1));
                            BuildPane();
                            _MarkForUpdate();
                            lastClick = -2;
                        }
                        break;
                    } else {
                        mousePt.y-=(GetSlotHeight()+1);
                        if (mousePt.y<=slotHeight) {
                            if (mousePt.y>=0) {
                                if (mousePt.y<slotHeight/2) {
                                    mousePt.y = -1;
                                } else {
                                    mousePt.y = 0;
                                }
                            } else {
                                // scroll up
                                if (startRow>0) {
                                    startRow--;
                                    endRow--;
                                    _SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/(speciesIndex.lLength-endRow+startRow+1));
                                    BuildPane();
                                    _MarkForUpdate();
                                    lastClick = -2;
                                }
                                break;
                            }
                        } else {
                            mousePt.y=(mousePt.y-(GetSlotHeight()+1))/slotHeight;
                        }
                    }

                    if ((mousePt.y<-1)||(mousePt.y>=(endRow-startRow))) {
                        break;
                    }
                    if (mousePt.y!=lastClick) {
                        HDC winDC    = GetDC   (parentWindow);
                        int saveROP2 = GetROP2 (winDC);
                        SetROP2 (winDC,R2_NOT);
                        if (lastClick>=-1) {
                            lastClick = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
                            MoveToEx(winDC,rel.left+1,lastClick,nil);
                            LineTo  (winDC,rel.left+headerWidth-1,lastClick);
                        }
                        lastClick = mousePt.y;
                        if (lastClick+startRow!=firstClick+originalStart) {
                            mousePt.y = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
                            MoveToEx (winDC,rel.left+1,mousePt.y,nil);
                            LineTo   (winDC,rel.left+headerWidth-1,mousePt.y);
                        }
                        SetROP2 (winDC,saveROP2);
                        ReleaseDC (parentWindow,winDC);
                    }
                }
                forceUpdateForScrolling = false;
                return true;
            } else {
                if (((mousePt.x<headerWidth)&&(startColumn>0))||(localPt.x!=mousePt.x)||(mousePt.x>_HYCanvas::GetMaxW()-5)) {
                    forceUpdateForScrolling = true;
                    ProcessSelectionChange (mousePt.x,mousePt.y,true,true,true);
                    forceUpdateForScrolling = false;
                    localPt = mousePt;
                }
                return true;
            }
        }
        break;
    }

    return false;
}
Exemplo n.º 17
0
//__________________________________________________________________
void		_HYSequencePane::SetSequenceOrder (_SimpleList& no)
{
	speciesIndex.Duplicate (&no);
	BuildPane();
	_MarkForUpdate();
}
Exemplo n.º 18
0
//__________________________________________________________________
void		_HYSequencePane::ProcessSelectionChange (long h, long v, bool shift, bool command, bool drag)
{
	if (vselection.lLength)
	{
		vselection.Clear();
		SendSelectionChange(true);
	}
	if (drag)
	{
		long k = columnStrings.lLength-endColumn+startColumn+1,
			 scrollAmount = 0;
			 
		if ( h<headerWidth && v>GetSlotHeight()+1)
		// scroll in columns from the left
		{
			if (selection.lData[0]>startColumn)
			{
				h = selection.lData[0];
				for (v=h-1;v>=startColumn;v--)
					selection.InsertElement((BaseRef)v,0,false,false);
				BuildPane();
				if (startColumn == 0)
					_MarkForUpdate();
			}
			if (startColumn>0)
			{
				long dsc = abs(dragScrollCounter);
				
				if (dsc < 25)
					scrollAmount = 1;
				else
					if (dsc < 50)
						scrollAmount = 2;
					else
						if (dsc < 150)
							scrollAmount = 3;
						else
							scrollAmount = 5;
							
				if (scrollAmount>startColumn)
					scrollAmount = startColumn;
					
				if (selection.lData[0] >= startColumn)
				{
					for (dsc = startColumn-1; dsc>=startColumn-scrollAmount; dsc--)
						selection.InsertElement((BaseRef)(dsc),0,false,false);
				}
				else
				{
					if (selection.lLength)
					{
						if (selection.lLength < scrollAmount)
							scrollAmount = selection.lLength;
							
						if (selection.lData[selection.lLength] >= startColumn)
						{
							while (selection.lLength && (selection.lData[selection.lLength] >= startColumn))
								selection.Delete (selection.lLength-1);
							BuildPane();
						}
													
						for (dsc = 0; (dsc<scrollAmount)&&(selection.lLength>1); dsc++)
							selection.Delete (selection.lLength-1);
					}
				}

					
				HScrollPane(-scrollAmount);
				
				dragScrollCounter -= scrollAmount;
				
				_SetHScrollerPos(((double)MAX_CONTROL_VALUE*startColumn)/k);
				SendSelectionChange();	

				return;
			}
		}
		else
		{
			if (h>=_HYCanvas::GetMaxW()-5 && v>GetSlotHeight()+1)
			// scroll in columns from the right
			{
				if (selection.lData[selection.lLength-1]<endColumn-1)
				{
					for (v=selection.lData[selection.lLength-1]+1;v<endColumn;v++)
						selection<<v;
					BuildPane();
					if (endColumn==columnStrings.lLength)
						_MarkForUpdate();
				}
				if (endColumn<columnStrings.lLength)
				{
					long dsc = abs(dragScrollCounter);
					
					if (dsc < 25)
						scrollAmount = 1;
					else
						if (dsc < 50)
							scrollAmount = 2;
						else
							if (dsc < 150)
								scrollAmount = 3;
							else
								scrollAmount = 5;
								
					if (scrollAmount>columnStrings.lLength-endColumn)
						scrollAmount = columnStrings.lLength-endColumn;
						
						
					if ((!selection.lLength)||(selection.lData[selection.lLength-1]<=endColumn))
						for (dsc = endColumn; dsc<endColumn+scrollAmount; dsc++)
							selection << dsc;
					else
					{
						if (selection.lLength)
						{
							if (selection.lLength < scrollAmount)
								scrollAmount = selection.lLength;
								
							if (selection.lData[0] < endColumn)
							{
								while (selection.lLength && (selection.lData[0] < endColumn))
									selection.Delete (0);
								BuildPane();
							}
														
							for (dsc = 0; (dsc<scrollAmount)&&(selection.lLength>1); dsc++)
								selection.Delete (0);
						}
					}

						
					HScrollPane(scrollAmount);
					
					dragScrollCounter+= scrollAmount;

					_SetHScrollerPos(((double)MAX_CONTROL_VALUE*startColumn)/k);
					SendSelectionChange();	
					return;
				}
			}
			else
				dragScrollCounter = 0;
		}
	}
	else
		dragScrollCounter = 0;
		
	if ( h>headerWidth && v>GetSlotHeight()+1 )
	{
		v=startRow+(v-(GetSlotHeight()+1))/(GetFont().size+HY_SEQUENCE_PANE_CHAR_SPACING);
		
		long	k, 
				p = headerWidth+charWidth+HY_SEQUENCE_PANE_CHAR_SPACING/2;
				
		for (k=startColumn; k<endColumn; k++,p+=charWidth)
		// find which column was clicked
		{
			if (k&&(k%blockWidth==0))
			{
				p+=2;
			}
			if (p>=h)
				break;
		}
		h = k;
		if (shift)
		{
			if (recentClick!=-1)
			{
				if (h==recentClick) 
					return;

				_SimpleList   * saveSelection = nil;
				
				if ( !command || drag)
				{
					saveSelection = (_SimpleList*)selection.makeDynamic();
					selection.Clear();
				}
					
				if (h>recentClick)
				{
					k=recentClick;
					p=h;
				}
				else
				{
					p=recentClick;
					k=h;
				}
				//if (!drag)
				{
					if (!command||!selection.lLength||drag)
						for (v=k;v<=p;v++)
							selection<<v;
					else
					{
						for (v=k;v<=p;v++)
						{
							AddColumnToSelection(v);
						}
					}
				}
				if (saveSelection)
				{
					bool doUpdate = false;
					if (!saveSelection->Equal(selection))
						doUpdate = true;
					DeleteObject (saveSelection);
					if (!doUpdate)
						return;
				}
				BuildPane();
				_MarkForUpdate();
				SendSelectionChange();	
				return;
			}
		}
		else
		{
			if (command)
			{
				v = selection.BinaryFind (h);
				if (v>=0)
					selection.Delete(v);
				else
					selection.InsertElement ((BaseRef)h,-v-2,false,false);
				BuildPane();
				_MarkForUpdate();
				SendSelectionChange();	
				return;
			}		
		}
		//if (selection.BinaryFind(h)>0) return;
		selection.Clear();
		selection<<h;
		recentClick = h;
		BuildPane();
		_MarkForUpdate();
	}
	else
		if ((h<headerWidth)&&(v<(GetSlotHeight()+1)))
		{
			if ((!drag)&&selection.lLength)
			{
				selection.Clear();
				vselection.Clear();
				BuildPane();
				_MarkForUpdate();
			}
		}
	SendSelectionChange();	
}
Exemplo n.º 19
0
//__________________________________________________________________
void		_HYSequencePane::RevertFileOrder (void)
{
	speciesIndex.Sort();
	BuildPane ();
	_MarkForUpdate();
}
Exemplo n.º 20
0
//__________________________________________________________________
bool	_HYSequencePane::ProcessEvent(_HYEvent* e)
{
	if (e->EventClass() == _hyScrollingEvent)
	{
		long h,v,k,t;
		_String firstArg = e->EventCode().Cut (0,(v=e->EventCode().Find(','))-1);
		h = firstArg.toNum();
		firstArg = e->EventCode().Cut (v+1,-1);
		DeleteObject(e);
		v = firstArg.toNum();
		if (h||v)
		{
			if (h)
			{
				if (settings.width&HY_COMPONENT_H_SCROLL)
				{
					k = columnStrings.lLength-endColumn+startColumn+1;
					t = _GetHScrollerPos()*(_Parameter)k/MAX_CONTROL_VALUE;
					if (startColumn == t)
					{
						if (h>0)
							t++;
						else
							t--;
						_SetHScrollerPos((MAX_CONTROL_VALUE*(_Parameter)t)/k);
					}
					if (!v)
					{
						HScrollPane (t-startColumn);
						return true;
					}
					startColumn = t;
				}
				else
					HScrollPane (h);
					//startColumn += v;

			}
			else
			{
				if (settings.width&HY_COMPONENT_V_SCROLL)
				{
					k = RowCount()-endRow+startRow+1;
					t = (_GetVScrollerPos()*(_Parameter)k) /MAX_CONTROL_VALUE;
					if (startRow != t)
						startRow = t;
					else
					{
						if (v>0)
							startRow++;
						else
							startRow--;
						_SetVScrollerPos((MAX_CONTROL_VALUE*(_Parameter)startRow)/k);
					}
				}
				else
					startRow += v;
				BuildPane();
			}
			if (messageRecipient)
				messageRecipient->ProcessEvent (generateScrollEvent(0,0));

			_MarkForUpdate();
		}
		return true;
	}
	DeleteObject (e);
	return false;
}
Exemplo n.º 21
0
//__________________________________________________________________
void	_HYSequencePane::HScrollPane (long dx)
{
	#ifndef __HYPHY_GTK__
	if (abs(dx)>=endColumn-startColumn-5)
	#endif
	{
		startColumn+=dx;
		BuildPane();
		_MarkForUpdate();
		return;
	}
	
	long visWidth = _HYCanvas::GetMaxW()-headerWidth-5,
		 visHeight = _HYCanvas::GetMaxH()-5,
		 slotHeight = GetSlotHeight(),h,v,lastColor = -1,adx,
		 loopStart,loopEnd,selectionIndex = 0;
	
	if (settings.width&HY_COMPONENT_V_SCROLL) visWidth-=HY_SCROLLER_WIDTH;
	if (settings.width&HY_COMPONENT_H_SCROLL) visHeight-=HY_SCROLLER_WIDTH;

	if (dx>0)
	{
		if (endColumn+dx>columnStrings.lLength)
			dx = columnStrings.lLength-endColumn;
		adx = dx;
		v = (startColumn+dx)/blockWidth-startColumn/blockWidth;
		if (startColumn&&(startColumn%blockWidth==0)) v++;
		if ((startColumn+dx)&&((startColumn+dx)%blockWidth==0)) v--;
	}
	else
	{
		if  (startColumn<-dx)
			dx=-startColumn;
		adx = -dx;
		v = startColumn/blockWidth-(startColumn+dx)/blockWidth;
		if (startColumn&&(startColumn%blockWidth==0)) v--;
		if ((startColumn+dx)&&((startColumn+dx)%blockWidth==0)) v++;
	}
	if (!dx)
		return;
			
	StartDraw();
	
	h = adx*charWidth+2*v;
	_HYRect		r = {0,0,visHeight,0,1},
				backCharRect;
				
	visWidth+=headerWidth;

	startColumn+=dx;
	endColumn+=dx;

	if (dx>0)
	{
		r.left = headerWidth+1;
		r.right = visWidth;
		_SlideRect (r,0,-h);
	}
	else
	{
		r.left = headerWidth+1;
		r.right = visWidth;
		_SlideRect (r,0,h);
	}
	

	if (dx>0)
	{
		r.right = visWidth;
		r.left = r.right-h;
	}
	else
	{
		r.left = headerWidth+1;
		r.right = headerWidth+h+1;
	}
	SetColor	(backColor);
	FillRect	(r);
	_HYColor    blackC = {0,0,0}, 
				charColor = {0,0,0},
				selectColor = highlightColor;
				
	r.top = 0;
	if (numbers)
	{
		r.bottom = (GetSlotHeight()+1);
		SetColor(headerColor);
		FillRect(r);
		r.top = r.bottom;
	}
	else
		r.top = r.bottom = 0;
	SetColor	(blackC);

	if (settings.width&HY_COMPONENT_BORDER_T)
		DrawLine 	(r);

	if (settings.width&HY_COMPONENT_BORDER_B)
	{
		r.top = r.bottom = visHeight-1;
		DrawLine (r);
	}
	r.top = 0;
	if (dx<0)
	{		
		if (numbers)
		{
			SetColor (headerColor);
			r.bottom = (GetSlotHeight()+1);
			r.left = 0;
			r.right = headerWidth;	
			FillRect (r);
		}
		h = HY_SEQUENCE_PANE_CHAR_SPACING/2+headerWidth;
	}
	else
	{
		h = HY_SEQUENCE_PANE_CHAR_SPACING/2+headerWidth;
		for (v=startColumn;v<endColumn-dx;v++,h+=charWidth)
			if (v&&(v%blockWidth)==0)
				h+=2;
	}
	r.bottom = visHeight;
	loopStart = dx>0?endColumn-dx:startColumn;
	loopEnd =  dx>0?endColumn:startColumn-dx;
	
	if (loopStart<0) loopStart = 0;
	if (loopEnd<0) loopEnd = 0;
	if (loopStart>columnStrings.lLength) loopStart = columnStrings.lLength;
	if (loopEnd>columnStrings.lLength) loopEnd = columnStrings.lLength;
	
	for (long c = loopStart; c < loopEnd; c++,h+=charWidth)
	{
		bool isColumnSelected = false;
		if (selectionIndex<selection.lLength)
		{
			visWidth = selection.lData[selectionIndex];
			while ((visWidth<c)&&(selectionIndex<selection.lLength))
			{
				selectionIndex++;
				visWidth = selection.lData[selectionIndex];
			}
			if (c==visWidth)
			{
				if (!invertColors)
				{
					_HYRect invR;
					invR.top = (GetSlotHeight()+1)+1;
					invR.bottom = visHeight-1;
					invR.right = h+charWidth;
					invR.left = h-2;
					if (c&&(c%blockWidth==0))
						invR.right+=2;
					/*else
						if ((c+1==loopEnd)&&(dx>0))
							invR.right+=3;
					*/
					charColor = GetColor();
					SetColor (selectColor);
					FillRect (invR);
					SetColor (charColor);					
				}
				selectionIndex++;
				isColumnSelected = true;
			}
		}
		if (c&&(c%blockWidth==0))
		{
			SetColor (blackC);
			if (numbers)
			{
				_String number (c);
				
				#ifdef __MAC__
					visWidth = h-2-GetVisibleStringWidth(number);
				#else
					visWidth = h-2-GetVisibleStringWidth(number, font);
				#endif
				
				if (visWidth>headerWidth)
					DisplayText (number,slotHeight-3,visWidth,true);
			}
			r.left = r.right = h;
			DrawLine (r);
			SetColor (charColor);
			h+=2;
		}
		if (numbers)
			v = slotHeight+(GetSlotHeight()+1);
		else
			v = slotHeight;
		
		_String *thisString = (_String*)columnStrings(c);
		unsigned char topChar = showDots?thisString->sData[speciesIndex.lData[0]]:0;
		
		backCharRect = (_HYRect)
		{
			v-slotHeight+1,h-1,v+1,h+charWidth-1,0
		};
		if ((c+1)%blockWidth == 0)
			backCharRect.right++;
			
		for (long r = startRow; r < endRow; r++,v+=slotHeight)
		{
			/*unsigned char thisC = thisString->sData[speciesIndex.lData[r]];
			if (r&&(thisC==topChar))
				thisC = '.';
			if (colorMap[thisC]!=lastColor)
			{
				lastColor = colorMap[thisC];
				charColor = LongToHYColor(characterColors.lData[lastColor]);
				SetColor (charColor);
			}
			DisplayChar (thisC,v,h);*/
			unsigned char thisC = thisString->sData[speciesIndex.lData[r]];
			long	 myColor	= colorMap[thisC];
			
			if (r && thisC==topChar)
				thisC = '.';
			
			if (invertColors && !isColumnSelected)
			{
				charColor = LongToHYColor (characterColors.lData[myColor]);
				if ((long)charColor.R+charColor.G+charColor.B > 100)
				{
					SetColor (charColor);
					FillRect 	(backCharRect);
				}
				backCharRect.top += slotHeight;
				backCharRect.bottom += slotHeight;
				SetColor	(blackC);
			}
			else
				if (colorMap[thisC]!=lastColor)
				{
					lastColor = colorMap[thisC];
					charColor = LongToHYColor(characterColors.lData[lastColor]);
					SetColor (charColor);
				}
			DisplayChar (thisC,v,h);
		}
	}
	
	if (numbers&&(dx<0))
	{
		loopEnd--;
		v = loopEnd%blockWidth;
		visWidth = blockWidth-log(double(loopEnd+blockWidth-1))/log((double)blockWidth);

		if (adx<blockWidth)
		{
			loopStart = (startColumn-dx)%blockWidth;
			if ((startColumn-dx)/blockWidth!=startColumn/blockWidth)
			// scrolled thru a block divider
			{
				if (loopStart==0)
					h += (blockWidth-v-1)*charWidth;
				else
					h = 0;
			}
			else
			{
				if (loopStart>visWidth)
					h += (blockWidth-v-1)*charWidth;
				else
					h = 0;
			}
		}
		else
		{
			loopStart = (startColumn-dx)%blockWidth;
			
			if (loopStart) 
				if (loopStart>=visWidth)
					h -= (loopStart-blockWidth)*charWidth;
				else
					h = 0;

		}
		
		if (h)
		{
			_String number (v?((loopEnd/blockWidth)+1)*blockWidth:loopEnd);
			SetColor (blackC);
			#ifdef __MAC__
				visWidth = h-2-GetVisibleStringWidth(number);
			#else
				visWidth = h-2-GetVisibleStringWidth(number, font);
			#endif
			while ((visWidth < headerWidth)&&(number.sLength))
			{
				number.Trim (1,-1);
				#ifdef __MAC__
					visWidth = h-2-GetVisibleStringWidth(number);
				#else
					visWidth = h-2-GetVisibleStringWidth(number, font);
				#endif
			}
			if (number.sLength)
				DisplayText (number,slotHeight-3,visWidth,true);
		}
	}
	
	EndDraw();	
	if (messageRecipient)
		messageRecipient->ProcessEvent(generateScrollEvent(0,0));
	_MarkForUpdate();
}
Exemplo n.º 22
0
//__________________________________________________________________
void	_HYSequencePane::SetHighliteColor (_HYColor newColor)
{
	highlightColor = newColor;
	BuildPane();
	_MarkForUpdate();
}
Exemplo n.º 23
0
//__________________________________________________________________
void	_HYSequencePane::SetHeaderColor (_HYColor newColor)
{
	headerColor = newColor;
	BuildPane();
	_MarkForUpdate();
}
Exemplo n.º 24
0
//__________________________________________________________________
void		_HYSequencePane::ProcessVSelectionChange (long h, long v, bool shift, bool command, bool drag, bool editName)
{
	if (selection.lLength)
	{
		selection.Clear();
		BuildPane();
		_MarkForUpdate();
		SendSelectionChange();
	}

	if (drag)
		return;

	if ((h<headerWidth)&&(v>(GetSlotHeight()+1)))
	{
		long k, p;
		v = (v-(GetSlotHeight()+1))/(GetFont().size+HY_SEQUENCE_PANE_CHAR_SPACING)+startRow;
		if (v>=endRow)
			return;
			
		if (editName)
		{
			EditSequenceName (v);
			return;
		}
		
		if (shift)
		{
			if (recentClick!=-1)
			{
				if (v==recentClick) 
				{
					return;
				}
				if ((!command)||drag)
					vselection.Clear();
				if (v>recentClick)
				{
					k=recentClick;
					p=v;
				}
				else
				{
					p=recentClick;
					k=v;
				}
				if (!command||!vselection.lLength||drag)
					for (h=k;h<=p;h++)
						vselection<<h;
				else
				{
					for (h=k;h<=p;h++)
					{
						AddSpeciesToSelection(h);
					}
				}
				StartDraw();
				BuildHeaders();
				EndDraw();
				_MarkForUpdate();
				SendSelectionChange();	
				return;
			}
		}
		else
		{
			if (command)
			{
				h = vselection.BinaryFind (v);
				if (h>=0)
					vselection.Delete(h);
				else
					vselection.InsertElement ((BaseRef)v,-h-2,false,false);
				StartDraw();
				BuildHeaders();
				EndDraw();
				_MarkForUpdate();
				SendSelectionChange(true);
				return;
			}		
		}
		if (vselection.BinaryFind(v)>0) return;
		vselection.Clear();
		vselection<<v;
		recentClick = v;
		StartDraw();
		BuildHeaders();
		EndDraw();
		_MarkForUpdate();
	}
	
	SendSelectionChange(true);	
}
Exemplo n.º 25
0
//__________________________________________________________________
void	_HYSequencePane::SetBackColor (_HYColor newColor)
{
	backColor = newColor;
	BuildPane();
	_MarkForUpdate();
}
Exemplo n.º 26
0
bool _HYSequencePane::_ProcessOSEvent (Ptr vEvent)
{
	static			bool	amScrolling = false,
							vertical;
					
	static			long   localPt_x,
						   localPt_y,	
						   originalStart,
						   originalSpan,
						   lastClick,
						   firstClick;


	if (_HYPlatformComponent::_ProcessOSEvent (vEvent)) 
		return true;	
		
	_HY_GTK_UI_Message *theMessage = (_HY_GTK_UI_Message*)vEvent;
	if (active) 
	{
		gdouble   xc, 
				  yc;

		if (gdk_event_get_coords (theMessage->theEvent,&xc,&yc))
		{
			switch (theMessage->theEvent->type)
			{
				case GDK_BUTTON_PRESS:
				case GDK_2BUTTON_PRESS:
					{
						GdkEventButton * bevent = (GdkEventButton*)theMessage->theEvent;
						
						long  globalPt_x = xc,
							  globalPt_y = yc;
							  
						localPt_x = globalPt_x-rel.left-parentWindow->allocation.x;
						localPt_y = globalPt_y-rel.top-parentWindow->allocation.y;
							  
						vertical = (localPt_x<headerWidth)&&(localPt_y>=(GetSlotHeight()+1));

						if (((GdkEventButton*)bevent)->button == 1)
						{
							if (vertical)
								ProcessVSelectionChange (localPt_x,localPt_y,bevent->state & GDK_SHIFT_MASK,bevent->state & GDK_CONTROL_MASK, false, bevent->type == GDK_2BUTTON_PRESS);
							else
								ProcessSelectionChange  (localPt_x,localPt_y,bevent->state & GDK_SHIFT_MASK,bevent->state & GDK_CONTROL_MASK);
						}
						else
						{
							if ((((GdkEventButton*)bevent)->button == 2 || ((GdkEventButton*)bevent)->button == 3 )&& (vertical&&vselection.lLength || !vertical &&selection.lLength))
							{
								ProcessContextualPopUp (globalPt_x, globalPt_y);
								return true;
							}
						}
					}
					break;
				case GDK_BUTTON_RELEASE:
				case GDK_LEAVE_NOTIFY:
				{
					if (amScrolling)
					{
						if (messageRecipient)
							((_HYTWindow*)messageRecipient)->trackMouseComponent = (Ptr)nil;
							
						/*gdk_pointer_ungrab (((GdkEventButton*)theMessage->theEvent)->time);*/
						
						if  (vertical)
						{
							_HYRect invalRectH = {parentWindow->allocation.x+rel.left,
												  parentWindow->allocation.y+rel.top+(GetSlotHeight()+1)+1,rel.left+headerWidth,rel.bottom-HY_SCROLLER_WIDTH};
							GdkRectangle irect = HYRect2GDKRect(invalRectH);
							irect.x+=parentWindow->allocation.x;
							irect.y+=parentWindow->allocation.y;
							gdk_window_invalidate_rect (parentWindow->window, &irect, false);
							if ( localPt_x<headerWidth && localPt_x>0 && lastClick>-2)
								MoveSpecies (firstClick+originalStart,lastClick+startRow);
						}
						amScrolling = false;
					}
					break;
				}
					
				case GDK_MOTION_NOTIFY:
				{
					GdkEventMotion * motEvent = (GdkEventMotion*)theMessage->theEvent;
					if (motEvent->state & GDK_BUTTON1_MASK)
					{
						if (amScrolling)
						{
							gint mousePt_x = motEvent->x - rel.left - parentWindow->allocation.x,
								 mousePt_y = motEvent->y - rel.top  - parentWindow->allocation.y;
								 
							if (vertical) // vertical scrolling
							{
								long  wHeight = rel.bottom-rel.top-HY_SCROLLER_WIDTH,
									  slotHeight = GetSlotHeight();

								if ( mousePt_y <  GetSlotHeight()+1 || localPt_y != mousePt_y || mousePt_y>wHeight )
								{
									localPt_x = mousePt_x;
									localPt_y = mousePt_y;
									
									if (mousePt_y>wHeight)
									{
										// scroll down
										if ((endRow<=speciesIndex.lLength)&&(vselection.lData[0]!=speciesIndex.lLength-1))
										{
											if (endRow-startRow<originalSpan) 
												break;
											startRow++;
											endRow++;
											_SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/
															 (speciesIndex.lLength-endRow+startRow+1));
											BuildPane();
											forceUpdateForScrolling = true;
											_MarkForUpdate();
											forceUpdateForScrolling = false;
											lastClick = -2;
										}
										break;
									}
									else
									{
										mousePt_y-=(GetSlotHeight()+1);
										if (mousePt_y<=slotHeight)
										{
											if (mousePt_y>=0)
											{
												if (mousePt_y<slotHeight/2)
													mousePt_y = -1;
												else
													mousePt_y = 0;
											}
											else
											{
												// scroll up
												if (startRow>0)
												{
													startRow--;
													endRow--;
													_SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/(speciesIndex.lLength-endRow+startRow+1));
													BuildPane();
													forceUpdateForScrolling = true;
													_MarkForUpdate();
													forceUpdateForScrolling = false;
													lastClick = -2;
												}
												break;
											}
										}
										else
											mousePt_y=(mousePt_y-(GetSlotHeight()+1))/slotHeight;
									}
										
									if ( mousePt_y<-1 || mousePt_y>= endRow-startRow ) 
										break;
										
									if (mousePt_y!=lastClick)
									{
										GdkDrawable * tempDr = GDK_DRAWABLE(parentWindow->window);
										GdkGC * tempGC = gdk_gc_new (tempDr);

										GdkColor black = HYColorToGDKColor((_HYColor){0,0,0});
										gdk_gc_set_foreground (theContext, &black);

										gdk_gc_set_function (tempGC, GDK_INVERT);
										gdk_gc_set_line_attributes (tempGC, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
										if (lastClick>=-1)
										{
											lastClick = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
											gdk_draw_line  (tempDr,tempGC,parentWindow->allocation.x+rel.left+1,parentWindow->allocation.y+lastClick,
																		  parentWindow->allocation.x+rel.left+headerWidth-1,parentWindow->allocation.y+lastClick);

										}
										
										lastClick = mousePt_y;
										
										if (lastClick+startRow != firstClick+originalStart)
										{
											mousePt_y = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
											gdk_draw_line  (tempDr,tempGC,parentWindow->allocation.x+rel.left+1,parentWindow->allocation.y+mousePt_y,
																				parentWindow->allocation.x+rel.left+headerWidth-1,parentWindow->allocation.y+mousePt_y);
										}
										g_object_unref (tempGC);
									}
								}
								return true;
							}
							else // horizontal scrolling
							{
								long	rightWindowBound = _HYCanvas::GetMaxW()-HY_SCROLLER_WIDTH;
								guint32 serverTime = gdk_x11_get_server_time (parentWindow->window);
								if ( mousePt_x<headerWidth && startColumn>0 || localPt_x!=mousePt_x || mousePt_x> rightWindowBound)
								{
									forceUpdateForScrolling = true;
									if (mousePt_x<headerWidth && startColumn>0)
									{
										gint	  wx, wy;
										gdk_window_get_origin (parentWindow->window,&wx,&wy);
										wx += parentWindow->allocation.x+rel.left;
										wy += parentWindow->allocation.y+rel.top;
										do
										{
											guint32 serverTime2 = gdk_x11_get_server_time (parentWindow->window);
											if (serverTime2-serverTime < 100)
												ProcessSelectionChange (mousePt_x,mousePt_y,true,true,true);
											GdkModifierType keyDown;
											gdk_display_get_pointer (gdk_display_get_default(),NULL,&mousePt_x,&mousePt_y,&keyDown);
											mousePt_x -= wx;
											mousePt_y -= wy;
											serverTime = serverTime2;
											if ((keyDown & GDK_BUTTON1_MASK)==0)
												break;
												
											gtk_main_iteration_do(true);
										}
										while (mousePt_x<headerWidth && startColumn>0);
									}
									else
									{
										if (mousePt_x> rightWindowBound)
										{
											gint	  wx, wy;
											gdk_window_get_origin (parentWindow->window,&wx,&wy);
											wx += parentWindow->allocation.x;
											wy += parentWindow->allocation.y;
											do
											{
												guint32 serverTime2 = gdk_x11_get_server_time (parentWindow->window);
												if (serverTime2-serverTime < 100)
													ProcessSelectionChange (mousePt_x+HY_SCROLLER_WIDTH,mousePt_y,true,true,true);
												GdkModifierType keyDown;
												gdk_display_get_pointer (gdk_display_get_default(),NULL,&mousePt_x,&mousePt_y,&keyDown);
												mousePt_x -= wx;
												mousePt_y -= wy;
												serverTime = serverTime2;
												if ((keyDown & GDK_BUTTON1_MASK)==0)
													break;
													
												gtk_main_iteration_do(true);
											}
											while (mousePt_x> rightWindowBound && endColumn < columnStrings.lLength);
										}
										else
											if (serverTime-gdk_event_get_time(theMessage->theEvent) < 100)
												ProcessSelectionChange (mousePt_x,mousePt_y,true,true,true);	
									}
									
									forceUpdateForScrolling = false;
									localPt_x = mousePt_x;
									localPt_y = mousePt_y;
								}
								return true;
							}
						}					
						else
						{
							
							/*gdk_pointer_grab (parentWindow->window,false,
									  GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
									  NULL, NULL, (((GdkEventMotion*)theMessage->theEvent))->time);*/
											  
							if (messageRecipient)
								((_HYTWindow*)messageRecipient)->trackMouseComponent = (Ptr)((_HYComponent*)this);

							amScrolling = true;
							originalStart = startRow,
							originalSpan  = endRow-startRow;
							lastClick = -2;
							firstClick = (localPt_y-(GetSlotHeight()+1))/GetSlotHeight();
							return true;
						}					
					}
					break;
				}
			}
		}
	}


	return false;
}
Exemplo n.º 27
0
void		_HYSequencePane::ChangeHeaders (void)
{
	BuildPane();
	_MarkForUpdate();
	SendSelectionChange(true);
}