further work on panel quality

This commit is contained in:
Greg Gauthier 2025-05-07 22:16:48 +01:00
parent 38f9df983d
commit a1a067d417
2 changed files with 35 additions and 12 deletions

View File

@ -159,8 +159,8 @@
/* Create a form panel */ /* Create a form panel */
max_y = win~lines max_y = win~lines
max_x = win~cols max_x = win~cols
form_height = 14 form_height = 15
form_width = 55 form_width = 60
start_y = (max_y - form_height) % 2 start_y = (max_y - form_height) % 2
start_x = (max_x - form_width) % 2 start_x = (max_x - form_width) % 2
formwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 0, "Add New Contact", .true) formwin = self~DrawSubPanel(form_height, form_width, start_y, start_x, 0, "Add New Contact", .true)
@ -168,8 +168,10 @@
/* Create form fields */ /* Create form fields */
formwin~mvaddstr(3, 2, "First Name: ") formwin~mvaddstr(3, 2, "First Name: ")
formwin~mvaddstr(4, 2, "Last Name: ") formwin~mvaddstr(4, 2, "Last Name: ")
formwin~mvaddstr(5, 2, "Phone: "); formwin~mvaddstr(5, 35, "Type: "); formwin~mvaddstr(5, 2, "Phone: "); formwin~mvaddstr(5, 42, "Type: ");
formwin~mvaddstr(6, 2, "Email: "); formwin~mvaddstr(7, 2, "Email Type: "); formwin~mvaddstr(6, 2, "Email: "); formwin~mvaddstr(6, 42, "Type: ");
formwin~mvaddstr(7, 2, "Street: ")
formwin~mvaddstr(8, 2, "City: "); formwin~mvaddstr(8, 28, "State: "); formwin~mvaddstr(8, 40, "PostCode: ")
formwin~mvaddstr(form_height-2, 2, "[Enter] to save, [Esc] to cancel") formwin~mvaddstr(form_height-2, 2, "[Enter] to save, [Esc] to cancel")
formwin~refresh() formwin~refresh()
@ -189,8 +191,8 @@
self~dropWindow(formwin) self~dropWindow(formwin)
RETURN RETURN
END END
phone_type = self~getInputField(formwin, 5, 45, 15) phone_type = self~getInputField(formwin, 5, 48, 15)
if phone = .nil then do if phone_type = .nil then do
self~dropWindow(formwin) self~dropWindow(formwin)
RETURN RETURN
END END
@ -199,8 +201,29 @@
self~dropWindow(formwin) self~dropWindow(formwin)
RETURN RETURN
END END
email_type = self~getInputField(formwin, 7, 14, 15) email_type = self~getInputField(formwin, 6, 48, 15)
if email = .nil then do if email_type = .nil then do
self~dropWindow(formwin)
RETURN
END
street = self~getInputField(formwin, 7, 10, 25)
if street = .nil then do
self~dropWindow(formwin)
RETURN
END
city = self~getInputField(formwin, 8, 10, 15)
if city = .nil then do
self~dropWindow(formwin)
RETURN
END
state = self~getInputField(formwin, 8, 35, 2)
if state = .nil then do
self~dropWindow(formwin)
RETURN
END
post = self~getInputField(formwin, 8, 50, 10)
if post = .nil then do
self~dropWindow(formwin) self~dropWindow(formwin)
RETURN RETURN
END END
@ -223,12 +246,12 @@
/* Display result message */ /* Display result message */
if result > 0 then do /* should be a result id number */ if result > 0 then do /* should be a result id number */
formwin~mvaddstr(8, 2, "Contact ID ["result"] added successfully!") formwin~mvaddstr(10, 2, "Contact ID ["result"] added successfully!")
formwin~refresh() formwin~refresh()
call SysWait 0.5 call SysWait 0.5
end end
else do else do
formwin~mvaddstr(8, 2, "Failed to add contact.") formwin~mvaddstr(10, 2, "Failed to add contact.")
formwin~refresh() formwin~refresh()
call SysWait 0.5 call SysWait 0.5
end end
@ -409,8 +432,8 @@
if buffer~length > 0 then do if buffer~length > 0 then do
buffer = buffer~left(buffer~length - 1) buffer = buffer~left(buffer~length - 1)
win~move(y, x) win~move(y, x)
win~addstr(buffer || " ") /* Erase the last character */ win~addstr(buffer || " ") /* Erase the last character */
win~move(y, x + buffer~length) win~move(y, x + buffer~length - 1)
end end
end end
otherwise do otherwise do

Binary file not shown.