diff --git a/desk.acc/control.panel.s b/desk.acc/control.panel.s index ab44abbf..a632fffc 100644 --- a/desk.acc/control.panel.s +++ b/desk.acc/control.panel.s @@ -16,10 +16,12 @@ .include "../inc/macros.inc" .include "../inc/prodos.inc" .include "../mgtk/mgtk.inc" + .include "../toolkits/btk.inc" .include "../common.inc" .include "../desktop/desktop.inc" MGTKEntry := MGTKAuxEntry + BTKEntry := BTKAuxEntry ;;; ============================================================ ;;; Memory map @@ -169,37 +171,6 @@ grafport: .tag MGTK::GrafPort ;;; Padding between radio/checkbox and label kLabelPadding = 5 -kRadioButtonWidth = 15 -kRadioButtonHeight = 7 - -.params rb_params - DEFINE_POINT viewloc, 0, 0 -mapbits: .addr SELF_MODIFIED -mapwidth: .byte 3 -reserved: .byte 0 - DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight -.endparams - -checked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - -unchecked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - kCheckboxWidth = 17 kCheckboxHeight = 8 @@ -346,10 +317,12 @@ arrows_table: DEFINE_POINT dblclick_arrow_pos6, kDblClickX + 155, kDblClickY + 23 ASSERT_RECORD_TABLE_SIZE arrows_table, kNumArrows, .sizeof(MGTK::Point) - ;; for hit testing - DEFINE_RECT_SZ dblclick_button_rect1, kDblClickX + 175, kDblClickY + 25, kRadioButtonWidth, kRadioButtonHeight - DEFINE_RECT_SZ dblclick_button_rect2, kDblClickX + 130, kDblClickY + 25, kRadioButtonWidth, kRadioButtonHeight - DEFINE_RECT_SZ dblclick_button_rect3, kDblClickX + 85, kDblClickY + 25, kRadioButtonWidth, kRadioButtonHeight + DEFINE_BUTTON dblclick_button1_rec, kDAWindowId,,, kDblClickX + 175, kDblClickY + 25 + DEFINE_BUTTON dblclick_button2_rec, kDAWindowId,,, kDblClickX + 130, kDblClickY + 25 + DEFINE_BUTTON dblclick_button3_rec, kDAWindowId,,, kDblClickX + 85, kDblClickY + 25 + DEFINE_BUTTON_PARAMS dblclick_button1_params, dblclick_button1_rec + DEFINE_BUTTON_PARAMS dblclick_button2_params, dblclick_button2_rec + DEFINE_BUTTON_PARAMS dblclick_button3_params, dblclick_button3_rec dblclick_bitmap: .byte PX(%0000000),PX(%0000000),PX(%0000000),PX(%0000011),PX(%0000000),PX(%0000000),PX(%0000000),PX(%0000000) @@ -414,11 +387,10 @@ kMouseTrackingY = 78 DEFINE_LABEL mouse_tracking, res_string_label_mouse_tracking, kMouseTrackingX + 30, kMouseTrackingY + 45 - DEFINE_LABEL tracking_slow, res_string_label_slow, kMouseTrackingX + 84 + kRadioButtonWidth + kLabelPadding, kMouseTrackingY + 16 - DEFINE_LABEL tracking_fast, res_string_label_fast, kMouseTrackingX + 84 + kRadioButtonWidth + kLabelPadding, kMouseTrackingY + 29 - ;; for hit testing; label width is added dynamically - DEFINE_RECT_SZ tracking_button_rect1, kMouseTrackingX + 84, kMouseTrackingY + 8, kRadioButtonWidth + kLabelPadding, kRadioButtonHeight - DEFINE_RECT_SZ tracking_button_rect2, kMouseTrackingX + 84, kMouseTrackingY + 21, kRadioButtonWidth + kLabelPadding, kRadioButtonHeight + DEFINE_BUTTON tracking_slow_rec, kDAWindowId, res_string_label_slow,, kMouseTrackingX + 84, kMouseTrackingY + 8 + DEFINE_BUTTON tracking_fast_rec, kDAWindowId, res_string_label_fast,, kMouseTrackingX + 84, kMouseTrackingY + 21 + DEFINE_BUTTON_PARAMS tracking_slow_params, tracking_slow_rec + DEFINE_BUTTON_PARAMS tracking_fast_params, tracking_fast_rec .params mouse_tracking_params DEFINE_POINT viewloc, kMouseTrackingX + 5, kMouseTrackingY @@ -481,10 +453,13 @@ ipblink_selection: DEFINE_LABEL ipblink2, res_string_label_ipblink2, kIPBlinkDisplayX-4, kIPBlinkDisplayY + 21 DEFINE_LABEL ipblink_slow, res_string_label_slow, kIPBlinkDisplayX + 100, kIPBlinkDisplayY + 34 DEFINE_LABEL ipblink_fast, res_string_label_fast, kIPBlinkDisplayX + 150, kIPBlinkDisplayY + 34 - ;; for hit testing - DEFINE_RECT_SZ ipblink_btn1_rect, kIPBlinkDisplayX + 116, kIPBlinkDisplayY + 16, kRadioButtonWidth, kRadioButtonHeight - DEFINE_RECT_SZ ipblink_btn2_rect, kIPBlinkDisplayX + 136, kIPBlinkDisplayY + 16, kRadioButtonWidth, kRadioButtonHeight - DEFINE_RECT_SZ ipblink_btn3_rect, kIPBlinkDisplayX + 156, kIPBlinkDisplayY + 16, kRadioButtonWidth, kRadioButtonHeight + + DEFINE_BUTTON ipblink_btn1_rec, kDAWindowId,,, kIPBlinkDisplayX + 116, kIPBlinkDisplayY + 16 + DEFINE_BUTTON ipblink_btn2_rec, kDAWindowId,,, kIPBlinkDisplayX + 136, kIPBlinkDisplayY + 16 + DEFINE_BUTTON ipblink_btn3_rec, kDAWindowId,,, kIPBlinkDisplayX + 156, kIPBlinkDisplayY + 16 + DEFINE_BUTTON_PARAMS ipblink_btn1_params, ipblink_btn1_rec + DEFINE_BUTTON_PARAMS ipblink_btn2_params, ipblink_btn2_rec + DEFINE_BUTTON_PARAMS ipblink_btn3_params, ipblink_btn3_rec .params ipblink_bitmap_params DEFINE_POINT viewloc, kIPBlinkDisplayX + 123, kIPBlinkDisplayY @@ -558,10 +533,6 @@ ipblink_ip_bitmap: param_call MeasureString, rgb_color_label_str addax rect_rgb::x2 - param_call MeasureString, tracking_slow_label_str - addax tracking_button_rect1::x2 - param_call MeasureString, tracking_fast_label_str - addax tracking_button_rect2::x2 MGTK_CALL MGTK::OpenWindow, winfo jsr DrawWindow @@ -685,21 +656,21 @@ ipblink_ip_bitmap: ;; ---------------------------------------- - MGTK_CALL MGTK::InRect, dblclick_button_rect1 + MGTK_CALL MGTK::InRect, dblclick_button1_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #1 jmp HandleDblclickClick END_IF - MGTK_CALL MGTK::InRect, dblclick_button_rect2 + MGTK_CALL MGTK::InRect, dblclick_button2_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #2 jmp HandleDblclickClick END_IF - MGTK_CALL MGTK::InRect, dblclick_button_rect3 + MGTK_CALL MGTK::InRect, dblclick_button3_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #3 @@ -708,14 +679,14 @@ ipblink_ip_bitmap: ;; ---------------------------------------- - MGTK_CALL MGTK::InRect, tracking_button_rect1 + MGTK_CALL MGTK::InRect, tracking_slow_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #0 jmp HandleTrackingClick END_IF - MGTK_CALL MGTK::InRect, tracking_button_rect2 + MGTK_CALL MGTK::InRect, tracking_fast_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #1 @@ -724,21 +695,21 @@ ipblink_ip_bitmap: ;; ---------------------------------------- - MGTK_CALL MGTK::InRect, ipblink_btn1_rect + MGTK_CALL MGTK::InRect, ipblink_btn1_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #1 jmp HandleIpblinkClick END_IF - MGTK_CALL MGTK::InRect, ipblink_btn2_rect + MGTK_CALL MGTK::InRect, ipblink_btn2_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #2 jmp HandleIpblinkClick END_IF - MGTK_CALL MGTK::InRect, ipblink_btn3_rect + MGTK_CALL MGTK::InRect, ipblink_btn3_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #3 @@ -924,7 +895,7 @@ next: dex MGTK_CALL MGTK::GetWinPort, getwinport_params MGTK_CALL MGTK::SetPort, grafport MGTK_CALL MGTK::HideCursor - jsr DrawDblclickButtons + jsr UpdateDblclickButtons MGTK_CALL MGTK::ShowCursor jmp InputLoop .endproc @@ -975,7 +946,7 @@ next: dex MGTK_CALL MGTK::GetWinPort, getwinport_params MGTK_CALL MGTK::SetPort, grafport MGTK_CALL MGTK::HideCursor - jsr DrawTrackingButtons + jsr UpdateTrackingButtons MGTK_CALL MGTK::ShowCursor jmp InputLoop @@ -1087,8 +1058,11 @@ loop: ldy #3 bne loop .endscope + BTK_CALL BTK::RadioDraw, dblclick_button1_params + BTK_CALL BTK::RadioDraw, dblclick_button2_params + BTK_CALL BTK::RadioDraw, dblclick_button3_params - jsr DrawDblclickButtons + jsr UpdateDblclickButtons MGTK_CALL MGTK::PaintBits, dblclick_params @@ -1098,13 +1072,9 @@ loop: ldy #3 MGTK_CALL MGTK::MoveTo, mouse_tracking_label_pos param_call DrawString, mouse_tracking_label_str - MGTK_CALL MGTK::MoveTo, tracking_slow_label_pos - param_call DrawString, tracking_slow_label_str - - MGTK_CALL MGTK::MoveTo, tracking_fast_label_pos - param_call DrawString, tracking_fast_label_str - - jsr DrawTrackingButtons + BTK_CALL BTK::RadioDraw, tracking_slow_params + BTK_CALL BTK::RadioDraw, tracking_fast_params + jsr UpdateTrackingButtons MGTK_CALL MGTK::PaintBits, mouse_tracking_params @@ -1125,7 +1095,10 @@ loop: ldy #3 MGTK_CALL MGTK::MoveTo, ipblink_fast_label_pos param_call DrawString, ipblink_fast_label_str - jsr DrawIpblinkButtons + BTK_CALL BTK::RadioDraw, ipblink_btn1_params + BTK_CALL BTK::RadioDraw, ipblink_btn2_params + BTK_CALL BTK::RadioDraw, ipblink_btn3_params + jsr UpdateIpblinkButtons ;; ============================== ;; Frame @@ -1148,58 +1121,77 @@ arrow_num: .endproc -.proc DrawDblclickButtons - MGTK_CALL MGTK::SetPenMode, notpencopy - - ldax #dblclick_button_rect1 - ldy dblclick_selection - cpy #1 - jsr DrawRadioButton +.proc ZToN + beq :+ + lda #0 + rts +: lda #$80 + rts +.endproc - ldax #dblclick_button_rect2 - ldy dblclick_selection - cpy #2 - jsr DrawRadioButton +.proc UpdateDblclickButtons + lda dblclick_selection + cmp #1 + jsr ZToN + sta dblclick_button1_rec::state + BTK_CALL BTK::RadioUpdate, dblclick_button1_params + + lda dblclick_selection + cmp #2 + jsr ZToN + sta dblclick_button2_rec::state + BTK_CALL BTK::RadioUpdate, dblclick_button2_params + + lda dblclick_selection + cmp #3 + jsr ZToN + sta dblclick_button3_rec::state + BTK_CALL BTK::RadioUpdate, dblclick_button3_params - ldax #dblclick_button_rect3 - ldy dblclick_selection - cpy #3 - jmp DrawRadioButton + rts .endproc - -.proc DrawTrackingButtons +.proc UpdateTrackingButtons MGTK_CALL MGTK::SetPenMode, notpencopy - ldax #tracking_button_rect1 - ldy SETTINGS + DeskTopSettings::mouse_tracking - cpy #0 - jsr DrawRadioButton + lda SETTINGS + DeskTopSettings::mouse_tracking + cmp #0 + jsr ZToN + sta tracking_slow_rec::state + BTK_CALL BTK::RadioUpdate, tracking_slow_params + + lda SETTINGS + DeskTopSettings::mouse_tracking + cmp #1 + jsr ZToN + sta tracking_fast_rec::state + BTK_CALL BTK::RadioUpdate, tracking_fast_params - ldax #tracking_button_rect2 - ldy SETTINGS + DeskTopSettings::mouse_tracking - cpy #1 - jmp DrawRadioButton + rts .endproc -.proc DrawIpblinkButtons +.proc UpdateIpblinkButtons MGTK_CALL MGTK::SetPenMode, notpencopy - ldax #ipblink_btn1_rect - ldy ipblink_selection - cpy #1 - jsr DrawRadioButton + lda ipblink_selection + cmp #1 + jsr ZToN + sta ipblink_btn1_rec::state + BTK_CALL BTK::RadioUpdate, ipblink_btn1_params - ldax #ipblink_btn2_rect - ldy ipblink_selection - cpy #2 - jsr DrawRadioButton + lda ipblink_selection + cmp #2 + jsr ZToN + sta ipblink_btn2_rec::state + BTK_CALL BTK::RadioUpdate, ipblink_btn2_params - ldax #ipblink_btn3_rect - ldy ipblink_selection - cpy #3 - jmp DrawRadioButton + lda ipblink_selection + cmp #3 + jsr ZToN + sta ipblink_btn3_rec::state + BTK_CALL BTK::RadioUpdate, ipblink_btn3_params + + rts .endproc .proc DrawRGBCheckbox @@ -1212,28 +1204,6 @@ arrow_num: .endproc -;;; A,X = pos ptr, Z = checked -.proc DrawRadioButton - ptr := $06 - - stax ptr - - IF_EQ - copy16 #checked_rb_bitmap, rb_params::mapbits - ELSE - copy16 #unchecked_rb_bitmap, rb_params::mapbits - END_IF - - ldy #3 -: lda (ptr),y - sta rb_params::viewloc,y - dey - bpl :- - - MGTK_CALL MGTK::PaintBits, rb_params - rts -.endproc - ;;; A,X = pos ptr, Z = checked .proc DrawCheckbox ptr := $06 @@ -1667,7 +1637,7 @@ next: dex MGTK_CALL MGTK::GetWinPort, getwinport_params MGTK_CALL MGTK::SetPort, grafport MGTK_CALL MGTK::HideCursor - jsr DrawIpblinkButtons + jsr UpdateIpblinkButtons MGTK_CALL MGTK::ShowCursor jmp InputLoop .endproc diff --git a/desk.acc/date.and.time.s b/desk.acc/date.and.time.s index db121210..80196deb 100644 --- a/desk.acc/date.and.time.s +++ b/desk.acc/date.and.time.s @@ -378,48 +378,14 @@ nextwinfo: .addr 0 ;;; ============================================================ ;;; 12/24 Hour Resources -;;; Padding between radio/checkbox and label -kLabelPadding = 5 - -kRadioButtonWidth = 15 -kRadioButtonHeight = 7 - -.params rb_params - DEFINE_POINT viewloc, 0, 0 -mapbits: .addr SELF_MODIFIED -mapwidth: .byte 3 -reserved: .byte 0 - DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight -.endparams - -checked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - -unchecked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) kOptionDisplayX = 30 kOptionDisplayY = 44 - DEFINE_LABEL clock_12hour, res_string_label_clock_12hour, kOptionDisplayX+60+kRadioButtonWidth+kLabelPadding-10, kOptionDisplayY+8 - DEFINE_LABEL clock_24hour, res_string_label_clock_24hour, kOptionDisplayX+120+kRadioButtonWidth+kLabelPadding, kOptionDisplayY+8 - ;; for hit testing; label width is added dynamically - DEFINE_RECT_SZ rect_12hour, kOptionDisplayX+60-10, kOptionDisplayY, kRadioButtonWidth+kLabelPadding, kRadioButtonHeight - DEFINE_RECT_SZ rect_24hour, kOptionDisplayX+120, kOptionDisplayY, kRadioButtonWidth+kLabelPadding, kRadioButtonHeight + DEFINE_BUTTON clock_12hour_rec, kDAWindowId, res_string_label_clock_12hour,, kOptionDisplayX+60-10, kOptionDisplayY + DEFINE_BUTTON clock_24hour_rec, kDAWindowId, res_string_label_clock_24hour,, kOptionDisplayX+120, kOptionDisplayY + DEFINE_BUTTON_PARAMS clock_12hour_params, clock_12hour_rec + DEFINE_BUTTON_PARAMS clock_24hour_params, clock_24hour_rec .params date_bitmap_params DEFINE_POINT viewloc, 14, 40 @@ -528,11 +494,6 @@ init_window: : sta RAMRDON - param_call MeasureString, clock_12hour_label_str - addax rect_12hour::x2 - param_call MeasureString, clock_24hour_label_str - addax rect_24hour::x2 - MGTK_CALL MGTK::OpenWindow, winfo lda #0 sta selected_field @@ -666,14 +627,14 @@ hit: cmp #MGTK::inrect_inside jeq OnClickOk - MGTK_CALL MGTK::InRect, rect_12hour + MGTK_CALL MGTK::InRect, clock_12hour_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #$00 jmp HandleOptionClick END_IF - MGTK_CALL MGTK::InRect, rect_24hour + MGTK_CALL MGTK::InRect, clock_24hour_rec::rect cmp #MGTK::inrect_inside IF_EQ lda #$80 @@ -1150,29 +1111,36 @@ label_downarrow: ;; -------------------------------------------------- - MGTK_CALL MGTK::MoveTo, clock_12hour_label_pos - param_call DrawString, clock_12hour_label_str - MGTK_CALL MGTK::MoveTo, clock_24hour_label_pos - param_call DrawString, clock_24hour_label_str - BTK_CALL BTK::Draw, ok_button_params + BTK_CALL BTK::RadioDraw, clock_12hour_params + BTK_CALL BTK::RadioDraw, clock_24hour_params - FALL_THROUGH_TO DrawOptionButtons + FALL_THROUGH_TO UpdateOptionButtons .endproc -.proc DrawOptionButtons +.proc UpdateOptionButtons MGTK_CALL MGTK::SetPenMode, notpencopy - ldax #rect_12hour - ldy SETTINGS + DeskTopSettings::clock_24hours - cpy #0 - jsr DrawRadioButton + lda SETTINGS + DeskTopSettings::clock_24hours + cmp #0 + jsr ZToN + sta clock_12hour_rec::state + BTK_CALL BTK::RadioUpdate, clock_12hour_params + + lda SETTINGS + DeskTopSettings::clock_24hours + cmp #$80 + jsr ZToN + sta clock_24hour_rec::state + BTK_CALL BTK::RadioUpdate, clock_24hour_params - ldax #rect_24hour - ldy SETTINGS + DeskTopSettings::clock_24hours - cpy #$80 - jsr DrawRadioButton + rts +.endproc +.proc ZToN + beq :+ + lda #0 + rts +: lda #$80 rts .endproc @@ -1360,7 +1328,7 @@ loop: cmp #10 .proc HandleOptionClick sta SETTINGS + DeskTopSettings::clock_24hours MGTK_CALL MGTK::HideCursor - jsr DrawOptionButtons + jsr UpdateOptionButtons MGTK_CALL MGTK::ShowCursor ;; Set dirty bit @@ -1385,30 +1353,6 @@ loop: cmp #10 jmp InputLoop .endproc -;;; ============================================================ - -;;; A,X = pos ptr, Z = checked -.proc DrawRadioButton - ptr := $06 - - stax ptr - - IF_EQ - copy16 #checked_rb_bitmap, rb_params::mapbits - ELSE - copy16 #unchecked_rb_bitmap, rb_params::mapbits - END_IF - - ldy #3 -: lda (ptr),y - sta rb_params::viewloc,y - dey - bpl :- - - MGTK_CALL MGTK::PaintBits, rb_params - rts -.endproc - ;;; ============================================================ ;;; Assert: Called from Aux diff --git a/desk.acc/joystick.s b/desk.acc/joystick.s index f96782c2..7ec13575 100644 --- a/desk.acc/joystick.s +++ b/desk.acc/joystick.s @@ -11,10 +11,12 @@ .include "../inc/apple2.inc" .include "../inc/macros.inc" .include "../mgtk/mgtk.inc" + .include "../toolkits/btk.inc" .include "../common.inc" .include "../desktop/desktop.inc" MGTKEntry := MGTKAuxEntry + BTKEntry := BTKAuxEntry ;;; ============================================================ @@ -139,49 +141,6 @@ window_id: .byte kDAWindowId grafport: .tag MGTK::GrafPort - -;;; ============================================================ -;;; Common Resources - -kRadioButtonWidth = 15 -kRadioButtonHeight = 7 - -.params checked_rb_params - DEFINE_POINT viewloc, 0, 0 -mapbits: .addr checked_rb_bitmap -mapwidth: .byte 3 -reserved: .byte 0 - DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight -.endparams - -checked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - -.params unchecked_rb_params - DEFINE_POINT viewloc, 0, 0 -mapbits: .addr unchecked_rb_bitmap -mapwidth: .byte 3 -reserved: .byte 0 - DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight -.endparams - -unchecked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - ;;; ============================================================ ;;; Joystick Calibration Resources @@ -196,17 +155,12 @@ kJoystickDisplayH = 64 DEFINE_RECT_SZ joy_disp_frame_rect, kJoystickDisplayX , kJoystickDisplayY , kJoystickDisplayW + 8, kJoystickDisplayH + 5 DEFINE_RECT_SZ joy_disp_rect, kJoystickDisplayX + 1, kJoystickDisplayY + 1, kJoystickDisplayW + 6, kJoystickDisplayH + 3 - DEFINE_POINT joy_btn0, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 10 - DEFINE_POINT joy_btn1, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 30 - DEFINE_POINT joy_btn2, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 50 - - DEFINE_POINT joy_btn0_lpos, kJoystickDisplayX + kJoystickDisplayW + kRadioButtonWidth + 30, kJoystickDisplayY + 10 + 8 - DEFINE_POINT joy_btn1_lpos, kJoystickDisplayX + kJoystickDisplayW + kRadioButtonWidth + 30, kJoystickDisplayY + 30 + 8 - DEFINE_POINT joy_btn2_lpos, kJoystickDisplayX + kJoystickDisplayW + kRadioButtonWidth + 30, kJoystickDisplayY + 50 + 8 - -joy_btn0_label: PASCAL_STRING res_string_label_joy_btn0 ; dialog label -joy_btn1_label: PASCAL_STRING res_string_label_joy_btn1 ; dialog label -joy_btn2_label: PASCAL_STRING res_string_label_joy_btn2 ; dialog label + DEFINE_BUTTON joy_btn0_rec, kDAWindowId, res_string_label_joy_btn0,, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 10 + DEFINE_BUTTON joy_btn1_rec, kDAWindowId, res_string_label_joy_btn1,, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 30 + DEFINE_BUTTON joy_btn2_rec, kDAWindowId, res_string_label_joy_btn2,, kJoystickDisplayX + kJoystickDisplayW + 20, kJoystickDisplayY + 50 + DEFINE_BUTTON_PARAMS joy_btn0_params, joy_btn0_rec + DEFINE_BUTTON_PARAMS joy_btn1_params, joy_btn1_rec + DEFINE_BUTTON_PARAMS joy_btn2_params, joy_btn2_rec .params joy_marker DEFINE_POINT viewloc, 0, 0 @@ -405,12 +359,9 @@ notpencopy: .byte MGTK::notpencopy MGTK_CALL MGTK::FrameRect, joy_disp_frame_rect - MGTK_CALL MGTK::MoveTo, joy_btn0_lpos - param_call DrawString, joy_btn0_label - MGTK_CALL MGTK::MoveTo, joy_btn1_lpos - param_call DrawString, joy_btn1_label - MGTK_CALL MGTK::MoveTo, joy_btn2_lpos - param_call DrawString, joy_btn2_label + BTK_CALL BTK::RadioDraw, joy_btn0_params + BTK_CALL BTK::RadioDraw, joy_btn1_params + BTK_CALL BTK::RadioDraw, joy_btn2_params copy #0, last_joy_valid_flag @@ -421,33 +372,6 @@ done: MGTK_CALL MGTK::ShowCursor .endproc - -;;; A,X = pos ptr, Z = checked -.proc DrawRadioButton - ptr := $06 - - stax ptr - beq checked - -unchecked: - ldy #3 -: lda (ptr),y - sta unchecked_rb_params::viewloc,y - dey - bpl :- - MGTK_CALL MGTK::PaintBits, unchecked_rb_params - rts - -checked: - ldy #3 -: lda (ptr),y - sta checked_rb_params::viewloc,y - dey - bpl :- - MGTK_CALL MGTK::PaintBits, checked_rb_params - rts -.endproc - ;;; ============================================================ ;; TODO: Read and visualize all 4 paddles. @@ -535,20 +459,20 @@ changed: MGTK_CALL MGTK::PaintBits, joy_marker - ldax #joy_btn0 - ldy curr+InputState::butn0 - cpy #$80 - jsr DrawRadioButton + lda curr+InputState::butn0 + and #$80 + sta joy_btn0_rec::state + BTK_CALL BTK::RadioDraw, joy_btn0_params - ldax #joy_btn1 - ldy curr+InputState::butn1 - cpy #$80 - jsr DrawRadioButton + lda curr+InputState::butn1 + and #$80 + sta joy_btn1_rec::state + BTK_CALL BTK::RadioDraw, joy_btn1_params - ldax #joy_btn2 - ldy curr+InputState::butn2 - cpy #$80 - jsr DrawRadioButton + lda curr+InputState::butn2 + and #$80 + sta joy_btn2_rec::state + BTK_CALL BTK::RadioDraw, joy_btn2_params MGTK_CALL MGTK::ShowCursor done: rts diff --git a/desktop/internal.inc b/desktop/internal.inc index 2646842a..1b80e5b2 100644 --- a/desktop/internal.inc +++ b/desktop/internal.inc @@ -278,7 +278,7 @@ _segoffset .set 0 DEFSEG OverlayShortcutPick, $9000, $0B00 DEFSEG OverlayFileDialog, $5000, $1100 DEFSEG OverlayFileCopy, $7000, $0100 - DEFSEG OverlayShortcutEdit, $7000, $0400 + DEFSEG OverlayShortcutEdit, $7000, $0300 ;;; These pseudo-overlays restore DeskTop after overlays are used diff --git a/desktop/ovl_selector_edit.s b/desktop/ovl_selector_edit.s index 8a1c2a35..d9dd7be2 100644 --- a/desktop/ovl_selector_edit.s +++ b/desktop/ovl_selector_edit.s @@ -8,6 +8,7 @@ .org ::kOverlayShortcutEditAddress MGTKEntry := MGTKRelayImpl + BTKEntry := BTKRelayImpl ;;; Called back from file dialog's `Start` .proc Init @@ -27,7 +28,7 @@ jsr file_dialog::SetPortForDialog lda which_run_list sec - jsr DrawRunListButton + jsr UpdateRunListButton lda copy_when sec jsr DrawCopyWhenButton @@ -97,40 +98,22 @@ buffer: .res 16, 0 MGTK_CALL MGTK::MoveTo, add_a_new_entry_to_label_pos param_call file_dialog::DrawString, add_a_new_entry_to_label_str - MGTK_CALL MGTK::MoveTo, primary_run_list_label_pos - param_call file_dialog::DrawString, primary_run_list_label_str - param_call file_dialog::MeasureString, primary_run_list_label_str - addax rect_primary_run_list_ctrl::x2 - - MGTK_CALL MGTK::MoveTo, secondary_run_list_label_pos - param_call file_dialog::DrawString, secondary_run_list_label_str - param_call file_dialog::MeasureString, secondary_run_list_label_str - addax rect_secondary_run_list_ctrl::x2 + BTK_CALL BTK::RadioDraw, primary_run_list_params + BTK_CALL BTK::RadioDraw, secondary_run_list_params MGTK_CALL MGTK::MoveTo, down_load_label_pos param_call file_dialog::DrawString, down_load_label_str - MGTK_CALL MGTK::MoveTo, at_first_boot_label_pos - param_call file_dialog::DrawString, at_first_boot_label_str - param_call file_dialog::MeasureString, at_first_boot_label_str - addax rect_at_first_boot_ctrl::x2 - - MGTK_CALL MGTK::MoveTo, at_first_use_label_pos - param_call file_dialog::DrawString, at_first_use_label_str - param_call file_dialog::MeasureString, at_first_use_label_str - addax rect_at_first_use_ctrl::x2 - - MGTK_CALL MGTK::MoveTo, never_label_pos - param_call file_dialog::DrawString, never_label_str - param_call file_dialog::MeasureString, never_label_str - addax rect_never_ctrl::x2 + BTK_CALL BTK::RadioDraw, at_first_boot_params + BTK_CALL BTK::RadioDraw, at_first_use_params + BTK_CALL BTK::RadioDraw, never_params lda #1 clc - jsr DrawRunListButton + jsr UpdateRunListButton lda #2 clc - jsr DrawRunListButton + jsr UpdateRunListButton lda #1 clc jsr DrawCopyWhenButton @@ -244,23 +227,23 @@ is_add_flag: ; high bit set = Add, clear = Edit ;;; ============================================================ .proc HandleClick - MGTK_CALL MGTK::InRect, rect_primary_run_list_ctrl + MGTK_CALL MGTK::InRect, primary_run_list_rec::rect cmp #MGTK::inrect_inside jeq ClickPrimaryRunListCtrl - MGTK_CALL MGTK::InRect, rect_secondary_run_list_ctrl + MGTK_CALL MGTK::InRect, secondary_run_list_rec::rect cmp #MGTK::inrect_inside jeq ClickSecondaryRunListCtrl - MGTK_CALL MGTK::InRect, rect_at_first_boot_ctrl + MGTK_CALL MGTK::InRect, at_first_boot_rec::rect cmp #MGTK::inrect_inside jeq ClickAtFirstBootCtrl - MGTK_CALL MGTK::InRect, rect_at_first_use_ctrl + MGTK_CALL MGTK::InRect, at_first_use_rec::rect cmp #MGTK::inrect_inside jeq ClickAtFirstUseCtrl - MGTK_CALL MGTK::InRect, rect_never_ctrl + MGTK_CALL MGTK::InRect, never_rec::rect cmp #MGTK::inrect_inside jeq ClickNeverCtrl @@ -272,11 +255,11 @@ is_add_flag: ; high bit set = Add, clear = Edit cmp #1 beq :+ clc - jsr DrawRunListButton + jsr UpdateRunListButton lda #1 sta which_run_list sec - jsr DrawRunListButton + jsr UpdateRunListButton : return #$FF .endproc @@ -285,11 +268,11 @@ is_add_flag: ; high bit set = Add, clear = Edit cmp #2 beq :+ clc - jsr DrawRunListButton + jsr UpdateRunListButton lda #2 sta which_run_list sec - jsr DrawRunListButton + jsr UpdateRunListButton : return #$FF .endproc @@ -334,60 +317,43 @@ is_add_flag: ; high bit set = Add, clear = Edit ;;; ============================================================ -.proc DrawRunListButton - pha - IF_CC - copy16 #unchecked_rb_bitmap, rb_params::mapbits - ELSE - copy16 #checked_rb_bitmap, rb_params::mapbits - END_IF - - pla +.proc UpdateRunListButton + ldx #0 + bcc :+ + ldx #$80 +: cmp #1 IF_EQ - ldax #rect_primary_run_list_ctrl + stx primary_run_list_rec::state + BTK_CALL BTK::RadioUpdate, primary_run_list_params ELSE - ldax #rect_secondary_run_list_ctrl + stx secondary_run_list_rec::state + BTK_CALL BTK::RadioUpdate, secondary_run_list_params END_IF - ptr := $06 -draw: - stax ptr - ldy #.sizeof(MGTK::Point)-1 -: lda (ptr),y - sta rb_params::viewloc,y - dey - bpl :- - - jsr file_dialog::SetPortForDialog - MGTK_CALL MGTK::SetPenMode, notpencopy - MGTK_CALL MGTK::HideCursor - MGTK_CALL MGTK::PaintBits, rb_params - MGTK_CALL MGTK::ShowCursor rts .endproc .proc DrawCopyWhenButton - pha - IF_CC - copy16 #unchecked_rb_bitmap, rb_params::mapbits - ELSE - copy16 #checked_rb_bitmap, rb_params::mapbits - END_IF - - pla + ldx #0 + bcc :+ + ldx #$80 +: cmp #1 bne :+ - ldax #rect_at_first_boot_ctrl - bne DrawRunListButton::draw ; always - -: cmp #2 + stx at_first_boot_rec::state + BTK_CALL BTK::RadioUpdate, at_first_boot_params + rts +: + cmp #2 bne :+ - ldax #rect_at_first_use_ctrl - bne DrawRunListButton::draw ; always - -: ldax #rect_never_ctrl - bne DrawRunListButton::draw ; always + stx at_first_use_rec::state + BTK_CALL BTK::RadioUpdate, at_first_use_params + rts +: + stx never_rec::state + BTK_CALL BTK::RadioUpdate, never_params + rts .endproc ;;; ============================================================ diff --git a/desktop/res.s b/desktop/res.s index 57862629..7f752057 100644 --- a/desktop/res.s +++ b/desktop/res.s @@ -383,79 +383,39 @@ str_kb_suffix: file_count: .word 0 +;;; ============================================================ + + FONT := DEFAULT_FONT + .define FD_EXTENDED 1 + buf_input1 := path_buf0 + buf_input2 := path_buf1 + .include "../lib/file_dialog_res.s" + ;;; ============================================================ ;;; Resources for Add/Edit a Shortcut dialog enter_the_name_to_appear_label: PASCAL_STRING res_string_selector_label_enter_name - -;;; Padding between radio/checkbox and label -kLabelPadding = 5 - -kRadioButtonWidth = 15 -kRadioButtonHeight = 7 - -.params rb_params - DEFINE_POINT viewloc, 0, 0 -mapbits: .addr SELF_MODIFIED -mapwidth: .byte 3 -reserved: .byte 0 - DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight -.endparams - -checked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1100111),PX(%1111100),PX(%1100000) - .byte PX(%1110001),PX(%1110001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - -unchecked_rb_bitmap: - .byte PX(%0000111),PX(%1111100),PX(%0000000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1100000),PX(%0000000),PX(%1100000) - .byte PX(%1110000),PX(%0000001),PX(%1100000) - .byte PX(%0011100),PX(%0000111),PX(%0000000) - .byte PX(%0000111),PX(%1111100),PX(%0000000) - kRadioButtonLeft = 332 -kRadioButtonHOffset = kLabelPadding -kRadioControlHeight = 8 ; system font height - 1 - ;; Rect widths are dynamically computed based on label + kFDWinId = file_dialog_res::kFilePickerDlgWindowID DEFINE_LABEL add_a_new_entry_to, res_string_selector_label_add_a_new_entry_to, 329, 37 - DEFINE_RECT_SZ rect_primary_run_list_ctrl, kRadioButtonLeft, 39, kRadioButtonWidth + kRadioButtonHOffset, kRadioControlHeight - DEFINE_LABEL primary_run_list, {kGlyphOpenApple,res_string_selector_label_primary_run_list}, kRadioButtonLeft + kRadioButtonWidth + kRadioButtonHOffset, 47 - - DEFINE_RECT_SZ rect_secondary_run_list_ctrl, kRadioButtonLeft, 48, kRadioButtonWidth + kRadioButtonHOffset, kRadioControlHeight - DEFINE_LABEL secondary_run_list, {kGlyphOpenApple,res_string_selector_label_secondary_run_list}, kRadioButtonLeft + kRadioButtonWidth + kRadioButtonHOffset, 56 + DEFINE_BUTTON primary_run_list_rec, kFDWinId, {kGlyphOpenApple,res_string_selector_label_primary_run_list},, kRadioButtonLeft, 39 + DEFINE_BUTTON_PARAMS primary_run_list_params, primary_run_list_rec + DEFINE_BUTTON secondary_run_list_rec, kFDWinId, {kGlyphOpenApple,res_string_selector_label_secondary_run_list},, kRadioButtonLeft, 48 + DEFINE_BUTTON_PARAMS secondary_run_list_params, secondary_run_list_rec DEFINE_LABEL down_load, res_string_selector_label_download, 329, 71 - DEFINE_RECT_SZ rect_at_first_boot_ctrl, kRadioButtonLeft, 73, kRadioButtonWidth + kRadioButtonHOffset, kRadioControlHeight - DEFINE_LABEL at_first_boot, {kGlyphOpenApple,res_string_selector_label_at_first_boot}, kRadioButtonLeft + kRadioButtonWidth + kRadioButtonHOffset, 81 - - DEFINE_RECT_SZ rect_at_first_use_ctrl, kRadioButtonLeft, 82, kRadioButtonWidth + kRadioButtonHOffset, kRadioControlHeight - DEFINE_LABEL at_first_use, {kGlyphOpenApple,res_string_selector_label_at_first_use}, kRadioButtonLeft + kRadioButtonWidth + kRadioButtonHOffset, 90 - - DEFINE_RECT_SZ rect_never_ctrl, kRadioButtonLeft, 91, kRadioButtonWidth + kRadioButtonHOffset, kRadioControlHeight - DEFINE_LABEL never, {kGlyphOpenApple,res_string_selector_label_never}, kRadioButtonLeft + kRadioButtonWidth + kRadioButtonHOffset, 99 - -;;; ============================================================ - - FONT := DEFAULT_FONT - .define FD_EXTENDED 1 - buf_input1 := path_buf0 - buf_input2 := path_buf1 - .include "../lib/file_dialog_res.s" + DEFINE_BUTTON at_first_boot_rec, kFDWinId, {kGlyphOpenApple,res_string_selector_label_at_first_boot},, kRadioButtonLeft, 73 + DEFINE_BUTTON_PARAMS at_first_boot_params, at_first_boot_rec + DEFINE_BUTTON at_first_use_rec, kFDWinId, {kGlyphOpenApple,res_string_selector_label_at_first_use},, kRadioButtonLeft, 82 + DEFINE_BUTTON_PARAMS at_first_use_params, at_first_use_rec + DEFINE_BUTTON never_rec, kFDWinId, {kGlyphOpenApple,res_string_selector_label_never},, kRadioButtonLeft, 91 + DEFINE_BUTTON_PARAMS never_params, never_rec ;;; ============================================================ diff --git a/selector/selector.s b/selector/selector.s index 8e873344..c5be7ad3 100644 --- a/selector/selector.s +++ b/selector/selector.s @@ -54,7 +54,7 @@ _segoffset .set 0 _segoffset .set kLoaderOffset DEFSEG SegmentLoader, $2000, $0300 DEFSEG SegmentInvoker, INVOKER, $0160 - DEFSEG SegmentApp, $4000, $6500 + DEFSEG SegmentApp, $4000, $6600 DEFSEG SegmentAlert, $D000, $0800 ;;; Dynamically loaded overlays diff --git a/toolkits/BTK.md b/toolkits/BTK.md index 5a33cd85..26e00f1f 100644 --- a/toolkits/BTK.md +++ b/toolkits/BTK.md @@ -17,7 +17,7 @@ This defines the state of a control instance. .addr a_label Address of the button label. .addr a_shortcut Address of the button shortcut label, null if none). MGTK:Rect rect Bounding rect of the control. -.byte state Button state. bit7 = disabled. +.byte state Button state. bit7 = disabled (or checked, if radio). ``` ## Commands @@ -44,6 +44,7 @@ Parameters: .addr a_record Address of the ButtonRecord ``` + ### Hilite ($02) Redraw the control label, considering the disable state. @@ -52,6 +53,7 @@ Parameters: .addr a_record Address of the ButtonRecord ``` + ### Track ($03) Start a nested event loop tracking after a click is initiated in the control. Returns with N=0/Z=1 if clicked, N=1/Z=0 if cancelled. @@ -60,6 +62,31 @@ Parameters: .addr a_record Address of the ButtonRecord ``` + +### RadioDraw ($04) +Draw a radio button. + +Parameters: +``` +.addr a_record Address of the ButtonRecord +``` + +The high bit of the `ButtonRecord::state` signifies whether or not the button is checked. + +The shortcut is ignored. After the call, the `ButtonRecord::rect` is updated to the bounding box of the button and (if not null) the label. This can be used for later hit testing. + + +### RadioUpdate ($03) +Update the bitmap of a radio button. + +Parameters: +``` +.addr a_record Address of the ButtonRecord +``` + +The high bit of the `ButtonRecord::state` signifies whether or not the button is checked. + + ## Convenience Macros * `BTK_CALL` can be used to make calls in the form `BTK_CALL command, params`, if `BTKEntry` is defined. diff --git a/toolkits/btk.inc b/toolkits/btk.inc index 42c3c6c6..072167c8 100644 --- a/toolkits/btk.inc +++ b/toolkits/btk.inc @@ -32,7 +32,12 @@ state .byte .macro DEFINE_BUTTON name, winid, label, shortcut, left, top, width, height .params name window_id: .byte winid + +.ifnblank label a_label: .addr str_label +.else +a_label: .addr 0 +.endif .ifnblank shortcut a_shortcut: .addr str_shortcut @@ -51,9 +56,11 @@ a_shortcut: .addr 0 state: .byte 0 .res .sizeof(BTK::ButtonRecord) - (*-window_id) - ;; TODO: Use a string pool for these, somehow -str_label: PASCAL_STRING label + ;; TODO: Use a string pool for these, somehow +.ifnblank label +str_label: PASCAL_STRING {label} +.endif .ifnblank shortcut str_shortcut: PASCAL_STRING shortcut .endif @@ -65,6 +72,7 @@ str_shortcut: PASCAL_STRING shortcut Draw = $00 ; Draw button ;;; .addr record +;;; .byte update_flag Flash = $01 ; Flash button ;;; .addr record @@ -75,6 +83,13 @@ Hilite = $02 ; Redraw label (after state change) Track = $03 ; Handle click within control bounds ;;; .addr record +RadioDraw = $04 ; Draw a radio button (and update hit rect) +;;; .addr record + +RadioUpdate = $05 ; Update a radio button after a click +;;; .addr record + + .endscope ; BTK .macro DEFINE_BUTTON_PARAMS name, rec diff --git a/toolkits/btk.s b/toolkits/btk.s index 4e4b258c..52576074 100644 --- a/toolkits/btk.s +++ b/toolkits/btk.s @@ -82,6 +82,8 @@ jump_table: .addr FlashImpl .addr HiliteImpl .addr TrackImpl + .addr RadioDrawImpl + .addr RadioUpdateImpl ;; Must be non-zero length_table: @@ -89,6 +91,8 @@ length_table: .byte 2 ; Flash .byte 2 ; Hilite .byte 2 ; Track + .byte 2 ; RadioDraw + .byte 2 ; RadioUpdate .endproc ;;; ============================================================ @@ -182,17 +186,7 @@ skip_port: MGTK_CALL MGTK::MoveTo, pos ;; Draw the string (left aligned) -PARAM_BLOCK dt_params, $6 -textptr .addr -textlen .byte -END_PARAM_BLOCK - ldy #0 - lda (a_label),y - beq :+ - sta dt_params::textlen - add16_8 a_label, #1, dt_params::textptr - MGTK_CALL MGTK::DrawText, dt_params -: + jsr _DrawLabel ;; Draw the shortcut (if present, right aligned) PARAM_BLOCK tw_params, $6 @@ -234,6 +228,47 @@ HiliteImpl__skip_port := HiliteImpl::skip_port ;;; ============================================================ +;;; Input: `a_label` points at string +;;; Trashes $06..$08 +.proc _DrawLabel +PARAM_BLOCK dt_params, $6 +textptr .addr +textlen .byte +END_PARAM_BLOCK + ldy #0 + lda (a_label),y + beq :+ + sta dt_params::textlen + add16_8 a_label, #1, dt_params::textptr + MGTK_CALL MGTK::DrawText, dt_params +: rts +.endproc + +;;; Inputs: `a_label` points at string +;;; Output: A,X = width +;;; Trashes: $06..$0A +.proc _MeasureLabel +PARAM_BLOCK tw_params, $6 +textptr .addr +textlen .byte +width .word +END_PARAM_BLOCK + ldy #0 + lda (a_label),y + bne :+ + lda #0 + tax + rts +: + sta tw_params::textlen + add16_8 a_label, #1, tw_params::textptr + MGTK_CALL MGTK::TextWidth, tw_params + ldax tw_params::width + rts +.endproc + +;;; ============================================================ + .params event_params kind := * + 0 ;; if `kind` is key_down @@ -311,6 +346,113 @@ down_flag: .endproc ; TrackImpl +;;; ============================================================ + +;;; Padding between radio/checkbox and label +kLabelPadding = 5 + +kRadioButtonWidth = 15 +kRadioButtonHeight = 7 + +.params rb_params + DEFINE_POINT viewloc, 0, 0 +mapbits: .addr SELF_MODIFIED +mapwidth: .byte 3 +reserved: .byte 0 + DEFINE_RECT maprect, 0, 0, kRadioButtonWidth, kRadioButtonHeight +.endparams + +checked_rb_bitmap: + .byte PX(%0000111),PX(%1111100),PX(%0000000) + .byte PX(%0011100),PX(%0000111),PX(%0000000) + .byte PX(%1110001),PX(%1110001),PX(%1100000) + .byte PX(%1100111),PX(%1111100),PX(%1100000) + .byte PX(%1100111),PX(%1111100),PX(%1100000) + .byte PX(%1110001),PX(%1110001),PX(%1100000) + .byte PX(%0011100),PX(%0000111),PX(%0000000) + .byte PX(%0000111),PX(%1111100),PX(%0000000) + +unchecked_rb_bitmap: + .byte PX(%0000111),PX(%1111100),PX(%0000000) + .byte PX(%0011100),PX(%0000111),PX(%0000000) + .byte PX(%1110000),PX(%0000001),PX(%1100000) + .byte PX(%1100000),PX(%0000000),PX(%1100000) + .byte PX(%1100000),PX(%0000000),PX(%1100000) + .byte PX(%1110000),PX(%0000001),PX(%1100000) + .byte PX(%0011100),PX(%0000111),PX(%0000000) + .byte PX(%0000111),PX(%1111100),PX(%0000000) + +;;; ============================================================ + +.proc RadioDrawImpl + PARAM_BLOCK params, btk::command_data +a_record .addr + END_PARAM_BLOCK + .assert a_record = params::a_record, error, "a_record must be first" + + jsr _SetPort + + ;; Initial size is just the button + add16_8 rect+MGTK::Rect::x1, #kRadioButtonWidth, rect+MGTK::Rect::x2 + add16_8 rect+MGTK::Rect::y1, #kRadioButtonHeight, rect+MGTK::Rect::y2 + + ;; No label? skip + lda a_label + ora a_label+1 + beq update_rect + + ;; Draw the label + pos := $B + add16_8 rect+MGTK::Rect::x1, #kLabelPadding + kRadioButtonWidth, pos+MGTK::Point::xcoord + add16_8 rect+MGTK::Rect::y1, #kSystemFontHeight - 1, pos+MGTK::Point::ycoord + MGTK_CALL MGTK::MoveTo, pos + jsr _DrawLabel + + ;; And measure it for hit testing + jsr _MeasureLabel + addax rect+MGTK::Rect::x2 + add16_8 rect+MGTK::Rect::x2, #kLabelPadding + add16_8 rect+MGTK::Rect::y2, #kSystemFontHeight - kRadioButtonHeight + + ;; Write rect back to button record +update_rect: + ldx #.sizeof(MGTK::Rect)-1 + ldy #BTK::ButtonRecord::rect + .sizeof(MGTK::Rect)-1 +: lda rect,x + sta (a_record),y + dey + dex + bpl :- + + jmp _DrawRadioBitmap +.endproc ; RadioDrawImpl + +;;; ============================================================ + +.proc RadioUpdateImpl + PARAM_BLOCK params, btk::command_data +a_record .addr + END_PARAM_BLOCK + .assert a_record = params::a_record, error, "a_record must be first" + + jsr _SetPort + + FALL_THROUGH_TO _DrawRadioBitmap +.endproc ; RadioUpdateImpl + +.proc _DrawRadioBitmap + COPY_STRUCT MGTK::Point, rect+MGTK::Rect::topleft, rb_params::viewloc + ldax #unchecked_rb_bitmap + bit state + IF_NS + ldax #checked_rb_bitmap + END_IF + stax rb_params::mapbits + + MGTK_CALL MGTK::SetPenMode, notpencopy + MGTK_CALL MGTK::PaintBits, rb_params + rts +.endproc ;;; ============================================================