<commit_before><commit_msg>[wxhaskell-from-cvs @ 2003-09-08 15:11:00 by dleijen]<commit_after>{--------------------------------------------------------------------------------
   List control demo.
--------------------------------------------------------------------------------}
module Main where

import Graphics.UI.WX
import Graphics.UI.WXCore 


entries = [
   ("BouncingBalls.hs"           ,"2402"  ,"Jul 19 16:50")
  ,("ByeDemo.hs"                 ,"1414"  ,"Jul 13 23:18")
  ,("Camels.hs"                  ,"7633"  ,"Aug 20 11:57")
  ,("Controls.hs"                ,"3862"  ,"Aug 20 11:57")
  ,("HelloWorld.hs"              ,"1028"  ,"Aug 15 10:09")
  ,("ImageViewer.hs"             ,"3756"  ,"Aug 20 11:57")
  ,("Layout.hs"                  ,"1075"  ,"Jul 13 23:18")
  ,("ListCtrl.hs"                 ,"750"  ,"Sep  8 16:22")
  ,("Minimal.hs"                  ,"147"  ,"Jul 13 23:18")
  ,("Paint.hs"                   ,"1024"  ,"Aug 20 11:57")
  ,("Process.hs"                 ,"2261"  ,"Aug 20 11:57")
  ,("TimeFlows.hs"               ,"4929"  ,"Aug 20 11:57")
  ,("TimeFlowsEx.hs"             ,"8648"  ,"Aug 20 11:57")
  ,("desert.bmp"                ,"61302"  ,"Jul 13 23:31")
  ]

main :: IO ()
main
  = start gui

gui :: IO ()
gui
  = do -- main gui elements: frame, panel, text control, and the notebook
       f       <- frame [text := "List Sample"]
       -- panel: just for the nice grey color
       p       <- panel f []
       textlog <- textCtrl p WrapLine [enable := False]

       -- use text control as logger
       textCtrlMakeLogActiveTarget textlog
       logMessage "logging enabled"              

       -- list control
       l       <- listCtrlCreate p idAny rectNull wxLC_REPORT
       listCtrlInsertColumn l 0 "Name" wxLIST_FORMAT_LEFT (-1)
       listCtrlInsertColumn l 0 "Size" wxLIST_FORMAT_LEFT (-1)
       listCtrlInsertColumn l 0 "Date" wxLIST_FORMAT_LEFT (-1)
       mapM_ (\(idx,(name,size,date)) -> do listCtrlInsertItemWithLabel l idx name (-1)
                                            listCtrlSetItem l idx 0 name (-1)
                                            listCtrlSetItem l idx 1 size (-1)
                                            listCtrlSetItem l idx 2 date (-1)
                                            return ())
                                            (zip [0..] entries)
       listCtrlOnEvent l onListEvent 

       -- specify layout
       set f [layout     := container p $ margin 10 $ 
                            column 5 [ fill  $ widget l
                                     , hfill $ widget textlog
                                     ]
             ,clientSize := sz 400 300 ]
       return ()
  where
    onListEvent eventList
      = case eventList of
          ListItemSelected info   -> logMessage ("item selected: " ++ show (listItemIndex info))
          other                   -> logMessage ("list control event.")

{'fraction_non_alphanumeric': 0.17027863777089783, 'fraction_numerical': 0.06019951840385277, 'mean_word_length': 1.2300613496932515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5411690', 'n_tokens_mistral': 943, 'n_tokens_neox': 784, 'n_words': 236}