Beispiel #1
0
/** Create a window layer submenu. */
void CreateWindowLayerMenu(Menu *menu, ClientNode *np)
{

   Menu *submenu;
   MenuItem *item;

   item = CreateMenuItem(MENU_ITEM_SUBMENU);
   item->name = CopyString(_("Layer"));
   item->action.type = MA_NONE;
   item->next = menu->items;
   menu->items = item;

   submenu = CreateMenu();
   item->submenu = submenu;

   if(np->state.layer == LAYER_ABOVE) {
      AddWindowMenuItem(submenu, _("[Above]"), MA_LAYER, np, LAYER_ABOVE);
   } else {
      AddWindowMenuItem(submenu, _("Above"), MA_LAYER, np, LAYER_ABOVE);
   }
   if(np->state.layer == LAYER_NORMAL) {
      AddWindowMenuItem(submenu, _("[Normal]"), MA_LAYER, np, LAYER_NORMAL);
   } else {
      AddWindowMenuItem(submenu, _("Normal"), MA_LAYER, np, LAYER_NORMAL);
   }
   if(np->state.layer == LAYER_BELOW) {
      AddWindowMenuItem(submenu, _("[Below]"), MA_LAYER, np, LAYER_BELOW);
   } else {
      AddWindowMenuItem(submenu, _("Below"), MA_LAYER, np, LAYER_BELOW);
   }

}
Beispiel #2
0
/** Create a send to submenu. */
void CreateWindowSendToMenu(Menu *menu, ClientNode *np)
{

   unsigned int mask;
   unsigned int x;

   mask = 0;
   for(x = 0; x < settings.desktopCount; x++) {
      if(np->state.desktop == x || (np->state.status & STAT_STICKY)) {
         mask |= 1 << x;
      }
   }

   AddWindowMenuItem(menu, _("Send To"), MA_NONE, np, 0);

   /* Now the first item in the menu is for the desktop list. */
   menu->items->submenu = CreateDesktopMenu(mask, np);

}
Beispiel #3
0
/** Create a window layer submenu. */
void CreateWindowLayerMenu(Menu *menu)
{

   Menu *submenu;
   MenuItem *item;

   item = Allocate(sizeof(MenuItem));
   item->type = MENU_ITEM_SUBMENU;
   item->name = CopyString(_("Layer"));
   item->action.type = MA_NONE;
   item->action.data.str = NULL;
   item->iconName = NULL;

   item->next = menu->items;
   menu->items = item;

   submenu = Allocate(sizeof(Menu));
   item->submenu = submenu;
   submenu->itemHeight = 0;
   submenu->items = NULL;
   submenu->label = NULL;

   if(client->state.layer == LAYER_ABOVE) {
      AddWindowMenuItem(submenu, _("[Above]"), MA_LAYER, LAYER_ABOVE);
   } else {
      AddWindowMenuItem(submenu, _("Above"), MA_LAYER, LAYER_ABOVE);
   }
   if(client->state.layer == LAYER_NORMAL) {
      AddWindowMenuItem(submenu, _("[Normal]"), MA_LAYER, LAYER_NORMAL);
   } else {
      AddWindowMenuItem(submenu, _("Normal"), MA_LAYER, LAYER_NORMAL);
   }
   if(client->state.layer == LAYER_BELOW) {
      AddWindowMenuItem(submenu, _("[Below]"), MA_LAYER, LAYER_BELOW);
   } else {
      AddWindowMenuItem(submenu, _("Below"), MA_LAYER, LAYER_BELOW);
   }

}
Beispiel #4
0
int 
OpenDocument(
    WORD    mode,
    WORD    type,
    int     doc,
    LPSTR   FileName,
    int     dupView,
    int     Preference,
    BOOL    bUserActivated
    )

/*++

Routine Description:

    This routine is used to create a new document or to duplicate
    the view of an existing document.

Arguments:

    mode        - Supplies MODE_DUPLICATE if the document is to be duplicated
                           MODE_RELOAD if the file is to be reloaded
                           MODE_CREATE if the document is to be created
    type        - Supplies the document type
    doc         - Supplies
    FileName    - Supplies a pointer to the name of the file for the document
    dupView     - Supplies the view to be duplicated (mode == MODE_DUPLICATE)
    Preference  - Supplies the view preference (-1 if none)
    bUserActivated - Indicates whether this action was initiated by the
                user or by windbg. The value is to determine the Z order of
                any windows that are opened.

Return Value:

    -1 on failure
    view number on success (>= 0)
    return-value - Description of conditions needed to return value. - or -

--*/

{
    LPLINEREC   pl;
    int         nView = 0;
    BOOL        create;
    int         n;
    int         language;
    LPDOCREC    d;
    LPVIEWREC   views;

    //
    //  In mode duplicate, we create a new nView being a copy of the previous
    //  nView of the same document
    //

    if (mode == MODE_DUPLICATE) {

        //
        // Search a free entry for the nView we will create
        //

        if ( (Preference != -1) && Views[ Preference ].Doc == -1 ) {
            nView = Preference;
        } else {
            for (nView = 0; (nView < MAX_VIEWS) && (Views[nView].Doc != -1); nView++);
        }

        if (nView == MAX_VIEWS) {
            ErrorBox(ERR_Too_Many_Opened_Views);
            return -1;
        }

        //
        // Copy parameters from previous nView
        //

        Assert( Docs[Views[dupView].Doc].FirstView >= 0);

        //
        //      Find the last nView for this document
        //

        n = dupView;
        while (Views[n].NextView != -1) {
            n = Views[n].NextView;
        }

        Assert(n < MAX_VIEWS);

        //
        //     Attach new nView to last one found
        //

        Views[nView] = Views[n];
        Views[n].NextView = nView;
        Views[nView].hwndClient = NULL;

        //
        //
        //

        Views[nView].iYTop = Views[dupView].iYTop;

        //
        //     Enlist nView in window menu
        //

        AddWindowMenuItem(Views[dupView].Doc, nView);

        return nView;

    } else if (mode == MODE_RELOAD) {
        nView = Docs[doc].FirstView;
    }

    //
    // First search a free entry for the document
    //

    if (mode != MODE_RELOAD) {
        for (doc = 0; (doc < MAX_DOCUMENTS) && (Docs[doc].FirstView != -1); doc++);
    }

    if (doc >= MAX_DOCUMENTS) {
        ErrorBox(ERR_Too_Many_Opened_Documents);
        return -1;
    }

    d = &Docs[doc];

    if (type == DOC_WIN) {

        //
        //      Check if file is not already loaded
        //

        if (mode == MODE_RELOAD) {
            DestroyDocument(doc);
            language = SetLanguage(doc);
        } else {
            if (FileName != NULL) {
                TCHAR szAbsolutePath[_MAX_PATH] = {0};

                Assert(sizeof(szAbsolutePath) == sizeof(d->szFileName));

                // We may have a relative path name to a file. Try to get the absolute path.
                if ( _fullpath(szAbsolutePath, FileName, sizeof(szAbsolutePath) ) ) {
                    // success
                    _tcscpy(d->szFileName, szAbsolutePath);
                } else {
                    // error. Use as is.
                    _tcscpy(d->szFileName, FileName);
                }

                for (n = 0; n < MAX_DOCUMENTS; n++) {
                    if (Docs[n].FirstView != -1
                        && _strcmpi(Docs[n].szFileName, d->szFileName) == 0) {

                        SetMessageText_StatusBar(ERR_File_Already_Loaded, STATUS_INFOTEXT, FileName);
                        MessageBeep(0);

                        //
                        //  Reactivate window
                        //

                        //SendMessage(g_hwndMDIClient, WM_MDIACTIVATE, (WPARAM) Views[Docs[n].FirstView].hwndFrame, 0L);
                        ActivateMDIChild(Views[Docs[n].FirstView].hwndFrame, bUserActivated);
                        return -1;
                    }
                }

                language = SetLanguage(doc);

            } else {
                // shouldn't happen anymore
                Assert(0);
// BUGBUG - dead code - kcarlos
#if 0
                //
                //  Initialize document record and first nView
                //

                register int i, j;

                for (i = 0; i < MAX_DOCUMENTS; i++) {
                    CreateUntitled(d->FileName, i + 1);
                    for (j = 0; j < MAX_DOCUMENTS; j++) {
                        if (j != doc &&
                            _strcmpi (d->szFileName, Docs[j].szFileName) == 0) {
                            break;
                        }
                    }
                    if (j >= MAX_DOCUMENTS) {
                        break;
                    }
                }

                language = C_LANGUAGE;
#endif
            }
        }
    } else {

        WORD winTitle;
        char rgch[MAX_MSG_TXT];

        language = NO_LANGUAGE;

        //
        //  Non Document type, Load window title from ressource
        //

        switch (type) {

        case DISASM_WIN:
            winTitle = SYS_DisasmWin_Title;
            break;       
        case COMMAND_WIN:
            winTitle = SYS_CmdWin_Title;
            break;
        case MEMORY_WIN:
            winTitle = SYS_MemoryWin_Title;
            break;
        default:
            Assert(FALSE);
            return -1;
            break;
        }
        Dbg(LoadString(g_hInst, winTitle, rgch, MAX_MSG_TXT));
        RemoveMnemonic(rgch, d->szFileName);

        if (type == MEMORY_WIN) {
            lstrcat (d->szFileName,"(");
            lstrcat (d->szFileName,TempMemWinDesc.szAddress);
            lstrcat (d->szFileName,")");
        }
    }

    //
    //  Then search a free entry for the first nView we will create
    //

    if (mode != MODE_RELOAD) {

        if ( (Preference != -1) && Views[ Preference ].Doc == -1 ) {
            nView = Preference;
        } else {
            for (nView = 0; nView < MAX_VIEWS && Views[nView].Doc != -1; nView++);
        }
        if (nView == MAX_VIEWS) {
            ErrorBox(ERR_Too_Many_Opened_Views);
            return -1;
        }
    }

    //
    // Check if file exist
    //

    if (mode == MODE_CREATE || type != DOC_WIN) {
        create = TRUE;
    } else {
        if (mode == MODE_OPEN || FileExist(FileName)) {
            create = FALSE;
        } else {
            if (mode == MODE_OPENCREATE) {
                // Tell the user that the file does not exist.

                // kcarlos
                // BUGBUG
                // Quick hack. To fix a bug, hopefully this all disappear soon.
                VarMsgBox(hwndFrame, SYS_Does_Not_Exist_Create, MB_OK, FileName);
                return -1;
            } else {
                create = FALSE;
            }
        }
    }

    d->readOnly = FALSE;
    d->docType = type;
    d->language = (WORD) language;
    d->untitled = (FileName == NULL);
    d->ismodified = FALSE;

    if (create) {

        LPBLOCKDEF pb;

        //
        //  Initialize the file with a null-string
        //


        d->LastBlock = d->FirstBlock = (LPBLOCKDEF)DocAlloc(sizeof(BLOCKDEF));
        GetSystemTimeAsFileTime(&d->time);

        if (d->FirstBlock == NULL) {
            ErrorBox(SYS_Allocate_Memory);
            return -1;
        }

        pb = d->FirstBlock;

        //
        //  Initialize first block
        //

        pb->PrevBlock = pb->NextBlock = NULL;
        pb->LastLineOffset = 0;

        //
        // Initialize first line
        //

        pl = (LPLINEREC)pb->Data;
        pl->PrevLength = 0;
        pl->Length = LHD;
        pl->Status = 0;

        d->NbLines = 1;         // We start with one null line

    } else {

        //
        // Load the file and check if it's a valid one
        //

        if (!LoadFile(doc)) {
            return -1;
        }
    }

    //
    // Initialize current pointers
    //

    d->CurrentBlock = d->FirstBlock;
    d->CurrentLine = 0;
    d->CurrentLineOffset = 0;
    pl = (LPLINEREC)(d->FirstBlock->Data);
    ExpandTabs(&pl);

    //
    // Undo/redo part
    //

    d->undo.h = 0;
    d->redo.h = 0;
    d->playCount = REC_CANNOTUNDO;
    if (g_contGlobalPreferences_WkSp.m_dwUndoResize == 0 || type != DOC_WIN) {
        d->recType = REC_STOPPED;
    } else {
        d->recType = REC_UNDO;
    }
    CreateRecBuf(doc, REC_UNDO, g_contGlobalPreferences_WkSp.m_dwUndoResize);

    if (mode == MODE_RELOAD) {
        RefreshWindowsTitle(doc);
    } else {

        //
        //  Initialize nView part
        //

        views = &Views[nView];
        views->NextView = -1;
        views->X = views->Y = 0;
        views->hwndClient = views->hwndFrame = NULL;
        views->hScrollBar = g_contGlobalPreferences_WkSp.m_bHorzScrollBars;
        views->vScrollBar = g_contGlobalPreferences_WkSp.m_bVertScrollBars;
        views->scrollFactor = 0;
        views->iYTop = -1;

        //
        //  Everything is OK, add title in window menu and return the nView
        //

        d->FirstView = nView;
        views->Doc = doc;
        AddWindowMenuItem(doc, nView);
    }

    //
    // Check syntax if C
    //

    if (d->language == C_LANGUAGE) {
        d->lineTop = 0;
        d->lineBottom = d->NbLines;
        CheckSyntax(doc);
    }

    return nView;
}                                       // OpenDocument()
Beispiel #5
0
/** Create a new window menu. */
Menu *CreateWindowMenu(void)
{

   Menu *menu;

   menu = Allocate(sizeof(Menu));
   menu->itemHeight = 0;
   menu->items = NULL;
   menu->label = NULL;

   /* Note that items are added in reverse order of display. */

   if(!(client->state.status & STAT_WMDIALOG)) {
      AddWindowMenuItem(menu, _("Close"), MA_CLOSE, 0);
      AddWindowMenuItem(menu, _("Kill"), MA_KILL, 0);
      AddWindowMenuItem(menu, NULL, MA_NONE, 0);
   }

   if(!(client->state.status & (STAT_FULLSCREEN | STAT_MINIMIZED)
        || client->state.maxFlags)) {
      if(client->state.status & (STAT_MAPPED | STAT_SHADED)) {
         if(client->state.border & BORDER_RESIZE) {
            AddWindowMenuItem(menu, _("Resize"), MA_RESIZE, 0);
         }
         if(client->state.border & BORDER_MOVE) {
            AddWindowMenuItem(menu, _("Move"), MA_MOVE, 0);
         }
      }
   }

   if(client->state.status & STAT_MINIMIZED) {
      AddWindowMenuItem(menu, _("Restore"), MA_RESTORE, 0);
   } else if(client->state.border & BORDER_MIN) {
      AddWindowMenuItem(menu, _("Minimize"), MA_MINIMIZE, 0);
   }

   if(!(client->state.status & STAT_FULLSCREEN)) {
      if(client->state.status & STAT_SHADED) {
         AddWindowMenuItem(menu, _("Unshade"), MA_SHADE, 0);
      } else if(client->state.border & BORDER_SHADE) {
         AddWindowMenuItem(menu, _("Shade"), MA_SHADE, 0);
      }
      if((client->state.border & BORDER_MAX) &&
         (client->state.status & (STAT_MAPPED | STAT_SHADED))) {
         if(!(client->state.maxFlags & MAX_VERT)) {
            AddWindowMenuItem(menu, _("Maximize-y"), MA_MAXIMIZE_V, 0);
         }
         if(!(client->state.maxFlags & MAX_HORIZ)) {
            AddWindowMenuItem(menu, _("Maximize-x"), MA_MAXIMIZE_H, 0);
         }
         if(client->state.maxFlags) {
            AddWindowMenuItem(menu, _("Restore"), MA_MAXIMIZE, 0);
         } else {
            AddWindowMenuItem(menu, _("Maximize"), MA_MAXIMIZE, 0);
         }
      }
   }

   if(!(client->state.status & STAT_WMDIALOG)) {

      if(settings.desktopCount > 1) {
         if(client->state.status & STAT_STICKY) {
            AddWindowMenuItem(menu, _("Unstick"), MA_STICK, 0);
         } else {
            AddWindowMenuItem(menu, _("Stick"), MA_STICK, 0);
         }
      }

      CreateWindowLayerMenu(menu);

      if(settings.desktopCount > 1) {
         if(!(client->state.status & STAT_STICKY)) {
            CreateWindowSendToMenu(menu);
         }
      }

   }

   return menu;
}
Beispiel #6
0
/** Create a new window menu. */
Menu *CreateWindowMenu(ClientNode *np)
{

   Menu *menu;

   menu = CreateMenu();

   /* Note that items are added in reverse order of display. */

   if(!(np->state.status & STAT_WMDIALOG)) {
      AddWindowMenuItem(menu, _("Close"), MA_CLOSE, np, 0);
      AddWindowMenuItem(menu, _("Kill"), MA_KILL, np, 0);
      AddWindowMenuItem(menu, NULL, MA_NONE, np, 0);
   }

   if(!(np->state.status & (STAT_FULLSCREEN | STAT_MINIMIZED)
        || np->state.maxFlags)) {
      if(np->state.status & (STAT_MAPPED | STAT_SHADED)) {
         if(np->state.border & BORDER_RESIZE) {
            AddWindowMenuItem(menu, _("Resize"), MA_RESIZE, np, 0);
         }
         if(np->state.border & BORDER_MOVE) {
            AddWindowMenuItem(menu, _("Move"), MA_MOVE, np, 0);
         }
      }
   }

   if((np->state.border & BORDER_MIN) && !(np->state.status & STAT_MINIMIZED)) {
      AddWindowMenuItem(menu, _("Minimize"), MA_MINIMIZE, np, 0);
   }

   if(!(np->state.status & STAT_FULLSCREEN)) {
      if(!(np->state.status & STAT_MINIMIZED)) {
         if(np->state.status & STAT_SHADED) {
            AddWindowMenuItem(menu, _("Unshade"), MA_SHADE, np, 0);
         } else if(np->state.border & BORDER_SHADE) {
            AddWindowMenuItem(menu, _("Shade"), MA_SHADE, np, 0);
         }
      }
      if(np->state.border & BORDER_MAX) {
         if(np->state.status & STAT_MINIMIZED
            || !(np->state.maxFlags & MAX_VERT)
            || np->state.maxFlags & MAX_HORIZ) {
            AddWindowMenuItem(menu, _("Maximize-y"), MA_MAXIMIZE_V, np, 0);
         }
         if(np->state.status & STAT_MINIMIZED
            || !(np->state.maxFlags & MAX_HORIZ)
            || np->state.maxFlags & MAX_VERT) {
            AddWindowMenuItem(menu, _("Maximize-x"), MA_MAXIMIZE_H, np, 0);
         }
         if(np->state.status & STAT_MINIMIZED
            || !(np->state.maxFlags & (MAX_VERT | MAX_HORIZ))) {
            AddWindowMenuItem(menu, _("Maximize"), MA_MAXIMIZE, np, 0);
         }
         if(!(np->state.status & STAT_MINIMIZED)) {
            if((np->state.maxFlags & MAX_HORIZ)
               && (np->state.maxFlags & MAX_VERT)) {
               AddWindowMenuItem(menu, _("Restore"), MA_MAXIMIZE, np, 0);
            } else if(np->state.maxFlags & MAX_VERT) {
               AddWindowMenuItem(menu, _("Restore"), MA_MAXIMIZE_V, np, 0);
            } else if(np->state.maxFlags & MAX_HORIZ) {
               AddWindowMenuItem(menu, _("Restore"), MA_MAXIMIZE_H, np, 0);
            }
         }
      }
   }

   if(np->state.status & STAT_MINIMIZED) {
      AddWindowMenuItem(menu, _("Restore"), MA_RESTORE, np, 0);
   }

   if(!(np->state.status & STAT_WMDIALOG)) {
      if(settings.desktopCount > 1) {
         if(np->state.status & STAT_STICKY) {
            AddWindowMenuItem(menu, _("Unstick"), MA_STICK, np, 0);
         } else {
            AddWindowMenuItem(menu, _("Stick"), MA_STICK, np, 0);
         }
      }

      CreateWindowLayerMenu(menu, np);

      if(settings.desktopCount > 1) {
         if(!(np->state.status & STAT_STICKY)) {
            CreateWindowSendToMenu(menu, np);
         }
      }

   }

   return menu;
}