home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
p2demo21.exe
/
PEL
/
DIALOG.PEL
< prev
next >
Wrap
Text File
|
1995-04-07
|
62KB
|
1,931 lines
# $Header: P:\source\wmacros\dialog.pev 1.144 07 Apr 1995 16:35:42 PFHDWM0 $
## $Tabs:4 7$
##############################################################################
#
# Compuware Corporation
# 31440 Northwestern Highway
# Farmington Hills, Michigan 48334-2564
#
# This source code listing contains information that is
# proprietary to Compuware Corporation and may not be copied
# duplicated, translated, transmitted, stored, retrieved
# or in any manner or by any method conveyed or disclosed
# to a third party or parties without express written
# permission from Compuware Corporation.
#
#
##############################################################################
#### $Workfile: dialog.pel $: dialog window interface
## dialog manager functions and variables available to the user
#
# hDlg create_dialog_template( callback_function_id, parent, label_str, x0, y0, width, height )
# void delete_dialog_template( dlghand )
# void begin_dialog( dlghand )
# bool add_dialog_control( dlghand, index, dctrl, label_str, x0, y0, width, height )
# long set_dialog_item( dlghand, index, dac, opt value, opt value2, opt value3, opt value4, opt value5, opt value6, opt value7 )
# any query_dialog_item( dlghand, index, dac )
# void set_dialog_focus( dlghand, index )
# hDlg callback_dlg_hand
# int callback_index
# int callback_message
## Dialog control styles:
#
global DCTRL_DEFAULT_PUSH_BUTTON = 1
global DCTRL_PUSH_BUTTON = 2
global DCTRL_RADIO_BUTTON = 3
global DCTRL_CHECK_BOX = 4
global DCTRL_TRISTATE = 5
global DCTRL_EDIT = 6
global DCTRL_EDIT_KEY = 7
global DCTRL_STATIC_TEXT = 8
global DCTRL_GROUP_BOX = 9
global DCTRL_LIST_BOX = 10
global DCTRL_COMBO_BOX = 11
global DCTRL_NOTEBOOK = 12
global DCTRL_MULTI_LIST_BOX = 13
global DCTRL_MLE = 14
global DCTRL_MLE_KEY = 15
global DCTRL_VALUESET = 16
global DCTRL_SPINBUTTON = 17
# Editor Window Codes
global EWC_TO_TOP = 1
global EWC_MINIMIZE = 2
global EWC_MAXIMIZE = 3
global EWC_NORMAL = 4
global EWC_X_POS = 5
global EWC_Y_POS = 6
global EWC_WIDTH = 7
global EWC_HEIGHT = 8
global EWC_RESTORE_X_POS = 9
global EWC_RESTORE_Y_POS = 10
global EWC_RESTORE_WIDTH = 11
global EWC_RESTORE_HEIGHT = 12
global EWC_CLIENT_WIDTH = 13
global EWC_CLIENT_HEIGHT = 14
global EWC_ENABLE = 15
global EWC_DISABLE = 16
global EWC_HANDLE = 17
# Dialog Window Codes
global DWC_TITLE = 1
global DWC_POSITION = 2
global DWC_SIZE = 3
global DWC_HIDE = 4
global DWC_SHOW = 5
global DWC_TO_TOP = 6
global DWC_SYS_MENU = 7
global DWC_SIZEBORDER = 8
global DWC_NORMALBORDER = 9
global DWC_STATUSBAR = 10
global DWC_STATUSBARTEXT = 11
global DWC_STATUSBARSIZE = 12
global DWC_NORMALSIZE = 13
global DWC_ICONIZED = 14
global DWC_ZOOMED = 15
global DWC_STICKONTOP = 16
## Dialog action codes:
#
global DAC_TEXT = 1
global DAC_ENABLE = 2
global DAC_DISABLE = 3
global DAC_HIDE = 4
global DAC_SHOW = 5
global DAC_UNCHECK = 6
global DAC_CHECK = 7
global DAC_GRAY_CHECK = 8
global DAC_ADD_ITEM = 9
global DAC_COUNT_ITEMS = DAC_ADD_ITEM
global DAC_DELETE_ITEM = 10
global DAC_SELECT_ITEM = 11
global DAC_SET_MAJOR_TAB_SIZE = 12
global DAC_SET_MINOR_TAB_SIZE = 13
global DAC_SET_BUTTON_SIZE = 14
global DAC_SET_BINDER_TYPE = 15
global DAC_SET_TAB_TYPE = 16
global DAC_SET_TAB_LOCATION = 17
global DAC_SET_TAB_ALIGN = 18
global DAC_SET_STATUS_ALIGN = 19
global DAC_SET_BACKPAGES = 20
global DAC_APPEND_PAGE = 21
global DAC_INSERT_PAGE_AT_TOP = 22
global DAC_INSERT_PAGE_BEFORE = 23
global DAC_INSERT_PAGE_AFTER = 24
global DAC_SETFOCUS = 25
global DAC_FIRST_ITEM = 26
global DAC_NEXT_ITEM = 27
global DAC_DESELECT_ITEM = 28
global DAC_UNSELECT_ITEM = DAC_DESELECT_ITEM
global DAC_COUNT_SELECTED = 29
global DAC_SELECT_INDEX = 30
global DAC_FIRST_INDEX = 31
global DAC_NEXT_INDEX = 32
global DAC_GET_INDEX_ITEM = 33
global DAC_ADD_INDEX = 34
global DAC_DELETE_INDEX = 35
global DAC_DESELECT_INDEX = 36
global DAC_DESELECT_INDEX_RANGE = 37
global DAC_SELECT_INDEX_RANGE = 38
global DAC_SIZE = 39
global DAC_POSITION = 40
global DAC_SET_TEXT_LEN = 41
global DAC_SORT_ASCENDING = 42
global DAC_SORT_DESCENDING = 43
global DAC_NO_SORT = 44
global DAC_EDIT_TEXT = 45
global DAC_EDIT_KEY_TEXT = 46
global DAC_CLEAR_LIST = 47
global DAC_FIND = 48
global DAC_FONT = 49
global DAC_SELECTED_RANGE = 50
global DAC_SELECTION = DAC_SELECTED_RANGE
global DAC_SELECTED_TEXT = 51
global DAC_PASTE = DAC_SELECTED_TEXT
global DAC_COPY = 52
global DAC_CUT = 53
global DAC_CLEAR = 54
global DAC_UNDO = 55
global DAC_MODIFIED = 56
global DAC_LINEUP = 57
global DAC_LINEDOWN = 58
global DAC_PAGEUP = 59
global DAC_PAGEDOWN = 60
global DAC_SCROLL_VERT = 61
global DAC_SCROLL_HORIZ = 62
global DAC_COUNT_LINES = 63
global DAC_GET_LINE = 64
global DAC_VS_QUERY_ITEM = 65
global DAC_VS_QUERY_METRICS = 66
global DAC_VS_QUERY_SELECTED = 67
global DAC_VS_SET_ITEM = 68
global DAC_VS_SET_METRICS = 69
global DAC_VS_SELECT_ITEM = 70
global DAC_FG_COLOR = 71
global DAC_BG_COLOR = 72
global DAC_SPIN_OVERRIDELIMITS = 73
global DAC_SPIN_LIMITS = 74
global DAC_SPIN_VALUE = 75
global DAC_SPIN_MASTER = 76
global DAC_SPIN_TEXTLIMIT = 77
global DAC_SPIN_DOWN = 78
global DAC_SPIN_UP = 79
global DAC_VS_COLORS = 80
# Dialog Styles
# Only the border styles work dynamically
#global DS_SYSMENU = 41
#global DS_MINBUTTON = 42
#global DS_MAXBUTTON = 43
global DS_BORDER = 44
global DS_SIZEBORDER = 45
global DS_NOBORDER = 46
## Messages passed to the callback function in callback_msg:
#
global DM_INIT = 1
global DM_CLICK = 2
global DM_SELECT = 3
global DM_DOUBLE_CLICK = 4
global DM_SET_FOCUS = 5
global DM_KILL_FOCUS = 6
global DM_CHANGE = 7
global DM_DROP_DOWN = 8
global DM_OK = 9
global DM_CANCEL = 10
global DM_KEY = 11
global DM_HELPREQUESTED = 12
global DM_PAGECHANGED = 13
global DM_CLOSE = 14
global DM_INVALID_PCHAR = 15
global DM_ACTIVATE = 16
global DM_DEACTIVATE = 17
global DM_RESIZE = 18
global DM_MENUSELECT = 19
global DM_MENUCOMMAND = 20
global DM_AFTER_ACTIVATE = 21
global DM_VS_ENTER = 22
global DM_VS_HELP = 23
global DM_VS_SELECT = 24
global DM_SPIN_UP = 25
global DM_SPIN_DOWN = 26
global DM_SPIN_END = 27
global DM_SPIN_CHANGE = 28
## dialog manager callback function return values:
#
global DRC_EXIT = 0
global DRC_CONTINUE = 1
global DRC_MSG_PROCESSED = 2
## value returned by dialog callback function to caller
#
local dialog_return_value
# Handle of the Dialog List dialog
local DialogList
## dialog handles
#
global dhBufferList
## dialog item indices
#
global DI_CANCEL = 2
global DI_OK = 1
global IDB_SCL_SAVE_AS = 1383
global IDD_LIST = 1512
local IDD_CMD_DLG = 1570
local IDL_CMD_HISTORY = 1571
local IDE_COMMAND = 1572
local CommandDlg = 0
# !!?? ------------------------------------------------------------------
# !!?? for debugging callback functions
# !!??
# !!?? returns a string identifying the callback message and the
# !!?? currently active control
global function identMsg()
{
local msg
if ( callback_msg == DM_INIT )
msg = "DM_INIT"
else if ( callback_msg == DM_SELECT )
msg = "DM_SELECT"
else if ( callback_msg == DM_CLICK )
msg = "DM_CLICK"
else if ( callback_msg == DM_DOUBLE_CLICK )
msg = "DM_DOUBLE_CLICK"
else if ( callback_msg == DM_SET_FOCUS )
msg = "DM_SET_FOCUS"
else if ( callback_msg == DM_KILL_FOCUS )
msg = "DM_KILL_FOCUS"
else if ( callback_msg == DM_CHANGE )
msg = "DM_CHANGE"
else if ( callback_msg == DM_DROP_DOWN )
msg = "DM_DROP_DOWN"
else if ( callback_msg == DM_OK )
msg = "DM_OK"
else if ( callback_msg == DM_CANCEL )
msg = "DM_CANCEL"
else if ( callback_msg == DM_KEY )
msg = "DM_KEY"
else if ( callback_msg == DM_HELPREQUESTED)
msg = "DM_HELPREQUESTED"
else if ( callback_msg == DM_CLOSE)
msg = "DM_CLOSE"
else if ( callback_msg == DM_INVALID_PCHAR)
msg = "DM_INVALID_PCHAR"
else if ( callback_msg == DM_RESIZE )
msg = "DM_RESIZE"
else if ( callback_msg == DM_ACTIVATE )
msg = "DM_ACTIVATE"
else if ( callback_msg == DM_DEACTIVATE )
msg = "DM_DEACTIVATE"
else if ( callback_msg == DM_MENUSELECT )
msg = "DM_MENUSELECT"
else if ( callback_msg == DM_MENUCOMMAND )
msg = "DM_MENUCOMMAND"
else if ( callback_msg == DM_AFTER_ACTIVATE )
msg = "DM_AFTER_ACTIVATE"
else
msg = "?unknown(" callback_msg ")"
return "msg=(" msg ") "
}
#local function identIdx()
#{
# local indx
#
# if ( callback_index == IDL_LIST ){
# indx = "IDL_LIST"
# } else if ( callback_index == IDB_SAVE_FILE ){
# indx = "IDB_SAVE_FILE"
# } else if ( callback_index == IDB_DELETE_FILE ){
# indx = "IDB_DELETE_FILE"
# } else if ( callback_index == IDB_READONLY ){
# indx = "IDB_READONLY"
# } else if ( callback_index == DI_OK ){
# indx = "DI_OK"
# } else if ( callback_index == DI_CANCEL ){
# indx = "DI_CANCEL"
# } else if ( callback_index == DI_HELP ){
# indx = "DI_HELP"
# } else if ( callback_msg == DM_CLOSE ){
# indx = "DM_CLOSE"
# } else {
# if ( callback_msg != DM_INIT || callback_index != 0 ){
# indx = "?unknown(" callback_index ")"
# }
# }
#
# return "idx=(" indx ")"
#}
# !!?? end of debugging code
# !!?? ------------------------------------------------------------------
############################################################################
## Buffer list dialog
#
global function buffer_list_dialog(old_list)
{
local w, h
if ( mdi_mode == 2 && old_list != 1 )
{
if ( query_editwin_property( EWC_MINIMIZE ) )
set_editwin_property( EWC_NORMAL )
set_editwin_property( EWC_TO_TOP )
set_container_item( current_buffer )
return
}
else if ( !dhBufferList )
{
#
# build the dialog
#
w = 400
h = 240
dhBufferList = create_dialog( function_id( "buffer_list_callback" ),
0, IDD_BUFFERLIST, resource_dll );
attach_help(editor_helpfile, dhBufferList)
add_dialog_item( dhBufferList, IDL_LIST, DCTRL_MULTI_LIST_BOX )
add_dialog_item( dhBufferList, IDB_SAVE_FILE, DCTRL_PUSH_BUTTON )
add_dialog_item( dhBufferList, IDB_DELETE_FILE, DCTRL_PUSH_BUTTON )
add_dialog_item( dhBufferList, IDB_READONLY, DCTRL_PUSH_BUTTON )
}
if ( save_changes_list )
{
set_dialog_window( dhBufferList, DWC_TITLE, "Exit" )
set_dialog_item( dhBufferList, IDB_READONLY, DAC_HIDE, 1)
set_dialog_item( dhBufferList, IDB_DELETE_FILE, DAC_HIDE, 1)
set_dialog_item( dhBufferList, DI_OK, DAC_HIDE, 1)
set_dialog_item( dhBufferList, IDB_LOCK_FILE, DAC_HIDE, 1)
set_dialog_item( dhBufferList, IDB_SCL_SAVE_ALL, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_SCL_SAVE_AS, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_SCL_QUIT, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_SAVE_FILE, DAC_ENABLE )
}
else
{
set_dialog_window( dhBufferList, DWC_TITLE, "Buffer List" )
set_dialog_item( dhBufferList, IDB_LOCK_FILE, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_READONLY, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_DELETE_FILE, DAC_SHOW, 1)
set_dialog_item( dhBufferList, DI_OK, DAC_SHOW, 1)
set_dialog_item( dhBufferList, IDB_SCL_SAVE_ALL, DAC_HIDE, 1)
set_dialog_item( dhBufferList, IDB_SCL_SAVE_AS, DAC_HIDE, 1)
set_dialog_item( dhBufferList, IDB_SCL_QUIT, DAC_HIDE, 1)
}
set_dialog_window( dhBufferList, DWC_POSITION, 100, 100)
dialog_return_value = ""
begin_dialog( dhBufferList )
# WGN 3/31/95 - Added call to delete_dialog so that the modal Buffer List doesn't show
# up in the Dialog List after it's cancelled.
delete_dialog( dhBufferList )
dhBufferList = 0
update_current_view()
return dialog_return_value
}
function buffer_list_callback()
{
# local dbgmsg = identMsg() # !!??
local sel
local temp
if ( ( callback_msg == DM_CLICK && callback_index == DI_HELP ) ||
( callback_msg == DM_HELPREQUESTED ) )
{
if(isWindows())
display_help("Buffer List", callback_dialog_handle);
else
display_help("bufferlist", callback_dialog_handle)
return DRC_MSG_PROCESSED
}
else if ( callback_msg == DM_INIT )
{
# fill the list box
bufferListUpdate()
# Initially disable all of the buttons
bufferListActivateButtons()
set_dialog_item(dhBufferList, IDL_LIST, DAC_SETFOCUS)
}
else if ( callback_msg == DM_SELECT )
{
if ( callback_index == IDL_LIST )
bufferListActivateButtons()
else
{
# notify( dbgmsg )
beep() # !!??
}
return DRC_MSG_PROCESSED
}
else if (callback_msg == DM_CLICK && (callback_index == IDB_SAVE_FILE ||
callback_index == IDB_DELETE_FILE ||
callback_index == IDB_READONLY ||
callback_index == IDB_LOCK_FILE ||
callback_index == IDB_SCL_SAVE_AS ))
{
# add selected command to the list of pending commands
bufferListRegisterCommand( callback_index )
set_dialog_item(dhBufferList, IDL_LIST, DAC_DESELECT_INDEX)
set_dialog_item(dhBufferList, IDL_LIST, DAC_SETFOCUS)
return DRC_MSG_PROCESSED
}
else if (!save_changes_list && (callback_msg == DM_OK ||
callback_msg == DM_DOUBLE_CLICK ||
(callback_msg == DM_CLICK &&
callback_index == DI_OK)))
{
# processing all pending commands
# bufferListProcessCommands()
# return selected buffer name, if any
sel = bufferListSelected()
if ( sel >= 0 )
dialog_return_value = bufferListText(sel)
else
dialog_return_value = ""
return DRC_EXIT
}
else if ( ((callback_msg == DM_CLICK) && (callback_index == IDB_SCL_QUIT)) ||
((callback_msg == DM_OK) && save_changes_list) )
{
dialog_return_value = ""
return DRC_EXIT
}
else if ( (callback_msg == DM_CLICK) && (callback_index == IDB_SCL_SAVE_ALL) )
{
temp = query_dialog_item(dhBufferList, IDL_LIST, DAC_FIRST_INDEX)
set_dialog_item(dhBufferList, IDL_LIST, DAC_SELECT_INDEX_RANGE, 0, buffer_list_index)
bufferListRegisterCommand( IDB_SAVE_FILE )
set_dialog_item(dhBufferList, IDL_LIST, DAC_DESELECT_INDEX_RANGE, 0, buffer_list_index)
set_dialog_item(dhBufferList, IDL_LIST, DAC_SELECT_INDEX, temp)
set_dialog_item(dhBufferList, IDL_LIST, DAC_SETFOCUS)
return DRC_MSG_PROCESSED
}
else if (( callback_msg == DM_CANCEL ) ||
( callback_msg == DM_CLICK && callback_index == DI_CANCEL ))
{
process_ok = 0
dialog_return_value = ""
return DRC_EXIT
}
else if ( callback_msg == DM_SET_FOCUS )
{
if ( callback_index == IDB_DELETE_FILE )
set_dialog_item(dhBufferList, IDL_LIST, DAC_SETFOCUS)
}
# else if ( callback_msg == DM_KILL_FOCUS )
# {
# # And this Message !!??.
# }
return DRC_CONTINUE
}
#=======================================================================
# create_list_dialog
# creates a dialog box containing a list box that is used for
# displaying information similar to error information. Where you
# have some text and a location in a file to goto when that text
# is selected. Also used in grep and routines.
#
# paramters:
# title - title of dialog box
# help_file - Help file for dialog box
#=======================================================================
global DLG_LIST_DIALOG = 1511
global DLG_LIST_DIALOG2 = 1514
local DLG_HEIGHT_DIFF = 35
local DLG_HEIGHT_DIFF2 = 170
local DLG_WIDTH_DIFF = 30
# used in errorfix.pel
local dialog_data_list[]
local dialog_title_list[]
local dialog_delete_list[]
local dialog_item_count_list[]
local bookmark_delete_list[]
local last_dialog_selected = 0
global function create_list_dialog(title, help_file, sub_callback, needs_input)
{
local dlgid
local newtitle
local id = 1
local callbackid = 0
if ( argcount() < 3 )
callbackid = function_id( "dlg_list_callback" )
else
{
callbackid = function_id( sub_callback )
if ( !callbackid )
callbackid = function_id( "dlg_list_callback" )
}
check_for_deleted_dialogs()
newtitle = title
while ( newtitle in dialog_title_list )
{
# append an identifer to end of title and try again
newtitle = sprintf("%s-%d", title, id)
id++
}
# WGN 3/16 - replaced prompt_display_handle with 0 so that the search
# results dialog will not be a child of the Find Dialog.
dlgid = create_mdialog( callbackid,
(mdi_mode == 2) \
? -1 \
: 0,
needs_input \
? DLG_LIST_DIALOG2 \
: DLG_LIST_DIALOG,
resource_dll )
# add items for the buttons. Since the buttons are disabled the assumed type
# is incorrect so we must explicitly tell the dialog manager what type these
# controls are.
add_dialog_item( dlgid, DI_GOTO_BUTTON, DCTRL_DEFAULT_PUSH_BUTTON )
add_dialog_item( dlgid, DI_NEXT_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_PREV_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, IDB_CLOSE_BTN, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_HELP, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_STOP_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_DELETE_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, IDL_LIST, DCTRL_LIST_BOX )
if (needs_input)
{
add_dialog_item( dlgid, DI_ENTER_BUTTON, DCTRL_PUSH_BUTTON )
add_dialog_item( dlgid, DI_INPUT, DCTRL_EDIT )
}
set_dialog_window( dlgid, DWC_TITLE, newtitle )
attach_help(help_file, dlgid)
dialog_item_count_list[dlgid] = 0
dialog_title_list[newtitle] = dlgid
reinitialize_dialog_list()
return dlgid
}
#=======================================================================
# begin_list_dialog(dlgid)
# displays the dialog list box specified by dlgid parameter
#=======================================================================
global function begin_list_dialog(dlgid)
{
begin_dialog(dlgid)
}
#=======================================================================
# delete_list_dialog(dlgid)
# deletes the dialog list box from memory
#=======================================================================
global function delete_list_dialog(dlgid)
{
local count
local dlg_title
if ( dlgid in dialog_item_count_list )
{
count = dialog_item_count_list[dlgid]
while ( count > 0 )
{
delete dialog_data_list[dlgid,count]
count--
}
delete dialog_item_count_list[dlgid]
dlg_title = query_dialog_window(dlgid, DWC_TITLE)
delete dialog_title_list[dlg_title]
delete_dialog(dlgid)
reinitialize_dialog_list()
}
else
warning( "delete_list_dialog: invalid dialog handle(%d)", dlgid )
}
#=======================================================================
# add_item_to_list
# adds an item to a list box dialog.
#
# parameters:
# dlgid - dialog box to add item to
# data - data to put in the list box
# filename - filename to load when item is selected
# line - line in file to goto when item is selected
# col - column in file to goto when item is selected
# hlen - highlight length. If zero no text is highlighted,
# if -1 the whole line is highlighted, -2 all characters
# from col to the end-of-line are selected, otherwise
# hlen characters are highlighted starting at col.
#=======================================================================
global function add_item_to_list(dlgid, data, filename, line, col, hlen)
{
local index
local text = 1;
index = set_dialog_item( dlgid, IDL_LIST, DAC_ADD_ITEM, data )
if ( index != -1 )
{
dialog_data_list[dlgid,index] = filename FS line FS col FS hlen
dialog_data_list[dlgid,index,text] = data;
dialog_item_count_list[dlgid] = dialog_item_count_list[dlgid] + 1
}
else
warning("Could not add item to list.")
return index
}
local function remove_item(dlgid, index)
{
local i, count = dialog_item_count_list[dlgid] - 1;
local text = 1, newtext;
if (bookmark_delete_list[dlgid, index])
{
newtext = dialog_data_list[dlgid, index, text];
bookmark_delete_list[dlgid, index] = FALSE;
}
else
{
newtext = "(DEL) " dialog_data_list[dlgid, index, text];
bookmark_delete_list[dlgid, index] = TRUE;
}
set_dialog_item(dlgid, IDL_LIST, DAC_DELETE_INDEX, index );
set_dialog_item(dlgid, IDL_LIST, DAC_ADD_INDEX, newtext, index );
}
local dlg_initialized[]
global function dlg_is_initialized( handle )
{
if ( argcount() < 1 )
handle = callback_dialog_handle
return( handle in dlg_initialized )
}
global function set_dlg_initialized( handle )
{
if ( argcount() < 1 )
handle = callback_dialog_handle
dlg_initialized[ handle ] = TRUE
}
global function unset_dlg_initialized( handle )
{
if ( argcount() < 1 )
handle = callback_dialog_handle
delete dlg_initialized[ handle ]
}
global function valid_list_dialog( handle )
{
return( handle in dialog_item_count_list )
}
#=======================================================================
# dlg_list_callback()
# callback function for the dialog boxes that takes care
# of getting the next, prev, and goto buttons.
#=======================================================================
global function dlg_list_callback()
{
local size
local sbar_size
local index
local ret = DRC_CONTINUE
# set the current dialog box. This is used in next/prev item because we
# really don't know what dialog box the user wants to use.
# DWM--DM_DEACTIVATE can get sent after DM_CLOSE, so check for that case
if ( callback_msg != DM_DEACTIVATE )
last_dialog_selected = callback_dialog_handle
if ( callback_msg == DM_INIT )
{
set_dialog_item(callback_dialog_handle, IDL_LIST, DAC_SETFOCUS)
set_dialog_item(callback_dialog_handle, IDL_LIST, DAC_SELECT_INDEX, 0)
if ( !dlg_is_initialized() )
{
# list_size = query_dialog_item(callback_dialog_handle, IDL_LIST, DAC_SIZE)
# font = query_dialog_item(callback_dialog_handle, IDL_LIST, DAC_FONT)
# warning("Initial ListBox height is: %d, Font is %x", list_size % 65536, font)
fix_stop_button( callback_dialog_handle, FALSE )
# size = query_dialog_window(callback_dialog_handle, DWC_SIZE)
# sbar_size = query_dialog_window(callback_dialog_handle, DWC_STATUSBARSIZE)
# move_buttons(callback_dialog_handle, sbar_size)
# change_dialog_size( callback_dialog_handle, size, FALSE )
set_dlg_initialized()
}
}
else if (callback_msg == DM_CLOSE || callback_msg == DM_CANCEL ||
( callback_msg == DM_CLICK && callback_index == IDB_CLOSE_BTN ) )
{
close_dialog_box( callback_dialog_handle )
ret = DRC_EXIT;
}
else if (callback_msg == DM_HELPREQUESTED)
{
if(isWindows())
display_help("Dialog List", callback_dialog_handle);
else
display_help("dlglist", callback_dialog_handle);
ret = DRC_MSG_PROCESSED
}
else if (callback_msg == DM_CLICK )
{
# goto button pressed
if ( callback_index == DI_GOTO_BUTTON )
{
process_selection()
ret = DRC_MSG_PROCESSED
}
# next button pressed
else if ( callback_index == DI_NEXT_BUTTON )
{
goto_next_item(callback_dialog_handle)
ret = DRC_MSG_PROCESSED
}
# previous button pressed
else if ( callback_index == DI_PREV_BUTTON )
{
goto_prev_item(callback_dialog_handle)
ret = DRC_MSG_PROCESSED
}
else if ( callback_index == DI_HELP )
{
display_help("HelpOnHelp", callback_dialog_handle)
ret = DRC_MSG_PROCESSED
}
}
# if list box is double clicked get the error text and goto error
else if (callback_msg == DM_DOUBLE_CLICK && callback_index == IDL_LIST)
{
process_selection()
ret = DRC_MSG_PROCESSED
}
else if ( callback_msg == DM_SELECT && callback_index == IDL_LIST)
{
if (selection_ok(callback_dialog_handle))
set_dialog_item(callback_dialog_handle, DI_GOTO_BUTTON, DAC_ENABLE )
else
set_dialog_item(callback_dialog_handle, DI_GOTO_BUTTON, DAC_DISABLE )
ret = DRC_MSG_PROCESSED
}
# The list box should always have the focus
else if ( callback_msg == DM_SET_FOCUS )
{
if ( callback_index != IDL_LIST )
set_dialog_item(callback_dialog_handle, IDL_LIST, DAC_SETFOCUS)
}
else if ( callback_msg == DM_AFTER_ACTIVATE )
{
set_dialog_item(callback_dialog_handle, IDL_LIST, DAC_SETFOCUS)
}
else if ( callback_msg == DM_RESIZE )
{
resize_dialog( callback_dialog_handle, FALSE )
ret = DRC_MSG_PROCESSED
}
return ret
}
global function compile_list_callback()
{
local index, data
local call_hand = callback_dialog_handle
local call_msg = callback_msg
local call_idx = callback_index
local ret = DRC_CONTINUE;
local size, sbar_size
if ( call_msg == DM_INIT )
{
if ( !dlg_is_initialized( call_hand ) )
{
set_dialog_window( call_hand, DWC_STATUSBAR, 1)
fix_stop_button( call_hand, 1 )
if (optional_function("compile_has_input", callback_dialog_handle) && \
query_dialog_item(callback_dialog_handle, DI_INPUT, DAC_ENABLE))
{
set_dialog_item(callback_dialog_handle, DI_INPUT, DAC_SETFOCUS)
}
else
{
size = query_dialog_window(callback_dialog_handle, DWC_SIZE)
sbar_size = query_dialog_window(callback_dialog_handle, DWC_STATUSBARSIZE)
move_buttons(callback_dialog_handle, sbar_size)
change_dialog_size( callback_dialog_handle, size, 1 )
}
set_dlg_initialized()
}
}
else if ( call_msg == DM_CLICK || call_msg == DM_DOUBLE_CLICK )
{
if ( call_idx == DI_STOP_BUTTON )
{
optional_function( "stop_button_pressed", call_hand )
ret = DRC_MSG_PROCESSED
}
else if ( call_idx == DI_DELETE_BUTTON )
{
index = query_dialog_item( call_hand, IDL_LIST, DAC_SELECT_INDEX );
close_dialog_box( call_hand );
ret = DRC_MSG_PROCESSED
}
else if ( call_idx == DI_ENTER_BUTTON )
{
data = query_dialog_item(call_hand, DI_INPUT, DAC_EDIT_TEXT)
optional_function( "send_compile_data", call_hand, data )
set_dialog_item(call_hand, DI_INPUT, DAC_EDIT_TEXT, "")
ret = DRC_MSG_PROCESSED
}
}
else if ( callback_msg == DM_SET_FOCUS )
{
if (optional_function("compile_has_input", callback_dialog_handle) && \
query_dialog_item(callback_dialog_handle, DI_INPUT, DAC_ENABLE) && \
callback_index != DI_INPUT)
{
set_dialog_item(callback_dialog_handle, DI_INPUT, DAC_SETFOCUS)
}
}
else if ( callback_msg == DM_RESIZE )
{
resize_dialog( callback_dialog_handle, 1 )
ret = DRC_MSG_PROCESSED
}
if ( ret != DRC_MSG_PROCESSED )
return dlg_list_callback()
else
return ret
}
global function bookmark_list_callback()
{
local index;
local ret = DRC_CONTINUE;
local call_hand = callback_dialog_handle
local call_msg = callback_msg
local call_idx = callback_index
local text = 1;
local size, sbar_size
if ( call_msg == DM_INIT )
{
if ( !dlg_is_initialized() )
{
fix_stop_button( call_hand, 2 )
# sbar_size = query_dialog_window(callback_dialog_handle, DWC_STATUSBARSIZE)
# move_buttons(callback_dialog_handle, sbar_size)
# size = query_dialog_window(callback_dialog_handle, DWC_SIZE)
# change_dialog_size( callback_dialog_handle, size, FALSE )
set_dlg_initialized()
}
}
else if ( call_msg == DM_CLICK || call_msg == DM_DOUBLE_CLICK )
{
if ( call_idx == DI_DELETE_BUTTON )
{
index = query_dialog_item( call_hand, IDL_LIST, DAC_SELECT_INDEX );
bookmark_delete_pressed( dialog_data_list[call_hand, index, text], dialog_data_list[call_hand, index] );
remove_item(call_hand, index);
set_dialog_item(callback_dialog_handle, DI_DELETE_BUTTON, DAC_DISABLE )
# close_dialog_box( call_hand );
ret = DRC_MSG_PROCESSED
}
else
set_dialog_item(callback_dialog_handle, DI_DELETE_BUTTON, DAC_ENABLE )
}
else if(call_msg == DM_SELECT)
set_dialog_item(callback_dialog_handle, DI_DELETE_BUTTON, DAC_ENABLE )
else if ( callback_msg == DM_RESIZE )
{
resize_dialog( callback_dialog_handle, 2 )
ret = DRC_MSG_PROCESSED
}
if ( ret != DRC_MSG_PROCESSED )
return dlg_list_callback()
else
return ret
}
global function grep_list_callback()
{
local ret = DRC_EXIT
local call_hand = callback_dialog_handle
local call_msg = callback_msg
local call_idx = callback_index
local size, sbar_size
local start_line, start_col, start_buffer
if ( !process_background(IN_BACKGROUND) )
{
start_line = current_line
start_col = current_column
start_buffer = current_buffer
}
if ( call_msg == DM_INIT )
{
if ( !dlg_is_initialized( call_hand ) )
{
set_dialog_window( call_hand, DWC_STATUSBAR, 1)
fix_stop_button( call_hand, 1 )
size = query_dialog_window(callback_dialog_handle, DWC_SIZE)
sbar_size = query_dialog_window(callback_dialog_handle, DWC_STATUSBARSIZE)
move_buttons(callback_dialog_handle, sbar_size)
change_dialog_size( callback_dialog_handle, size, 1 )
set_dlg_initialized()
}
}
else if ( call_msg == DM_CLICK || call_msg == DM_DOUBLE_CLICK )
{
if ( call_idx == DI_STOP_BUTTON )
{
set_dialog_item( call_hand, DI_STOP_BUTTON, DAC_DISABLE )
process_background( STOP_BACKGROUND )
ret = DRC_MSG_PROCESSED
}
}
else if ( ( call_msg == DM_CLOSE || call_msg == DM_CANCEL ) ||
( callback_msg == DM_CLICK && callback_index == IDB_CLOSE_BTN ) )
{
current_window = current_window
if ( query_dialog_item(call_hand, DI_STOP_BUTTON, DAC_ENABLE) )
{
set_dialog_item( call_hand, DI_STOP_BUTTON, DAC_DISABLE )
process_background( STOP_BACKGROUND )
}
ret = DRC_EXIT
}
else if ( callback_msg == DM_RESIZE )
{
resize_dialog( callback_dialog_handle, 1 )
ret = DRC_MSG_PROCESSED
}
if ( ret == DRC_EXIT )
ret = dlg_list_callback()
if ( !process_background(IN_BACKGROUND) )
{
# If the current message caused a buffer position change
# while processing in the foreground, then save that pos.
if ( start_line != current_line ||
start_col != current_column ||
start_buffer != current_buffer )
save_foreground_context()
}
return ret
}
local function close_dialog_box( dlghand )
{
local count
local dlg_title
if ( argcount() < 1 )
dlghand = callback_dialog_handle
count = dialog_item_count_list[ dlghand ]
while ( count >= 0 )
{
delete dialog_data_list[ dlghand, count ]
count--
}
last_dialog_selected = 0
delete dialog_item_count_list[ dlghand ]
dlg_title = query_dialog_window( dlghand, DWC_TITLE )
delete dialog_title_list[ dlg_title ]
dialog_delete_list[ dlghand ] = 0
reinitialize_dialog_list()
unset_dlg_initialized( dlghand )
# errorfix uses this to stop a compile if the dialog box is closed
# while the compile is going on.
optional_function( "close_dialog_box", dlghand )
}
local function process_selection(dlghandle, behindwin)
{
local index
local arr[]
local filename
local line
local column
local hlen
local text
local title
if ( !dlghandle )
dlghandle = callback_dialog_handle
# get current text from list box
index = query_dialog_item(dlghandle, IDL_LIST, DAC_SELECT_INDEX)
if ( index >= 0 )
{
if ( split( dialog_data_list[dlghandle,index], arr ) )
{
filename = arr[1]
line = arr[2]
column = arr[3]
hlen = arr[4]
# delete any temporary selection that may have been installed
unhilight_temp_selection();
if (line && length(filename))
{
create_buf_and_win(filename, behindwin)
# if this is a compile dialog box then go to the old line
# otherwise use goto_line. This allows the user to make
# changes to the file after compiling and then use next error
# to position to the correct place. If the user saves the file
# then old line is reset and will then function just like goto_line
title = query_dialog_window(dlghandle, DWC_TITLE)
if ( substr(title, 1, 7) == "Compile" )
goto_old_line(line)
else
goto_line(line)
line=current_line
goto_pos(line, column)
# highlight to error line
if ( hlen > 0 )
{
create_linecol_selection(NORMAL_SELECTION, line, column+hlen,
line, column)
}
else if ( hlen == -1 ) # Hilight Line
{
create_linecol_selection(LINE_SELECTION, line, column, line,
column+hlen)
}
else if ( hlen == -2 ) # Hilight to End-of-Line
{
goto_eol()
hlen = current_column - column
if (hlen < 1)
hlen = 1
create_linecol_selection(NORMAL_SELECTION, line, column+hlen,
line, column)
}
text = query_dialog_item( dlghandle, IDL_LIST, DAC_GET_INDEX_ITEM, index )
if ( and(status_bar_flags, STB_MESSAGES) )
message(text "")
update_current_view()
}
else
beep() # No Error Information for this item.
}
else
{
warning("Cannot retrieve information from list box.")
}
}
}
local function selection_ok(dlghand, index)
{
local arr[]
if (argcount() < 2 || index < 0)
index = query_dialog_item(dlghand, IDL_LIST, DAC_SELECT_INDEX)
if ( index >= 0 )
{
if ( split( dialog_data_list[dlghand,index], arr ) )
{
if (arr[2] && length(arr[1]))
return TRUE
}
}
return FALSE
}
global function goto_next_item(dlg_handle, listbox)
{
local numitems
local numleft
local selecteditem
local behindwin = dlg_handle
if ( argcount() <= 0 )
{
dlg_handle = last_dialog_selected
listbox = IDL_LIST
}
else if ( argcount() <= 1 )
listbox = IDL_LIST
if ( dlg_handle == 0 )
{
message("No list dialog selected")
return
}
numitems = query_dialog_item(dlg_handle, listbox, DAC_COUNT_ITEMS)
selecteditem = query_dialog_item(dlg_handle, listbox, DAC_SELECT_INDEX)
# DWM 4/19/94
# I don't know why this was here, but it was causing an unsightly "jumping"
# during next and prev items
# if (selecteditem >= 0 )
# set_dialog_item(dlg_handle, listbox, DAC_DESELECT_INDEX, selecteditem)
numleft = numitems
do
{
selecteditem++
numleft--
# go back to top of list
if ( selecteditem >= numitems )
selecteditem = 0
}
while ( numleft > 0 && !selection_ok(dlg_handle, selecteditem) )
if ( numitems > 0 && selecteditem != -1 )
{
set_dialog_item(dlg_handle, listbox, DAC_SELECT_INDEX, selecteditem)
process_selection(dlg_handle, behindwin)
}
else
message("No items in current listbox: %s", query_dialog_window(dlg_handle, DWC_TITLE))
}
local function select_next_item(dlghandle, listbox)
{
local numitems
local selecteditem
numitems = query_dialog_item(dlghandle, listbox, DAC_COUNT_ITEMS)
selecteditem = query_dialog_item(dlghandle, listbox, DAC_SELECT_INDEX)
if (selecteditem >= 0 )
set_dialog_item(dlghandle, listbox, DAC_DESELECT_INDEX, selecteditem)
selecteditem++
# go back to top of list
if (selecteditem >= numitems)
selecteditem = 0
set_dialog_item(dlghandle, listbox, DAC_SELECT_INDEX, selecteditem)
}
global function goto_prev_item(dlg_handle, listbox)
{
local numitems
local numleft
local selecteditem
local behindwin = dlg_handle
if ( argcount() <= 0 )
{
dlg_handle = last_dialog_selected
listbox = IDL_LIST
}
else if ( argcount() <= 1 )
listbox = IDL_LIST
if ( dlg_handle == 0 )
{
message("No list dialog selected")
return
}
numitems = query_dialog_item(dlg_handle, listbox, DAC_COUNT_ITEMS)
selecteditem = query_dialog_item(dlg_handle, listbox, DAC_SELECT_INDEX)
# DWM 4/19/94
# I don't know why this was here, but it was causing an unsightly "jumping"
# during next and prev items
# if ( selecteditem >= 0 )
# set_dialog_item(dlg_handle, listbox, DAC_DESELECT_INDEX, selecteditem)
numleft = numitems
do
{
numleft--
selecteditem--
# go back to top of list
if ( selecteditem < 0 )
selecteditem = numitems-1
}
while ( numleft > 0 && !selection_ok(dlg_handle, selecteditem) )
if ( numitems > 0 && selecteditem != -1 )
{
set_dialog_item(dlg_handle, listbox, DAC_SELECT_INDEX, selecteditem)
process_selection(dlg_handle, behindwin)
}
else
message("No items in current listbox: %s", query_dialog_window(dlg_handle, DWC_TITLE))
}
local function select_prev_item(dlghandle, listbox)
{
local numitems
local selecteditem
numitems = query_dialog_item(dlghandle, listbox, DAC_COUNT_ITEMS)
selecteditem = query_dialog_item(dlghandle, listbox, DAC_SELECT_INDEX)
if (selecteditem >= 0 )
set_dialog_item(dlghandle, listbox, DAC_DESELECT_INDEX, selecteditem)
selecteditem--
# go back to top of list
if (selecteditem < 0)
selecteditem = numitems-1
set_dialog_item(dlghandle, listbox, DAC_SELECT_INDEX, selecteditem)
}
global function dialog_list()
{
local i
local callbackid
if ( !DialogList )
{
callbackid = function_id( "dialog_list_callback" )
DialogList = create_mdialog(callbackid, mdi_mode == 2 ? -1 : 0, DLG_LIST_DIALOG, resource_dll)
fix_stop_button( DialogList )
add_dialog_item( DialogList, IDL_LIST, DCTRL_LIST_BOX )
set_dialog_window( DialogList, DWC_TITLE, "Dialog List" )
attach_help(editor_helpfile, DialogList)
begin_dialog( DialogList )
}
else
{
set_dialog_window(DialogList, DWC_SHOW )
set_dialog_window(DialogList, DWC_TO_TOP )
}
reinitialize_dialog_list();
}
global function dialog_list_callback()
{
local call_hand = callback_dialog_handle
local call_msg = callback_msg
local call_idx = callback_index
local ret = DRC_CONTINUE
local count
local size, sbar_size
if ( call_msg == DM_INIT )
{
set_dialog_item(call_hand, IDL_LIST, DAC_SETFOCUS)
set_dialog_item(call_hand, IDL_LIST, DAC_SELECT_INDEX, 0)
if ( !dlg_is_initialized() )
{
# size = query_dialog_window(callback_dialog_handle, DWC_SIZE)
# sbar_size = query_dialog_window(callback_dialog_handle, DWC_STATUSBARSIZE)
# move_buttons(callback_dialog_handle, sbar_size)
# change_dialog_size( callback_dialog_handle, size, FALSE )
set_dlg_initialized()
}
}
else if (call_msg == DM_ACTIVATE)
{
reinitialize_dialog_list()
}
else if (call_msg == DM_HELPREQUESTED)
{
display_help("dialoglist", call_hand)
ret = DRC_MSG_PROCESSED
}
else if (call_msg == DM_CLOSE || call_msg == DM_CANCEL )
{
# DialogList = 0
# delete_dialog(call_hand)
current_window = current_window
}
else if (call_msg == DM_CLICK )
{
# goto button pressed
if ( call_idx == DI_GOTO_BUTTON )
{
if (goto_dialog_box())
set_dialog_window(call_hand, DWC_HIDE)
ret = DRC_MSG_PROCESSED
}
# next button pressed
else if ( call_idx == DI_NEXT_BUTTON )
{
select_next_item(call_hand, IDL_LIST)
if (goto_dialog_box())
set_dialog_window(call_hand, DWC_HIDE)
ret = DRC_MSG_PROCESSED
}
# previous button pressed
else if ( call_idx == DI_PREV_BUTTON )
{
select_prev_item(call_hand, IDL_LIST)
if (goto_dialog_box())
set_dialog_window(call_hand, DWC_HIDE)
ret = DRC_MSG_PROCESSED
}
else if ( call_idx == DI_HELP )
{
display_help("HelpOnHelp", call_hand)
ret = DRC_MSG_PROCESSED
}
else if (call_idx == IDB_CLOSE_BTN )
{
ret = DRC_EXIT
}
}
# if list box is double clicked get the error text and goto error
else if (call_msg == DM_DOUBLE_CLICK && call_idx == IDL_LIST)
{
if (goto_dialog_box())
set_dialog_window(call_hand, DWC_HIDE)
ret = DRC_MSG_PROCESSED
}
# The list box should always have the focus
else if ((call_msg == DM_SET_FOCUS) && (call_idx != IDL_LIST))
{
set_dialog_item(call_hand, IDL_LIST, DAC_SETFOCUS)
}
else if ( call_msg == DM_RESIZE )
{
resize_dialog( call_hand )
}
return ret
}
#local button
local function fix_stop_button( handle, compile )
{
local help, new, close, stop, button
# hide the stop button and shift the other two when we
# aren't compiling
#
if ( !compile )
{
# hide button since we won't need it
#
set_dialog_item( handle, DI_STOP_BUTTON, DAC_HIDE )
set_dialog_item( handle, DI_DELETE_BUTTON, DAC_HIDE )
# get position of stop and close button
#
close.pos = query_dialog_item( handle, IDB_CLOSE_BTN, DAC_POSITION)
stop.pos = query_dialog_item( handle, DI_STOP_BUTTON, DAC_POSITION)
# use x and y of stop button and move cancel to it
#
new.x = stop.pos / 65536
new.y = stop.pos % 65536
set_dialog_item( handle, IDB_CLOSE_BTN, DAC_POSITION, new.x, new.y)
# use x and y of old cancel position, and move help to it
#
new.x = close.pos / 65536
new.y = close.pos % 65536
set_dialog_item( handle, DI_HELP, DAC_POSITION, new.x, new.y)
}
else if (compile == 1)
set_dialog_item( handle, DI_DELETE_BUTTON, DAC_HIDE )
else if (compile == 2)
set_dialog_item( handle, DI_STOP_BUTTON, DAC_HIDE )
# get size and position of help button and determine the distance
# before we hide the buttons
#
help.size = query_dialog_item( handle, DI_HELP, DAC_SIZE)
help.pos = query_dialog_item( handle, DI_HELP, DAC_POSITION)
new.width = help.size / 65536
new.height = help.size % 65536
new.x = help.pos / 65536
new.y = help.pos % 65536
button.top = new.y + new.height + 40
button.width = new.x + new.width + 15
save_button_positions( handle, compile )
}
local button_pos[]
local function save_button_positions(handle, compile)
{
local i
for (i in button_pos)
delete button_pos[i]
# if (isWindows())
{
button_pos[DI_GOTO_BUTTON] = query_dialog_item( handle, DI_GOTO_BUTTON, DAC_POSITION)
button_pos[DI_NEXT_BUTTON] = query_dialog_item( handle, DI_NEXT_BUTTON, DAC_POSITION)
button_pos[DI_PREV_BUTTON] = query_dialog_item( handle, DI_PREV_BUTTON, DAC_POSITION)
button_pos[IDB_CLOSE_BTN] = query_dialog_item( handle, IDB_CLOSE_BTN, DAC_POSITION)
button_pos[DI_HELP] = query_dialog_item( handle, DI_HELP, DAC_POSITION)
if (compile == 1)
button_pos[DI_STOP_BUTTON] = query_dialog_item( handle, DI_STOP_BUTTON, DAC_POSITION)
else if (compile == 2)
button_pos[DI_DELETE_BUTTON] = query_dialog_item( handle, DI_DELETE_BUTTON, DAC_POSITION)
}
}
local function set_button_positions(handle)
{
local i
for (i in button_pos)
{
set_dialog_item(handle, i, DAC_POSITION,
button_pos[i] / 65536,
button_pos[i] % 65536)
}
}
local function move_buttons(handle, dist)
{
local i
local newY, oldX
local oldPos
if (!button_pos)
save_button_positions(handle, 0)
for (i in button_pos)
{
#oldPos = button_pos[i]
#oldX = button_pos[i] / 65536
newY = and((button_pos[ i ] % 65536) + dist, 0x0000FFFF)
#button_pos[i] = shiftl(oldX, 16) + newY
button_pos[i] = and(button_pos[i],0xFFFF0000)
#warning("old = %x, new = %x", oldPos, button_pos[i])
button_pos[i] += newY
#warning("old = %x, new = %x", oldPos, button_pos[i])
#warning("Old = %x, New = %x, Oldx = %d, %s", oldPos, button_pos[i], oldX, i)
}
set_button_positions(handle)
oldX = query_dialog_item(handle, IDL_LIST, DAC_POSITION) / 65536
newY = (query_dialog_item(handle, IDL_LIST, DAC_POSITION) % 65536) + dist
set_dialog_item(handle, IDL_LIST, DAC_POSITION, oldX, newY )
}
local function resize_dialog( handle, compile )
{
if (query_dialog_window(handle, DWC_ICONIZED))
set_dialog_window(handle, DWC_HIDE)
else
{
change_dialog_size(handle, callback_data, compile)
# Make sure the dialog is shown Normal Sized if it is not zoomed..
if (!query_dialog_window(handle, DWC_ZOOMED))
set_dialog_window(handle, DWC_SHOW)
}
}
local function change_dialog_size(handle, newsize, compile)
{
local new # new size of the dialog
local edit_field_size # height of the edit field
local list_height # height of the listbox
local sbar_height # height of the status bar
local item_height # height of an item in the listbox !! Should be queried !!
local rem # difference between the current list_height and a multiple of item_height
sbar_height = query_dialog_window(handle, DWC_STATUSBARSIZE) % 65536
# new size is stored in a long as (short width)(short height)
new.width = newsize / 65536
new.height = newsize % 65536
if ( new.width && new.height )
{
save_button_positions(handle, compile)
# resize edit control to match new dialog size (if it's there)
if (optional_function("compile_has_input", handle))
{
list_height = new.height - DLG_HEIGHT_DIFF2
edit_field_size = query_dialog_item(handle, DI_INPUT, DAC_SIZE)
set_dialog_item(handle, DI_INPUT, DAC_SIZE,
new.width - DLG_WIDTH_DIFF + 5, edit_field_size % 65536)
}
else
list_height = new.height -
query_dialog_item( handle, IDL_LIST, DAC_POSITION) % 65536 -
DLG_HEIGHT_DIFF
# NOTE: The purpose of this code is to keep the size of the listbox = to a
# multiple of the height of the items in it. This code should be replaced
# with code to get the height of items in the listbox.
# if (screen_width > 800)
# item_height = 20
# else if (screen_width < 700)
# item_height = 16
# else
# item_height = 18
#
# if ( list_height > item_height && (rem = list_height % item_height))
# list_height -= rem
# message("sbar = %d, list = %d, total = %d", sbar_height, list_height, new.height)
# resize list box to match new dialog size
set_dialog_item(handle, IDL_LIST, DAC_SIZE,
new.width - DLG_WIDTH_DIFF, list_height )
# Move the buttons for Windows.
if (isWindows())
{
set_button_positions(handle)
# set_dialog_item(handle, DI_GOTO_BUTTON, DAC_POSITION,
# button_pos[DI_GOTO_BUTTON] / 65536,
# button_pos[DI_GOTO_BUTTON] % 65536)
#
# set_dialog_item(handle, DI_NEXT_BUTTON, DAC_POSITION,
# button_pos[DI_NEXT_BUTTON] / 65536,
# button_pos[DI_NEXT_BUTTON] % 65536)
#
# set_dialog_item(handle, DI_PREV_BUTTON, DAC_POSITION,
# button_pos[DI_PREV_BUTTON] / 65536,
# button_pos[DI_PREV_BUTTON] % 65536)
#
# set_dialog_item(handle, IDB_CLOSE_BTN, DAC_POSITION,
# button_pos[IDB_CLOSE_BTN] / 65536,
# button_pos[IDB_CLOSE_BTN] % 65536)
#
# set_dialog_item(handle, DI_HELP, DAC_POSITION,
# button_pos[DI_HELP] / 65536,
# button_pos[DI_HELP] % 65536)
##
# if (compile == 1)
# {
# set_dialog_item(handle, DI_STOP_BUTTON, DAC_POSITION,
# button_pos[DI_STOP_BUTTON] / 65536,
# button_pos[DI_STOP_BUTTON] % 65536)
# }
# else if (compile == 2)
# {
# set_dialog_item(handle, DI_DELETE_BUTTON, DAC_POSITION,
# button_pos[DI_DELETE_BUTTON] / 65536,
# button_pos[DI_DELETE_BUTTON] % 65536)
# }
}
}
# show/hide the group of buttons if new dimensions are smaller
# than the group of buttons
#
if ( compile == 1)
show_button( handle, DI_STOP_BUTTON, new )
else if(compile == 2)
show_button( handle, DI_DELETE_BUTTON, new )
if (query_dialog_item( callback_dialog_handle, DI_ENTER_BUTTON, DAC_SHOW))
show_button( handle, DI_ENTER_BUTTON, new )
show_button( handle, DI_GOTO_BUTTON, new )
show_button( handle, DI_NEXT_BUTTON, new )
show_button( handle, DI_PREV_BUTTON, new )
show_button( handle, IDB_CLOSE_BTN, new )
show_button( handle, DI_HELP, new )
}
global function show_button(dlgid, btnid, new)
{
local button, show
button.size = query_dialog_item( dlgid, btnid, DAC_SIZE)
button.pos = query_dialog_item( dlgid, btnid, DAC_POSITION)
button.width = button.size / 65536
button.height = button.size % 65536
button.x = button.pos / 65536
button.y = button.pos % 65536
button.top = button.y + button.height + 40
button.width = button.x + button.width + 15
show = ( new.height < button.top || new.width < button.width ) \
? DAC_HIDE : DAC_SHOW
set_dialog_item( dlgid, btnid, show )
}
local function goto_dialog_box()
{
local dlg_title
local dlg_handle
local ret = FALSE
if ( query_dialog_item( callback_dialog_handle, IDL_LIST, DAC_COUNT_ITEMS) )
{
dlg_title = query_dialog_item( callback_dialog_handle, IDL_LIST, DAC_SELECT_ITEM)
if ( dlg_title )
{
dlg_handle = first_dialog()
while (dlg_handle)
{
if (!(dlg_handle in dialog_delete_list) &&
dlg_title == query_dialog_window(dlg_handle, DWC_TITLE) )
{
set_dialog_window(dlg_handle, DWC_SHOW )
set_dialog_window(dlg_handle, DWC_TO_TOP )
# last_dialog_selected = dlg_handle
ret = TRUE
break
}
dlg_handle = next_dialog()
}
# set_dialog_window(dialog_title_list[dlg_title], DWC_SHOW )
# set_dialog_window(dialog_title_list[dlg_title], DWC_TO_TOP )
# last_dialog_selected = dialog_title_list[dlg_title]
}
}
if (!ret)
{
warning("Selected dialog has been deleted")
reinitialize_dialog_list()
}
return ret
}
global function reinitialize_dialog_list()
{
local i
local cnt = 0
local compile, enable
local dlg_handle
local title
if ( DialogList )
{
# clear listbox
set_dialog_item(DialogList, IDL_LIST, DAC_CLEAR_LIST )
dlg_handle = first_dialog()
while (dlg_handle)
{
if (dlg_handle != DialogList && !(dlg_handle in dialog_delete_list) )
{
cnt++
title = query_dialog_window(dlg_handle, DWC_TITLE)
set_dialog_item(DialogList, IDL_LIST, DAC_ADD_ITEM, title)
}
dlg_handle = next_dialog()
}
# for ( i in dialog_title_list )
# {
# cnt++
# set_dialog_item(DialogList, IDL_LIST, DAC_ADD_ITEM, i )
# }
enable = ( cnt > 0 ) ? DAC_ENABLE : DAC_DISABLE
# if the STOP button is visible, enable/disable it
#
if ( query_dialog_item( DialogList, DI_STOP_BUTTON, DAC_SHOW) )
set_dialog_item( DialogList, DI_STOP_BUTTON, enable )
if ( query_dialog_item( DialogList, DI_DELETE_BUTTON, DAC_SHOW) )
set_dialog_item( DialogList, DI_DELETE_BUTTON, enable )
set_dialog_item( DialogList, DI_GOTO_BUTTON, enable )
set_dialog_item( DialogList, DI_NEXT_BUTTON, enable )
set_dialog_item( DialogList, DI_PREV_BUTTON, enable )
}
}
local function check_for_deleted_dialogs()
{
local index
for ( index in dialog_delete_list )
{
delete dialog_delete_list[index]
delete_dialog(index)
}
}
################################ COMMAND ##################
function gui_command()
{
CommandDlg = create_dialog(function_id("command_dlg_callback"), 0,
IDD_CMD_DLG, resource_dll )
add_dialog_item( CommandDlg, IDE_COMMAND, DCTRL_EDIT_KEY )
attach_help(editor_helpfile, CommandDlg)
setup_prompt_history("XMACRO")
initialize_command_dlg()
begin_dialog( CommandDlg )
delete_dialog( CommandDlg )
if ( dialog_return_value != "" )
invoke_function( dialog_return_value )
}
function initialize_command_dlg()
{
local cmd_array
local i
cmd_array = get_history( "XMACRO" )
for (i in cmd_array )
{
set_dialog_item(CommandDlg, IDL_CMD_HISTORY, DAC_ADD_ITEM, cmd_array[i])
}
set_dialog_item( CommandDlg, IDE_COMMAND, DAC_SET_TEXT_LEN, 256 )
set_dialog_item( CommandDlg, IDE_COMMAND, DAC_SETFOCUS )
dialog_return_value = ""
}
function command_dlg_callback()
{
local call_hand = callback_dialog_handle
local call_msg = callback_msg
local call_idx = callback_index
local retval
if ( ( call_msg == DM_CLICK && call_idx == DI_HELP ) ||
( call_msg == DM_HELPREQUESTED ) )
{
if(isWindows())
display_help("Command dialog", CommandDlg );
else
display_help("command", CommandDlg );
return DRC_MSG_PROCESSED
} # end DI_HELP
else if ( call_msg == DM_OK )
{
cleanup_prompt_history("XMACRO")
dialog_return_value = query_dialog_item(call_hand, IDE_COMMAND, DAC_EDIT_KEY_TEXT)
} # end DM_OK
else if ( call_msg == DM_CLOSE || call_idx == DI_CANCEL)
{
cleanup_prompt_history("XMACRO")
dialog_return_value = ""
return DRC_EXIT
} # end DM_CANCEL
else if ( (call_msg == DM_CLICK) || (call_msg == DM_DOUBLE_CLICK) )
{
return DRC_MSG_PROCESSED
} # end DM_DOUBLE_CLICK && DM_CLICK
else if ( call_msg == DM_KILL_FOCUS )
{
if ( call_idx == IDE_COMMAND )
{
retval = query_dialog_item(call_hand, call_idx, DAC_EDIT_KEY_TEXT)
set_dialog_item(call_hand, call_idx, DAC_EDIT_KEY_TEXT,
retval "")
}
return DRC_MSG_PROCESSED
} # end DM_KILL_FOCUS
else if ( call_msg == DM_SELECT )
{
if ( call_idx == IDL_CMD_HISTORY )
{
retval = query_dialog_item(call_hand, call_idx, DAC_SELECT_ITEM)
set_dialog_item(call_hand, IDE_COMMAND, DAC_EDIT_KEY_TEXT,
retval, 1 )
}
return DRC_MSG_PROCESSED
} # end DM_SELECT
else if (call_msg == DM_INVALID_PCHAR)
{
if ( callback_index == IDE_COMMAND )
{
dialog_history( call_hand, call_idx, "XMACRO")
set_dialog_item(call_hand, IDL_CMD_HISTORY,
DAC_SELECT_ITEM, prompt_response)
}
return DRC_MSG_PROCESSED
}
return DRC_CONTINUE
}