< prev index next >

src/windows/native/sun/windows/CmdIDList.h

Print this page
rev 12529 : 8169966: Larger AWT menus
Reviewed-by: azvegint, prr, rhalade, mschoene
   1 /*
   2  * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef CMDIDLIST_H
  27 #define CMDIDLIST_H
  28 
  29 #include "awt.h"
  30 #include "awt_Object.h"
  31 
  32 // Mapping from command ids to objects.
  33 class AwtCmdIDList {
  34 public:
  35     AwtCmdIDList();
  36     ~AwtCmdIDList();
  37 
  38     UINT Add(AwtObject* obj);
  39     AwtObject* Lookup(UINT id);
  40     void Remove(UINT id);

  41 
  42     CriticalSection    m_lock;
  43 
  44 private:
  45 
  46     // next_free_index is used to build a list of free ids.  Since the
  47     // array index is less then 32k, we can't confuse in-use entry
  48     // (pointer) with an index of the next free entry.  NIL is -1.
  49     union CmdIDEntry {
  50         int next_free_index;    // index of the next entry in the free list
  51         AwtObject *obj;         // object that is assigned this id
  52     };
  53 
  54     CmdIDEntry *m_array;  // the vector's contents
  55 
  56     int m_first_free;     // head of the free list, may be -1 (nil)
  57     UINT m_capacity;      // size of currently allocated m_array
  58 
  59     void BuildFreeList(UINT first_index);
  60 };
   1 /*
   2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef CMDIDLIST_H
  27 #define CMDIDLIST_H
  28 
  29 #include "awt.h"
  30 #include "awt_Object.h"
  31 
  32 // Mapping from command ids to objects.
  33 class AwtCmdIDList {
  34 public:
  35     AwtCmdIDList();
  36     ~AwtCmdIDList();
  37 
  38     UINT Add(AwtObject* obj);
  39     AwtObject* Lookup(UINT id);
  40     void Remove(UINT id);
  41     jboolean isFreeIDAvailable();
  42 
  43     CriticalSection    m_lock;
  44 
  45 private:
  46 
  47     // next_free_index is used to build a list of free ids.  Since the
  48     // array index is less then 32k, we can't confuse in-use entry
  49     // (pointer) with an index of the next free entry.  NIL is -1.
  50     union CmdIDEntry {
  51         int next_free_index;    // index of the next entry in the free list
  52         AwtObject *obj;         // object that is assigned this id
  53     };
  54 
  55     CmdIDEntry *m_array;  // the vector's contents
  56 
  57     int m_first_free;     // head of the free list, may be -1 (nil)
  58     UINT m_capacity;      // size of currently allocated m_array
  59 
  60     void BuildFreeList(UINT first_index);
  61 };
< prev index next >