void WhistleListener::createAudioInput()
{
    m_audioInput = new QAudioInput(m_device, m_format, this);
    connect(m_audioInput, SIGNAL(notify()), SLOT(notified()));
    //connect(m_audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
    start();
    m_audioInput->start(this);
}
void IRCChannelWidget::setFileReq(const list<IRCClient::FileRecvReq>& fileReqs)
{
    _fileReqsMtx.lock();
    cout << "adding items" << endl;
    _fileReqs = fileReqs;
    _fileReqsMtx.unlock();
    notified();
}
 void AudioTest::createAudioOutput()
 {
     delete m_audioOutput;
     m_audioOutput = 0;
     m_audioOutput = new QAudioOutput(m_device, m_format, this);
     connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
     connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
     m_generator->start();
     m_audioOutput->start(m_generator);
 }
Beispiel #4
0
// static
void
msg_status_cache::init_db()
{
  m_this = new msg_status_cache();
  db_cnx db;
  db_listener* listener = new db_listener(db, "new_message");
  connect(listener, SIGNAL(notified()), m_this, SLOT(db_new_mail_notif()));

  /*
  message_port::connect_sender(m_this, SIGNAL(new_mail_notified(mail_id_t)),
			       SLOT(broadcast_new_mail(mail_id_t)));
  */
}
IRCChannelWidget::IRCChannelWidget(QWidget *parent, IRCClient* client) :
    QWidget(parent), _kickAction(this), _sendFileAction(this), _whoIsAction(this), _userOptions(this), _defaultChannel(0), _privMsg(this)
{
    _subject = 0;
    _client = client;
    _msgScreen = new QPlainTextEdit(this);
    // we use the text-edit to display text
    _msgScreen->setReadOnly(true);
    _lineEdit = new QLineEdit(this);
    _submitText = new QPushButton(this);
    _submitText->setText("submit");
    _submitText->setMinimumWidth(180);
    _users = new QListWidget(this);
    _users->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding);

    // on entering or pressing submit we let the GUI know that we want to send text
    connect(_lineEdit, SIGNAL(returnPressed()),this, SLOT(textEntered()));
    connect(_submitText, SIGNAL(clicked()), this, SLOT(textEntered()));
    connect(this, SIGNAL(notified()), this, SLOT(updateGui()));

    // create our grid layout
    constructMainLayout();

    stealFocus();

    // create rightclickmenu and actions connected to functions handeling the actions
    _users->setContextMenuPolicy(Qt::CustomContextMenu);
    _whoIsAction.setText("Who Is");
    _sendFileAction.setText("Send File");
    _kickAction.setText("Kick");
    _privMsg.setText("Privmsg");
    _userOptions.addAction(&_whoIsAction);
    _userOptions.addAction(&_sendFileAction);
    _userOptions.addAction(&_kickAction);
    _userOptions.addAction(&_privMsg);


    connect(_users, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showUserOptionsMenu(const QPoint &)));
    connect(&_whoIsAction, SIGNAL(triggered()), this, SLOT(sendWhoIs()));
    connect(&_sendFileAction, SIGNAL(triggered()), this, SLOT(sendFile()));
    connect(&_kickAction, SIGNAL(triggered()), this, SLOT(kickUser()));
    connect(&_privMsg, SIGNAL(triggered()), this, SLOT(setMsg()));
}
void IRCChannelWidget::notify(Subject *subject)
{
    if (!_subject)
        _subject = dynamic_cast<Channel*>(subject);

    queue<TextMessage> newMsgs = _subject->getLastMsgs();
    while (!newMsgs.empty()) {
        addMsgToQueue(newMsgs.front());
        newMsgs.pop();
    }

    list<User> newUsrs = _subject->getAddUsers();
    list<User> leftUsrs = _subject->getRemUsers();
    _newUsrsMtx.lock();
    _newUsrs.insert(_newUsrs.end(),newUsrs.begin(), newUsrs.end());
    _newUsrsMtx.unlock();
    _leftUsrsMtx.lock();
    _leftUsrs.insert(_leftUsrs.begin(), leftUsrs.begin(), leftUsrs.end());
    _leftUsrsMtx.unlock();

    notified();

}
Beispiel #7
0
/*virtual*/ void Listener::execute(ExecuteContext &_rexectx){
	idbg("here");
	cassert(this->socketOk());
	if(notified()){
		Locker<Mutex>	lock(Manager::specific().mutex(*this));
		ulong sm = this->grabSignalMask();
		if(sm & frame::S_KILL){ 
			_rexectx.close();
			return;
		}
	}
	
	solid::uint cnt(10);
	
	while(cnt--){
		if(state == 0){
			switch(this->socketAccept(sd)){
				case frame::aio::AsyncError:
					_rexectx.close();
					return;
				case frame::aio::AsyncSuccess:break;
				case frame::aio::AsyncWait:
					state = 1;
					return;
			}
		}
		state = 0;
		cassert(sd.ok());
		//TODO: one may do some filtering on sd based on sd.remoteAddress()
		if(ctxptr.get()){
			rsvc.insertConnection(sd, ctxptr.get(), true);
		}else{
			rsvc.insertConnection(sd);
		}
	}
	_rexectx.reschedule();
}
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_INITDIALOG :
    {
        ProjectPanel::initMenus();

        // Create toolbar menu
        int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST;
        _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
                                       0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL);
        TBBUTTON tbButtons[2];

        NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
        generic_string workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY);
        generic_string edit_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 1, PM_EDITMENUENTRY);

        tbButtons[0].idCommand = IDB_PROJECT_BTN;
        tbButtons[0].iBitmap = I_IMAGENONE;
        tbButtons[0].fsState = TBSTATE_ENABLED;
        tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
        tbButtons[0].iString = (INT_PTR)workspace_entry.c_str();

        tbButtons[1].idCommand = IDB_EDIT_BTN;
        tbButtons[1].iBitmap = I_IMAGENONE;
        tbButtons[1].fsState = TBSTATE_ENABLED;
        tbButtons[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
        tbButtons[1].iString = (INT_PTR)edit_entry.c_str();

        SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
        SendMessage(_hToolbarMenu, TB_ADDBUTTONS,       (WPARAM)sizeof(tbButtons) / sizeof(TBBUTTON),       (LPARAM)&tbButtons);
        SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
        ShowWindow(_hToolbarMenu, SW_SHOW);

        _treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);

        setImageList(IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);
        _treeView.addCanNotDropInList(INDEX_LEAF);
        _treeView.addCanNotDropInList(INDEX_LEAF_INVALID);

        _treeView.addCanNotDragOutList(INDEX_CLEAN_ROOT);
        _treeView.addCanNotDragOutList(INDEX_DIRTY_ROOT);
        _treeView.addCanNotDragOutList(INDEX_PROJECT);

        _treeView.display();
        if (!openWorkSpace(_workSpaceFilePath.c_str()))
            newWorkSpace();

        return TRUE;
    }


    case WM_MOUSEMOVE:
        if (_treeView.isDragging())
            _treeView.dragItem(_hSelf, LOWORD(lParam), HIWORD(lParam));
        break;
    case WM_LBUTTONUP:
        if (_treeView.isDragging())
            if (_treeView.dropItem())
                setWorkSpaceDirty(true);
        break;

    case WM_NOTIFY:
    {
        notified((LPNMHDR)lParam);
    }
    return TRUE;

    case WM_SIZE:
    {
        int width = LOWORD(lParam);
        int height = HIWORD(lParam);
        RECT toolbarMenuRect;
        ::GetClientRect(_hToolbarMenu, &toolbarMenuRect);

        ::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);

        HWND hwnd = _treeView.getHSelf();
        if (hwnd)
            ::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
        break;
    }

    case WM_CONTEXTMENU:
        if (!_treeView.isDragging())
            showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
        return TRUE;

    case WM_COMMAND:
    {
        popupMenuCmd(LOWORD(wParam));
        break;
    }

    case WM_DESTROY:
    {
        _treeView.destroy();
        destroyMenus();
        ::DestroyWindow(_hToolbarMenu);
        break;
    }
    case WM_KEYDOWN:
        //if (wParam == VK_F2)
    {
        ::MessageBoxA(NULL,"vkF2","",MB_OK);
    }
    break;

    default :
        return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
    return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}
INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG :
        {
			FileBrowser::initPopupMenus();

			_treeView.init(_hInst, _hSelf, ID_FILEBROWSERTREEVIEW);
			setImageList(IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);

			_treeView.addCanNotDropInList(INDEX_OPEN_ROOT);
			_treeView.addCanNotDropInList(INDEX_CLOSE_ROOT);
			_treeView.addCanNotDropInList(INDEX_OPEN_NODE);
			_treeView.addCanNotDropInList(INDEX_CLOSED_NODE);
			_treeView.addCanNotDropInList(INDEX_LEAF);
			_treeView.addCanNotDropInList(INDEX_LEAF_INVALID);

			_treeView.addCanNotDragOutList(INDEX_OPEN_ROOT);
			_treeView.addCanNotDragOutList(INDEX_CLOSE_ROOT);
			_treeView.addCanNotDragOutList(INDEX_OPEN_NODE);
			_treeView.addCanNotDragOutList(INDEX_CLOSED_NODE);
			_treeView.addCanNotDragOutList(INDEX_LEAF);
			_treeView.addCanNotDragOutList(INDEX_LEAF_INVALID);

			_treeView.makeLabelEditable(false);
			_treeView.display();

            return TRUE;
        }

		case WM_MOUSEMOVE:
			if (_treeView.isDragging())
				_treeView.dragItem(_hSelf, LOWORD(lParam), HIWORD(lParam));
			break;
		case WM_LBUTTONUP:
			if (_treeView.isDragging())
				if (_treeView.dropItem())
				{
				
				}
			break;

		case WM_NOTIFY:
		{
			notified((LPNMHDR)lParam);
		}
		return TRUE;

        case WM_SIZE:
        {
            int width = LOWORD(lParam);
            int height = HIWORD(lParam);

			HWND hwnd = _treeView.getHSelf();
			if (hwnd)
				::MoveWindow(hwnd, 0, 0, width, height, TRUE);
            break;
        }

        case WM_CONTEXTMENU:
			if (!_treeView.isDragging())
				showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
        return TRUE;

		case WM_COMMAND:
		{
			popupMenuCmd(LOWORD(wParam));
			break;
		}

		case WM_DESTROY:
        {
			_treeView.destroy();
			destroyMenus();
            break;
        }

		case FB_ADDFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);
			generic_string path = rootPath;

			generic_string addedFilePath = file2Change[0].substr(0, sepPos + 1);
			addedFilePath += pathSuffix;
			bool isAdded = addInTree(rootPath, addedFilePath, nullptr, linarPathArray);
			if (not isAdded)
			{
				//MessageBox(NULL, addedFilePath.c_str(), TEXT("file/folder is not added"), MB_OK);
			}
			break;
		}

		case FB_RMFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);
			// search recursively and modify the tree structure

			bool isRemoved = deleteFromTree(rootPath, nullptr, linarPathArray);
			if (not isRemoved)
			{
				//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
			}
			break;
		}

		case FB_RNFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);

			size_t sepPos2 = file2Change[1].find(separator);
			if (sepPos2 == generic_string::npos)
				return false;

			generic_string pathSuffix2 = file2Change[1].substr(sepPos2 + separator.length(), file2Change[1].length() - 1);
			vector<generic_string> linarPathArray2 = split(pathSuffix2, '\\');

			bool isRenamed = renameInTree(rootPath, nullptr, linarPathArray, linarPathArray2);
			if (not isRenamed)
			{
				//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
			}
			break;
		}

        default :
            return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
	return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}
Beispiel #10
0
bool deviceTransaction(iguanaDev *idev,       /* required */
                       dataPacket *request,   /* required */
                       dataPacket **response) /* optional */
{
    bool retval = false;
    packetType *type;

    /* For old devices setting pin configs actually becomes 2
       requests, awkward, but the way it has to be to support old
       firmware. */
    if (idev->version <= 3 && 
        (request->code == IG_DEV_SETPINCONFIG ||
         request->code == IG_DEV_GETPINCONFIG))
        return oldPinConfig(idev, request, response);

    type = checkIncomingProtocol(idev, request, response == NULL);
    if (type)
    {
        unsigned char msg[MAX_PACKET_SIZE] = {CTL_START, CTL_START, CTL_TODEV};
        uint64_t then, now;
        int length = MIN_CTL_LENGTH, result, sent = 0;

#ifdef LIBUSB_NO_THREADS
        bool unlocked = false;
#endif

        /* possibly change the code, then translate for the device */
        switch(request->code)
        {
        case IG_DEV_GETID:
            msg[CODE_OFFSET] = IG_DEV_EXECUTE;
            break;
            
        case IG_DEV_SETID:
        {
            unsigned char *block;
            block = generateIDBlock((char*)request->data, idev->version);
            free(request->data);
            request->data = block;
            request->dataLen = 68;

            msg[CODE_OFFSET] = IG_DEV_WRITEBLOCK;
            break;
        }

        /* clear the features if any page is written since this could
           change the returned timings */
        case IG_DEV_WRITEBLOCK:
            idev->features = UNKNOWN_FEATURES;
        default:
            msg[CODE_OFFSET] = request->code;
            break;
        }
        if (! translateDevice(msg + CODE_OFFSET, idev->version, false))
            message(LOG_ERROR, "Failed to translate code for device.\n");

        /* compute the outgoing checksum for IG_DEV_WRITEBLOCK */
        if (msg[CODE_OFFSET] == IG_DEV_WRITEBLOCK &&
            request->dataLen == 68)
        {
            int x;
            uint32_t chksum = 0;
            for(x = 4; x < 68; x++)
                chksum += request->data[x];
            request->data[2] = (chksum & 0xFF00) >> 8;
            request->data[3] = chksum & 0xFF;
        }

        /* SEND and PINBURST do not get their data packed into the
           request packet, unlike everything else. */
        if (request->code != IG_DEV_SEND &&
            request->code != IG_DEV_RESEND &&
            request->code != IG_DEV_PINBURST &&
            request->code != IG_DEV_REPEATER)
        {
            if (request->code != IG_DEV_SETPINCONFIG)
            {
                sent = request->dataLen;
                /* this is only used to get addresses in WRITEBLOCK */
                if (sent > 4)
                    sent = 4;
                memcpy(msg + MIN_CTL_LENGTH, request->data, sent);
                length += sent;
            }
        }
        /* as of version 3 SEND and PINBURST require a length argument */
        else if (idev->version >= 3)
        {
            int dataPos = MIN_CTL_LENGTH;
            if (request->code == IG_DEV_RESEND)
            {
                /* prepare to append the channels and carrier */
                request->data = realloc(request->data, MAX_PACKET_SIZE);
                request->dataLen = MAX_PACKET_SIZE;

                 /* the size will be overwritten in the device firmware */
                request->data[dataPos++] = 0xFF;
            }
            else
                msg[length++] = (unsigned char)request->dataLen;

            /* select which channels to transmit on */
            if (request->code == IG_DEV_SEND ||
                request->code == IG_DEV_RESEND ||
                request->code == IG_DEV_REPEATER)
            {
                if (request->code == IG_DEV_RESEND)
                    request->data[dataPos++] = idev->channels;
                else
                    msg[length++] = idev->channels;

                /* is the carrier frequency finally adjustable? */
                if ((idev->version & 0x00FF) &&
                    (idev->version & 0xFF00))
                {
                    unsigned char *delays;
                    /* the cycle count WAS stable so default to that count: */
                    uint8_t loopCycles = 5 + 5 + 7 + 6 + 6 + 7 + \
                                         (5 + 7) + (5 + 7) + 5;
                    /* we can use the cycle count provided by the
                       firmware with body-4 */
                    if ((idev->version & 0x00FF) >= 0x0004 &&
                        checkFeatures(idev, UNKNOWN_FEATURES))
                        loopCycles = idev->cycles;

                    /* compute the delay length off the carrier */
                    if (request->code == IG_DEV_RESEND)
                        delays = request->data + dataPos;
                    else
                    {
                        delays = msg + length;
                        length += 2;
                    }
                    computeCarrierDelays(idev->carrier, delays, loopCycles);
                }
            }
        }


#ifdef LIBUSB_NO_THREADS_OPTION
        if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
        {
            /* force the reader to give up the lock */
            idev->needToWrite = true;
            EnterCriticalSection(&idev->devLock);
            idev->needToWrite = false;
        }
#endif

        /* flush any extraneous CTL_TODEV responses */
        flushToDevResponsePackets(idev);
        /* time the transfer */
        then = microsSinceX();
        result = interruptSend(idev->usbDev, msg, length,
                               idev->settings->sendTimeout);
        /* error if we were not able to write ALL the data */
        if (result != length)
            printError(LOG_ERROR,
                       "failed to write control packet", idev->usbDev);
        /* if there is more data need to transmit the data stream
           before releasing the devLock */
        else if (request->dataLen > sent &&
                 ! sendData(idev,
                            request->data + sent, request->dataLen - sent,
                            idev->version < 3 && request->code == IG_DEV_SEND))
            message(LOG_ERROR, "Failed to send IR data.\n");
        /* if no ack is necessary then return success now */
        else if (! type->ack)
            retval = true;
        else
        {
            int amount;

#ifdef LIBUSB_NO_THREADS_OPTION
            if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
            {
                /* unlock as soon as possible after all data has been sent */
                LeaveCriticalSection(&idev->devLock);
                unlocked = true;
            }
#endif

            /* using sendTimeout to ensure reader has necessary time
               to recieve the ack */
            amount = notified(idev->responsePipe[READ],
                              idev->settings->sendTimeout);
            if (amount < 0)
                message(LOG_ERROR, "Failed to read control ack: %s\n",
                        translateError(errno));
            else if (amount > 0)
            {
                dataPacket *pos;

                EnterCriticalSection(&idev->listLock);
                pos = idev->response;

                /* un-translate the SETID/WRITEBLOCK codes */
                if (request->code == IG_DEV_SETID &&
                    pos->code == IG_DEV_WRITEBLOCK)
                    pos->code = IG_DEV_SETID;

                errno = EINVAL;
                if (pos->code != IG_DEV_INVALID_ARG)
                {
                    if (pos->code != request->code)
                        message(LOG_ERROR,
                                "Bad ack for send: 0x%x != 0x%x\n",
                                pos->code, request->code);
                    else if (! payloadMatch((unsigned char)type->inData, (unsigned char)pos->dataLen))
                        message(LOG_ERROR, "Response size does not match specification (version 0x%x: %d != %d)\n", idev->version, pos->dataLen,type->inData);
                    else
                    {
                        /* store the retrieved response */
                        if (response != NULL)
                            *response = pos;
                        else
                            freeDataPacket(pos);
                        pos = NULL;

                        /* how long did this all take? */
                        now = microsSinceX();
                        message(LOG_INFO,
                                "Transaction: 0x%x (%lld microseconds)\n",
                                request->code, now - then);
                        retval = true;
                    }
                }

                freeDataPacket(pos);
                idev->response = NULL;
                LeaveCriticalSection(&idev->listLock);
            }
            else
            {
                message(LOG_INFO,
                        "Timeout while waiting for response from device.\n");
                errno = ETIMEDOUT;
            }
        }

#ifdef LIBUSB_NO_THREADS_OPTION
        if (idev->libusbNoThreads)
#endif
#ifdef LIBUSB_NO_THREADS
            /* certain errors may result in unlocking here */
            if (!unlocked)
                LeaveCriticalSection(&idev->devLock);
#endif
    }
BOOL CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
		// Make edit field red if not found
		case WM_CTLCOLOREDIT :
		{
			// if the text not found modify the background color of the editor
			static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR);
			TCHAR text2search[MAX_PATH] ;
			::SendMessage(_hSearchEdit, WM_GETTEXT, MAX_PATH, (LPARAM)text2search);
			if (text2search[0] == '\0')
			{
				return FALSE; // no text, use the default color
			}

			HTREEITEM searchViewRoot = _treeViewSearchResult.getRoot();
			if (searchViewRoot)
			{
				if (_treeViewSearchResult.getChildFrom(searchViewRoot))
					return FALSE; // children on root found, use the default color
			}
			else
				return FALSE; // no root (no parser), use the default color
			// text not found
			SetTextColor((HDC)wParam, TXT_COLOR);
			SetBkColor((HDC)wParam, BCKGRD_COLOR);
			return (LRESULT)hBrushBackground;
		}

        case WM_INITDIALOG :
        {
			int editWidth = 100;
			int editHeight = 20;
			// Create toolbar menu
			//int style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
			int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
			_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
								   0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL);
			
			//::GetWindowLongPtr(_hToolbarMenu, GWL_WNDPROC);
			oldFunclstToolbarProc = (WNDPROC)::SetWindowLongPtr(_hToolbarMenu, GWLP_WNDPROC, (LONG_PTR)funclstToolbarProc);
			TBBUTTON tbButtons[3];

			// Add the bmap image into toolbar's imagelist 
			TBADDBITMAP addbmp = {_hInst, 0};
			addbmp.nID = IDI_FUNCLIST_SORTBUTTON;
			::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
			addbmp.nID = IDI_FUNCLIST_RELOADBUTTON;
			::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, (LPARAM)&addbmp);

			// Place holder of search text field
			tbButtons[0].idCommand = 0;
			tbButtons[0].iBitmap = editWidth + 10;
			tbButtons[0].fsState = TBSTATE_ENABLED;
			tbButtons[0].fsStyle = BTNS_SEP;
			tbButtons[0].iString = 0;
			
			tbButtons[1].idCommand = IDC_SORTBUTTON_FUNCLIST;
			tbButtons[1].iBitmap = 0;
			tbButtons[1].fsState =  TBSTATE_ENABLED;
			tbButtons[1].fsStyle = BTNS_CHECK | BTNS_AUTOSIZE;
			tbButtons[1].iString = (INT_PTR)TEXT("");

			tbButtons[2].idCommand = IDC_RELOADBUTTON_FUNCLIST;
			tbButtons[2].iBitmap = 1;
			tbButtons[2].fsState = TBSTATE_ENABLED;
			tbButtons[2].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
			tbButtons[2].iString = (INT_PTR)TEXT("");

			::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
			::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE , (WPARAM)0, (LPARAM)MAKELONG (16, 16));
			::SendMessage(_hToolbarMenu, TB_ADDBUTTONS,       (WPARAM)sizeof(tbButtons) / sizeof(TBBUTTON),       (LPARAM)&tbButtons);
			::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);

			ShowWindow(_hToolbarMenu, SW_SHOW);

			// tips text for toolbar buttons
			NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
			_sortTipStr = pNativeSpeaker->getAttrNameStr(_sortTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_SORTLOCALNODENAME);
			_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
			
			_hSearchEdit = CreateWindowEx(0L, L"Edit", NULL, 
                                   WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL, 
                                   2, 2, editWidth, editHeight, 
                                   _hToolbarMenu, (HMENU) IDC_SEARCHFIELD_FUNCLIST, _hInst, 0 );

			HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);

			if (hf)
				::SendMessage(_hSearchEdit, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));

			_treeViewSearchResult.init(_hInst, _hSelf, IDC_LIST_FUNCLIST_AUX);
			_treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST);
			setTreeViewImageList(IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF);
			
			_treeView.display();
            return TRUE;
        }
		
		case WM_DESTROY:
			_treeView.destroy();
			_treeViewSearchResult.destroy();
			::DestroyWindow(_hToolbarMenu);
			break;

		case WM_COMMAND : 
		{
			if (HIWORD(wParam) == EN_CHANGE)
			{
				switch (LOWORD(wParam))
				{
					case  IDC_SEARCHFIELD_FUNCLIST:
					{
						searchFuncAndSwitchView();
						return TRUE;
					}
				}
			}

			switch (LOWORD(wParam))
            {
				case IDC_SORTBUTTON_FUNCLIST:
				{
					sortOrUnsort();
				}
				return TRUE;

				case IDC_RELOADBUTTON_FUNCLIST:
				{
					reload();
				}
				return TRUE;
			}
		}
		break;
		
		case WM_NOTIFY:
		{
			notified((LPNMHDR)lParam);
		}
		return TRUE;

        case WM_SIZE:
        {
            int width = LOWORD(lParam);
            int height = HIWORD(lParam);
			RECT toolbarMenuRect;
            ::GetClientRect(_hToolbarMenu, &toolbarMenuRect);

            ::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);
			
			HWND hwnd = _treeView.getHSelf();
			if (hwnd)
				::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);

			HWND hwnd_aux = _treeViewSearchResult.getHSelf();
			if (hwnd_aux)
				::MoveWindow(hwnd_aux, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
			
            break;
        }

        default :
            return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
	return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}