void wxComboBox::SetLayoutDirection(wxLayoutDirection dir) { // Edit field and drop-down list must be handled explicitly. // Edit field is a special EDIT control (e.g. it always returns null // extended style flags), so its layout direction should be set using the // same extended flag as for ordinary window but reset simply with // alignment flags. if ( !HasFlag(wxCB_READONLY) ) { if ( dir == wxLayout_RightToLeft ) { wxUpdateLayoutDirection(GetEditHWND(), dir); } else { LONG_PTR style = ::GetWindowLongPtr(GetEditHWND(), GWL_STYLE); if ( !(style & ES_CENTER) ) { style &= ~ES_RIGHT; ::SetWindowLongPtr(GetEditHWND(), GWL_STYLE, style); } } } // Layout for the drop-down list also must be set explicitly. WinStruct<COMBOBOXINFO> info; if ( ::GetComboBoxInfo(GetHwnd(), &info) ) { wxUpdateLayoutDirection(info.hwndList, dir); } wxChoice::SetLayoutDirection(dir); }
void wxComboBox::DoSetToolTip(wxToolTip *tip) { wxChoice::DoSetToolTip(tip); if ( tip && !HasFlag(wxCB_READONLY) ) tip->AddOtherWindow(GetEditHWND()); }
void wxComboBox::Undo() { if (CanUndo()) { HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) ::SendMessage(hEditWnd, EM_UNDO, 0, 0); } }
wxTextPos wxComboBox::GetLastPosition() const { HWND hEditWnd = (HWND) GetEditHWND(); // Get number of characters in the last (only) line. We'll add this to the character // index for the last line, 1st position. wxTextPos lineLength = (wxTextPos)SendMessage(hEditWnd, EM_LINELENGTH, (WPARAM) 0, (LPARAM)0L); return lineLength; }
void wxComboBox::Redo() { if (CanUndo()) { // Same as Undo, since Undo undoes the undo, i.e. a redo. HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) ::SendMessage(hEditWnd, EM_UNDO, 0, 0); } }
bool wxComboBox::CanRedo() const { if (!IsEditable()) return false; HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) return ::SendMessage(hEditWnd, EM_CANUNDO, 0, 0) != 0; else return false; }
void wxTextEntry::WriteText(const wxString& text) { wxString newText = wxGetWindowText(GetEditHWND()); long from, to; GetSelection(&from, &to); if (from > to){ long swp = to; to = from; from = swp; } // Compose the new Text by replacing the selection of the old text newText.replace(from, to - from, text); // Set control to the new text ::WinSetWindowText(GetEditHwnd(), text.c_str()); }
void wxComboBox::SetInsertionPoint(long pos) { if ( GetWindowStyle() & wxCB_READONLY ) return; #ifdef __WIN32__ HWND hWnd = GetHwnd(); ::SendMessage(hWnd, CB_SETEDITSEL, 0, MAKELPARAM(pos, pos)); HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) { // Scroll insertion point into view SendMessage(hEditWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); // Why is this necessary? (Copied from wxTextCtrl::SetInsertionPoint) SendMessage(hEditWnd, EM_REPLACESEL, 0, (LPARAM) wxEmptyString); } #endif // __WIN32__ }
bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { // pretend that wxComboBox is hidden while it is positioned and resized and // show it only right before leaving this method because otherwise there is // some noticeable flicker while the control rearranges itself m_isShown = false; if ( !CreateAndInit(parent, id, pos, size, n, choices, style, validator, name) ) return false; // we shouldn't call SetValue() for an empty string because this would // (correctly) result in an assert with a read only combobox and is useless // for the other ones anyhow if ( !value.empty() ) SetValue(value); // a (not read only) combobox is, in fact, 2 controls: the combobox itself // and an edit control inside it and if we want to catch events from this // edit control, we must subclass it as well if ( !(style & wxCB_READONLY) ) { gs_wndprocEdit = wxSetWindowProc((HWND)GetEditHWND(), wxComboEditWndProc); } // and finally, show the control Show(true); return true; }
wxString wxTextEntry::DoGetValue() const { return wxGetWindowText(GetEditHWND()); }