8#include <QtGui/qwindow.h>
9#include <QtGui/private/qpixmap_win_p.h>
10#include <QtCore/qdebug.h>
11#include <QtCore/qvariant.h>
12#include <QtCore/qmetaobject.h>
13#include <QtCore/qpointer.h>
39template <
class Derived,
class Needle>
43 if (
v.at(
i) == needle)
50template <
class Derived,
class Base>
55 v->insert(
index,
static_cast<Derived *
>(newItemIn));
58 v->append(
static_cast<Derived *
>(newItemIn));
65 return reinterpret_cast<const wchar_t *
>(
s.utf16());
70template <
class Predicate>
77 if (
item->subMenu()) {
87template <
class Predicate>
106template <
class Predicate>
123template <
class Predicate>
136template <
class Menu >
142template <
class MenuType>
146 if (entries.
at(
i)->isVisible())
154 memset(&menuItemInfo, 0,
sizeof(MENUITEMINFO));
155 menuItemInfo.cbSize =
sizeof(MENUITEMINFO);
161 menuItemInfo.fMask = MIIM_STRING;
163 menuItemInfo.cch = UINT(
text.
size());
168 MENUITEMINFO menuItemInfo;
170 menuItemInfo.fMask = MIIM_STATE;
171 return GetMenuItemInfo(hMenu, uItem, fByPosition, &menuItemInfo) == TRUE ? menuItemInfo.fState : 0;
176 MENUITEMINFO menuItemInfo;
178 menuItemInfo.fMask = MIIM_STATE;
179 menuItemInfo.fState =
flags;
180 SetMenuItemInfo(hMenu, uItem, fByPosition, &menuItemInfo);
184 bool value, UINT trueState, UINT falseState)
186 const UINT oldState =
menuItemState(hMenu, uItem, fByPosition);
201 : m_parentMenu(parentMenu)
204 qCDebug(lcQpaMenus) << __FUNCTION__ << static_cast<const void *>(
this)
210 qCDebug(lcQpaMenus) << __FUNCTION__ << static_cast<const void *>(
this);
215void QWindowsMenuItem::freeBitmap()
218 DeleteObject(m_hbitmap);
225 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' <<
icon <<
')' <<
this;
229 if (m_parentMenu !=
nullptr)
233void QWindowsMenuItem::updateBitmap()
237 const int size = m_iconSize ? m_iconSize : GetSystemMetrics(SM_CYMENUCHECK);
240 MENUITEMINFO itemInfo;
242 itemInfo.fMask = MIIM_BITMAP;
243 itemInfo.hbmpItem = m_hbitmap;
249 qCDebug(lcQpaMenus).nospace().noquote()
250 << __FUNCTION__ <<
"(\"" <<
text <<
"\") " <<
this;
254 if (m_parentMenu !=
nullptr)
258void QWindowsMenuItem::updateText()
260 MENUITEMINFO menuItemInfo;
268 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << menuIn <<
')' <<
this;
269 if (menuIn == m_subMenu)
271 const uint oldId = m_id;
272 if (menuIn !=
nullptr) {
275 m_id = m_subMenu->
id();
276 if (m_parentMenu !=
nullptr) {
277 ModifyMenu(m_parentMenu->
menuHandle(), oldId, MF_BYCOMMAND | MF_POPUP,
284 if (m_parentMenu !=
nullptr) {
286 ModifyMenu(m_parentMenu->
menuHandle(), oldId, MF_BYCOMMAND,
299 if (m_parentMenu ==
nullptr)
304 insertIntoMenuHelper(m_parentMenu,
false, m_parentMenu->
menuItems().
indexOf(
this));
315 if (m_parentMenu ==
nullptr)
317 MENUITEMINFO menuItemInfo;
319 menuItemInfo.fMask = MIIM_FTYPE;
320 menuItemInfo.fType =
isSeparator ? MFT_SEPARATOR : MFT_STRING;
326 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << checkable <<
')' <<
this;
327 if (m_checkable == checkable)
329 m_checkable = checkable;
330 if (m_parentMenu ==
nullptr)
334 state |= m_checked ? MF_CHECKED : MF_UNCHECKED;
336 state &= ~(MF_CHECKED | MF_UNCHECKED);
342 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << isChecked <<
')' <<
this;
343 if (m_checked == isChecked)
345 m_checked = isChecked;
350 if (m_parentMenu ==
nullptr || !m_checkable)
355#if QT_CONFIG(shortcut)
362 if (m_parentMenu !=
nullptr)
369 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' <<
enabled <<
')' <<
this;
373 if (m_parentMenu !=
nullptr)
379 if (m_iconSize ==
size)
382 if (m_parentMenu !=
nullptr)
388 return m_parentMenu ? m_parentMenu->
menuHandle() :
nullptr;
395 UINT
result = MF_STRING | (m_enabled ? MF_ENABLED : MF_GRAYED);
396 if (m_subMenu !=
nullptr)
399 result |= m_checked ? MF_CHECKED : MF_UNCHECKED;
408#if QT_CONFIG(shortcut)
419 if (m_id == 0 && m_subMenu ==
nullptr)
429 UINT_PTR idBefore = 0;
434 idBefore =
menu->menuItems().at(nextIndex)->id();
448 m_parentMenu =
nullptr;
463 : m_parentMenu(parentMenu)
466 qCDebug(lcQpaMenus) << __FUNCTION__ << static_cast<const void *>(
this)
467 <<
"parentMenu=" <<
parentMenu <<
"HMENU=" << m_hMenu;
472 qCDebug(lcQpaMenus).noquote().nospace() << __FUNCTION__
473 <<
" \"" <<m_text <<
"\", " <<
static_cast<const void *
>(
this);
474 for (
int i = m_menuItems.
size() - 1;
i>= 0; --
i)
477 DestroyMenu(m_hMenu);
482 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << menuItemIn <<
", before=" << before <<
')' <<
this;
491 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << menuItemIn <<
')' <<
this;
497 qCDebug(lcQpaMenus).nospace().noquote()
498 << __FUNCTION__ <<
"(\"" <<
text <<
"\") " <<
this;
507 MENUITEMINFO menuItemInfo;
509 SetMenuItemInfo(ph,
id(), FALSE, &menuItemInfo);
514 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' <<
icon <<
')' <<
this;
520 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' <<
enabled <<
')' <<
this;
532 const auto it = std::find_if(m_menuItems.
cbegin(), m_menuItems.
cend(),
534 return it != m_menuItems.
cend() ? *
it :
nullptr;
539 UINT_PTR idBefore = 0;
544 idBefore = bar->
menus().
at(nextIndex)->
id();
546 m_parentMenuBar = bar;
547 m_parentMenu =
nullptr;
557 m_parentMenuBar =
nullptr;
559 return RemoveMenu(bar->menuBarHandle(),
id(), MF_BYCOMMAND) == TRUE;
562 m_parentMenu =
nullptr;
565 item->setMenu(
nullptr);
566 return item !=
nullptr;
573 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << visible <<
')' <<
this;
574 if (m_visible == visible)
586 RemoveMenu(ph,
id(), MF_BYCOMMAND);
589 m_parentMenuBar->
redraw();
607 qCDebug(lcQpaMenus) << __FUNCTION__ <<
this <<
"returns" <<
result;
614 qCDebug(lcQpaMenus) << __FUNCTION__ <<
this <<
"returns" <<
result;
620 m_parentMenu =
item->parentMenu();
625 return m_parentMenu ? m_parentMenu->
menuHandle() :
nullptr;
630 return m_parentMenuBar ? m_parentMenuBar->
menuBarHandle() :
nullptr;
653 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'>' <<
this << parentWindow << targetRect <<
item;
669 x,
y, 0, windowHandle,
nullptr) == TRUE;
680 qCDebug(lcQpaMenus) << __FUNCTION__ <<
"id=" <<
id;
706 qCDebug(lcQpaMenus) << __FUNCTION__ << static_cast<const void *>(
this);
711 qCDebug(lcQpaMenus) << __FUNCTION__ << static_cast<const void *>(
this);
712 for (
int m = m_menus.
size() - 1;
m >= 0; --
m)
715 DestroyMenu(m_hMenuBar);
720 qCDebug(lcQpaMenus) << __FUNCTION__ << menuIn <<
"before=" << before;
728 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' <<
menu <<
')' <<
this;
731 m_menus[
index]->removeFromParent();
741 qCDebug(lcQpaMenus) << __FUNCTION__ <<
'(' << newParentWindow <<
')' <<
this;
742 if (newParentWindow ==
nullptr) {
756 ? qobject_cast<QWindowsMenuBar *>(menuBarV.
value<
QObject *>()) :
nullptr;
761 const HWND hwnd =
window->handle();
762 const BOOL
result = SetMenu(hwnd, m_hMenuBar);
769void QWindowsMenuBar::removeFromWindow()
772 const HWND hwnd =
window->handle();
773 SetMenu(hwnd,
nullptr);
774 window->setMenuBar(
nullptr);
787 qCDebug(lcQpaMenus) << __FUNCTION__ <<
this <<
"returns" <<
result;
795 qCDebug(lcQpaMenus) << __FUNCTION__ <<
"id=" <<
id;
822 DrawMenuBar(
window->handle());
825#ifndef QT_NO_DEBUG_STREAM
830 if (
const int size =
v.size()) {
831 d <<
'[' <<
size <<
"](";
832 for (
int i = 0;
i <
size; ++
i) {
835 if (!
v.at(
i)->isVisible())
837 d <<
'"' <<
v.at(
i)->text() <<
'"';
848 d <<
'"' << m_text <<
"\", ";
849 d << static_cast<const void *>(
this);
851 d <<
", parentMenu=" <<
static_cast<const void *
>(m_parentMenu);
853 d <<
", subMenu=" <<
static_cast<const void *
>(m_subMenu);
856#if QT_CONFIG(shortcut)
858 d <<
", shortcut=" << m_shortcut;
865 d <<
", checked=" << m_checked;
873 d <<
"QPlatformMenuItem(";
884 d <<
'"' << m_text <<
"\", " <<
static_cast<const void *
>(
this)
885 <<
", handle=" << m_hMenu;
886 if (m_parentMenuBar !=
nullptr)
887 d <<
" [on menubar]";
888 if (m_parentMenu !=
nullptr)
902 d << static_cast<const void *>(
this) <<
' ';
912 d <<
m->metaObject()->className() <<
'(';
916 d <<
"QPlatformMenu(0)";
926 d <<
"QPlatformMenuBar(";
Qt::LayoutDirection layoutDirection
the default layout direction for this application
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
QString toString(SequenceFormat format=PortableText) const
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
const_iterator cend() const noexcept
const_iterator cbegin() const noexcept
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
\inmodule QtCore\reentrant
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
bool canConvert(QMetaType targetType) const
Base class for QWindowsForeignWindow, QWindowsWindow.
Singleton container for all relevant information.
static void forceNcCalcSize(HWND hwnd)
static QWindowsContext * instance()
list append(new Employee("Blackpool", "Stephen"))
QSet< QString >::iterator it
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
AudioChannelLayoutTag tag
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static bool isSeparator(char c)
#define qCDebug(category,...)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept