Ejemplo n.º 1
0
/**
 * @param pView new focus view
 */
void CFrame::setFocusView (CView *pView)
{
	static bool recursion = false;
	if (pView == pFocusView || (recursion && pFocusView != 0))
		return;

	if (!bActive)
	{
		pActiveFocusView = pView;
		return;
	}

	recursion = true;

	CView *pOldFocusView = pFocusView;
	if (pView == 0  || (pView && pView->isAttached () == false))
		pFocusView = 0;
	else
		pFocusView = pView;
	if (pFocusView && pFocusView->wantsFocus ())
	{
		pFocusView->invalid ();

		CView* receiver = pFocusView->getParentView ();
		while (receiver != this && receiver != 0)
		{
			receiver->notify (pFocusView, kMsgNewFocusView);
			receiver = receiver->getParentView ();
		}
		notify (pFocusView, kMsgNewFocusView);
	}

	if (pOldFocusView)
	{
		if (pOldFocusView->wantsFocus ())
		{
			pOldFocusView->invalid ();

			CView* receiver = pOldFocusView->getParentView ();
			while (receiver != this && receiver != 0)
			{
				receiver->notify (pOldFocusView, kMsgOldFocusView);
				receiver = receiver->getParentView ();
			}
			notify (pOldFocusView, kMsgOldFocusView);
		}
		pOldFocusView->looseFocus ();
	}
	if (pFocusView && pFocusView->wantsFocus ())
		pFocusView->takeFocus ();
	recursion = false;
}
Ejemplo n.º 2
0
void CDisplayView::mouse(CDrawContext *dstcon, CPoint &where)
{
  unsigned long delta=250, ticks = getParent()->getTicks();
  bool dblclick = false;
	long button = dstcon->getMouseButtons();

  if (!(button & kLButton))
  {
		return;
  }

  dblclick = (ticks-stTicks)<delta;
  stTicks = ticks;

  if(dblclick)
  {
    if(mEdit)
    {
      getParent()->setEditView(this);
      setBackColor(kGreyCColor);
      setFontColor(kWhiteCColor);
      setText(mText);
      takeFocus(dstcon);
      mDrawText = true;
    }
  }
  else
  {
    if(mParentView)
    {
      mParentView->notify(mView,(const char *)VNTF_MOUSE);
      mParentView->mouse(dstcon,where);
    }
  }
}
Ejemplo n.º 3
0
void CDisplayView::valueChanged(CDrawContext *pContext, CControl *pControl)
{
  if(mParentView)
  {
    mParentView->notify(this,text);
    mFrame->setDirty();
  }
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------
void COptionMenu::looseFocus ()
{	
	CView* receiver = pParentView ? pParentView : pParentFrame;
	while (receiver)
	{
		if (receiver->notify (this, kMsgLooseFocus) == kMessageNotified)
			break;
		receiver = receiver->getParentView ();
	}
	CParamDisplay::looseFocus ();
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------
void CTextEdit::looseFocus ()
{
	if (platformControl == 0)
		return;

	IPlatformTextEdit* _platformControl = platformControl;
	platformControl = 0;
	
	updateText (_platformControl);
	
	_platformControl->forget ();

	// if you want to destroy the text edit do it with the loose focus message
	CView* receiver = pParentView ? pParentView : pParentFrame;
	while (receiver)
	{
		if (receiver->notify (this, kMsgLooseFocus) == kMessageNotified)
			break;
		receiver = receiver->getParentView ();
	}
}
Ejemplo n.º 6
0
void cBitmapFontEditable::takeFocus(CDrawContext *pContext) {
  if(!m_editing) {
    getText((char*)&m_old_buffer);
  }
  m_editing = true;
  
  if(m_edit_index) {
    m_edit_index = 0;
    memset(m_edit_buffer, 0x0, sizeof(char) * MAX_EDIT_CHARS);
  }
  setText(" ");
    
#if WINDOWS || MACX
	// calculate offset for CViewContainers
	CRect rect (size);
	CView* parent = getParentView ();
	CRect vSize;
	while (parent)
	{
		if (parent->notify (this, kMsgCheckIfViewContainer) == kMessageNotified)
		{
			parent->getViewSize (vSize);
			rect.offset (vSize.left, vSize.top);
		}
		parent = parent->getParentView ();
	}
	if (pContext)
		rect.offset (pContext->offset.h, pContext->offset.v);
#endif
  
#if WINDOWS
//	int wstyle = 0;
//	if (horiTxtAlign == kLeftText)
//		wstyle |= ES_LEFT;
//	else if (horiTxtAlign == kRightText)
//		wstyle |= ES_RIGHT;
//	else
//		wstyle |= ES_CENTER;
//  
//	wstyle |= WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
//	platformControl = (void*)CreateWindow (
//                                         "EDIT", text, wstyle,
//                                         rect.left, rect.top, rect.width ()/* + 1*/, rect.height ()/* + 1*/,
//                                         (HWND)getFrame ()->getSystemWindow (), NULL, GetInstance (), 0);
//  
//	// get/set the current font
//	LOGFONT logfont = {0};
//  
//	long fontH = gStandardFontSize [fontID];
//	if (fontH > rect.height () - 2)
//		fontH = rect.height () - 2;
//  
//	logfont.lfWeight = FW_NORMAL;
//	logfont.lfHeight = -fontH;
//	logfont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
//	strcpy (logfont.lfFaceName, gStandardFontName[fontID]);
//  
//	logfont.lfClipPrecision	 = CLIP_STROKE_PRECIS;
//	logfont.lfOutPrecision	 = OUT_STRING_PRECIS;
//	logfont.lfQuality 	     = DEFAULT_QUALITY;
//	logfont.lfCharSet        = ANSI_CHARSET;
//  
//	platformFont = (HANDLE)CreateFontIndirect (&logfont);
//	platformFontColor = 0;
//  
	SetWindowLongPtr ((HWND)platformControl, GWLP_USERDATA, (LONG_PTR)this);
//	SendMessage ((HWND)platformControl, WM_SETFONT, (WPARAM)platformFont, true);
	SendMessage ((HWND)platformControl, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG (0, 0));
//	SendMessage ((HWND)platformControl, EM_SETSEL, 0, -1);
	SendMessage ((HWND)platformControl, EM_LIMITTEXT, 255, 0);
	SetFocus ((HWND)platformControl);

	oldWndProcEdit = (WINDOWSPROC)SetWindowLongPtr ((HWND)platformControl, GWLP_WNDPROC, (LONG_PTR)WindowProcEdit);
  
#elif MAC
	WindowRef window = (WindowRef)getFrame()->getSystemWindow();
  SetUserFocusWindow(window);
  AdvanceKeyboardFocus(window);
  EventTypeSpec eventTypes[] = {
    { kEventClassMouse, kEventMouseDown },
    { kEventClassWindow, kEventWindowDeactivated },
    { kEventClassKeyboard, kEventRawKeyDown },
    { kEventClassKeyboard, kEventRawKeyRepeat }
  };
  InstallWindowEventHandler(window, TextControlProc, GetEventTypeCount(eventTypes),
                            eventTypes, this, &gEventHandler);
#endif
  
  setDirty();
}