Example #1
0
LRESULT CALLBACK win_proc(HWND win, UINT message, WPARAM w_param, 
                          LPARAM l_param)
{
  DEV_BROADCAST_HDR *hdr = (DEV_BROADCAST_HDR *) l_param;

  switch(message) 
    {
    case WM_DESTROY:
      if(notification_handle_hub)
        UnregisterDeviceNotification(notification_handle_hub);
      if(notification_handle_dev)
        UnregisterDeviceNotification(notification_handle_dev);

      PostQuitMessage(0);
      break;

    case WM_SIZE:
      on_size(LOWORD(l_param), HIWORD(l_param));
      break;

    case WM_COMMAND:
      switch(LOWORD(w_param))
        {
        case ID_EXIT:
          PostQuitMessage(0);
          break;
        case ID_REFRESH:
          on_refresh();
          break;
        default:
          return DefWindowProc(win, message, w_param, l_param );
        }
      break;

    case WM_DEVICECHANGE:
      switch(w_param)
        {
        case DBT_DEVICEREMOVECOMPLETE:
          if(hdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) 
            on_refresh();
          break;
        case DBT_DEVICEARRIVAL:
          if(hdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
            on_refresh();
          break;
        default:
          ;
        }
      break;

    default:
      return DefWindowProc(win, message, w_param, l_param);
    }

  return 0;
}
JoystickListWidget::JoystickListWidget()
  : Gtk::Dialog("Joystick Preferences"),
    label("Below is a list of available joysticks on the system. Press Refresh to "
          "update the list, press Properties to get a separate device dialog. The "
          "devices listed are only joystick devices, not evdev devices or SDL "
          "devices, you can view the other ones via the top tab.")
    //frame("Device List"),
{
  set_has_separator(false);
  set_default_size(450, 310);

  label.set_line_wrap();

  scrolled.set_border_width(5);
  scrolled.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
  scrolled.add(treeview);
  get_vbox()->add(scrolled);

  add_button(Gtk::Stock::REFRESH, 2);
  add_button(Gtk::Stock::PROPERTIES, 1);
  add_button(Gtk::Stock::CLOSE, 0);

  signal_response().connect(sigc::mem_fun(this, &JoystickListWidget::on_response));

  // Set model
  device_list = Gtk::ListStore::create(DeviceListColumns::instance());
  treeview.set_model(device_list);
  treeview.set_headers_visible(false);
  treeview.append_column("Icon", DeviceListColumns::instance().icon);
  treeview.append_column("Name", DeviceListColumns::instance().name);

  treeview.signal_row_activated().connect(sigc::mem_fun(this, &JoystickListWidget::on_row_activated));

  on_refresh();
}
Example #3
0
    _variant_t Get(const std::_tstring & section, const std::_tstring & label, const _variant_t & defaultVal)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        SectionLabelDefault sl(SectionLabel(section, label), defaultVal);
        ConfigCacheT::const_iterator found = m_cache.find(sl.first);
        if(sl == GLOBAL_USER && found != m_cache.end())
            if (!CString(m_cache[sl.first]).IsEmpty())
                return m_cache[sl.first];
        if(sl == GLOBAL_PASSWORD && found != m_cache.end())
            if (!CString(m_cache[sl.first]).IsEmpty())
                return m_cache[sl.first];

        if (!m_CfgPath.empty())
        {
            if (found != m_cache.end())
                return found->second;

            CString _defaultVal = defaultVal, _val;
            if (!m_Cfg.GetString(section.c_str(), label.c_str(), _val, _defaultVal))
            {
                //ATLTRACE(_T("GetString(%s,%s,Err=%x)\r\n"), section, label, ::GetLastError() );
                _val = _defaultVal;
            }
            SectionLabel id(section, label);
            if (CString(m_cache[id]).CompareNoCase(_val) != 0)
            {
                m_cache[id] = _val;
                _variant_t retVal = m_cache[sl.first];
                proc.unlock();
                on_refresh(&id);
                return retVal;
            }
        }
        return m_cache[sl.first];
    }
Example #4
0
	void operator()(clib::CThreadQueue * threadQueue, clib::THREAD_EVENT evt)
	{
		if (threadQueue == &m_classifyThreads)
		{
			switch(evt)
			{
			case clib::THREAD_EVENT_END:
				on_refresh(this, EVENT_CLASSIFIED);
			}
		}
		else if (threadQueue == &m_resolveThreads)
		{
			switch(evt)
			{
			case clib::THREAD_EVENT_END:
				on_refresh(this, EVENT_RESOLVED);
			}
		}
	}
Example #5
0
	void StartResolve()
	{
		clib::recursive_mutex::scoped_lock proc(m_mutex);
		if (m_resolved)
		{
			proc.unlock();
			on_refresh(this, EVENT_RESOLVED);
			return;
		}
		m_resolved = true;
		Analysis::IEntityVector entities;
		GetEntities(&entities);
		m_resolveThreads.Append(__FUNCTION__, boost::bind(&threadResolve, this, entities));
	}
void
JoystickListWidget::on_response(int v)
{
  if (v == 0)
    {
      hide();
    }
  else if (v == 1)
    {
      on_properties();
    }
  else if (v == 2)
    {
      on_refresh();
    }
}
Example #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    timer(new QTimer)
{
    ui->setupUi(this);
//    this->showFullScreen();
//	this->setFocus();
//	repaint();
	resize(400,180);
	move(10,10);
//	timer->setInterval(500);
//	connect(timer, SIGNAL(timeout()), this, SLOT(on_refresh()));
//	timer->start();
#ifdef REFRESH
	QTimer::singleShot(100, this, SLOT(on_refresh()));
#endif
}
Example #8
0
 void Set(const std::_tstring & section, const std::_tstring & label, const _variant_t & val)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     SectionLabelDefault sl(SectionLabel(section, label), _T(""));
     if(sl == GLOBAL_USER)
     {
         InitConfigPath(m_CfgName, _T("cfg"));
     }
     SectionLabel id(section, label);
     if (m_cache.find(id) == m_cache.end() || CString(m_cache[id]).CompareNoCase(CString(val)) != 0)
     {
         if (!m_CfgPath.empty() && sl != GLOBAL_PASSWORD)
         {
             CString _val = val;
             if ( !m_Cfg.PutString(section.c_str(), label.c_str(), _val) )
             {
                 ATLTRACE(_T("PutString(%s,%s,Err=%x)\r\n"), section, label, ::GetLastError() );
             }
         }
         m_cache[id] = val;
         proc.unlock();
         on_refresh(&id);
     }
 }
Example #9
0
    ExplorerReplicaSetFolderItem::ExplorerReplicaSetFolderItem(ExplorerTreeItem *parent, MongoServer *const server) :
        BaseClass(parent), _server(server)
    {
        //VERIFY(connect(this, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(on_expanded())));

        auto repSetStatus = new QAction("Status of Replica Set", this);
        VERIFY(connect(repSetStatus, SIGNAL(triggered()), SLOT(on_repSetStatus())));

        auto refresh = new QAction("Refresh", this);
        VERIFY(connect(refresh, SIGNAL(triggered()), SLOT(on_refresh())));

        BaseClass::_contextMenu->addAction(repSetStatus);
        BaseClass::_contextMenu->addSeparator();
        BaseClass::_contextMenu->addAction(refresh);

        AppRegistry::instance().bus()->subscribe(this, ReplicaSetFolderLoading::Type, _server);

        setIcon(0, GuiRegistry::instance().folderIcon());
        // todo: use repSize()
        setText(0, "Replica Set (" + QString::number(_server->replicaSetInfo()->membersAndHealths.size()) + " nodes)");

        setExpanded(false);
        setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
    }
Example #10
0
	void Refresh() 
	{
		on_refresh(this);
	}
Example #11
0
int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev_instance,
                     LPSTR cmd_line, int cmd_show)
{
  MSG msg;
  WNDCLASSEX win_class;
  DEV_BROADCAST_DEVICEINTERFACE dev_if;

  LoadLibrary("comctl32.dll");

  win_class.cbSize = sizeof(WNDCLASSEX); 
  
  win_class.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS ;
  win_class.lpfnWndProc = win_proc;
  win_class.cbClsExtra = 0;
  win_class.cbWndExtra = 0;
  win_class.hInstance = instance;
  win_class.hIcon = NULL;
  win_class.hCursor = LoadCursor(NULL, IDC_ARROW);
  win_class.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
  win_class.lpszMenuName = NULL;
  win_class.lpszClassName = LIBUSB_WINDOW_CLASS;
  win_class.hIconSm = NULL;

  RegisterClassEx(&win_class);

  main_win = CreateWindowEx(WS_EX_APPWINDOW| WS_EX_CONTROLPARENT,
                            LIBUSB_WINDOW_CLASS, 
                            "TestLibUsb - Windows Version", 
                            WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN 
                            | WS_DLGFRAME,
                            CW_USEDEFAULT, 0, 500, 500, NULL, NULL, 
                            instance, NULL);
  if(!main_win) 
    {
      return FALSE;
    }


  exit_button = CreateWindow("BUTTON", "Exit",
                             WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                             10, 10, 
                             LIBUSB_BUTTON_WIDTH, LIBUSB_BUTTON_HEIGHT, 
                             main_win, (HMENU) ID_EXIT, instance, NULL);

  refresh_button = CreateWindow("BUTTON", "Refresh",
                                WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                                10, 100, 
                                LIBUSB_BUTTON_WIDTH, LIBUSB_BUTTON_HEIGHT, 
                                main_win, (HMENU) ID_REFRESH, instance, 
                                NULL);

  edit_box = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", NULL,
                            WS_CHILD | WS_VISIBLE | WS_VSCROLL | 
                            ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL 
                            | ES_AUTOHSCROLL | ES_READONLY, 
                            CW_USEDEFAULT, CW_USEDEFAULT, 
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            main_win, (HMENU) ID_EDIT, instance, NULL); 

  SendMessage(edit_box, WM_SETFONT, (WPARAM) CreateFont(13, 8, 0, 0,
                                                        400, 0, 0, 0,
                                                        0, 1, 2, 1,
                                                        49, "Courier"), 0);

  ShowWindow(main_win, cmd_show);
  UpdateWindow(main_win);
  BringWindowToTop(main_win);

  usb_set_debug(4);
  usb_init();
  usb_find_busses();

  on_refresh();

  dev_if.dbcc_size = sizeof(dev_if);
  dev_if.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
  dev_if.dbcc_classguid = GUID_DEVINTERFACE_USB_HUB;

  notification_handle_hub = RegisterDeviceNotification(main_win, &dev_if, 0);

  dev_if.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;

  notification_handle_dev = RegisterDeviceNotification(main_win, &dev_if, 0);

  while(GetMessage(&msg, NULL, 0, 0) ) 
    {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }

  DestroyWindow(main_win);
  UnregisterClass(LIBUSB_WINDOW_CLASS, instance);

  return 0;
}
Example #12
0
	void StartClassify(const CComBSTR & scriptText)
	{
		clib::recursive_mutex::scoped_lock proc(m_mutex);
		if (m_classified)
		{
			proc.unlock();
			on_refresh(this, EVENT_CLASSIFIED);
			return;
		}
		m_classified = true;
		ClassifyStructVector request;
		
		//Process Main Frame
		InsertScript(m_doc, scriptText);
		PrepRequest(m_doc, request);
		
		//Process Child Frames
		CComQIPtr<IOleContainer> pContainer = m_doc;
		if (!pContainer)
			return;

		CComPtr<IEnumUnknown> pEnumerator;
		HRESULT hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
		if (FAILED(hr))
			return;

		CComPtr<IUnknown> pUnk;
		ULONG uFetched;
		for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
		{
			CComQIPtr<IWebBrowser2> pBrowser = pUnk;
			if (pBrowser)
			{
				CComPtr<IDispatch> spDispDoc;
				HRESULT hr = pBrowser->get_Document(&spDispDoc);
				if (SUCCEEDED(hr))
				{
					// ...and query for an HTML document.
					CComQIPtr<IHTMLDocument> spHTMLDoc = spDispDoc;
					if (spHTMLDoc)
					{
						InsertScript(spHTMLDoc, scriptText);
						PrepRequest(spHTMLDoc, request);
					}
				}
			}
			pUnk.Release();
		}

		m_classifyThreads.SetMaxThreadCount(0);
		ClassifyStructVector batchRequest;
		int textLen = 0;
		for(ClassifyStructVector::iterator itr = request.begin(); itr != request.end(); ++itr)
		{
			textLen += itr->text.length();
			batchRequest.push_back(*itr);
			if (textLen > BATCH_SIZE)
			{
				m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
				batchRequest.clear();
				textLen = 0;
			}
		}
		if (batchRequest.size())
		{
			m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
			batchRequest.clear();
		}
		m_classifyThreads.SetMaxThreadCount(THREAD_COUNT);
		//int textLen = 0;
		//BOOL finished = false;
		//HRESULT hr = S_OK;
		//while(hr == S_OK && !finished)
		//{
		//	MARKUP_CONTEXT_TYPE pContext = CONTEXT_TYPE_None;
		//	long pcch = -1;
		//	prev->MoveToPointer(finger);
		//	hr = finger->Right(true, &pContext, NULL, &pcch, NULL);
		//	if (pContext == CONTEXT_TYPE_Text && pcch > 1)
		//	{
		//		ClassifyStruct newItem;
		//		newItem.text.resize(pcch);
		//		prev->Right(false, NULL, NULL, &pcch, &newItem.text[0]);
		//		std::wstring testStr = newItem.text;
		//		boost::algorithm::trim(testStr);
		//		if (testStr.length())
		//		{
		//			markupServices->CreateMarkupPointer(&newItem.textNode);
		//			newItem.textNode->MoveToPointer(prev);
		//			request.push_back(newItem);
		//			textLen += pcch;
		//			if (textLen > 1000)
		//			{
		//				m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, request));
		//				request.clear();
		//				textLen = 0;
		//			}
		//		}
		//	}
		//	finger->IsRightOfOrEqualTo(end, &finished);
		//}
		//if (request.size())
		//{
		//	m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, request));
		//	request.clear();
		//}
		//m_classifyThreads.SetMaxThreadCount(THREAD_COUNT);
	}
Example #13
0
ListUsb::ListUsb()
{
    set_title("lsusb");
    maximize();
    
    add(m_box);
    m_scrolled_window.add(m_tree_view);
    m_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);

    m_refActionGroup=Gtk::ActionGroup::create();
    m_refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
          sigc::mem_fun(*this, &ListUsb::on_quit));
    m_refActionGroup->add(Gtk::Action::create("Refresh", Gtk::Stock::REFRESH),
          sigc::mem_fun(*this, &ListUsb::on_refresh));
  
    m_refUIManager=Gtk::UIManager::create();
    m_refUIManager->insert_action_group(m_refActionGroup);

    add_accel_group(m_refUIManager->get_accel_group());

    Glib::ustring ui_info = 
        "<ui>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='Refresh'/>"
        "    <toolitem action='Quit'/>"
        "  </toolbar>"
        "</ui>";

    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
        m_refUIManager->add_ui_from_string(ui_info);
    }
    catch(const Glib::Error& ex)
    {
        fprintf(stderr,"building menus failed: %s",ex.what().c_str());
    }
    #else
    std::auto_ptr<Glib::Error> ex;
    m_refUIManager->add_ui_from_string(ui_info,ex);
    if(ex.get())
    {
        fprintf(stderr,"building menus failed: %s",ex->what());
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED

    Gtk::Widget* pToolbar = m_refUIManager->get_widget("/ToolBar") ;
    if(pToolbar)
        m_box.pack_start(*pToolbar,Gtk::PACK_SHRINK);
    m_box.pack_start(m_scrolled_window);

    m_ref_tree_model=Gtk::TreeStore::create(m_columns);
    m_tree_view.set_model(m_ref_tree_model);
    
    //Add the TreeView's view columns:
    Gtk::TreeViewColumn col_name("Name",m_columns.m_col_name);
    Gtk::TreeViewColumn col_value("Value",m_columns.m_col_value);
    Gtk::TreeViewColumn col_comment("Comment",m_columns.m_col_comment);
    
    col_name.set_resizable();
    col_value.set_resizable();
    col_comment.set_resizable();
    
    m_tree_view.append_column(col_name);
    m_tree_view.append_column(col_value);
    m_tree_view.append_column(col_comment);

    show_all_children();
    
    on_refresh();
}
Example #14
0
/* browserwindow_on_refresh */
static void _browserwindow_on_refresh(gpointer data)
{
	BrowserWindow * browser = data;

	on_refresh(browser->browser);
}