예제 #1
0
파일: messages.c 프로젝트: lubing521/uTox
_Bool messages_mup(MESSAGES *m){

    if(m->iover != MSG_IDX_MAX) {
        MESSAGE *msg = m->data->data[m->iover];
        if(msg->msg_type == MSG_TYPE_TEXT){
            if(m->urlover != STRING_IDX_MAX && m->urlmdown) {
                char_t url[m->urllen + 1];
                memcpy(url, msg->msg + m->urlover, m->urllen * sizeof(char_t));
                url[m->urllen] = 0;
                openurl(url);
                m->urlmdown = 0;
            }
        }
    }

    //temporary, change this
    if(m->select) {
        char_t *lel = malloc(65536); //TODO: De-hardcode this value.
        setselection(lel, messages_selection(m, lel, 65536, 0));
        free(lel);


        m->select = 0;
    }

    m->idown = MSG_IDX_MAX;

    return 0;
}
예제 #2
0
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
		{
			char tmp[256];
            wsprintf(tmp, "%s %s", APPNAME, VERSION, COPYRIGHT, AUTHOR);
            SendDlgItemMessage(hwndDlg, ID_ABOUT_LINE1, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)tmp);
            
            wsprintf(tmp, "%s %s", COPYRIGHT, AUTHOR);
            SendDlgItemMessage(hwndDlg, ID_ABOUT_LINE2, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)tmp);

			int nBolds[] = {ID_ABOUT_LINE1};
			for(int i=0; i<sizeof(nBolds)/sizeof(nBolds[0]); i++)
			{
				LOGFONT lf;
				HWND hwnd = GetDlgItem(hwndDlg, nBolds[i]);				
				HFONT hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
				GetObject(hFont, sizeof(LOGFONT), &lf);
				lf.lfWeight = FW_BOLD;
				hFont = CreateFontIndirect(&lf);
				SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);
			}

            break;
		} // WM_INITDIALOG

        case WM_LBUTTONUP:
        case WM_MOUSEMOVE:
        {
        	HWND hwnd;
            RECT rc;
            POINT pt;
            
			for(int i=0; i<ARRAYSIZE(gWebControls); i++)
			{
				hwnd = GetDlgItem(hwndDlg, gWebControls[i].nCtrl);
				GetWindowRect(hwnd, &rc);
				GetCursorPos(&pt);
	            if(PtInRect(&rc, pt))
				{
					if(gWebControls[i].bHover == FALSE)
					{
						gWebControls[i].bHover = TRUE;
						RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW|RDW_INVALIDATE|RDW_ERASE);
					}

					SetCapture(hwndDlg);

					// set the cursor to hand
					HCURSOR hcursor;
					if((hcursor = LoadCursor(NULL, IDC_HAND)))
						SetCursor(hcursor);

					// goto url on btn up
					if(uMsg == WM_LBUTTONUP)
						openurl(gWebControls[i].pstrAddr);

					return FALSE;
				}

				if(gWebControls[i].bHover == TRUE)
				{
					gWebControls[i].bHover = FALSE;
					RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW|RDW_INVALIDATE|RDW_ERASE);
				}

			}

            // release mouse capture
            ReleaseCapture();

            break;
        } // WM_LBUTTONUP, WM_MOUSEMOVE
        
        case WM_CTLCOLORSTATIC:
		{
            HDC hdc = (HDC)wParam;
			HWND hwnd = (HWND)lParam;
			int nId = GetDlgCtrlID(hwnd);

			switch(nId)
			{
                case ID_ABOUT_WEB:	
				case ID_ABOUT_EMAIL:
				{
                    LOGFONT lf;
					HFONT hFont;
					WebCtrlInfo *info = GetWebControlInfo(nId);
					hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
					GetObject(hFont, sizeof(LOGFONT), &lf);
					if(info->bHover)
					{
                        //lf.lfUnderline = TRUE;
						SetTextColor(hdc, GetSysColor(COLOR_HOTLIGHT));
					}
					else
					{
						//lf.lfUnderline = FALSE;
						SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
					}
					hFont = CreateFontIndirect(&lf);
					SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, (LPARAM)FALSE);
					SetBkMode(hdc, TRANSPARENT);
					HBRUSH br = (HBRUSH)GetStockObject(NULL_BRUSH);
                    return ((LRESULT)br);
				}
			}
			break;

		} // WM_CTLCOLORSTATIC

	}
    return FALSE;
}
예제 #3
0
파일: messages.c 프로젝트: lubing521/uTox
_Bool messages_mdown(MESSAGES *m)
{
    m->idown = MSG_IDX_MAX;
    if(m->iover != MSG_IDX_MAX) {
        MESSAGE *msg = m->data->data[m->iover];
        switch(msg->msg_type) {
        case MSG_TYPE_TEXT:
        case MSG_TYPE_ACTION_TEXT: {
            if(m->urlover != STRING_IDX_MAX) {
                m->urlmdown = 1;
            }

            m->data->istart = m->data->iend = m->idown = m->iover;
            m->data->start = m->data->end = m->down = m->over;
            m->select = 1;
            break;
        }

        case MSG_TYPE_IMAGE: {
            MSG_IMG *img = (void*)msg;
            if(m->over) {
                if(!img->zoom) {
                    img->zoom = 1;
                    message_updateheight(m, msg, m->data);
                } else {
                    m->idown = m->iover;
                }
            }
            break;
        }

        case MSG_TYPE_FILE: {
            MSG_FILE *file = (void*)msg;
            if(m->over == 0) {
                break;
            }

            switch(file->status) {
            case FILE_TRANSFER_STATUS_NONE: {
                if(!msg->author) {
                    if(m->over == 2) {
                        savefilerecv(m->data->id, file);
                    } else if(m->over == 1) {
                        //decline
                        tox_postmessage(TOX_FILE_INCOMING_CANCEL, m->data->id, file->filenumber, NULL);
                    }
                } else if(m->over == 1) {
                    //cancel
                    tox_postmessage(TOX_FILE_OUTGOING_CANCEL, m->data->id, file->filenumber, NULL);
                }


                break;
            }

            case FILE_TRANSFER_STATUS_ACTIVE: {
                if(m->over == 2) {
                    //pause
                    tox_postmessage((msg->author ? TOX_FILE_OUTGOING_PAUSE : TOX_FILE_INCOMING_PAUSE), m->data->id, file->filenumber, NULL);
                } else if(m->over == 1) {
                    //cancel
                    tox_postmessage((msg->author ? TOX_FILE_OUTGOING_CANCEL : TOX_FILE_INCOMING_CANCEL), m->data->id, file->filenumber, NULL);
                }
                break;
            }

            case FILE_TRANSFER_STATUS_PAUSED_US: {
                if(m->over == 2) {
                    //resume
                    tox_postmessage((msg->author ? TOX_FILE_OUTGOING_RESUME : TOX_FILE_INCOMING_RESUME), m->data->id, file->filenumber, NULL);
                } else if(m->over == 1) {
                    //cancel
                    tox_postmessage((msg->author ? TOX_FILE_OUTGOING_CANCEL : TOX_FILE_INCOMING_CANCEL), m->data->id, file->filenumber, NULL);
                }
                break;
            }

            case FILE_TRANSFER_STATUS_PAUSED_THEM:
            case FILE_TRANSFER_STATUS_BROKEN: {
                //cancel
                if(m->over == 1) {
                    tox_postmessage((msg->author ? TOX_FILE_OUTGOING_CANCEL : TOX_FILE_INCOMING_CANCEL), m->data->id, file->filenumber, NULL);
                }
                break;
            }

            case FILE_TRANSFER_STATUS_COMPLETED: {
                if(m->over) {
                    if(file->inline_png) {
                        savefiledata(file);
                    } else {
                        openurl(file->path);
                    }
                }
                break;
            }
            }
            break;
        }
        }

        return 1;
    } else {
        if(m->data->istart != m->data->iend || m->data->start != m->data->end) {
            m->data->istart = 0;
            m->data->iend = 0;
            m->data->start = 0;
            m->data->end = 0;
            return 1;
        }
    }

    return 0;
}