Calendar gadget size fixed

Mac OSX specific forum
WilliamL
Addict
Addict
Posts: 1224
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Calendar gadget size fixed

Post by WilliamL »

It seems that no matter the x/y size of the CalendarGadget I get the same size of calendar and just extra space at the top and right of the calendar if I exceed the size below.

Code: Select all

#calendarwnd=1
#calendar1=1

calendarx=138 ; change this size
calendary=149 ; change this size
xoffset=10
yoffset=10
wndx=xoffset+calendarx+xoffset
wndy=yoffset+calendary+yoffset

If OpenWindow(#calendarwnd,0,0,wndx,wndy, "Micro Calendar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CalendarGadget(#calendar1,xoffset,yoffset,calendarx,calendary)
EndIf

Repeat  
Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by WilliamL on Fri Feb 28, 2020 9:32 pm, edited 2 times in total.
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1
User avatar
mk-soft
Always Here
Always Here
Posts: 5393
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Calendar gadget size fixed

Post by mk-soft »

I think we can't change the size of NSDatePicker... :(

Code: Select all

;-TOP Dump Object Methods

; by mk-soft, 29.12.2019, v1.06

Structure udtArray
  i.i[0]
EndStructure

ImportC ""
  class_copyMethodList(*Class, *p_methodCount) ; -> An array of pointers of type Method describing
                                            ;    the instance methods implemented by the class
                                            ;    Any instance methods implemented by superclasses are Not included
                                            ;    You must free the array with free()
  
  class_getName(*Class) ; -> UnsafePointer<Int8> -> *string
  sel_getName(*Selector) ; -> const char *
  method_getName(*Method) ; -> Selector
  method_getTypeEncoding(*Method) ; -> const char *
  method_getReturnType(*Method, *dst, dst_len) ; -> void
  method_getNumberOfArguments(*Method) ; -> unsigned int
  method_getArgumentType(*Method, index, *dst, dst_len) ; -> void
  
  NSGetSizeAndAlignment(*StringPtr, *p_size, *p_align) ; -> const char *
                                                       ;    Obtains the actual size and the aligned size of an encoded type.
EndImport

; ----

Procedure.s GetArgumentType(*String)
  Protected r1.s, arg.s, size.i
  arg = PeekS(*String, -1, #PB_UTF8)
  r1 + arg + " - "
  
  If Left(arg, 1) = "^"
    r1 + "A pointer to type of "
    arg = Mid(arg, 2)
  EndIf
  
  Select arg
    Case "c" : r1 + "A char "
    Case "i" : r1 + "An int "
    Case "s" : r1 + "A short "
    Case "l" : r1 + "A long "
    Case "q" : r1 + "A long long"
    Case "C" : r1 + "An unsigned char "
    Case "I" : r1 + "An unsigned int "
    Case "S" : r1 + "An unsigned short "
    Case "L" : r1 + "An unsigned long "
    Case "Q" : r1 + "An unsigned long long "
    Case "f" : r1 + "A float "
    Case "d" : r1 + "A double "
    Case "B" : r1 + "A C++ bool Or a C99 _Bool "
    Case "v" : r1 + "A void"
    Case "*" : r1 + "A character string (char *) "
    Case "@" : r1 + "An object (whether statically typed Or typed id) "
    Case "#" : r1 + "A class object (Class) "
    Case ":" : r1 + "A method selector (SEL) "
    Default:
      NSGetSizeAndAlignment(*String, @size, #Null)
      r1 + "[" + Str(size) + " bytes]"
  EndSelect
  
  If Right(arg, 1) = "?"
    r1 + "An unknown type (e.g. function pointer)"
  EndIf
  
  ProcedureReturn r1
  
EndProcedure

; ----

Procedure.s DumpObjectMethods(*Object, Super = #False, HidePrivate = #True, ShowEncoding = #False, FirstArgument = 2)
  Protected r1.s, i, c, n, methodCount, Method.s
  Protected *Class, *Method, *Methods.udtArray
  Protected *String = AllocateMemory(1024)
  
  *Class = object_getclass_(*Object)
  If Super
    *Class = class_getsuperclass_(*Class) 
    r1 = "SuperClass "
  Else
    r1 = "Class "
  EndIf
  
  *Methods = class_copyMethodList(*Class, @methodCount)
  
  r1 + PeekS(class_getName(*Class), -1, #PB_UTF8) + " - Count of Methods " + methodCount + #LF$
  For i = 0 To methodCount - 1
    *Method = *Methods\i[i];
    Method = PeekS(sel_getName(method_getName(*Method)), -1, #PB_UTF8)
    If HidePrivate And Left(Method, 1) = "_"
      Continue
    EndIf
    r1 + "Method " + Method + #LF$
    If ShowEncoding
      r1 + " * Encoding " + PeekS(method_getTypeEncoding(*Method), -1, #PB_UTF8) + #LF$
    EndIf
    method_getReturnType(*Method, *String, 1024)
    r1 + " -- ReturnType = " + GetArgumentType(*String) + #LF$
    c = method_getNumberOfArguments(*Method)
    For n = FirstArgument To c - 1
      method_getArgumentType(*Method, n, *String, 1024)
      r1 + " -- Argument " + Str(n - FirstArgument + 1) + " = " + GetArgumentType(*String) + #LF$
    Next
  Next
  r1 + "End Class" + #LF$
  
  free_(*methods)
  FreeMemory(*String)
  
  ProcedureReturn r1
EndProcedure

; ****

#calendarwnd=1
#calendar1=1

calendarx=238 ; change this size
calendary=230 ; change this size
xoffset=10
yoffset=10
wndx=xoffset+calendarx+xoffset
wndy=yoffset+calendary+yoffset

Define rect.cgrect
rect\size\width = 200.0
rect\size\height = 200.0

If OpenWindow(#calendarwnd,0,0,wndx,wndy, "Micro Calendar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CalendarGadget(#calendar1,xoffset,yoffset,calendarx,calendary)
  Debug DumpObjectMethods(GadgetID(#calendar1), 1)
  Debug "NSControl.controlSize = " + CocoaMessage(0, GadgetID(#calendar1), "controlSize")
  Debug "NSControl.sizeThatFits = " + CocoaMessage(0, GadgetID(#calendar1), "sizeThatFits:@", rect)
  
EndIf

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
WilliamL
Addict
Addict
Posts: 1224
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Calendar gadget size fixed

Post by WilliamL »

Thanks for the reply mk-soft,

I couldn't decide if the Help info said the gadget could be resized or not. The spaces around the calendar were puzzling to me. Maybe change Help to...

(I think I posted a re-sizealble calendar many years ago)
MacBook Pro-M1 (2021), Sonoma 14.4.1, PB 6.10LTS M1
Post Reply