On Tue, Nov 6, 2012 at 2:01 PM, <amphitr...@ok.de> wrote:

> Unlucky in using self~constDir[SYMBOLIC_ID] = numericID I changed
> all Symbolic IDs in the example within paragraph 23.2.3.2
>


Hi Mike,

I just wanted to point out a few things about symbolic IDs from your
example code.  In addition, you had this question in the code:

 expose sysMenu /* why is sysMenu exposed? It is only used here */

The answer is that the code in the reference manual is just a snippet of
code.  The sysMenu object is used in other places in the complete program.

Regarding symbolic IDs.  Symbolic IDs work well once you understand the
details.  The original ooDialog implementation used the constDir attribute
of a dialog.  This was a rather limiting choice.  Not everything is a
dialog.  When I started adding enhancements this short coming became
apparent.  Menus, resource images, etc.. are not dialogs.  So, the original
concept was extended to what is called the global constDir.

All new code should use the global constDir.  For one thing, it has a far
more efficient look up mechanism.   To use symbolic IDs in menus, resource
images, and other possible new classes that are not dialogs, you *must* use
the global constDir.  The program you posted would be better off by
starting it this way:

  .application~useGlobalConstDir('O')

  .constDir[IDC_EDIT]      = 100
  .constDir[IDC_PB_WRITE]  = 100
  .constDir[IDM_PASTE]     = 64
  .constDir[IDM_COPY]      = 80
  .constDir[IDM_CUT]       = 96
  .constDir[IDM_MENU_EDIT] = 301
  .constDir[IDM_SEPARATOR] = 305

  dlg = .SimpleDialog~new
  dlg~execute("SHOWTOP")

The .application object is documented in the Utility Classes and Objects
section in the reference manual.  As you probably saw from your previous
question, the symbolic IDs in the constDir need to be present before your
program uses them.

Here is a rework of the entire program that should work fine for you:

/* Simple Dialog with an edit control and system menu */

  .application~useGlobalConstDir('O')

  .constDir[IDC_EDIT]      = 100
  .constDir[IDC_PB_WRITE]  = 100
  .constDir[IDM_PASTE]     = 64
  .constDir[IDM_COPY]      = 80
  .constDir[IDM_CUT]       = 96
  .constDir[IDM_MENU_EDIT] = 301
  .constDir[IDM_SEPARATOR] = 305

  dlg = .SimpleDialog~new
  dlg~execute("SHOWTOP")

  ::requires "ooDialog.cls"

  ::class 'SimpleDialog' subclass UserDialog

  ::method init
  forward class (super) continue
  self~create(30, 30, 257, 123, "Simple Dialog", "CENTER")

  ::method defineDialog
  self~createEdit(IDC_EDIT, 7, 7, 243, 85,                      -
                  "MULTILINE VSCROLL NOBORDER NOTAB READONLY")
  self~createPushButton(IDC_PB_WRITE, 7, 99, 50, 14, , "Write", -
                        onWrite)
  self~createPushButton(IDCANCEL, 197, 99, 50, 14, , "Quit")

  ::method initDialog
  expose sysMenu
  self~setControlSysColor(IDC_EDIT, 7, 4)
  hFont = self~createFontEx("Courier New", 9)
  self~setControlFont(IDC_EDIT, hFont, .false)

  /* Modify the system menu, taken from
        ooDialog Reference Version 4.2.0, pp 1155 f */
  -- Get the system menu.
  sysMenu = .SystemMenu~new(self)
  -- Modify the system menu by inserting an "Edit" menu into it
  popup = .PopupMenu~new(IDM_MENU_EDIT)
  popup~insertItem(IDM_PASTE, IDM_PASTE, "Paste")
  popup~insertItem(IDM_PASTE, IDM_COPY, "Copy")
  popup~insertItem(IDM_PASTE, IDM_CUT, "Cut")
  sysMenu~insertPopup(SC_MOVE, IDM_MENU_EDIT, popup, "Edit")
  sysMenu~insertSeparator(SC_MOVE, IDM_SEPARATOR)
  itemIDs = .set~of(IDM_PASTE, IDM_COPY, IDM_CUT)
  sysMenu~connectSomeCommandEvents(itemIDs)

  ::method onWrite unguarded
  expose editControl charcount   -- remember until next time
  line = 'It is now' date() time()
  if editControl~defaultName = 'a String' then do
   editControl = self~newEdit(IDC_EDIT)
   charcount = 1                       -- first cursor pos
  end
  else line = .endOfLine || line       -- insert a CRLF
  editControl~select(charcount, charcount)
  charcount = charcount + length(line)
  editControl~replaceSelText(line)

  ::method copy
  use arg id, x, y
  say 'In SystemMenu->Edit->Copy, ID:' id 'x:' x 'y:' y
  return .true

  ::method cut
  use arg id, x, y
  say 'In SystemMenu->Edit->Cut, ID:' id 'x:' x 'y:' y
  return .true

  ::method paste
  use arg id, x, y
  say 'In SystemMenu->Edit->Paste, ID:' id 'x:' x 'y:' y
  return .true


--
Mark Miesfeld
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to