示例#1
0
Bar::Item& ToolButton::Key(dword key)
{
	if(key) {
		accel = key;
		UpdateTip();
	}
	return *this;
}
示例#2
0
Bar::Item& ToolButton::Text(const char *txt)
{
	String newtext;
	ExtractAccessKey(txt, newtext);
	if(newtext != text) {
		text = newtext;
		UpdateTip();
		Refresh();
	}
	return *this;
}
示例#3
0
//----  --------------------------------------------------------------------------------------------------------
// Function:	TimerProc
// Required:	HWND hwnd - Unused
//		UINT uMsg - Unused
//		UINT idEvent - The event type
//		DWORD dwTime - Unused
// Returns:	None
// Purpose:	Tells us our timer tick has occurred - so update text with new time
//----  --------------------------------------------------------------------------------------------------------
LRESULT Applet::DoTimer(UINT idEvent)
{
  std::wstring tmp;

  if (idEvent == MOUSE_TIMER)
  {
    return BaseApplet::DoTimer(idEvent);
  }

  // Only draw the time if this is a timer event and the edit box isn't focused
  if (idEvent == ID_CLOCKTIMER)
  {
    time_t tVal;
    struct tm* stVal;

    _tzset(); /**< Grab the current timezone information for localtime to do it's job correctly */
    time(&tVal); /**< Grab the raw time */
    stVal = localtime(&tVal); /**< Format the rawtime to localtime */

    // Format the time
    tmp = ELwcsftime(pSettings->GetDisplayTimeFormat(), stVal);
    SetCommandText(tmp);

    tmp = ELwcsftime(pSettings->GetDisplayTipFormat(), stVal);
    UpdateTip(tmp);

    if (IsWindowVisible(mainWnd))
    {
      DrawAlphaBlend();
    }

    return 0;
  }

  return 1;
}
示例#4
0
void CActivityView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	UpdateTip(nFlags,point);
	CScrollView::OnLButtonUp(nFlags, point);
}
示例#5
0
void CActivityView::OnMouseMove(UINT nFlags, CPoint point) 
{
	UpdateTip(nFlags,point);
	CScrollView::OnMouseMove(nFlags, point);
}
示例#6
0
Bar::Item& ToolButton::Tip(const char *tip)
{
	tiptext = tip;
	UpdateTip();
	return *this;
}
示例#7
0
void Editor_CharAdded(SCNotification* ne, TriggerEditor* te) {
	// Process keys
	if(ne->ch == '\n') { // Automatic indent
		int pos = te->SendSciMessage(SCI_GETCURRENTPOS, 0, 0);
		int line = te->SendSciMessage(SCI_LINEFROMPOSITION, pos, 0);
		int curlinelen = te->SendSciMessage(SCI_LINELENGTH, line, 0);
		if(line == 0 || curlinelen > 2) return;

		// Get previous line
		int prevlinelen = te->SendSciMessage(SCI_LINELENGTH, line - 1, 0);
		char *s = new char[prevlinelen + 1];
		char *p = s;
		te->SendSciMessage(SCI_GETLINE, line - 1, (LPARAM)s);
		s[prevlinelen] = '\0';

		// Count indentation
		int indentn = 0;
		while(*p == ' ' || *p == '\t') {
			/**/ if(*p == ' ') indentn += 1;
			else if(*p == '\t') indentn += 4;
			p++;
		}

		indentn = (indentn + 3) / 4;


		// Count number of braces.
		int braceopening = 0;
		while(*p) {
			/**/ if(*p == '{') braceopening++;
			else if(*p == '}') braceopening--;
			p++;
		}

		indentn += braceopening;
		if(indentn < 0) indentn = 0;

		// Apply indentation
		char* tabstring = (char*)alloca(indentn + 1);
		memset(tabstring, '\t', indentn);
		tabstring[indentn] = '\0';
		te->SendSciMessage(SCI_REPLACESEL, 0, (LPARAM)tabstring);

		// Clearup
		delete[] s;
	}

	else if(ne->ch == '(') { // Call tip
		int pos = te->SendSciMessage(SCI_GETCURRENTPOS, 0, 0);
		if(pos == 0) return;

		// Get a word before '(' (current position).
		int wstart = te->SendSciMessage(SCI_WORDSTARTPOSITION, pos - 1, 0);
		int wend = te->SendSciMessage(SCI_WORDENDPOSITION, wstart, 1);

		Sci_TextRange tr;
		tr.chrg.cpMin = wstart;
		tr.chrg.cpMax = wend;
		tr.lpstrText = new char[wend - wstart + 1];
		te->SendSciMessage(SCI_GETTEXTRANGE, 0, (LPARAM)&tr);

		// Match the name with documented functions.
		UpdateTip(te, "", wstart, tr.lpstrText, 0);
		delete[] tr.lpstrText;
	}

	else if(ne->ch == ')') { // Call tip end.
		if(te->SendSciMessage(SCI_CALLTIPACTIVE, 0, 0)) {
			int calltip_start = te->SendSciMessage(SCI_CALLTIPPOSSTART, 0, 0);
			int current_pos = te->SendSciMessage(SCI_GETCURRENTPOS, 0, 0);
			int textlen = calltip_start - current_pos;
			const char* strstart = (const char*)
				te->SendSciMessage(SCI_GETRANGEPOINTER, calltip_start, textlen);

			int parenthesisn = 0;
			for(int i = 0 ; i < textlen ; i++) {
				/**/ if(strstart[i] == '(') parenthesisn++;
				else if(strstart[i] == ')') parenthesisn--;
				if(parenthesisn < 0) break; //parenthesis overmatched. Something's got wrong.
			}

			if(parenthesisn == 0) { // ')' is indicator of the end of condition/action function call.
				// Deaths(EPD(a), b, c, d)
				//             |=========+===== This won't cancel the calltip
				//                       |===== This will.
				//
				te->SendSciMessage(SCI_CALLTIPCANCEL, 0, 0);
				UpdateTip(te, NULL, -1, NULL, -1);
			}
		}
	}

	else {
		int current_pos = te->SendSciMessage(SCI_GETCURRENTPOS, 0, 0);
		int find_length = 1024;
		if(find_length > current_pos) find_length = current_pos;

		const char* strstart = (const char*)
			te->SendSciMessage(SCI_GETRANGEPOINTER, current_pos - find_length, find_length);
		const char* p = strstart + find_length - 1;

		int parenthesis_depth = 1;
		int argindex = 0;
		int argstartpos = -1;
		while(p >= strstart) {
			if(p == strstart) break;
			else if(*p == ')') parenthesis_depth++;
			else if(*p == '(') {
				parenthesis_depth--;
				if(parenthesis_depth == 0) break;
			}
			else if(*p == ',') {
				if(argstartpos == -1) {
					argstartpos = (p - strstart) + (current_pos - find_length);
				}
				
				if(parenthesis_depth == 1) {
					argindex++;
				}
			}
			p--;
		}

		if(parenthesis_depth != 0)  // cannot find matching function call start
		{
			IssueGeneralAutocomplete(te);
			return;
		}

		// ok we found starting parenthesis.
		int p_opening_pos = (p - strstart) + (current_pos - find_length);
		if(p_opening_pos == 0)  // Line starts with ( : Not a function call, at least.
		{
			IssueGeneralAutocomplete(te);
			return;
		}
		if(argstartpos == -1) argstartpos = p_opening_pos;
		argstartpos++;

		// Get text of current argument.
		char* thisarg = new char[current_pos - argstartpos + 1];
		int thisarglen = current_pos - argstartpos;
		// argstartpos = (p - strstart) + (current_pos - find_length);
		// p = argstartpos + strstart - (current_pos - find_length)
		strncpy(thisarg, strstart + find_length - current_pos + argstartpos, thisarglen);
		thisarg[thisarglen] = 0;


		// Get a word before '(' (current position).
		int wstart = te->SendSciMessage(SCI_WORDSTARTPOSITION, p_opening_pos - 1, 0);
		int wend = te->SendSciMessage(SCI_WORDENDPOSITION, wstart, 1);

		Sci_TextRange tr;
		tr.chrg.cpMin = wstart;
		tr.chrg.cpMax = wend;
		tr.lpstrText = new char[wend - wstart + 1];
		te->SendSciMessage(SCI_GETTEXTRANGE, 0, (LPARAM)&tr);

		// Match the name with documented functions.
		UpdateTip(te, thisarg, wstart, tr.lpstrText, argindex);
		delete[] thisarg;
		delete[] tr.lpstrText;
	}
}