[Igarden-commit] CommonSource/YAAFExtensions PictureSelectDialog.h, 1.9.2.1, 1.9.2.2 PictureSelectD
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2008-04-12 19:02:21
|
Update of /cvsroot/igarden/CommonSource/YAAFExtensions In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv21438/YAAFExtensions Modified Files: Tag: Release_branch_v1 PictureSelectDialog.h PictureSelectDialog.cpp Log Message: Load up metadata fields in picture select dialog. Add "created by" metadata field. Index: PictureSelectDialog.cpp =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/PictureSelectDialog.cpp,v retrieving revision 1.13.2.7 retrieving revision 1.13.2.8 diff -C2 -d -r1.13.2.7 -r1.13.2.8 *** PictureSelectDialog.cpp 12 Apr 2008 12:35:26 -0000 1.13.2.7 --- PictureSelectDialog.cpp 12 Apr 2008 19:02:16 -0000 1.13.2.8 *************** *** 62,65 **** --- 62,66 ---- const int kPictureWebSite = 11; const int kPictureSupplier = 12; + const int kPictureCreator = 13; const char *kPictureSelectTag = "tag:www.redstartsw.com,2006:PictureSelect://"; *************** *** 187,190 **** --- 188,192 ---- AssertValidView(mainTitleView); mainTitleView->SetText(titleStr.c_str()); + LoadCurrentPictureProperties(); } else if(CIstrncmp(src, kPictureLoadTag, strlen(kPictureLoadTag)) == 0) *************** *** 219,223 **** { PictureSelectDialog *dialog = dynamic_cast<PictureSelectDialog*>(rgd); ! dialogCBResult_t result; if(msg == KXGHyperlinkHit) --- 221,225 ---- { PictureSelectDialog *dialog = dynamic_cast<PictureSelectDialog*>(rgd); ! dialogCBResult_t result = kIgnored; if(msg == KXGHyperlinkHit) *************** *** 279,283 **** - mainTitleView = dynamic_cast<RGHypertextView*>(dlog->FindViewByID(kPictureSelectMainTitle)); AssertValidView(mainTitleView); --- 281,284 ---- *************** *** 310,314 **** RebuildSupplierMenu(); ! HidePanel(); --- 311,316 ---- RebuildSupplierMenu(); ! LoadCurrentPictureProperties(); ! HidePanel(); *************** *** 328,350 **** // void PictureSelectDialog::OKClicked(XGDialog *dlog) ! { ! XGEditText *textCtl; ! char textBuf[256]; ! String title, copyright; ! if(_writable) ! { ! textCtl = dynamic_cast<XGEditText*>(dlog->FindViewByID(kPictureCopyright)); ! textCtl->GetTitle(textBuf); ! copyright = textBuf; ! ! textCtl = dynamic_cast<XGEditText*>(dlog->FindViewByID(kPictureCommon)); ! textCtl->GetTitle(textBuf); ! title = textBuf; ! ! SaveDefaultPictureProperties(title, copyright); ! ! // Exit(1); ! } XGBroadcast::RemoveBroadcast(_dlog); --- 330,336 ---- // void PictureSelectDialog::OKClicked(XGDialog *dlog) ! { if(_writable) ! SaveCurrentPictureProperties(); XGBroadcast::RemoveBroadcast(_dlog); *************** *** 417,446 **** void PictureSelectDialog::PopupValue(XGDialog *dlog, long /*viewID*/) { ! XGPopControl *popCtl = dynamic_cast<XGPopControl*>(dlog->FindViewByID(kPictureSupplier)); ! long index; ! ! index = popCtl->GetValue(); ! if(index < 2) ! SelectLocationChoice(-1); ! else ! { ! index -= 2; ! if(index >= NumLocationChoices()) ! { ! index = CreateLocationChoice(); ! if(index != 0) ! { ! RebuildSupplierMenu(); ! popCtl->SetValue(index+2); ! SelectLocationChoice(index); ! } ! } ! else ! SelectLocationChoice(index); ! } ! String titleStr; RGHypertextView *mainTitleView; GetDefaultPicture(titleStr); mainTitleView = dynamic_cast<RGHypertextView*>(dlog->FindViewByID(kPictureSelectMainTitle)); --- 403,411 ---- void PictureSelectDialog::PopupValue(XGDialog *dlog, long /*viewID*/) { ! String titleStr; RGHypertextView *mainTitleView; + SaveCurrentPictureProperties(); GetDefaultPicture(titleStr); mainTitleView = dynamic_cast<RGHypertextView*>(dlog->FindViewByID(kPictureSelectMainTitle)); *************** *** 456,476 **** long PictureSelectDialog::EditChanged(XGDialog *dlog, long /*gadgetID*/) { - XGEditText *textCtl; - char textBuf[256]; - String title, copyright; - - textCtl = dynamic_cast<XGEditText*>(dlog->FindViewByID(kPictureCopyright)); - textCtl->GetTitle(textBuf); - copyright = textBuf; - - textCtl = dynamic_cast<XGEditText*>(dlog->FindViewByID(kPictureCommon)); - textCtl->GetTitle(textBuf); - title = textBuf; - - SaveDefaultPictureProperties(title, copyright); - String titleStr; RGHypertextView *mainTitleView; GetDefaultPicture(titleStr); mainTitleView = dynamic_cast<RGHypertextView*>(dlog->FindViewByID(kPictureSelectMainTitle)); --- 421,428 ---- long PictureSelectDialog::EditChanged(XGDialog *dlog, long /*gadgetID*/) { String titleStr; RGHypertextView *mainTitleView; + SaveCurrentPictureProperties(); GetDefaultPicture(titleStr); mainTitleView = dynamic_cast<RGHypertextView*>(dlog->FindViewByID(kPictureSelectMainTitle)); *************** *** 482,485 **** --- 434,455 ---- } + #pragma mark overriden by subclass + + //******************************************* + /// NumLocationChoices + // + long PictureSelectDialog::NumLocationChoices() + { + return 0; + } + + //******************************************* + /// GetIndexedLocationChoiceName + // + void PictureSelectDialog::GetIndexedLocationChoiceName(long /*index*/, String & /*name*/) + { + } + + #pragma mark other //******************************************* *************** *** 488,502 **** void PictureSelectDialog::HandlePaste() { - RGBorderlessIcon *triangle = dynamic_cast<RGBorderlessIcon*>(_dlog->FindViewByID(kPictureDisclosureIcon)); - PRECONDITION(triangle != NULL); PRECONDITION(_writable); - triangle->ShowView(); XGEditText *textCtl; RGHypertextView *titleCtl; titleCtl = dynamic_cast<RGHypertextView*>(_dlog->FindViewByID(kPictureSelectMainTitle)); AssertValidView(titleCtl); ! titleCtl->SetText(stx("Click on the triangle control to add copyright information for this picture")); textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCopyright)); --- 458,471 ---- void PictureSelectDialog::HandlePaste() { PRECONDITION(_writable); XGEditText *textCtl; RGHypertextView *titleCtl; + RGBorderlessIcon*triangle = dynamic_cast<RGBorderlessIcon*>(_dlog->FindViewByID(kPictureDisclosureIcon)); + ShowPanel(); titleCtl = dynamic_cast<RGHypertextView*>(_dlog->FindViewByID(kPictureSelectMainTitle)); AssertValidView(titleCtl); ! titleCtl->SetText(""); textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCopyright)); *************** *** 506,509 **** --- 475,481 ---- textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureWebSite)); textCtl->SetTitle(""); + + triangle->ShowView(); + _pasted = true; } *************** *** 519,531 **** AssertValidView(expansion); if(triangle->GetValue()) - { ShowPanel(); - expansion->ShowDisclosure(true); - } else - { - expansion->ShowDisclosure(false); HidePanel(); - } return 0; --- 491,497 ---- *************** *** 573,580 **** void PictureSelectDialog::HidePanel() { ! _dlog->FindViewByID(kPictureCopyright)->HideView(); ! _dlog->FindViewByID(kPictureCommon)->HideView(); ! _dlog->FindViewByID(kPictureSupplier)->HideView(); ! _dlog->FindViewByID(kPictureWebSite)->HideView(); } --- 539,553 ---- void PictureSelectDialog::HidePanel() { ! RGDisclosureView *expansion = dynamic_cast<RGDisclosureView*>(_dlog->FindViewByID(kPictureDisclosurePane)); ! RGBorderlessIcon *triangle = dynamic_cast<RGBorderlessIcon*>(_dlog->FindViewByID(kPictureDisclosureIcon)); ! ! SetGadgetState(kPictureCopyright, false); ! SetGadgetState(kPictureCommon, false); ! SetGadgetState(kPictureSupplier, false); ! SetGadgetState(kPictureWebSite, false); ! SetGadgetState(kPictureCreator, false); ! ! expansion->ShowDisclosure(false); ! triangle->SetValue(0); } *************** *** 584,635 **** void PictureSelectDialog::ShowPanel() { ! XGView *view; ! ! view = _dlog->FindViewByID(kPictureCopyright); ! view->ShowView(); ! if(_writable) ! view->EnableView(); ! else ! view->DisableView(); ! view = _dlog->FindViewByID(kPictureCommon); ! view->ShowView(); ! if(_writable) ! view->EnableView(); ! else ! view->DisableView(); if(NumLocationChoices() != 0) { ! view = _dlog->FindViewByID(kPictureSupplier); ! view->ShowView(); ! if(_writable) ! view->EnableView(); ! else ! view->DisableView(); } ! // _dlog->FindViewByID(kPictureWebSite)->ShowView(); } //******************************************* ! /// NumLocationChoices // ! long PictureSelectDialog::NumLocationChoices() { ! return 0; } ! //******************************************* ! /// GetIndexedLocationChoiceName ! // ! void PictureSelectDialog::GetIndexedLocationChoiceName(long /*index*/, String & /*name*/) { } ! //******************************************* ! /// SelectLocationChoice ! // ! void PictureSelectDialog::SelectLocationChoice(long index) { } --- 557,658 ---- void PictureSelectDialog::ShowPanel() { ! RGDisclosureView *expansion = dynamic_cast<RGDisclosureView*>(_dlog->FindViewByID(kPictureDisclosurePane)); ! RGBorderlessIcon *triangle = dynamic_cast<RGBorderlessIcon*>(_dlog->FindViewByID(kPictureDisclosureIcon)); ! SetGadgetState(kPictureCopyright, true); ! SetGadgetState(kPictureCommon, true); ! SetGadgetState(kPictureCreator, true); if(NumLocationChoices() != 0) { ! SetGadgetState(kPictureSupplier, true); } ! ! expansion->ShowDisclosure(true); ! triangle->SetValue(1); } //******************************************* ! /// SaveCurrentPictureProperties // ! /// Save the data within the dialog. required override of OKPressed() to change outside the dialog. ! // ! void PictureSelectDialog::SaveCurrentPictureProperties() { ! XGEditText *textCtl; ! char textBuf[256]; ! String title, copyright, author; ! ! if(_writable) ! { ! textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCopyright)); ! textCtl->GetTitle(textBuf); ! copyright = textBuf; ! ! textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCommon)); ! textCtl->GetTitle(textBuf); ! title = textBuf; ! ! textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCreator)); ! textCtl->GetTitle(textBuf); ! author = textBuf; ! ! XGPopControl *popCtl = dynamic_cast<XGPopControl*>(_dlog->FindViewByID(kPictureSupplier)); ! long index; ! ! index = popCtl->GetValue(); ! if(index < 2) ! SaveDefaultPictureProperties(title, copyright, author, -1); ! else ! { ! index -= 2; ! if(index >= NumLocationChoices()) ! { ! index = CreateLocationChoice(); ! if(index != 0) ! { ! RebuildSupplierMenu(); ! popCtl->SetValue(index+2); ! SaveDefaultPictureProperties(title, copyright, author, index); ! } ! } ! else ! SaveDefaultPictureProperties(title, copyright, author, index); ! } ! } } ! void PictureSelectDialog::LoadCurrentPictureProperties() { + XGEditText *textCtl; + long locationChoice; + String title, copyright, creator; + + GetDefaultPictureProperties(title, copyright, creator, locationChoice); + + textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCopyright)); + textCtl->SetTitle(copyright.c_str()); + textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCommon)); + textCtl->SetTitle(title.c_str()); + textCtl = dynamic_cast<XGEditText*>(_dlog->FindViewByID(kPictureCreator)); + textCtl->SetTitle(creator.c_str()); + + SetLocationMenuToMatch(locationChoice); } ! ! void PictureSelectDialog::SetGadgetState(long id, bool visible) { + XGView *view = _dlog->FindViewByID(id); + if(visible) + { + view->ShowView(); + if(_writable) + view->EnableView(); + else + view->DisableView(); + } + else + view->HideView(); } Index: PictureSelectDialog.h =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/PictureSelectDialog.h,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -C2 -d -r1.9.2.1 -r1.9.2.2 *** PictureSelectDialog.h 11 Apr 2008 10:25:58 -0000 1.9.2.1 --- PictureSelectDialog.h 12 Apr 2008 19:02:16 -0000 1.9.2.2 *************** *** 49,52 **** --- 49,55 ---- virtual long EditChanged(XGDialog *dlog, long gadgetID); virtual void PopupValue(XGDialog *dlog, long viewID); + + virtual void HidePanel(); + virtual void ShowPanel(); virtual long GetNumPictures() = 0; *************** *** 56,66 **** virtual void LoadAllPictures() = 0; virtual void SetDefaultPictureToIndexed(long index) = 0; ! virtual void SaveDefaultPictureProperties(String &title, String ©right) = 0; virtual long CreateLocationChoice() = 0; - virtual void HidePanel(); - virtual void ShowPanel(); virtual long NumLocationChoices(); virtual void GetIndexedLocationChoiceName(long index, String &name); - virtual void SelectLocationChoice(long index); virtual void ChangeDefaultPicture(CGWorld *picture); --- 59,67 ---- virtual void LoadAllPictures() = 0; virtual void SetDefaultPictureToIndexed(long index) = 0; ! virtual void SaveDefaultPictureProperties(String &title, String ©right, String &creator, long locationChoice) = 0; ! virtual void GetDefaultPictureProperties(String &title, String ©right, String &creator, long &locationChoice) = 0; virtual long CreateLocationChoice() = 0; virtual long NumLocationChoices(); virtual void GetIndexedLocationChoiceName(long index, String &name); virtual void ChangeDefaultPicture(CGWorld *picture); *************** *** 75,79 **** private: static dialogCBResult_t Eventhandler(XGDialog *d, class RGDialog *rgd,long msg,long arg,void *parg, void *callbackContext); ! XGDialog *_dlog; CQTImagePane *_imagePane; --- 76,83 ---- private: static dialogCBResult_t Eventhandler(XGDialog *d, class RGDialog *rgd,long msg,long arg,void *parg, void *callbackContext); ! void SaveCurrentPictureProperties(); ! void LoadCurrentPictureProperties(); ! void SetGadgetState(long id, bool visible); ! XGDialog *_dlog; CQTImagePane *_imagePane; |