xbrowse in a Toolbar?

xbrowse in a Toolbar?

Postby reinaldocrespo » Tue Feb 10, 2015 9:48 pm

Is it possible to place an xbrowse on a toolbar?

Code: Select all  Expand view

...
   DEFINE REBAR oReBar OF ::oWnd

   DEFINE TOOLBAR oToolBar OF oReBar SIZE 50, 58 IMAGELIST oImageList BALLOON // tooltips balloon style

...
      @ 01, 535 XBROWSE oBrw ARRAY { { "one" }, { "two" } } OF oToolBar SIZE 150, 30 PIXEL AUTOCOLS HEADERS "Schedules"
 


So far I haven't had any luck. The xbrowse does not display. Perhaps we can't place an xbrowse on a toolbar?

My purpose is to have a multi-select list. I'm thinking an xbrowse would be a nice solution.

Thank you,
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby Enrico Maria Giordano » Tue Feb 10, 2015 10:06 pm

Reinaldo,

can you build a compilable and runnable sample, please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: xbrowse in a Toolbar?

Postby reinaldocrespo » Tue Feb 10, 2015 10:32 pm

Enrico;

Good idea. Here is a reduced self-contained sample:

Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

FUNCTION Start()
   LOCAL oImageList, orebar, oToolBar, oBrw, oWnd


   DEFINE WINDOW oWnd MDI
   
   DEFINE IMAGELIST oImageList SIZE 32, 32

   DEFINE IMGBITMAP OF oImageList NAME "ViewCal132"   COLOR nRGB( 255, 0, 255 )

   DEFINE REBAR oReBar OF oWnd

   DEFINE TOOLBAR oToolBar OF oReBar SIZE 50, 58 IMAGELIST oImageList BALLOON // tooltips balloon style

   DEFINE TBBUTTON of oToolBar Action MsgInfo( "only testing" )

   DEFINE TBSEPARATOR OF oToolBar

   @ 01, 535 XBROWSE oBrw ARRAY { { "one" }, { "two" } } OF oToolBar SIZE 150, 30 PIXEL AUTOCOLS HEADERS "Header1"

   oReBar:InsertBand( oToolBar )

   ACTIVATE WINDOW oWnd
   
RETURN NIL
 
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby nageswaragunupudi » Tue Feb 10, 2015 10:53 pm

Probably you might have forgotten oBrw:CreateFromCode()

This sample code worked for me:
Code: Select all  Expand view
function XBrwOnToolBar()

   local oWnd, oReBar, oBar, oBrw

   DEFINE WINDOW oWnd
   DEFINE REBAR oReBar OF oWnd

   DEFINE TOOLBAR oBar OF oReBar SIZE 50, 58 BALLOON // tooltips balloon style

   @ 01, 535 XBROWSE oBrw ARRAY { { "one" }, { "two" } } OF oBar SIZE 150, 57 PIXEL AUTOCOLS HEADERS "Schedules" CELL
   WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHScroll         := .f.
      :nStretchCol      := 1
      //
      :CreateFromCode()
   END

   oRebar:InsertBand( oBar )

   ACTIVATE WINDOW oWnd MAXIMIZED

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse in a Toolbar?

Postby reinaldocrespo » Tue Feb 10, 2015 10:54 pm

Rao;

ooops.

Thank you.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby ukoenig » Tue Feb 10, 2015 11:29 pm

Maybe a colored rounded border needed ( can have a shadow ) ?

Image

Code: Select all  Expand view

@ 2, 650 TITLE oTitle SIZE  160, 68 OF oToolBar PIXEL SHADOWSIZE 0
oTitle:lRound := .T.    // Round
oTitle:lTransparent := .F.
oTitle:lBorder := .F.
oTitle:aGrdBack := { { 1, 255, 255 }, { 1, 255, 255 } }

@ 5, 5 XBROWSE oBrw ARRAY { { "one" }, { "two" } } OF oTitle SIZE 150, 57 PIXEL AUTOCOLS HEADERS "Schedules" CELL
WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHScroll         := .f.
      :nStretchCol      := 1
      //
      :CreateFromCode()
END
 


Image

Code: Select all  Expand view

@ 2, 650 TITLE oTitle SIZE  154, 62 OF oToolBar PIXEL SHADOW bottomright SHADOWSIZE 10
oTitle:lRound := .F.    // Round
oTitle:lTransparent := .F.
oTitle:lBorder := .F.
oTitle:aGrdBack := { { 1, NIL, NIL }, { 1, NIL, NIL } }

@ 1, 1 XBROWSE oBrw ARRAY { { "one" }, { "two" }, { "three" } } OF oTitle SIZE 150, 57 PIXEL AUTOCOLS HEADERS "Schedules" CELL
WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHScroll         := .f.
      :lHeader         := .f.
      :nStretchCol      := 1
      //
      :CreateFromCode()
END
 


best regards
Uwe :?:
Last edited by ukoenig on Wed Feb 11, 2015 12:02 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xbrowse in a Toolbar?

Postby reinaldocrespo » Tue Feb 10, 2015 11:35 pm

Rao,

How about removing the header? is it possible?

Thank you,

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby nageswaragunupudi » Tue Feb 10, 2015 11:40 pm

reinaldocrespo wrote:Rao,

How about removing the header? is it possible?

Thank you,

Reinaldo.

oBrw:lHeader := .f.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse in a Toolbar?

Postby reinaldocrespo » Tue Feb 10, 2015 11:49 pm

Rao,

Yes!

Thank you.

However... as I look at the result, I'm thinking perhaps I should place a multi-selectable dropdown listbox. Can you make a recommendation for a multi-selectable dropdown combobox style control?

Again, thank you.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby nageswaragunupudi » Wed Feb 11, 2015 12:46 am

A combobox is more suitable for this kind of interface than xbrowse.
Unfortunately, combobox does not support multiple selection, as far as I know.

Both listbox and xbrowse support multiple selection and listbox looks more elegant here than xbrowse. But both suffer from the limitation that their display is clipped by the size of the parent window ( In this case, the ToolBar ).

Alternative-1:

Have a Get with Bitmap Button (down arrow is the best) on the toolbar displaying the selected options. This gives a familiar look of a combobox.

The button action is to create a simple list box with multiple selection option, precisely positioned below the Get. The parent window is the parent window of the Rebar. We take care of the display coordinates of the listbox at runtime inside the button-action. We also provide a way to close the listbox. When closed, the selected options are displayed by the Get.

The idea is to give a look and feel of a dropdown combobox with multiple selection.

Alternative-2:
Much simpler.
One of the toolbar buttons to have a drop-down menu with selected items checked.

I prefer the second alternative.

There can probably many other alternative approaches but this strikes to my mind immediately.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse in a Toolbar?

Postby nageswaragunupudi » Wed Feb 11, 2015 1:56 am

This is a sample using 2nd alternative. I used buttonbar instead of rebar, but can be adopted to rebars too.
Code: Select all  Expand view
//----------------------------------------------------------------------------//

function TestSel()

   local oWnd, oBar, oFont
   local aItems   := { "One", "Two", "Three", "Four" }
   local aSel     := { "Three" }

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )
   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,64 2007
   DEFINE BUTTON OF oBar PROMPT "Test" ACTION XBrowse( aSel )
   DEFINE BUTTON OF oBar PROMPT { || If( Empty( aSel ), "Select", FW_ArrayAsList( aSel, ", " ) ) } ;
      MENU { || ItemMenu( aItems, aSel ) } ACTION This:ShowPopup()

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function ItemMenu( aItems, aSel )

   local oPop, cPrompt

   MENU oPop POPUP 2007
   FOR EACH cPrompt IN aItems
      MENUITEM cPrompt WHEN { |o| o:SetCheck( AScan( aSel, o:cPrompt ) > 0 ), .t. } ;
         ACTION If( oMenuItem:lChecked, ;
                    ( ADel( aSel, AScan( aSel, oMenuItem:cPrompt ), .t. ), ;
                      oMenuItem:SetCheck( .f. ) ), ;
                    ( AAdd( aSel, oMenuItem:cPrompt ), ;
                      oMenuItem:SetCheck( .t. ) ) )
   NEXT
   ENDMENU

return oPop

//----------------------------------------------------------------------------//
 

Note: Specifying a codeblock as prompt of a button is possible with recent versions of FWH. In older versions as well as toolbars, we need to keep modifying the prompt and refresh as and when required during runtime.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse in a Toolbar?

Postby reinaldocrespo » Wed Feb 11, 2015 2:20 am

Rao,

Yes, that will do perfectly. Thank you very much.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: xbrowse in a Toolbar?

Postby hua » Wed Feb 11, 2015 2:40 am

Excuse me for interrupting but can someone explain what "This:" is for and when to use it? TIA

Code: Select all  Expand view
DEFINE BUTTON OF oBar PROMPT { || If( Empty( aSel ), "Select", FW_ArrayAsList( aSel, ", " ) ) } ;
      MENU { || ItemMenu( aItems, aSel ) } ACTION This:ShowPopup()
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1070
Joined: Fri Oct 28, 2005 2:27 am

Re: xbrowse in a Toolbar?

Postby nageswaragunupudi » Wed Feb 11, 2015 3:00 am

hua wrote:Excuse me for interrupting but can someone explain what "This:" is for and when to use it? TIA

Code: Select all  Expand view
DEFINE BUTTON OF oBar PROMPT { || If( Empty( aSel ), "Select", FW_ArrayAsList( aSel, ", " ) ) } ;
      MENU { || ItemMenu( aItems, aSel ) } ACTION This:ShowPopup()


In this case, This refers to the button (tbtnbmp()) object.

From a reading of command translate "DEFINE BUTTON OF oBar" in fivewin.ch, we see that "ACTION This:ShowPopup()" will be translated by the pre-processor as { |This| This:ShowPopop() }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse in a Toolbar?

Postby hua » Wed Feb 11, 2015 3:06 am

I see. Thanks for the explanation Rao
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1070
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests