Exemplo n.º 1
0
NS_IMETHODIMP
otSystrayWin::SetTooltip(const nsAString &tooltip)
{
  otSystrayBase::SetTooltip(tooltip);

  if (mNid) {
    NOTIFYICONDATA nid;

    nid.cbSize = sizeof(nid);
    nid.hWnd = GetHWND();
    nid.uFlags = NIF_TIP;
    nid.uID = mNid;

    StringCchCopy(nid.szTip, 64, NS_ConvertUTF16toUTF8(mTooltip).get());

    Shell_NotifyIcon(NIM_MODIFY, &nid);
  }

  return NS_OK;
}
Exemplo n.º 2
0
wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
{
    wxSize sizeBtn = wxSpinButton::DoGetBestSize();

    int y;
    wxGetCharSize(GetHWND(), NULL, &y, GetFont());
    // JACS: we should always use the height calculated
    // from above, because otherwise we'll get a spin control
    // that's too big. So never use the height calculated
    // from wxSpinButton::DoGetBestSize().

    wxSize tsize(xlen + sizeBtn.x + MARGIN_BETWEEN + 3*y/10 + 10,
                 EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));

    // Check if the user requested a non-standard height.
    if ( ylen > 0 )
        tsize.IncBy(0, ylen - y);

    return tsize;
}
Exemplo n.º 3
0
LRESULT TopWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	GuiLock __;
	HWND hwnd = GetHWND();
#ifndef PLATFORM_WINCE
	bool inloop;
#endif
	switch(message) {
#ifndef PLATFORM_WINCE
	case WM_QUERYENDSESSION:
		inloop = InLoop();
		WhenClose();
		return inloop ? !InLoop() : !IsOpen();
#endif
	case WM_CLOSE:
		if(IsEnabled()) {
			IgnoreMouseUp();
			WhenClose();
		}
		return 0;
	case WM_WINDOWPOSCHANGED:
		if(!isopen)
			break;
#ifndef PLATFORM_WINCE
		if(IsIconic(hwnd))
			state = MINIMIZED;
		else
		if(IsZoomed(hwnd))
			state = MAXIMIZED;
		else
#endif
		{
			state = OVERLAPPED;
			if(IsWindowVisible(hwnd)) overlapped = GetScreenClient(hwnd); // 12-05-23 Tom added 'if(IsWindowVisible(hwnd))' to get only proper rectangles
		}
		LLOG("TopWindow::WindowProc::WM_WINDOWPOSCHANGED: overlapped = " << overlapped);
		Layout();
		break;
	}
	return Ctrl::WindowProc(message, wParam, lParam);
}
Exemplo n.º 4
0
	void UpdateMenus()
	{
		HMENU menu = GetMenu(GetHWND());
#define CHECKITEM(item,value) 	CheckMenuItem(menu,item,MF_BYCOMMAND | ((value) ? MF_CHECKED : MF_UNCHECKED));

		CHECKITEM(ID_EMULATION_SPEEDLIMIT,g_Config.bSpeedLimit);
//		CHECK(ID_OPTIONS_ENABLEFRAMEBUFFER,g_Config.bEnableFrameBuffer);
//		CHECK(ID_OPTIONS_EMULATESYSCALL,g_bEmulateSyscall);
		CHECKITEM(ID_OPTIONS_DISPLAYRAWFRAMEBUFFER, g_Config.bDisplayFramebuffer);
		CHECKITEM(ID_OPTIONS_IGNOREILLEGALREADS,g_Config.bIgnoreBadMemAccess);
		CHECKITEM(ID_CPU_INTERPRETER,g_Config.iCpuCore == CPU_INTERPRETER);
		CHECKITEM(ID_CPU_FASTINTERPRETER,g_Config.iCpuCore == CPU_FASTINTERPRETER);
		CHECKITEM(ID_CPU_DYNAREC,g_Config.iCpuCore == CPU_JIT);
		CHECKITEM(ID_OPTIONS_BUFFEREDRENDERING, g_Config.bBufferedRendering);
		CHECKITEM(ID_OPTIONS_SHOWDEBUGSTATISTICS, g_Config.bShowDebugStats);

		BOOL enable = !Core_IsStepping();
		EnableMenuItem(menu,ID_EMULATION_RUN,enable);
		EnableMenuItem(menu,ID_EMULATION_PAUSE,!enable);

		enable = g_State.bEmuThreadStarted;
		EnableMenuItem(menu,ID_FILE_LOAD,enable);
		EnableMenuItem(menu,ID_CPU_DYNAREC,enable);
		EnableMenuItem(menu,ID_CPU_INTERPRETER,enable);
		EnableMenuItem(menu,ID_CPU_FASTINTERPRETER,enable);
		EnableMenuItem(menu,ID_DVD_INSERTISO,enable);
		EnableMenuItem(menu,ID_FILE_BOOTBIOS,enable);
		EnableMenuItem(menu,ID_EMULATION_STOP,!enable);
		EnableMenuItem(menu,ID_OPTIONS_SETTINGS,enable);
		EnableMenuItem(menu,ID_PLUGINS_CHOOSEPLUGINS,enable);

		const int zoomitems[4] = {
			ID_OPTIONS_SCREEN1X,
			ID_OPTIONS_SCREEN2X,
			ID_OPTIONS_SCREEN3X,
			ID_OPTIONS_SCREEN4X,
		};
		for (int i = 0; i < 4; i++) {
			CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED));
		}
	}
Exemplo n.º 5
0
// Insert an item
bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
{
    wxChar buf[256];
    TC_ITEM tcItem;
    tcItem.mask = TCIF_PARAM;
    tcItem.lParam = (long) data;
    if (!text.empty())
    {
        tcItem.mask |= TCIF_TEXT;
        wxStrcpy(buf, (const wxChar*) text);
        tcItem.pszText = buf;
        tcItem.cchTextMax = 256;
    }
    if (imageId != -1)
    {
        tcItem.mask |= TCIF_IMAGE;
        tcItem.iImage = imageId;
    }

    return (TabCtrl_InsertItem( (HWND) GetHWND(), item, & tcItem) != -1);
}
Exemplo n.º 6
0
NS_IMETHODIMP
otSystrayWin::Hide()
{
  nsresult rv = otSystrayBase::Hide();

  if (NS_SUCCEEDED(rv) && mNid) {
    NOTIFYICONDATA nid;

    nid.cbSize = sizeof(nid);
    nid.hWnd = GetHWND();
    nid.uFlags = 0;
    nid.uID = mNid;

    Shell_NotifyIcon(NIM_DELETE, &nid);

    systrays[mNid-100] = 0;
    mNid = 0;
  }

  return rv;
}
Exemplo n.º 7
0
void Ctrl::WndFree()
{
	GuiLock __;
	if(!top) return;
	RevokeDragDrop(GetHWND());
	ReleaseUDropTarget(top->dndtgt);
	isopen = false;
	if(!top) return;
	HWND owner = GetWindow(top->hwnd, GW_OWNER);// CXL 31.10.2003 z DoRemove
	bool focus = ::GetFocus() == top->hwnd;
	LLOG("Ctrl::WndDestroy owner " << (void *)owner
	     << " focus " << focus
	     << " ::GetFocus() " << (void *)::GetFocus());
	if(owner && focus) { // CXL 7.11.2003 presun - melo by to fungovat take a neblikat...
		LLOG("Ctrl::WndFree->SetFocus " << UPP::Name(Ctrl::CtrlFromHWND(owner)));
		::SetFocus(owner);
	}
	LLOG(LOG_END << "//Ctrl::WndFree() in " <<UPP::Name(this));
	delete top;
	top = NULL;
}
Exemplo n.º 8
0
wxSize wxSpinCtrl::DoGetBestSize() const
{
    wxSize sizeBtn = wxSpinButton::DoGetBestSize();
    sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;

    int y;
    wxGetCharSize(GetHWND(), NULL, &y, GetFont());
    y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(y);

    // JACS: we should always use the height calculated
    // from above, because otherwise we'll get a spin control
    // that's too big. So never use the height calculated
    // from wxSpinButton::DoGetBestSize().

    // if ( sizeBtn.y < y )
    {
        // make the text tall enough
        sizeBtn.y = y;
    }

    return sizeBtn;
}
Exemplo n.º 9
0
LRESULT CLoginWnd::ScanQrcode(UINT uMsg, LoginResult *res, int error_code, BOOL& bHandled)
{
	if (!res)	QuitWithMsg(L"登录异常,即将退出!");

	//显示提示消息
	if (!res->szMsg || !strlen(res->szMsg))
	{
		strcpy(res->szMsg, "未知错误");
	}
	ShowLoginResult("错误码:%d,失败原因:%s", error_code, res->szMsg);

	//弹出页面
	ShellExecute(NULL, L"open", L"iexplore.exe", CA2W(res->szUrl), NULL, SW_SHOWNORMAL);

	//卡住主界面,等待用户扫码成功后重新登录
	MessageBox(GetHWND(), L"扫码授权成功后请重新登录", L"扫码授权", NULL);

	SAFE_DELETE(res);

	bHandled = TRUE;
	return 0;
}
Exemplo n.º 10
0
HRESULT DropTarget::DragEnter(IDataObject* data_object,
							  DWORD key_state,
							  POINTL cursor_position,
							  DWORD* effect) {
								  // Tell the helper that we entered so it can update the drag image.
								  IDropTargetHelper* drop_helper = DropHelper();
								  if (drop_helper) {
									  drop_helper->DragEnter(GetHWND(), data_object,
										  reinterpret_cast<POINT*>(&cursor_position), *effect);
								  }

								  // You can't drag and drop within the same HWND.
								  if (suspended_) {
									  *effect = DROPEFFECT_NONE;
									  return S_OK;
								  }

								  current_data_object_ = data_object;
								  POINT screen_pt = { cursor_position.x, cursor_position.y };
								  *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect);
								  return S_OK;
}
Exemplo n.º 11
0
wxSize wxCheckBox::DoGetBestSize() const
{
    static int s_checkSize = 0;

    if ( !s_checkSize )
    {
        wxScreenDC dc;
        dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));

        s_checkSize = dc.GetCharHeight();
    }

    wxString str = wxGetWindowText(GetHWND());

    int wCheckbox, hCheckbox;
    if ( !str.empty() )
    {
        wxClientDC dc(const_cast<wxCheckBox *>(this));
        dc.SetFont(GetFont());
        dc.GetMultiLineTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox);
        wCheckbox += s_checkSize + GetCharWidth();

        if ( hCheckbox < s_checkSize )
            hCheckbox = s_checkSize;
    }
    else
    {
        wCheckbox = s_checkSize;
        hCheckbox = s_checkSize;
    }
#ifdef __WXWINCE__
    hCheckbox += 1;
#endif

    wxSize best(wCheckbox, hCheckbox);
    CacheBestSize(best);
    return best;
}
Exemplo n.º 12
0
/*	void CEditWnd::Init(CEditUI* pOwner)
	{
		m_pOwner = pOwner;
		RECT rcPos = CalPos();
		UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
		if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
		Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
		HFONT hFont=NULL;
		int iFontIndex=m_pOwner->GetFont();
		if (iFontIndex!=-1)
			hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
		if (hFont==NULL)
			hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;

		SetWindowFont(m_hWnd, hFont, TRUE);
		Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
		if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
		Edit_SetText(m_hWnd, m_pOwner->GetText());
		Edit_SetModify(m_hWnd, FALSE);
		SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
		Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
		Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
		//Styls
		LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
		styleValue |= pOwner->GetWindowStyls();
		::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
		::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
		::SetFocus(m_hWnd);
		m_bInit = true;    
	}
	*/
	void CEditWnd::Init(CEditUI* pOwner)
	{
		m_pOwner = pOwner;
		RECT rcPos = CalPos();
		//UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
		UINT uStyle = WS_POPUP | ES_AUTOHSCROLL | WS_VISIBLE;
		RECT rcWnd={0};
		::GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWnd);
		rcPos.left += rcWnd.left;
		rcPos.right += rcWnd.left;
		rcPos.top += rcWnd.top;
		rcPos.bottom += rcWnd.top;

		if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
		Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
		HFONT hFont=NULL;
		int iFontIndex=m_pOwner->GetFont();
		if (iFontIndex!=-1)
			hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
		if (hFont==NULL)
			hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;

		SetWindowFont(m_hWnd, hFont, TRUE);
		Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
		if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
		Edit_SetText(m_hWnd, m_pOwner->GetText());
		Edit_SetModify(m_hWnd, FALSE);
		SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
		Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
		Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
		//Styls
		LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
		styleValue |= pOwner->GetWindowStyls();
		::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
		::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
		::SetFocus(m_hWnd);
		m_bInit = true;    
	}
Exemplo n.º 13
0
wxSize CSizeComboBox::DoGetBestSize() const
{
    int wChoice = 0;
    int hChoice;
    const unsigned int nItems = GetCount();
    for( unsigned int i = 0; i < nItems; i++ )
    {
        int wLine;
        GetTextExtent( GetString( i ), &wLine, NULL );
        if( wLine > wChoice )
            wChoice = wLine;
    }
    if( wChoice == 0 )
        wChoice = 100;
    wChoice += 5 * GetCharWidth();
    int cx, cy;
    wxGetCharSize( GetHWND(), &cx, &cy, GetFont() );
    int hItem = SendMessage( GetHwnd(), CB_GETITEMHEIGHT, (WPARAM) -1, 0 );
    hChoice = ( EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * 6 ) + hItem  - 6;
    wxSize best( wChoice, hChoice );
    CacheBestSize( best );
    return best;
}
Exemplo n.º 14
0
	void CEditWnd::Init(CEditUI* pOwner)
	{
		m_pOwner = pOwner;
		RECT rcPos = CalPos();
		UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
		if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
		Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
		SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE);
		Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
		if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
		Edit_SetText(m_hWnd, m_pOwner->GetText());
		Edit_SetModify(m_hWnd, FALSE);
		SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
		Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
		Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
		//Styls
		LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
		styleValue |= pOwner->GetWindowStyls();
		::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
		::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
		::SetFocus(m_hWnd);
		m_bInit = true;    
	}
Exemplo n.º 15
0
void wxMDIChildFrame::MSWDestroyWindow()
{
    wxMDIParentFrame * const parent = GetMDIParent();

    // Must make sure this handle is invalidated (set to NULL) since all sorts
    // of things could happen after the child client is destroyed, but before
    // the wxFrame is destroyed.

    HWND oldHandle = (HWND)GetHWND();
    SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY,
                (WPARAM)oldHandle, 0);

    if (parent->GetActiveChild() == NULL)
        ResetWindowStyle(NULL);

    if (m_hMenu)
    {
        ::DestroyMenu((HMENU) m_hMenu);
        m_hMenu = 0;
    }
    wxRemoveHandleAssociation(this);
    m_hWnd = 0;
}
Exemplo n.º 16
0
void LoginForm::setFrameRegion()
{
#ifdef WIN32
	wxRect wbr = getWindowsBorderRect();
	wxPoint br = wbr.GetBottomRight();

	br.x += 2;
	br.y += 2;

	wxRegion region = CreateRoundRectRgn(wbr.x, wbr.y, br.x, br.y, 5, 5);

	// Windows takes ownership of the region, so
	// we'll have to make a copy of the region to give to it.
	DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, nullptr);
	RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
	::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
	HRGN hrgn = ::ExtCreateRegion(nullptr, noBytes, rgnData);
	delete[] (char*) rgnData;

	// Now call the shape API with the new region.
	::SetWindowRgn((HWND)GetHWND(), hrgn, FALSE);
#endif // LINUX TODO
}
Exemplo n.º 17
0
	void UpdateCommands() {
		static GlobalUIState lastGlobalUIState = UISTATE_PAUSEMENU;
		static CoreState lastCoreState = CORE_ERROR;

		if (lastGlobalUIState == globalUIState && lastCoreState == coreState)
			return;

		lastCoreState = coreState;
		lastGlobalUIState = globalUIState;

		HMENU menu = GetMenu(GetHWND());

		const char* pauseMenuText =  (Core_IsStepping() || globalUIState != UISTATE_INGAME) ? "Run\tF8" : "Pause\tF8";
		ModifyMenu(menu, ID_TOGGLE_PAUSE, MF_BYCOMMAND | MF_STRING, ID_TOGGLE_PAUSE, pauseMenuText);

		UINT ingameEnable = globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED;
		EnableMenuItem(menu, ID_TOGGLE_PAUSE, ingameEnable);
		EnableMenuItem(menu, ID_EMULATION_STOP, ingameEnable);
		EnableMenuItem(menu, ID_EMULATION_RESET, ingameEnable);

		UINT menuEnable = globalUIState == UISTATE_MENU ? MF_ENABLED : MF_GRAYED;
		EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, !menuEnable);
		EnableMenuItem(menu, ID_FILE_LOADSTATEFILE, !menuEnable);
		EnableMenuItem(menu, ID_FILE_QUICKSAVESTATE, !menuEnable);
		EnableMenuItem(menu, ID_FILE_QUICKLOADSTATE, !menuEnable);
		EnableMenuItem(menu, ID_CPU_DYNAREC, menuEnable);
		EnableMenuItem(menu, ID_CPU_INTERPRETER, menuEnable);
		EnableMenuItem(menu, ID_CPU_MULTITHREADED, menuEnable);
		EnableMenuItem(menu, ID_IO_MULTITHREADED, menuEnable);
		EnableMenuItem(menu, ID_TOGGLE_PAUSE, !menuEnable);
		EnableMenuItem(menu, ID_EMULATION_STOP, !menuEnable);
		EnableMenuItem(menu, ID_EMULATION_RESET, !menuEnable);
		EnableMenuItem(menu, ID_DEBUG_LOG, !g_Config.bEnableLogging);
		EnableMenuItem(menu, ID_EMULATION_RENDER_MODE_OGL, menuEnable);
		EnableMenuItem(menu, ID_EMULATION_RENDER_MODE_SOFT, menuEnable);
		EnableMenuItem(menu, ID_EMULATION_ATRAC3_SOUND, !Atrac3plus_Decoder::IsInstalled());
	}
Exemplo n.º 18
0
bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name)
{
    SetName(name);

    wxWindowCreationHook hook(this);
    m_hWnd = (WXHWND)::CreateDialog((HINSTANCE) wxGetInstance(),
                                    name.c_str(),
                                    parent ? (HWND)parent->GetHWND() : 0,
                                    (DLGPROC)wxDlgProc);

    if ( !m_hWnd )
        return false;

    SubclassWin(GetHWND());

    if ( parent )
        parent->AddChild(this);
    else
        wxTopLevelWindows.Append(this);

    // Enumerate all children
    HWND hWndNext;
    hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD);

    if (hWndNext)
        CreateWindowFromHWND(this, (WXHWND) hWndNext);

    while (hWndNext != (HWND) NULL)
    {
        hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
        if (hWndNext)
            CreateWindowFromHWND(this, (WXHWND) hWndNext);
    }

    return true;
}
Exemplo n.º 19
0
wxSize wxSpinCtrl::DoGetBestSize() const
{
    wxSize                          vSizeBtn = wxSpinButton::DoGetBestSize();
    int                             nHeight;
    wxFont                          vFont = (wxFont)GetFont();

    vSizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;

    wxGetCharSize( GetHWND()
                  ,NULL
                  ,&nHeight
                  ,&vFont
                 );
    nHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nHeight)+4;

    if (vSizeBtn.y < nHeight)
    {
        //
        // Make the text tall enough
        //
        vSizeBtn.y = nHeight;
    }
    return vSizeBtn;
} // end of wxSpinCtrl::DoGetBestSize
Exemplo n.º 20
0
void wxBaseModalDialog::OnKeyDown(const wxKeyEvent &event)
{
#ifdef __WIN32__
	if (!GetHWND())
		return;
#endif
	wxASSERT(TRUE == IsModal());

	if(true == IsActive())
	{
		// "Esc" works as an accelerator for the "Cancel" button, but it
		// shouldn't close the dialog which doesn't have any cancel button
		if(WXK_ESCAPE == event.m_keyCode)
		{
			wxWindow *window = FindWindow(wxID_CANCEL);

			if( (NULL != window) &&
				(true == window->IsEnabled()))
			{
				Cancel();
			}
		}
		// Same thing for Return keys.
		else if( (WXK_RETURN == event.m_keyCode) ||
				 (WXK_NUMPAD_ENTER == event.m_keyCode))
		{
			wxWindow *window = FindWindow(wxID_OK);

			if( (NULL != window) &&
				(true == window->IsEnabled()))
			{
				Ok();
			}
		}
	}
}
Exemplo n.º 21
0
wxSize wxListBox::DoGetBestSize() const
{
    // find the widest string
    int wLine;
    int wListbox = 0;
    for (unsigned int i = 0; i < m_noItems; i++)
    {
        wxString str(GetString(i));
        GetTextExtent(str, &wLine, NULL);
        if ( wLine > wListbox )
            wListbox = wLine;
    }

    // give it some reasonable default value if there are no strings in the
    // list
    if ( wListbox == 0 )
        wListbox = 100;

    // the listbox should be slightly larger than the widest string
    int cx, cy;
    wxGetCharSize(GetHWND(), &cx, &cy, GetFont());

    wListbox += 3*cx;

    // Add room for the scrollbar
    wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);

    // don't make the listbox too tall (limit height to 10 items) but don't
    // make it too small neither
    int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*
                    wxMin(wxMax(m_noItems, 3), 10);

    wxSize best(wListbox, hListbox);
    CacheBestSize(best);
    return best;
}
Exemplo n.º 22
0
// helper for OnPaint(): really erase the background, i.e. do it even if we
// don't have any non default brush for doing it (DoEraseBackground() doesn't
// do anything in such case)
void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
{
    // note that we do not use the box background colour here, it shouldn't
    // apply to its interior for several reasons:
    //  1. wxGTK doesn't do it
    //  2. controls inside the box don't get correct bg colour because they
    //     are not our children so we'd have some really ugly colour mix if
    //     we did it
    //  3. this is backwards compatible behaviour and some people rely on it,
    //     see http://groups.google.com/groups?selm=4252E932.3080801%40able.es
    wxWindow *parent = GetParent();
    HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(dc.GetHDC(), GetHWND());

    // if there is no special brush for painting this control, just use the
    // solid background colour
    wxBrush brush;
    if ( !hbr )
    {
        brush = wxBrush(parent->GetBackgroundColour());
        hbr = GetHbrushOf(brush);
    }

    ::FillRect(GetHdcOf(dc), &rc, hbr);
}
Exemplo n.º 23
0
void wxSpinCtrl::DoGetPosition(int *x, int *y) const
{
    // Because both subcontrols are mirrored manually
    // (for layout direction purposes, see note)
    // and leftmost control can be either spin or buddy text
    // we need to get positions for both controls
    // and return this with lower horizonal value.
    // Note:
    // Logical positions in manual mirroring:
    // our layout == parent layout  =>  x(Text) < x(Button)
    // our layout != parent layout  =>  x(Button) < x(Text)

    // hack: pretend that our HWND is the text control just for a moment
    int xBuddy;
    WXHWND hWnd = GetHWND();
    wxConstCast(this, wxSpinCtrl)->m_hWnd = m_hwndBuddy;
    wxSpinButton::DoGetPosition(&xBuddy, y);

    int xText;
    wxConstCast(this, wxSpinCtrl)->m_hWnd = hWnd;
    wxSpinButton::DoGetPosition(&xText, y);

    *x = wxMin(xBuddy, xText);
}
Exemplo n.º 24
0
bool SessionForm::IsActiveSessionBox(const std::wstring &session_id)
{
	ASSERT(!session_id.empty());
	return (::GetForegroundWindow() == GetHWND() && FindSessionBox(session_id) == active_session_box_);
}
Exemplo n.º 25
0
bool SessionForm::IsActiveSessionBox(const SessionBox *session_box)
{
	ASSERT(NULL != session_box);
	return (session_box == active_session_box_ && ::GetForegroundWindow() == GetHWND() && !::IsIconic(GetHWND()) && IsWindowVisible(GetHWND()));
}
Exemplo n.º 26
0
bool Ctrl::IsWndOpen() const {
	GuiLock __;
	return GetHWND();
}
Exemplo n.º 27
0
void Ctrl::WndUpdate()
{
	GuiLock __;
	HWND hwnd = GetHWND();
	if(hwnd) ::UpdateWindow(hwnd);
}
Exemplo n.º 28
0
bool Ctrl::HasWndCapture() const
{
	GuiLock __;
	HWND hwnd = GetHWND();
	return hwnd && hwnd == ::GetCapture();
}
Exemplo n.º 29
0
bool Ctrl::HasWndFocus() const
{
	GuiLock __;
	HWND hwnd = GetHWND();
	return hwnd && ::GetFocus() == hwnd;
}
Exemplo n.º 30
0
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
                             wxWindowID id,
                             const wxString& title,
                             const wxPoint& pos,
                             const wxSize& size,
                             long style,
                             const wxString& name)
{
  SetName(name);

  if ( id != wxID_ANY )
    m_windowId = id;
  else
    m_windowId = (int)NewControlId();

  if ( parent )
  {
      parent->AddChild(this);
  }

  int x = pos.x;
  int y = pos.y;
  int width = size.x;
  int height = size.y;

  MDICREATESTRUCT mcs;

  mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE
                    ? wxMDIChildFrameClassName
                    : wxMDIChildFrameClassNameNoRedraw;
  mcs.szTitle = title;
  mcs.hOwner = wxGetInstance();
  if (x != wxDefaultCoord)
      mcs.x = x;
  else
      mcs.x = CW_USEDEFAULT;

  if (y != wxDefaultCoord)
      mcs.y = y;
  else
      mcs.y = CW_USEDEFAULT;

  if (width != wxDefaultCoord)
      mcs.cx = width;
  else
      mcs.cx = CW_USEDEFAULT;

  if (height != wxDefaultCoord)
      mcs.cy = height;
  else
      mcs.cy = CW_USEDEFAULT;

  DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
  if (style & wxMINIMIZE_BOX)
    msflags |= WS_MINIMIZEBOX;
  if (style & wxMAXIMIZE_BOX)
    msflags |= WS_MAXIMIZEBOX;
  if (style & wxTHICK_FRAME)
    msflags |= WS_THICKFRAME;
  if (style & wxSYSTEM_MENU)
    msflags |= WS_SYSMENU;
  if ((style & wxMINIMIZE) || (style & wxICONIZE))
    msflags |= WS_MINIMIZE;
  if (style & wxMAXIMIZE)
    msflags |= WS_MAXIMIZE;
  if (style & wxCAPTION)
    msflags |= WS_CAPTION;

  mcs.style = msflags;

  mcs.lParam = 0;

  wxWindowCreationHook hook(this);

  m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()),
                                 WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);

  wxAssociateWinWithHandle((HWND) GetHWND(), this);

  return true;
}