53 #include <private/qapplication_p.h> 54 #include <private/qmenu_p.h> 55 #include <private/qmenubar_p.h> 59 #include <QtCore/qlibrary.h> 62 # include <windowsm.h> 69 #ifndef SHCMBF_EMPTYBAR 70 #define SHCMBF_EMPTYBAR 0x0001 73 #ifndef SHCMBM_GETSUBMENU 74 #define SHCMBM_GETSUBMENU (WM_USER + 401) 78 # define SHMBOF_NODEFAULT 0x00000001 79 # define SHMBOF_NOTIFY 0x00000002 80 # define SHCMBM_OVERRIDEKEY (WM_USER + 0x193) 149 for (
int i = 0; i < actionItems.
size(); ++i) {
152 returnAction = action;
164 for (
int i = 0; i < actionItems.
size(); ++i) {
179 if (!(module = GetModuleHandle(L
"QtGui4")))
180 if (!(module = GetModuleHandle(L
"QtGuid4")))
182 Q_ASSERT_X(module,
"qt_wce_get_module_handle()",
"cannot get handle to module?");
189 memset(&tbbi,0,
sizeof(tbbi));
190 tbbi.cbSize =
sizeof(tbbi);
191 tbbi.dwMask = TBIF_COMMAND;
192 tbbi.idCommand = command;
193 SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi);
199 memset(&tbbi,0,
sizeof(tbbi));
200 tbbi.cbSize =
sizeof(tbbi);
201 tbbi.dwMask = TBIF_TEXT;
204 tbbi.pszText = (LPSTR) text.
utf16();
205 SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi);
224 LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
225 SHMBOF_NODEFAULT | SHMBOF_NOTIFY);
226 SendMessage(mbi.
hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam);
244 AppendMenu (menu, MF_SEPARATOR , 0, 0);
248 AppendMenu (menu, MF_STRING | flags | MF_POPUP,
252 AppendMenu (menu, MF_STRING | flags, action->
command, reinterpret_cast<const wchar_t *> (text.
utf16()));
256 CheckMenuItem(menu, action->
command, MF_BYCOMMAND | MF_CHECKED);
258 CheckMenuItem(menu, action->
command, MF_BYCOMMAND | MF_UNCHECKED);
265 while (RemoveMenu(hMenu, 0, MF_BYPOSITION));
279 for (
int i = 0; i < nativeMenuBars.
size(); ++i)
285 DrawMenuBar(wce_menubar->menubarHandle);
300 return d->wceCommands(command);
315 const HWND hwndActiveWindow = GetActiveWindow();
316 for (
int i = 0; i < nativeMenuBars.
size(); ++i) {
326 for (
int i = 0; i < actions.
size(); ++i) {
333 else if (action->
command == command) {
339 emit q_func()->triggered(foundAction);
347 if (wceClassicMenu) {
348 for (
int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i)
349 wceEmitSignals(wce_menubar->actionItemsClassic.at(i), command);
351 if (wceEmitSignals(wce_menubar->actionItems, command)) {
354 else if (wce_menubar->leftButtonIsMenu) {
355 wceEmitSignals(wce_menubar->actionItemsLeftButton, command);
357 else if ((wce_menubar->leftButtonAction) && (command == wce_menubar->leftButtonCommand)) {
358 emit q_func()->triggered(wce_menubar->leftButtonAction);
367 for (
int i = 0; i < wce_menu->actionItems.size(); ++i) {
374 else if (action->
command == command) {
380 emit q_func()->triggered(foundAction);
389 wce_menubar->parentWindowHandle = parent ? parent->
winId() : q->winId();
390 wce_menubar->leftButtonAction = defaultAction;
393 Q_ASSERT_X(wce_menubar->menubarHandle,
"wceCreateMenuBar",
"cannot create empty menu bar");
394 DrawMenuBar(wce_menubar->menubarHandle);
411 : menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0),
412 leftButtonAction(0), leftButtonIsMenu(false),
d(menubar)
460 if (before_index < 0) {
480 return d_func()->wceMenu();
532 if (before_index < 0) {
556 wce_menubar->rebuild();
561 d->q_func()->resize(0,0);
562 parentWindowHandle =
d->q_func()->parentWidget() ?
d->q_func()->parentWidget()->winId() :
d->q_func()->winId();
563 if (
d->wceClassicMenu) {
567 if (actions.
size() < 5) {
570 }
else if (actions.
size() < 7) {
578 Q_ASSERT_X(menubarHandle,
"rebuild !created",
"menubar already deleted");
580 DestroyWindow(menubarHandle);
582 Q_ASSERT_X(menubarHandle,
"rebuild classic menu",
"cannot create menubar from resource");
583 DrawMenuBar(menubarHandle);
589 for (
int i = 0; i < actionItemsClassic.size(); ++i)
590 if (!actionItemsClassic.value(i).empty())
592 actionItemsClassic.clear();
594 for (
int i = 0; i < actions.
size(); ++i) {
597 HMENU subMenuHandle = (HMENU) SendMessage(menubarHandle,
SHCMBM_GETSUBMENU,0 , menu_ids.
at(i));
598 DeleteMenu(subMenuHandle, item_ids.
at(i), MF_BYCOMMAND);
599 for (
int c = 0;
c < subActions.size(); ++
c) {
601 actionItemsClassic.
append(list);
603 action->
action = subActions.at(
c);
606 actionItemsClassic.last().append(action);
610 for (
int i = actions.
size();i<maxEntries;++i) {
615 leftButtonAction =
d->defaultAction;
616 if (!leftButtonAction)
619 leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu());
620 Q_ASSERT_X(menubarHandle,
"rebuild !created",
"menubar already deleted");
622 DestroyWindow(menubarHandle);
623 if (leftButtonIsMenu) {
625 Q_ASSERT_X(menubarHandle,
"rebuild !created left menubar",
"cannot create menubar from resource");
630 Q_ASSERT_X(leftButtonMenuHandle,
"rebuild !created",
"IDM_LEFTMENU not found - invalid resource?");
631 DeleteMenu(leftButtonMenuHandle,
IDM_VIEW, MF_BYCOMMAND);
634 Q_ASSERT_X(menubarHandle,
"rebuild !created no left menubar",
"cannot create menubar from resource");
638 leftButtonMenuHandle = 0;
652 if (!leftButtonIsMenu) {
653 if (leftButtonAction) {
664 for (
int i=0; i<actions.size(); ++i) {
666 action->
action = actions.at(i);
669 actionItemsLeftButton.append(action);
674 DrawMenuBar(menubarHandle);
679 #endif //QT_NO_MENUBAR bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
#define QT_END_NAMESPACE
This macro expands to.
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
#define it(className, varName)
QString text
the action's descriptive text
bool empty() const
This function is provided for STL compatibility.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
void insert(int i, const T &t)
Inserts value at index position i in the list.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
void * resolve(const char *symbol)
Returns the address of the exported symbol symbol.
The QString class provides a Unicode character string.
MenuRole menuRole
the action's menu role
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
const T & at(int i) const
Returns the item at index position i in the list.
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
T value(int i) const
Returns the value at index position i in the list.
void clear()
Removes all items from the list.
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
#define Q_ASSERT_X(cond, where, what)
QMenu * menu() const
Returns the menu contained by this action.
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
int size() const
Returns the number of items in the list.
QString iconText
the action's descriptive icon text
Q_CORE_EXPORT HINSTANCE qWinAppInst()
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
The QAction class provides an abstract user interface action that can be inserted into widgets...
The QLibrary class loads shared libraries at runtime.
The QList class is a template class that provides lists.
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
void removeAt(int i)
Removes the item at index position i.