(contentType string)
| 2307 | } |
| 2308 | |
| 2309 | func (card *Card) SetContents(contentType string) { |
| 2310 | |
| 2311 | if contentType == ContentTypeNull { |
| 2312 | return |
| 2313 | } |
| 2314 | |
| 2315 | prevContents := card.Contents |
| 2316 | |
| 2317 | if existingContents, exists := card.ContentsLibrary[contentType]; exists { |
| 2318 | card.Contents = existingContents |
| 2319 | } else { |
| 2320 | |
| 2321 | for _, prop := range card.Properties.Props { |
| 2322 | prop.InUse = false |
| 2323 | } |
| 2324 | |
| 2325 | switch contentType { |
| 2326 | case ContentTypeCheckbox: |
| 2327 | card.Contents = NewCheckboxContents(card) |
| 2328 | case ContentTypeNumbered: |
| 2329 | card.Contents = NewNumberedContents(card) |
| 2330 | case ContentTypeNote: |
| 2331 | card.Contents = NewNoteContents(card) |
| 2332 | case ContentTypePinboard: |
| 2333 | card.Contents = NewPinboardContents(card) |
| 2334 | case ContentTypeSound: |
| 2335 | card.Contents = NewSoundContents(card) |
| 2336 | case ContentTypeImage: |
| 2337 | card.Contents = NewImageContents(card) |
| 2338 | case ContentTypeTimer: |
| 2339 | card.Contents = NewTimerContents(card) |
| 2340 | case ContentTypeMap: |
| 2341 | card.Contents = NewMapContents(card) |
| 2342 | case ContentTypeSubpage: |
| 2343 | card.Contents = NewSubPageContents(card) |
| 2344 | case ContentTypeLink: |
| 2345 | card.Contents = NewLinkContents(card) |
| 2346 | case ContentTypeTable: |
| 2347 | card.Contents = NewTableContents(card) |
| 2348 | case ContentTypeInternet: |
| 2349 | webCard := NewInternetContents(card) |
| 2350 | if webCard == nil { |
| 2351 | // Web card couldn't be created, probably because of browser shenanigans |
| 2352 | card.Contents = NewCheckboxContents(card) |
| 2353 | } else { |
| 2354 | card.Contents = webCard |
| 2355 | } |
| 2356 | default: |
| 2357 | panic("Creation of card contents that haven't been implemented: " + contentType) |
| 2358 | } |
| 2359 | |
| 2360 | w := card.Rect.W |
| 2361 | if w <= 0 { |
| 2362 | w = card.Contents.DefaultSize().X |
| 2363 | } |
| 2364 | h := card.Rect.H |
| 2365 | if h <= 0 { |
| 2366 | h = card.Contents.DefaultSize().Y |
no test coverage detected