I've been modifying the Private Message (PM) module, adding some functions, fixing a bug or two, and arranging the controls into logical/esthetic groups. The task is nearly complete, but I'm having difficulty understanding how to code with theming in mind.

I've had the notion that the PM feature should be able to be themed apart from the rest of the site--if a site administrator should desire this--but I don't know my way around the Drupal/PHPTemplate setup to know if I'm going about it right, or making a mess. Is the code, as written, already entirely themable in a way of which I'm unaware?

Many PM code sections allow me to place a <div id="pmsg"></div> around the output. My thinking is that if I wanted to style the table or the fieldsets differently from other site pages, a style sheet could simply do:

#pmsg table
{
border: 1px solid #ccf...

etc.

But some code (the Create Folder page, for example) makes this more difficult, which makes me wonder whether I'm fighting with the code in my ignorance. For example:

function personalmsg_page() {
 
is followed by a lot of switch statements like 

  switch ($op) {
    case 'list':
      $output = _personalmsg_list($arg);
      $title = t('Personal messages');
      break;
    case 'view':
      $output = _personalmsg_view($arg);
      $title = t("Read message");
      $breadcrumb = array(l(t('Home'), ''), l(t('personal messages'), 'personalmsg'));
      break;
...

and ends in 

  drupal_set_title($title);
  drupal_set_breadcrumb($breadcrumb);
  print theme('page', $output);

I've studied the phpTemplate.engine file, and read the theming and engine docs, but I still don't have a good grasp of what I need to be doing in my code.

Advice?

Curtis