Exemple #1
0
Contact::Contact(const std::string &jid,
				 const std::string &resource,
				 const std::string &nickname,
				 const std::string &statusMessage,
				 const std::string &nodeInfo
				 )
{
    this->jid=Jid(jid, resource);
    this->rosterJid=jid;
    this->nickname=nickname;
	this->statusMessage=statusMessage;
	this->nodeInfo=nodeInfo;
    this->status=presence::OFFLINE;
    offlineIcon=presence::OFFLINE;

    enableServerHistory=DISABLED_STATE;

    nUnread=0;
    sortKey=0;

    transpIndex=identifyTransport(jid);

    composing=false;
    acceptComposing=false;

    update();
    messageList=ODRListRef(new ODRList);
}
Exemple #2
0
void ServiceDiscovery::parseResult() {
    //parsing items
    ODRList *list=new ODRList();

    if (!nodes.empty()) list->push_back(DiscoCommand::ref(new DiscoCommand(L"..", icons::ICON_DISCO_BACK, DiscoCommand::BACK)));
    if (infoReply) {
        if (infoReply->getTagName()=="query") {
            JabberDataBlockRefList::iterator i=infoReply->getChilds()->begin();
            while (i!=infoReply->getChilds()->end()) {
                JabberDataBlockRef feature=*(i++);
                if (feature->getTagName()!="feature") continue;
                std::string &var=feature->getAttribute("var");
                DiscoCommand *cmd=NULL;
                if (var=="jabber:iq:register") cmd=new DiscoCommand(L"Register", icons::ICON_REGISTER_INDEX, DiscoCommand::REGISTER);
                if (var=="jabber:iq:search") cmd=new DiscoCommand(L"Search", icons::ICON_SEARCH_INDEX, DiscoCommand::SEARCH);
                if (var=="vcard-temp") cmd=new DiscoCommand(L"vCard", icons::ICON_VCARD, DiscoCommand::VCARD);
                if (var=="http://jabber.org/protocol/muc") cmd=new DiscoCommand(L"Join conference", icons::ICON_GCJOIN_INDEX, DiscoCommand::JOINGC);
                //    ADD=6
                if (cmd) list->push_back(DiscoCommand::ref(cmd));
            }
            JabberDataBlockRef identity=infoReply->getChildByName("identity");
            if (identity) {
                if (identity->getAttribute("type")=="command-node" && 
                    identity->getAttribute("category")=="automation") {
                        list->push_back(DiscoCommand::ref(new DiscoCommand(L"Execute", icons::ICON_AD_HOC, DiscoCommand::EXECUTE)));
                }
            }
        } else {
            list->push_back(DiscoCommand::ref(new DiscoCommand(L"Error", icons::ICON_ERROR_INDEX, DiscoCommand::ERR)));
        }

        int b=list->size();
        if (itemReply) {
            if (infoReply->getTagName()=="query") {
                JabberDataBlockRefList::iterator i=itemReply->getChilds()->begin();
                while (i!=itemReply->getChilds()->end()) {
                    JabberDataBlockRef item=*(i++);
                    const std::string &jid=item->getAttribute("jid");
                    std::string name=item->getAttribute("name"); std::trim(name);
                    const std::string &node=item->getAttribute("node");
                    DiscoItem::ref contact=DiscoItem::ref(new DiscoItem(jid, node, name));
                    list->push_back(contact);
                }
                std::stable_sort(list->begin()+b, list->end(), DiscoItem::compare);

            } else {
                list->push_back(DiscoCommand::ref(new DiscoCommand(L"Error", icons::ICON_ERROR_INDEX, DiscoCommand::ERR)));
            }
        }
    }

    SetFocus(nodeList->getHWnd());
    nodeList->bindODRList(ODRListRef(list));
    nodeList->notifyListUpdate(true);
}
Exemple #3
0
DiscoListView::DiscoListView( HWND parent, const std::string & title ) {
    parentHWnd=parent;
    init();

    SetParent(thisHWnd, parent);

    this->title=utf8::utf8_wchar(title);

    wt=WndTitleRef(new WndTitle(this, 0));
    cursorPos=ODRRef();//odrlist->front();
    odrlist=ODRListRef(new ODRList());
}
Exemple #4
0
MucRoom::MucRoom( const std::string &jid ) {
    this->jid=Jid(jid);
    this->rosterJid=jid;
    //this->nickname=nickname;
    this->status=presence::OFFLINE;
    offlineIcon=presence::OFFLINE;

    nUnread=0;
    composing=false; acceptComposing=false;

    transpIndex=icons::ICON_GROUPCHAT_INDEX;

    update();
    messageList=ODRListRef(new ODRList);
}
Exemple #5
0
MucContact::MucContact( const std::string &jid ) 
{
    this->jid=Jid(jid);
    this->rosterJid=jid;

    this->group=this->jid.getBareJid();

    this->status=presence::OFFLINE;
    offlineIcon=presence::OFFLINE;

    composing=false;
    acceptComposing=false;

    nUnread=0;

    transpIndex=0;

    update();
    messageList=ODRListRef(new ODRList);
    enableServerHistory=Contact::DISABLED_STATE;
}
LRESULT CALLBACK VirtualListView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    VirtualListView *p=(VirtualListView *) GetWindowLong(hWnd, GWL_USERDATA);
 int klav=0;
    switch (message) {
    case WM_CREATE:
        {
            p=(VirtualListView *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );

            //p->listScrollHWND=CreateWindow(_T("SCROLLBAR"), NULL, 
            //    SBS_VERT | WS_VISIBLE | WS_CHILD,
            //    0, 0, CW_USEDEFAULT, CW_USEDEFAULT, 
            //    hWnd, NULL, g_hInst, NULL); 

            break;

        }

    case WM_PAINT:

        {
            PAINTSTRUCT ps;
            HDC hdc;
            HDC wnd;
            wnd = BeginPaint(hWnd, &ps);

            HBITMAP buf=CreateCompatibleBitmap(wnd, p->clientRect.right, p->clientRect.bottom);

            hdc=CreateCompatibleDC(NULL);
            SelectObject(hdc, buf);

            PatBlt(hdc, 0, 0, p->clientRect.right, p->clientRect.bottom, WHITENESS);
            // TODO: Add any drawing code here...

            SetBkMode(hdc, OPAQUE);

            int y=-p->winTop;
            int index=0;

            if (p->odrlist.get()) {
                ODRList::const_iterator i=p->odrlist->begin();
                while (i!=p->odrlist->end()) {
                    ODRRef odr=*i; i++; 
                    bool oddIndex=(index & 1) && p->colorInterleaving;
                    index++;

                    bool focused = (odr.get()==p->cursorPos.get());

                    RECT ritem={0, y, p->clientRect.right, y} ;
                    odr->measure(hdc, ritem);
                    //int iHeight=odr->getHeight();
                    //y+=iHeight;
                    y=ritem.bottom;
                    //index++;

                    if (ritem.bottom < 0) continue;
                    if (ritem.top > p->clientRect.bottom) continue;

                    int bkColor=COLORS[12];
                    if (focused) {
                        // focused item
                        SetTextColor(hdc, COLORS[8]);
                        bkColor=(GetFocus()==hWnd)?COLORS[9]:COLORS[10];
                        //DrawFocusRect(hdc, &ritem);
                    } else {
                        //usual item
                        SetTextColor(hdc, odr->getColor());
                        bkColor= (oddIndex)? COLORS[11] : COLORS[12];
                    }
                    HBRUSH bkBrush=CreateSolidBrush(bkColor);
                    SetBkColor(hdc, bkColor);
                    ritem.right=p->clientRect.right; //full window-wide cursor
                    FillRect(hdc, &ritem, bkBrush);
                    DeleteObject(bkBrush);
                    odr->draw(hdc, ritem);
                }
            }

            RECT rc = {0, 0, 100, 100};

            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_PAGE |SIF_POS |SIF_RANGE;
            si.nPage=p->clientRect.bottom;
            si.nPos=p->winTop;
            si.nMin=0;
            si.nMax=y+p->winTop;

            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);

            /*int titleBgnd=0x808080;
            HBRUSH tb=CreateSolidBrush(titleBgnd);
            SetBkColor(hdc, titleBgnd);
            SetTextColor(hdc, 0x000000);

            LPCTSTR t=p->title.c_str();
            DrwText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP);
            rc.right=p->clientRect.right;
            FillRect(hdc, &rc, tb);
            DrwText(hdc, t, -1, &rc, DT_LEFT | DT_TOP);
            DeleteObject(tb);*/

            BitBlt(wnd, 0,0,p->clientRect.right, p->clientRect.bottom, hdc, 0,0, SRCCOPY);
            DeleteDC(hdc);
            DeleteObject(buf);

            EndPaint(hWnd, &ps);
            break;
        }

    case WM_SIZE: 
        { 
            //HDWP hdwp; 

            int height=GET_Y_LPARAM(lParam);
            int width=GET_X_LPARAM(lParam);
            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&(p->clientRect), 0, 0, width, height ); 

            /*hdwp = BeginDeferWindowPos(1);

            DeferWindowPos(hdwp, p->listScrollHWND, HWND_TOP, width-SCROLLWIDTH, tabHeight, 
            SCROLLWIDTH, height-tabHeight, 
            SWP_NOZORDER 
            );
            EndDeferWindowPos(hdwp); */

            p->cursorFit();
            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_PAGE |SIF_POS;
            si.nPage=height;
            si.nPos=p->winTop;

            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);

            break; 
        } 

    case WM_LBUTTONDOWN:
        {
            SetFocus(hWnd);
            ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
            if (!(focused)) break;
            InvalidateRect(p->getHWnd(), NULL, true);

            SHRGINFO    shrg;
            shrg.cbSize = sizeof(shrg);
            shrg.hwndClient = hWnd;
            shrg.ptDown.x = LOWORD(lParam);
            shrg.ptDown.y = HIWORD(lParam);
            shrg.dwFlags = SHRG_RETURNCMD /*| SHRG_NOANIMATION*/;

            if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) {

                HMENU hmenu = p->getContextMenu();

                VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get());
                if (velement) hmenu=velement->getContextMenu(hmenu);

                if (hmenu==NULL) break;

                POINT pt={LOWORD(lParam), HIWORD(lParam) };
                ClientToScreen(hWnd, &pt);
                int cmdId=TrackPopupMenuEx(hmenu,
                    /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, 
                    pt.x, pt.y,
                    hWnd,
                    NULL);

                bool cmdProcessed=false;
                if (velement) 
					cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox);

                if (!cmdProcessed)
                    p->OnCommand(cmdId, NULL);

                DestroyMenu(hmenu);
            }
            break;
        }
    case WM_LBUTTONDBLCLK:
        {
            ODRRef oldCursor=p->cursorPos;
            ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
            if (!(focused)) break;
            InvalidateRect(p->getHWnd(), NULL, true);
            if (focused==oldCursor) p->eventOk();
            break;
        }

    case WM_SETFOCUS:
    case WM_KILLFOCUS:
        {
            InvalidateRect(p->getHWnd(), NULL, true);
            break;
        }
    case WM_KEYDOWN:
        {bool kl2=1;
          int vKey=(int)wParam;
            int lkeyData=lParam;
            if (lkeyData & 0x80000000) break; //keyRelease 
            switch (vKey) {
                        /* UFO START */
                        
                        case VK_RIGHT:
                                PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0);
                                break;

						case VK_3:kl2=0;
                              //  MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0);
                               SCROLLINFO si2;
            si2.cbSize=sizeof(SCROLLINFO);
            si2.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si2);

            //TODO: flicker-free scrolling
          
           /* case SB_LINEDOWN: *///  si2.nPos+=tabHeight; break;
            //case SB_LINEUP:    
			si2.nPos-=tabHeight; 
            //case SB_ENDSCROLL:  break;
            /*//case SB_PAGEUP:    */// si2.nPos-=si2.nPage; 
            //case SB_PAGEDOWN:   si2.nPos+=si2.nPage;  break;
           
      


            if (si2.nPos<0) si2.nPos=0; 
            if (si2.nPos+(int)si2.nPage >= si2.nMax) si2.nPos=si2.nMax-si2.nPage; 

            p->winTop= si2.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si2.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si2, TRUE); 
							break;
								
						case VK_9:kl2=0;
                                SCROLLINFO si3;
            si3.cbSize=sizeof(SCROLLINFO);
            si3.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si3);

            //TODO: flicker-free scrolling
          
           /* case SB_LINEDOWN: *///  
			si3.nPos+=tabHeight; 
            //case SB_LINEUP:    si2.nPos-=tabHeight; 
            //case SB_ENDSCROLL:  break;
            /*//case SB_PAGEUP:    */// si2.nPos-=si2.nPage; 
            //case SB_PAGEDOWN:   si2.nPos+=si2.nPage;  break;
           
      


            if (si3.nPos<0) si3.nPos=0; 
            if (si3.nPos+(int)si3.nPage >= si3.nMax) si3.nPos=si3.nMax-si3.nPage; 

            p->winTop= si3.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si3.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si3, TRUE); 
							break;
							// MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0);
                               
                        case VK_LEFT:
                                PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0);
                                break;
                        /* UFO END */
                        case VK_UP:
                p->moveCursor(-1);
                break;
				case VK_DOWN: 
                p->moveCursor(1);
                break;

           


                        case VK_RETURN:
                if (lkeyData &0xc0000000) break;
                p->eventOk();
                                break;
			}
            if(kl2)p->cursorFit();
            InvalidateRect(p->getHWnd(), NULL, true);


            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.nPos=p->winTop;
            si.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);


            break;
        }
    case WM_VSCROLL:
        {
            int scrollCode=(int)LOWORD(wParam);
            int nPos=(int)HIWORD(wParam);

            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si);

            //TODO: flicker-free scrolling
            switch (scrollCode) {
            case SB_LINEDOWN:   si.nPos+=tabHeight; break;
            case SB_LINEUP:     si.nPos-=tabHeight; break;
            case SB_ENDSCROLL:  break;
            case SB_PAGEUP:     si.nPos-=si.nPage;  break;
            case SB_PAGEDOWN:   si.nPos+=si.nPage;  break;
            case SB_THUMBTRACK:
            case SB_THUMBPOSITION: si.nPos=si.nTrackPos; break;
            //default:            si.nPos=si.nTrackPos; break;
            }


            if (si.nPos<0) si.nPos=0; 
            if (si.nPos+(int)si.nPage >= si.nMax) si.nPos=si.nMax-si.nPage; 

            p->winTop= si.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);
            return true;

        }

    case WM_COMMAND: 
        {
            int cmdId=LOWORD(wParam);
            p->OnCommand(cmdId, lParam);
            break;
        }

    case WM_VIRTUALLIST_REPLACE:
        {
            //TODO: create interconnecting message object to avoid pointers
            ODRListRef r=ODRListRef((ODRList *)lParam);
            p->bindODRList(r); //юурсмц ╧5

            //p->bindODRList(ODRSet::ref((ODRSet *)lParam)); //юурсмц ╧3
            p->notifyListUpdate(true);
            break;
        }

    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window

        return 0;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
LRESULT CALLBACK VirtualListView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    VirtualListView *p=(VirtualListView *) GetWindowLong(hWnd, GWL_USERDATA);
 int klav=0;
 lParamst=lParam;
//printf(" \nmess: 0x%06X  x:%d  y:%d",message,GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam));
    switch (message) {
    case WM_CREATE:
        {
            p=(VirtualListView *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );

            //p->listScrollHWND=CreateWindow(_T("SCROLLBAR"), NULL, 
            //    SBS_VERT | WS_VISIBLE | WS_CHILD,
            //    0, 0, CW_USEDEFAULT, CW_USEDEFAULT, 
            //    hWnd, NULL, g_hInst, NULL); 

            break;

        }

	case CLEARMESS:
		{/*int result=MessageBox(
				p->getHWnd(), 
				L"ќчистить окно от сообщений?", 
				L"ќчистить", 
				MB_YESNO | MB_ICONWARNING);*/
		PostMessage(p->parentHWnd, CLEARMESS, NULL, false);}

    case WM_PAINT:

        {
            PAINTSTRUCT ps;
            HDC hdc;
            HDC wnd;
            wnd = BeginPaint(hWnd, &ps);

            HBITMAP buf=CreateCompatibleBitmap(wnd, p->clientRect.right, p->clientRect.bottom);

            hdc=CreateCompatibleDC(NULL);
            SelectObject(hdc, buf);

            PatBlt(hdc, 0, 0, p->clientRect.right, p->clientRect.bottom, WHITENESS);
            // TODO: Add any drawing code here...

            SetBkMode(hdc, OPAQUE);

            int y=-p->winTop;
            int index=0;
		
            if (p->odrlist.get()) {
                ODRList::const_iterator i=p->odrlist->begin();
                while (i!=p->odrlist->end()) {
                    ODRRef odr=*i; i++; 
                    bool oddIndex=(index & 1) && p->colorInterleaving;
                    index++;

                    bool focused = (odr.get()==p->cursorPos.get());

                    RECT ritem={0, y, p->clientRect.right, y} ;
                    odr->measure(hdc, ritem);
                    //int iHeight=odr->getHeight();
                    //y+=iHeight;
                    y=ritem.bottom;
                    //index++;

                    if (ritem.bottom < 0) continue;
                    if (ritem.top > p->clientRect.bottom) continue;

                    int bkColor=COLORS[12];
                    if (focused) {
                        // focused item
                        SetTextColor(hdc, COLORS[8]);
                        bkColor=(GetFocus()==hWnd)?COLORS[9]:COLORS[10];
                        //DrawFocusRect(hdc, &ritem);
                    } else {
                        //usual item
                        SetTextColor(hdc, odr->getColor());
                        bkColor= (oddIndex)? COLORS[11] : COLORS[12];
                    }
                    HBRUSH bkBrush=CreateSolidBrush(bkColor);
                    SetBkColor(hdc, bkColor);
                    ritem.right=p->clientRect.right; //full window-wide cursor
                    FillRect(hdc, &ritem, bkBrush);
                    DeleteObject(bkBrush);
                    odr->draw(hdc, ritem,1);
                }
            }

            RECT rc = {0, 0, 100, 100};

            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_PAGE |SIF_POS |SIF_RANGE;
            si.nPage=p->clientRect.bottom;
            si.nPos=p->winTop;
            si.nMin=0;
            si.nMax=y+p->winTop;

            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);

            /*int titleBgnd=0x808080;
            HBRUSH tb=CreateSolidBrush(titleBgnd);
            SetBkColor(hdc, titleBgnd);
            SetTextColor(hdc, 0x000000);

            LPCTSTR t=p->title.c_str();
            DrwText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP);
            rc.right=p->clientRect.right;
            FillRect(hdc, &rc, tb);
            DrwText(hdc, t, -1, &rc, DT_LEFT | DT_TOP);
            DeleteObject(tb);*/

            BitBlt(wnd, 0,0,p->clientRect.right, p->clientRect.bottom, hdc, 0,0, SRCCOPY);
            DeleteDC(hdc);
            DeleteObject(buf);

            EndPaint(hWnd, &ps);
            break;
        }

    case WM_SIZE: 
        { 
            //HDWP hdwp; 

            int height=GET_Y_LPARAM(lParam);
            int width=GET_X_LPARAM(lParam);
            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&(p->clientRect), 0, 0, width, height ); 

            /*hdwp = BeginDeferWindowPos(1);

            DeferWindowPos(hdwp, p->listScrollHWND, HWND_TOP, width-SCROLLWIDTH, tabHeight, 
            SCROLLWIDTH, height-tabHeight, 
            SWP_NOZORDER 
            );
            EndDeferWindowPos(hdwp); */

            p->cursorFit();
            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_PAGE |SIF_POS;
            si.nPage=height;
            si.nPos=p->winTop;

            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);

            break; 
        } 

	case MSGListFocus:
		{
			SetFocus(hWnd);
			break;
		}


    case WM_LBUTTONDOWN:
		{	smile_aktiv=40;
			xmouse=GET_X_LPARAM(lParam);
			ymouse=GET_Y_LPARAM(lParam);
			movemode=0;//неопределили пока
			zaderzhka=0;
			xmouse_d=0;
			ymouse_d=0;
			taptrue=1;
			if(movetrue){break;}
			SetFocus(hWnd);
            ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
            if (!(focused)) break;
            InvalidateRect(p->getHWnd(), NULL, true);
			
            SHRGINFO    shrg;
            shrg.cbSize = sizeof(shrg);
            shrg.hwndClient = hWnd;
            shrg.ptDown.x = LOWORD(lParam);
            shrg.ptDown.y = HIWORD(lParam);
            shrg.dwFlags = SHRG_RETURNCMD /*| SHRG_NOANIMATION*/;

			if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) {

                HMENU hmenu = p->getContextMenu();

                VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get());
                if (velement) hmenu=velement->getContextMenu(hmenu);

                if (hmenu==NULL) break;

                POINT pt={LOWORD(lParam), HIWORD(lParam) };
                ClientToScreen(hWnd, &pt);
                int cmdId=TrackPopupMenuEx(hmenu,
                    /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, 
                    pt.x, pt.y,
                    hWnd,
                    NULL);

                bool cmdProcessed=false;
                if (velement) 
					cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox);

                if (!cmdProcessed)
                    p->OnCommand(cmdId, NULL);

                DestroyMenu(hmenu);
			}else{
			//нажатие на иконки
				p->is_icon_klik(xmouse);
			}
			
            break;
        }
    case WM_LBUTTONDBLCLK:
        {  smile_aktiv=40 ;
            ODRRef oldCursor=p->cursorPos;
            ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
            if (!(focused)) break;
            InvalidateRect(p->getHWnd(), NULL, true);
            if (focused==oldCursor) p->eventOk();
            break;
        }

    case WM_SETFOCUS:
    case WM_KILLFOCUS:
        {
            InvalidateRect(p->getHWnd(), NULL, true);
            break;
        }

	case WM_MOUSEMOVE:
		{//скролл тасканием 
			//movetrue=1;
			smile_aktiv=40 ;
			if(zaderzhka>0){
			printf("mode %d X: %d  Y: %d\n",movemode,xmouse_d,ymouse_d);
			
			if(movemode){
			//собственно само движение
				if(movemode==1){
				//верт
					if(ymouse_d<0){
					PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEDOWN, 0);
					//PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEDOWN, 0);
					}else{
					 PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEUP, 0);
					// PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEUP, 0);
					}
				}else{
				//гориз
					if (abs(xmouse_d)>50){
						if (xmouse_d<0){ PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0);}
						else{PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0);}
						xmouse_d=0;
					}}
			
			
			}
			else     
			//определ¤ем movemode 1-вертик   2-гориз
			{int absx,absy;
			 absx=xmouse_d;absy=ymouse_d;
			 if(xmouse_d<0)absx=xmouse_d*(-1);
			 if(ymouse_d<0)absy=ymouse_d*(-1);
			 
				if(absx > absy){movemode=2;}else{movemode=1;}
				movetrue=1;taptrue=0;
				printf("mode %d ax: %d  ay: %d\n",movemode,absx,absy);
			}
		zaderzhka=0;ymouse_d=0;
			}else{zaderzhka++;
			xmouse_d=xmouse_d+GET_X_LPARAM(lParam)-xmouse;
			ymouse_d=ymouse_d+GET_Y_LPARAM(lParam)- ymouse;
			
			xmouse=GET_X_LPARAM(lParam);
			ymouse=GET_Y_LPARAM(lParam);
			}
		break;}
	case WM_LBUTTONUP:
		{if(movetrue==1 && taptrue==1){
			movetrue=0;
			PostMessage(p->getHWnd(), WM_LBUTTONDOWN, 0, lParamst);
		}
		break;
		}

    case WM_KEYDOWN:
        {bool kl2=1;
		smile_aktiv=40 ;
          int vKey=(int)wParam;
            int lkeyData=lParam;
            if (lkeyData & 0x80000000) break; //keyRelease 
            switch (vKey)
			{
				/* UFO START */
				case VK_5:
				{
					ODRRef focused=p->cursorPos;
					if (!(focused)) break;
					InvalidateRect(p->getHWnd(), NULL, true);
					HMENU hmenu = p->getContextMenu();
					VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get());
					if (velement) hmenu=velement->getContextMenu(hmenu);
					if (hmenu==NULL) break;
					POINT pt={LOWORD(lParam), HIWORD(lParam) };
					ClientToScreen(hWnd, &pt);
					int cmdId=TrackPopupMenuEx(hmenu,
						/*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, 
						pt.x, pt.y,
						hWnd,
						NULL);

					bool cmdProcessed=false;
					if (velement) 
						cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox);

					if (!cmdProcessed)
						p->OnCommand(cmdId, NULL);

					DestroyMenu(hmenu); break;
				}

                        case VK_RIGHT:
                                PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0);
                                break;

						case VK_3:kl2=0;
                              //  MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0);
                               SCROLLINFO si2;
            si2.cbSize=sizeof(SCROLLINFO);
            si2.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si2);

            //TODO: flicker-free scrolling
          
           /* case SB_LINEDOWN: *///  si2.nPos+=tabHeight; break;
            //case SB_LINEUP:    
			si2.nPos-=tabHeight; 
            //case SB_ENDSCROLL:  break;
            /*//case SB_PAGEUP:    */// si2.nPos-=si2.nPage; 
            //case SB_PAGEDOWN:   si2.nPos+=si2.nPage;  break;
           
      


            if (si2.nPos<0) si2.nPos=0; 
            if (si2.nPos+(int)si2.nPage >= si2.nMax) si2.nPos=si2.nMax-si2.nPage; 

            p->winTop= si2.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si2.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si2, TRUE); 
							break;
								
						case VK_9:kl2=0;
                                SCROLLINFO si3;
            si3.cbSize=sizeof(SCROLLINFO);
            si3.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si3);

            //TODO: flicker-free scrolling
          
           /* case SB_LINEDOWN: *///  
			si3.nPos+=tabHeight; 
            //case SB_LINEUP:    si2.nPos-=tabHeight; 
            //case SB_ENDSCROLL:  break;
            /*//case SB_PAGEUP:    */// si2.nPos-=si2.nPage; 
            //case SB_PAGEDOWN:   si2.nPos+=si2.nPage;  break;
           
      


            if (si3.nPos<0) si3.nPos=0; 
            if (si3.nPos+(int)si3.nPage >= si3.nMax) si3.nPos=si3.nMax-si3.nPage; 

            p->winTop= si3.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si3.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si3, TRUE); 
							break;
							// MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0);
                               
                        case VK_LEFT:
                                PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0);
                                break;
                        /* UFO END */
                        case VK_UP:
                p->moveCursor(-1);
                break;
				case VK_DOWN: 
					/* UFO START */
					// переключаем фокус в поле ввода после второго нажати¤ кнопки вниз на последнем сообщении
					if (p->cursorAtEnd() && IsWindow(p->hEditBox) ) SetFocus(p->hEditBox);
					/* UFO END */
					p->moveCursor(1);
                break;

                case VK_RETURN:
					SHRGINFO    shrg;
					shrg.cbSize = sizeof(shrg);
					shrg.hwndClient = hWnd;
					shrg.ptDown.x = LOWORD(lParam);
					shrg.ptDown.y = HIWORD(lParam);
					shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;

					if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU)
					{
						ODRRef focused=p->cursorPos;
						if (!(focused)) break;
						InvalidateRect(p->getHWnd(), NULL, true);
						HMENU hmenu = p->getContextMenu();
						VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get());
						if (velement) hmenu=velement->getContextMenu(hmenu);
						if (hmenu==NULL) break;
						POINT pt={LOWORD(lParam), HIWORD(lParam) };
						ClientToScreen(hWnd, &pt);
						int cmdId=TrackPopupMenuEx(hmenu,
							/*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, 
							pt.x, pt.y,
							hWnd,
							NULL);

						bool cmdProcessed=false;
						if (velement) 
							cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox);

						if (!cmdProcessed)
							p->OnCommand(cmdId, NULL);

						DestroyMenu(hmenu);
						break;
					}
					if (lkeyData &0xc0000000) break;
					p->eventOk();
				break;
			}
            if(kl2)p->cursorFit();
            InvalidateRect(p->getHWnd(), NULL, true);


            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.nPos=p->winTop;
            si.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);


            break;
        }
    case WM_VSCROLL:
        {   smile_aktiv=40 ;
            int scrollCode=(int)LOWORD(wParam);
            int nPos=(int)HIWORD(wParam);

            SCROLLINFO si;
            si.cbSize=sizeof(SCROLLINFO);
            si.fMask=SIF_ALL;

            GetScrollInfo(p->thisHWnd, SB_VERT, &si);

            //TODO: flicker-free scrolling
            switch (scrollCode) {
            case SB_LINEDOWN:   si.nPos+=tabHeight; break;
            case SB_LINEUP:     si.nPos-=tabHeight; break;
            case SB_ENDSCROLL:  break;
            case SB_PAGEUP:     si.nPos-=si.nPage;  break;
            case SB_PAGEDOWN:   si.nPos+=si.nPage;  break;
            case SB_THUMBTRACK:
            case SB_THUMBPOSITION: si.nPos=si.nTrackPos; break;
            //default:            si.nPos=si.nTrackPos; break;
            }


            if (si.nPos<0) si.nPos=0; 
            if (si.nPos+(int)si.nPage >= si.nMax) si.nPos=si.nMax-si.nPage; 

            p->winTop= si.nPos;

            //TODO: flicker-free scrolling
            InvalidateRect(p->getHWnd(), NULL, true);

            si.fMask=SIF_POS;
            SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE);
            return true;

        }

    case WM_COMMAND: 
        {
            int cmdId=LOWORD(wParam);
            p->OnCommand(cmdId, lParam);
            break;
        }

    case WM_VIRTUALLIST_REPLACE:
        {
            //TODO: create interconnecting message object to avoid pointers
            ODRListRef r=ODRListRef((ODRList *)lParam);
            p->bindODRList(r); //ј’“”Ќ√ є5

            //p->bindODRList(ODRSet::ref((ODRSet *)lParam)); //ј’“”Ќ√ є3
            p->notifyListUpdate(true);
            break;
        }

    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window

        return 0;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Exemple #8
0
LRESULT CALLBACK ServiceDiscovery::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    PAINTSTRUCT ps;
    HDC hdc;
    ServiceDiscovery *p=(ServiceDiscovery *) GetWindowLong(hWnd, GWL_USERDATA);

    switch (message) {
    case WM_CREATE:
        {
            p=(ServiceDiscovery *) (((CREATESTRUCT *)lParam)->lpCreateParams);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG) p );

            //p->nodeList=VirtualListView::ref(new VirtualListView(hWnd, std::string("disco")));
            DiscoListView * dlv = new DiscoListView(hWnd, std::string("disco"));
            //dlv->serviceDiscovery=p->thisRef;

            p->nodeList=VirtualListView::ref(dlv);
            p->nodeList->setParent(hWnd);
            p->nodeList->showWindow(true);
            //p->nodeList->wrapList=false;
            //p->nodeList->colorInterleaving=true;

            RECT rect;
            p->editWnd=DoCreateComboControl(hWnd);
            GetWindowRect(p->editWnd, &rect);
            p->editHeight=rect.bottom-rect.top+2;
            mru::readMru(MRU_DISCO_JIDS, p->editWnd, NULL);

            //p->msgList->bindODRList(p->contact->messageList);
            break;
        }

    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

        {
            //p->contact->nUnread=0;
            RECT rc = {0, 0, 200, tabHeight};
            SetBkMode(hdc, TRANSPARENT);
            //SetTextColor(hdc, p->contact->getColor());
            //p->contact->draw(hdc, rc);

            skin->drawElement(hdc, icons::ICON_CLOSE, p->width-2-skin->getElementWidth(), 0);
            skin->drawElement(hdc, icons::ICON_SEARCH_INDEX, p->width-4-skin->getElementWidth()*2, 0);

            

            /*SetBkMode(hdc, TRANSPARENT);
            LPCTSTR t=p->title.c_str();
            DrawText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP);
            DrawText(hdc, t, -1, &rc, DT_LEFT | DT_TOP);*/
        }

        EndPaint(hWnd, &ps);
        break;

    case WM_SIZE: 
        { 
            HDWP hdwp; 
            RECT rc; 

            int height=GET_Y_LPARAM(lParam);
            p->width=GET_X_LPARAM(lParam);

            // Calculate the display rectangle, assuming the 
            // tab control is the size of the client area. 
            SetRect(&rc, 0, 0, 
                GET_X_LPARAM(lParam), height ); 

            // Size the tab control to fit the client area. 
            hdwp = BeginDeferWindowPos(2);

            DeferWindowPos(hdwp, p->editWnd, NULL, 1, 1, 
                GET_X_LPARAM(lParam)-(tabHeight*2+2), p->editHeight, 
                SWP_NOZORDER 
                ); 


            DeferWindowPos(hdwp, p->nodeList->getHWnd(), HWND_TOP, 0, p->editHeight, 
                GET_X_LPARAM(lParam), height - p->editHeight, 
                SWP_NOZORDER 
                );

            EndDeferWindowPos(hdwp); 

            break; 
        } 

    case WM_COMMAND: 
        {
            switch (LOWORD(wParam)) {
            case IDOK:
                {
                    updateComboHistory(p->editWnd);
                    while (!p->nodes.empty()) p->nodes.pop();
                    p->nodeList->bindODRList(ODRListRef());
                    p->newNode.clear();
                    p->go();
                    break;
                }
            }
        }
        if (HIWORD(wParam)==CBN_DROPDOWN) {
            int nitems=SendMessage(p->editWnd, CB_GETCOUNT, 0, 0);
            if (nitems<=0) break;
            int h=SendMessage(p->editWnd, CB_GETITEMHEIGHT, 0, 0)*10;//+p->editHeight;
            RECT rc;
            GetWindowRect((HWND)lParam, &rc);
            int result=SetWindowPos((HWND)lParam, NULL, 0,0, rc.right-rc.left, h, SWP_NOZORDER | SWP_NOMOVE );
        }
        break;             

    case WM_LBUTTONDOWN:
        SetFocus(hWnd);
        if ((GET_Y_LPARAM(lParam)) > p->editHeight) break;
        if (GET_X_LPARAM(lParam) > p->width-2-skin->getElementWidth()) {
            mru::saveMru(MRU_DISCO_JIDS, p->editWnd);
            PostMessage(GetParent(hWnd), WM_COMMAND, TabsCtrl::CLOSETAB, 0);
            break;
        }
        if (GET_X_LPARAM(lParam) > p->width-2-2*skin->getElementWidth()) {
            SendMessage(hWnd, WM_COMMAND, IDOK, 0);
        }
        break;

    case WM_NOTIFY_BLOCKARRIVED:
        p->parseResult();
        return 0;

    case WM_DESTROY:
        //TODO: Destroy all child data associated eith this window

        return 0;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}